ip_output.c (5f013c9bc70214dcacd5fbed5a06c217d6ff9c59) ip_output.c (60ff746739bf805a912484643c720b6124826140)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * The Internet Protocol (IP) output module.
7 *
8 * Authors: Ross Biro

--- 401 unchanged lines hidden (view full) ---

410 if (inet_opt && inet_opt->opt.is_strictroute && rt->rt_uses_gateway)
411 goto no_route;
412
413 /* OK, we know where to send it, allocate and build IP header. */
414 skb_push(skb, sizeof(struct iphdr) + (inet_opt ? inet_opt->opt.optlen : 0));
415 skb_reset_network_header(skb);
416 iph = ip_hdr(skb);
417 *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * The Internet Protocol (IP) output module.
7 *
8 * Authors: Ross Biro

--- 401 unchanged lines hidden (view full) ---

410 if (inet_opt && inet_opt->opt.is_strictroute && rt->rt_uses_gateway)
411 goto no_route;
412
413 /* OK, we know where to send it, allocate and build IP header. */
414 skb_push(skb, sizeof(struct iphdr) + (inet_opt ? inet_opt->opt.optlen : 0));
415 skb_reset_network_header(skb);
416 iph = ip_hdr(skb);
417 *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
418 if (ip_dont_fragment(sk, &rt->dst) && !skb->local_df)
418 if (ip_dont_fragment(sk, &rt->dst) && !skb->ignore_df)
419 iph->frag_off = htons(IP_DF);
420 else
421 iph->frag_off = 0;
422 iph->ttl = ip_select_ttl(inet, &rt->dst);
423 iph->protocol = sk->sk_protocol;
424 ip_copy_addrs(iph, fl4);
425
426 /* Transport layer set skb->h.foo itself. */

--- 69 unchanged lines hidden (view full) ---

496
497 /*
498 * Point into the IP datagram header.
499 */
500
501 iph = ip_hdr(skb);
502
503 mtu = ip_skb_dst_mtu(skb);
419 iph->frag_off = htons(IP_DF);
420 else
421 iph->frag_off = 0;
422 iph->ttl = ip_select_ttl(inet, &rt->dst);
423 iph->protocol = sk->sk_protocol;
424 ip_copy_addrs(iph, fl4);
425
426 /* Transport layer set skb->h.foo itself. */

--- 69 unchanged lines hidden (view full) ---

496
497 /*
498 * Point into the IP datagram header.
499 */
500
501 iph = ip_hdr(skb);
502
503 mtu = ip_skb_dst_mtu(skb);
504 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->local_df) ||
504 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||
505 (IPCB(skb)->frag_max_size &&
506 IPCB(skb)->frag_max_size > mtu))) {
507 IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
508 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
509 htonl(mtu));
510 kfree_skb(skb);
511 return -EMSGSIZE;
512 }

--- 348 unchanged lines hidden (view full) ---

861
862 exthdrlen = !skb ? rt->dst.header_len : 0;
863 mtu = cork->fragsize;
864
865 hh_len = LL_RESERVED_SPACE(rt->dst.dev);
866
867 fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);
868 maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;
505 (IPCB(skb)->frag_max_size &&
506 IPCB(skb)->frag_max_size > mtu))) {
507 IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
508 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED,
509 htonl(mtu));
510 kfree_skb(skb);
511 return -EMSGSIZE;
512 }

--- 348 unchanged lines hidden (view full) ---

861
862 exthdrlen = !skb ? rt->dst.header_len : 0;
863 mtu = cork->fragsize;
864
865 hh_len = LL_RESERVED_SPACE(rt->dst.dev);
866
867 fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);
868 maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;
869 maxnonfragsize = ip_sk_local_df(sk) ? 0xFFFF : mtu;
869 maxnonfragsize = ip_sk_ignore_df(sk) ? 0xFFFF : mtu;
870
871 if (cork->length + length > maxnonfragsize - fragheaderlen) {
872 ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport,
873 mtu - (opt ? opt->optlen : 0));
874 return -EMSGSIZE;
875 }
876
877 /*

--- 306 unchanged lines hidden (view full) ---

1184 if (!(rt->dst.dev->features&NETIF_F_SG))
1185 return -EOPNOTSUPP;
1186
1187 hh_len = LL_RESERVED_SPACE(rt->dst.dev);
1188 mtu = cork->fragsize;
1189
1190 fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);
1191 maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;
870
871 if (cork->length + length > maxnonfragsize - fragheaderlen) {
872 ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport,
873 mtu - (opt ? opt->optlen : 0));
874 return -EMSGSIZE;
875 }
876
877 /*

--- 306 unchanged lines hidden (view full) ---

1184 if (!(rt->dst.dev->features&NETIF_F_SG))
1185 return -EOPNOTSUPP;
1186
1187 hh_len = LL_RESERVED_SPACE(rt->dst.dev);
1188 mtu = cork->fragsize;
1189
1190 fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0);
1191 maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen;
1192 maxnonfragsize = ip_sk_local_df(sk) ? 0xFFFF : mtu;
1192 maxnonfragsize = ip_sk_ignore_df(sk) ? 0xFFFF : mtu;
1193
1194 if (cork->length + size > maxnonfragsize - fragheaderlen) {
1195 ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport,
1196 mtu - (opt ? opt->optlen : 0));
1197 return -EMSGSIZE;
1198 }
1199
1200 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)

--- 144 unchanged lines hidden (view full) ---

1345 tmp_skb->destructor = NULL;
1346 tmp_skb->sk = NULL;
1347 }
1348
1349 /* Unless user demanded real pmtu discovery (IP_PMTUDISC_DO), we allow
1350 * to fragment the frame generated here. No matter, what transforms
1351 * how transforms change size of the packet, it will come out.
1352 */
1193
1194 if (cork->length + size > maxnonfragsize - fragheaderlen) {
1195 ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport,
1196 mtu - (opt ? opt->optlen : 0));
1197 return -EMSGSIZE;
1198 }
1199
1200 if ((skb = skb_peek_tail(&sk->sk_write_queue)) == NULL)

--- 144 unchanged lines hidden (view full) ---

1345 tmp_skb->destructor = NULL;
1346 tmp_skb->sk = NULL;
1347 }
1348
1349 /* Unless user demanded real pmtu discovery (IP_PMTUDISC_DO), we allow
1350 * to fragment the frame generated here. No matter, what transforms
1351 * how transforms change size of the packet, it will come out.
1352 */
1353 skb->local_df = ip_sk_local_df(sk);
1353 skb->ignore_df = ip_sk_ignore_df(sk);
1354
1355 /* DF bit is set when we want to see DF on outgoing frames.
1354
1355 /* DF bit is set when we want to see DF on outgoing frames.
1356 * If local_df is set too, we still allow to fragment this frame
1356 * If ignore_df is set too, we still allow to fragment this frame
1357 * locally. */
1358 if (inet->pmtudisc == IP_PMTUDISC_DO ||
1359 inet->pmtudisc == IP_PMTUDISC_PROBE ||
1360 (skb->len <= dst_mtu(&rt->dst) &&
1361 ip_dont_fragment(sk, &rt->dst)))
1362 df = htons(IP_DF);
1363
1364 if (cork->flags & IPCORK_OPT)

--- 233 unchanged lines hidden ---
1357 * locally. */
1358 if (inet->pmtudisc == IP_PMTUDISC_DO ||
1359 inet->pmtudisc == IP_PMTUDISC_PROBE ||
1360 (skb->len <= dst_mtu(&rt->dst) &&
1361 ip_dont_fragment(sk, &rt->dst)))
1362 df = htons(IP_DF);
1363
1364 if (cork->flags & IPCORK_OPT)

--- 233 unchanged lines hidden ---