Lines Matching +full:foo +full:- +full:over +full:- +full:udp

1 // SPDX-License-Identifier: GPL-2.0-only
39 * silently drop skb instead of failing with -EPERM.
41 * Hirokazu Takahashi: HW checksumming for outgoing UDP
43 * Hirokazu Takahashi: sendfile() on UDP works now.
81 #include <linux/bpf-cgroup.h>
96 iph->check = 0; in ip_send_check()
97 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); in ip_send_check()
107 iph_set_totlen(iph, skb->len); in __ip_local_out()
117 skb->protocol = htons(ETH_P_IP); in __ip_local_out()
120 net, sk, skb, NULL, skb_dst(skb)->dev, in __ip_local_out()
139 int ttl = READ_ONCE(inet->uc_ttl); in ip_select_ttl()
160 skb_push(skb, sizeof(struct iphdr) + (opt ? opt->opt.optlen : 0)); in ip_build_and_send_pkt()
163 iph->version = 4; in ip_build_and_send_pkt()
164 iph->ihl = 5; in ip_build_and_send_pkt()
165 iph->tos = tos; in ip_build_and_send_pkt()
166 iph->ttl = ip_select_ttl(inet, &rt->dst); in ip_build_and_send_pkt()
167 iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr); in ip_build_and_send_pkt()
168 iph->saddr = saddr; in ip_build_and_send_pkt()
169 iph->protocol = sk->sk_protocol; in ip_build_and_send_pkt()
171 if (skb->len <= IPV4_MIN_MTU || ip_dont_fragment(sk, &rt->dst)) { in ip_build_and_send_pkt()
172 iph->frag_off = htons(IP_DF); in ip_build_and_send_pkt()
173 iph->id = 0; in ip_build_and_send_pkt()
175 iph->frag_off = 0; in ip_build_and_send_pkt()
179 if (sk->sk_protocol == IPPROTO_TCP) in ip_build_and_send_pkt()
180 iph->id = (__force __be16)get_random_u16(); in ip_build_and_send_pkt()
185 if (opt && opt->opt.optlen) { in ip_build_and_send_pkt()
186 iph->ihl += opt->opt.optlen>>2; in ip_build_and_send_pkt()
187 ip_options_build(skb, &opt->opt, daddr, rt); in ip_build_and_send_pkt()
190 skb->priority = READ_ONCE(sk->sk_priority); in ip_build_and_send_pkt()
191 if (!skb->mark) in ip_build_and_send_pkt()
192 skb->mark = READ_ONCE(sk->sk_mark); in ip_build_and_send_pkt()
195 return ip_local_out(net, skb->sk, skb); in ip_build_and_send_pkt()
203 struct net_device *dev = dst->dev; in ip_finish_output2()
208 if (rt->rt_type == RTN_MULTICAST) { in ip_finish_output2()
209 IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTMCAST, skb->len); in ip_finish_output2()
210 } else if (rt->rt_type == RTN_BROADCAST) in ip_finish_output2()
211 IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTBCAST, skb->len); in ip_finish_output2()
214 IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len); in ip_finish_output2()
216 if (unlikely(skb_headroom(skb) < hh_len && dev->header_ops)) { in ip_finish_output2()
219 return -ENOMEM; in ip_finish_output2()
222 if (lwtunnel_xmit_redirect(dst->lwtstate)) { in ip_finish_output2()
260 /* Slowpath - GSO segment length exceeds the egress MTU. in ip_finish_output_gso()
263 * - Forwarding of a TCP GRO skb, when DF flag is not set. in ip_finish_output_gso()
264 * - Forwarding of an skb that arrived on a virtualization interface in ip_finish_output_gso()
265 * (virtio-net/vhost/tap) with TSO/GSO size set by other network in ip_finish_output_gso()
267 * - Local GSO skb transmitted on an NETIF_F_TSO tunnel stacked over an in ip_finish_output_gso()
269 * - Arriving GRO skb (or GSO skb in a virtualized environment) that is in ip_finish_output_gso()
270 * bridged to a NETIF_F_TSO tunnel stacked over an interface with an in ip_finish_output_gso()
278 return -ENOMEM; in ip_finish_output_gso()
302 if (skb_dst(skb)->xfrm) { in __ip_finish_output()
303 IPCB(skb)->flags |= IPSKB_REROUTED; in __ip_finish_output()
311 if (skb->len > mtu || IPCB(skb)->frag_max_size) in __ip_finish_output()
352 /* Reset rt_iif so that inet_iif() will return skb->skb_iif. Setting in ip_mc_finish_output()
353 * this to non-zero causes ipi_ifindex in in_pktinfo to be overwritten, in ip_mc_finish_output()
356 new_rt = rt_dst_clone(net->loopback_dev, skb_rtable(skb)); in ip_mc_finish_output()
358 new_rt->rt_iif = 0; in ip_mc_finish_output()
360 skb_dst_set(skb, &new_rt->dst); in ip_mc_finish_output()
370 struct net_device *dev = rt->dst.dev; in ip_mc_output()
375 skb->dev = dev; in ip_mc_output()
376 skb->protocol = htons(ETH_P_IP); in ip_mc_output()
382 if (rt->rt_flags&RTCF_MULTICAST) { in ip_mc_output()
394 ((rt->rt_flags & RTCF_LOCAL) || in ip_mc_output()
395 !(IPCB(skb)->flags & IPSKB_FORWARDED)) in ip_mc_output()
401 net, sk, newskb, NULL, newskb->dev, in ip_mc_output()
407 if (ip_hdr(skb)->ttl == 0) { in ip_mc_output()
413 if (rt->rt_flags&RTCF_BROADCAST) { in ip_mc_output()
417 net, sk, newskb, NULL, newskb->dev, in ip_mc_output()
422 net, sk, skb, NULL, skb->dev, in ip_mc_output()
424 !(IPCB(skb)->flags & IPSKB_REROUTED)); in ip_mc_output()
429 struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev; in ip_output()
431 skb->dev = dev; in ip_output()
432 skb->protocol = htons(ETH_P_IP); in ip_output()
437 !(IPCB(skb)->flags & IPSKB_REROUTED)); in ip_output()
444 * iph->saddr = fl4->saddr;
445 * iph->daddr = fl4->daddr;
450 offsetof(typeof(*fl4), saddr) + sizeof(fl4->saddr)); in ip_copy_addrs()
452 iph->saddr = fl4->saddr; in ip_copy_addrs()
453 iph->daddr = fl4->daddr; in ip_copy_addrs()
456 /* Note: skb->sk can be different from sk, in case of tunnels */
472 inet_opt = rcu_dereference(inet->inet_opt); in __ip_queue_xmit()
473 fl4 = &fl->u.ip4; in __ip_queue_xmit()
484 daddr = inet->inet_daddr; in __ip_queue_xmit()
485 if (inet_opt && inet_opt->opt.srr) in __ip_queue_xmit()
486 daddr = inet_opt->opt.faddr; in __ip_queue_xmit()
493 daddr, inet->inet_saddr, in __ip_queue_xmit()
494 inet->inet_dport, in __ip_queue_xmit()
495 inet->inet_sport, in __ip_queue_xmit()
496 sk->sk_protocol, in __ip_queue_xmit()
498 sk->sk_bound_dev_if); in __ip_queue_xmit()
501 sk_setup_caps(sk, &rt->dst); in __ip_queue_xmit()
503 skb_dst_set_noref(skb, &rt->dst); in __ip_queue_xmit()
506 if (inet_opt && inet_opt->opt.is_strictroute && rt->rt_uses_gateway) in __ip_queue_xmit()
510 skb_push(skb, sizeof(struct iphdr) + (inet_opt ? inet_opt->opt.optlen : 0)); in __ip_queue_xmit()
514 if (ip_dont_fragment(sk, &rt->dst) && !skb->ignore_df) in __ip_queue_xmit()
515 iph->frag_off = htons(IP_DF); in __ip_queue_xmit()
517 iph->frag_off = 0; in __ip_queue_xmit()
518 iph->ttl = ip_select_ttl(inet, &rt->dst); in __ip_queue_xmit()
519 iph->protocol = sk->sk_protocol; in __ip_queue_xmit()
522 /* Transport layer set skb->h.foo itself. */ in __ip_queue_xmit()
524 if (inet_opt && inet_opt->opt.optlen) { in __ip_queue_xmit()
525 iph->ihl += inet_opt->opt.optlen >> 2; in __ip_queue_xmit()
526 ip_options_build(skb, &inet_opt->opt, inet->inet_daddr, rt); in __ip_queue_xmit()
530 skb_shinfo(skb)->gso_segs ?: 1); in __ip_queue_xmit()
532 /* TODO : should we use skb->sk here instead of sk ? */ in __ip_queue_xmit()
533 skb->priority = READ_ONCE(sk->sk_priority); in __ip_queue_xmit()
534 skb->mark = READ_ONCE(sk->sk_mark); in __ip_queue_xmit()
544 return -EHOSTUNREACH; in __ip_queue_xmit()
550 return __ip_queue_xmit(sk, skb, fl, READ_ONCE(inet_sk(sk)->tos)); in ip_queue_xmit()
556 to->pkt_type = from->pkt_type; in ip_copy_metadata()
557 to->priority = from->priority; in ip_copy_metadata()
558 to->protocol = from->protocol; in ip_copy_metadata()
559 to->skb_iif = from->skb_iif; in ip_copy_metadata()
562 to->dev = from->dev; in ip_copy_metadata()
563 to->mark = from->mark; in ip_copy_metadata()
568 to->tc_index = from->tc_index; in ip_copy_metadata()
573 to->ipvs_property = from->ipvs_property; in ip_copy_metadata()
584 if ((iph->frag_off & htons(IP_DF)) == 0) in ip_fragment()
587 if (unlikely(!skb->ignore_df || in ip_fragment()
588 (IPCB(skb)->frag_max_size && in ip_fragment()
589 IPCB(skb)->frag_max_size > mtu))) { in ip_fragment()
594 return -EMSGSIZE; in ip_fragment()
605 iter->frag = skb_shinfo(skb)->frag_list; in ip_fraglist_init()
608 iter->offset = 0; in ip_fraglist_init()
609 iter->iph = iph; in ip_fraglist_init()
610 iter->hlen = hlen; in ip_fraglist_init()
612 skb->data_len = first_len - skb_headlen(skb); in ip_fraglist_init()
613 skb->len = first_len; in ip_fraglist_init()
614 iph->tot_len = htons(first_len); in ip_fraglist_init()
615 iph->frag_off = htons(IP_MF); in ip_fraglist_init()
622 unsigned int hlen = iter->hlen; in ip_fraglist_prepare()
623 struct iphdr *iph = iter->iph; in ip_fraglist_prepare()
626 frag = iter->frag; in ip_fraglist_prepare()
627 frag->ip_summed = CHECKSUM_NONE; in ip_fraglist_prepare()
632 iter->iph = ip_hdr(frag); in ip_fraglist_prepare()
633 iph = iter->iph; in ip_fraglist_prepare()
634 iph->tot_len = htons(frag->len); in ip_fraglist_prepare()
636 iter->offset += skb->len - hlen; in ip_fraglist_prepare()
637 iph->frag_off = htons(iter->offset >> 3); in ip_fraglist_prepare()
638 if (frag->next) in ip_fraglist_prepare()
639 iph->frag_off |= htons(IP_MF); in ip_fraglist_prepare()
651 state->DF = DF; in ip_frag_init()
652 state->hlen = hlen; in ip_frag_init()
653 state->ll_rs = ll_rs; in ip_frag_init()
654 state->mtu = mtu; in ip_frag_init()
656 state->left = skb->len - hlen; /* Space per frame */ in ip_frag_init()
657 state->ptr = hlen; /* Where to start from */ in ip_frag_init()
659 state->offset = (ntohs(iph->frag_off) & IP_OFFSET) << 3; in ip_frag_init()
660 state->not_last_frag = iph->frag_off & htons(IP_MF); in ip_frag_init()
668 IPCB(to)->flags = IPCB(from)->flags; in ip_frag_ipcb()
682 unsigned int len = state->left; in ip_frag_next()
686 /* IF: it doesn't fit, use 'mtu' - the data space left */ in ip_frag_next()
687 if (len > state->mtu) in ip_frag_next()
688 len = state->mtu; in ip_frag_next()
691 if (len < state->left) { in ip_frag_next()
696 skb2 = alloc_skb(len + state->hlen + state->ll_rs, GFP_ATOMIC); in ip_frag_next()
698 return ERR_PTR(-ENOMEM); in ip_frag_next()
705 skb_reserve(skb2, state->ll_rs); in ip_frag_next()
706 skb_put(skb2, len + state->hlen); in ip_frag_next()
708 skb2->transport_header = skb2->network_header + state->hlen; in ip_frag_next()
715 if (skb->sk) in ip_frag_next()
716 skb_set_owner_w(skb2, skb->sk); in ip_frag_next()
722 skb_copy_from_linear_data(skb, skb_network_header(skb2), state->hlen); in ip_frag_next()
727 if (skb_copy_bits(skb, state->ptr, skb_transport_header(skb2), len)) in ip_frag_next()
729 state->left -= len; in ip_frag_next()
735 iph->frag_off = htons((state->offset >> 3)); in ip_frag_next()
736 if (state->DF) in ip_frag_next()
737 iph->frag_off |= htons(IP_DF); in ip_frag_next()
743 if (state->left > 0 || state->not_last_frag) in ip_frag_next()
744 iph->frag_off |= htons(IP_MF); in ip_frag_next()
745 state->ptr += len; in ip_frag_next()
746 state->offset += len; in ip_frag_next()
748 iph->tot_len = htons(len + state->hlen); in ip_frag_next()
768 u8 tstamp_type = skb->tstamp_type; in ip_do_fragment()
772 ktime_t tstamp = skb->tstamp; in ip_do_fragment()
777 if (skb->ip_summed == CHECKSUM_PARTIAL && in ip_do_fragment()
788 if (IPCB(skb)->frag_max_size && IPCB(skb)->frag_max_size < mtu) in ip_do_fragment()
789 mtu = IPCB(skb)->frag_max_size; in ip_do_fragment()
795 hlen = iph->ihl * 4; in ip_do_fragment()
796 mtu = mtu - hlen; /* Size of data space */ in ip_do_fragment()
797 IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; in ip_do_fragment()
798 ll_rs = LL_RESERVED_SPACE(rt->dst.dev); in ip_do_fragment()
811 if (first_len - hlen > mtu || in ip_do_fragment()
812 ((first_len - hlen) & 7) || in ip_do_fragment()
820 if (frag->len > mtu || in ip_do_fragment()
821 ((frag->len & 7) && frag->next) || in ip_do_fragment()
829 BUG_ON(frag->sk); in ip_do_fragment()
830 if (skb->sk) { in ip_do_fragment()
831 frag->sk = skb->sk; in ip_do_fragment()
832 frag->destructor = sock_wfree; in ip_do_fragment()
834 skb->truesize -= frag->truesize; in ip_do_fragment()
846 IPCB(iter.frag)->flags = IPCB(skb)->flags; in ip_do_fragment()
848 if (first_frag && IPCB(skb)->opt.optlen) { in ip_do_fragment()
849 /* ipcb->opt is not populated for frags in ip_do_fragment()
853 IPCB(iter.frag)->opt.optlen = in ip_do_fragment()
854 IPCB(skb)->opt.optlen; in ip_do_fragment()
885 frag2->sk = NULL; in ip_do_fragment()
886 frag2->destructor = NULL; in ip_do_fragment()
887 skb->truesize += frag2->truesize; in ip_do_fragment()
896 ip_frag_init(skb, hlen, ll_rs, mtu, IPCB(skb)->flags & IPSKB_FRAG_PMTU, in ip_do_fragment()
939 if (skb->ip_summed == CHECKSUM_PARTIAL) { in ip_generic_getfrag()
940 if (!copy_from_iter_full(to, len, &msg->msg_iter)) in ip_generic_getfrag()
941 return -EFAULT; in ip_generic_getfrag()
944 if (!csum_and_copy_from_iter_full(to, len, &csum, &msg->msg_iter)) in ip_generic_getfrag()
945 return -EFAULT; in ip_generic_getfrag()
946 skb->csum = csum_block_add(skb->csum, csum, odd); in ip_generic_getfrag()
965 struct ip_options *opt = cork->opt; in __ip_append_data()
975 struct rtable *rt = dst_rtable(cork->dst); in __ip_append_data()
982 exthdrlen = !skb ? rt->dst.header_len : 0; in __ip_append_data()
983 mtu = cork->gso_size ? IP_MAX_MTU : cork->fragsize; in __ip_append_data()
984 paged = !!cork->gso_size; in __ip_append_data()
986 hh_len = LL_RESERVED_SPACE(rt->dst.dev); in __ip_append_data()
988 fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); in __ip_append_data()
989 maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; in __ip_append_data()
992 if (cork->length + length > maxnonfragsize - fragheaderlen) { in __ip_append_data()
993 ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport, in __ip_append_data()
994 mtu - (opt ? opt->optlen : 0)); in __ip_append_data()
995 return -EMSGSIZE; in __ip_append_data()
1004 rt->dst.dev->features & (NETIF_F_HW_CSUM | NETIF_F_IP_CSUM) && in __ip_append_data()
1005 (!(flags & MSG_MORE) || cork->gso_size) && in __ip_append_data()
1006 (!exthdrlen || (rt->dst.dev->features & NETIF_F_HW_ESP_TX_CSUM))) in __ip_append_data()
1012 if (getfrag == ip_generic_getfrag && msg->msg_ubuf) { in __ip_append_data()
1013 if (skb_zcopy(skb) && msg->msg_ubuf != skb_zcopy(skb)) in __ip_append_data()
1014 return -EINVAL; in __ip_append_data()
1019 if ((rt->dst.dev->features & NETIF_F_SG) && in __ip_append_data()
1023 uarg = msg->msg_ubuf; in __ip_append_data()
1028 return -ENOBUFS; in __ip_append_data()
1030 if (rt->dst.dev->features & NETIF_F_SG && in __ip_append_data()
1035 uarg_to_msgzc(uarg)->zerocopy = 0; in __ip_append_data()
1041 return -EPERM; in __ip_append_data()
1042 if (rt->dst.dev->features & NETIF_F_SG && in __ip_append_data()
1050 cork->length += length; in __ip_append_data()
1052 hold_tskey = cork->tx_flags & SKBTX_ANY_TSTAMP && in __ip_append_data()
1053 READ_ONCE(sk->sk_tsflags) & SOF_TIMESTAMPING_OPT_ID; in __ip_append_data()
1055 tskey = atomic_inc_return(&sk->sk_tskey) - 1; in __ip_append_data()
1069 copy = mtu - skb->len; in __ip_append_data()
1071 copy = maxfraglen - skb->len; in __ip_append_data()
1083 fraggap = skb_prev->len - maxfraglen; in __ip_append_data()
1092 if (datalen > mtu - fragheaderlen) in __ip_append_data()
1093 datalen = maxfraglen - fragheaderlen; in __ip_append_data()
1106 alloc_extra += rt->dst.trailer_len; in __ip_append_data()
1109 !(rt->dst.dev->features&NETIF_F_SG)) in __ip_append_data()
1113 !(rt->dst.dev->features & NETIF_F_SG))) in __ip_append_data()
1117 pagedlen = datalen - transhdrlen; in __ip_append_data()
1127 if (refcount_read(&sk->sk_wmem_alloc) + wmem_alloc_delta <= in __ip_append_data()
1128 2 * sk->sk_sndbuf) in __ip_append_data()
1130 sk->sk_allocation); in __ip_append_data()
1132 err = -ENOBUFS; in __ip_append_data()
1140 skb->ip_summed = csummode; in __ip_append_data()
1141 skb->csum = 0; in __ip_append_data()
1147 data = skb_put(skb, fraglen + exthdrlen - pagedlen); in __ip_append_data()
1149 skb->transport_header = (skb->network_header + in __ip_append_data()
1154 skb->csum = skb_copy_and_csum_bits( in __ip_append_data()
1157 skb_prev->csum = csum_sub(skb_prev->csum, in __ip_append_data()
1158 skb->csum); in __ip_append_data()
1163 copy = datalen - transhdrlen - fraggap - pagedlen; in __ip_append_data()
1165 * because then the equation reduces to -fraggap. in __ip_append_data()
1168 err = -EFAULT; in __ip_append_data()
1176 length -= copy + transhdrlen; in __ip_append_data()
1182 skb_shinfo(skb)->tx_flags = cork->tx_flags; in __ip_append_data()
1183 cork->tx_flags = 0; in __ip_append_data()
1184 skb_shinfo(skb)->tskey = tskey; in __ip_append_data()
1194 if (!skb->destructor) { in __ip_append_data()
1195 skb->destructor = sock_wfree; in __ip_append_data()
1196 skb->sk = sk; in __ip_append_data()
1197 wmem_alloc_delta += skb->truesize; in __ip_append_data()
1206 if (!(rt->dst.dev->features&NETIF_F_SG) && in __ip_append_data()
1210 off = skb->len; in __ip_append_data()
1214 err = -EFAULT; in __ip_append_data()
1220 err = -EIO; in __ip_append_data()
1221 if (WARN_ON_ONCE(copy > msg->msg_iter.count)) in __ip_append_data()
1224 err = skb_splice_from_iter(skb, &msg->msg_iter, copy, in __ip_append_data()
1225 sk->sk_allocation); in __ip_append_data()
1231 int i = skb_shinfo(skb)->nr_frags; in __ip_append_data()
1233 err = -ENOMEM; in __ip_append_data()
1238 if (!skb_can_coalesce(skb, i, pfrag->page, in __ip_append_data()
1239 pfrag->offset)) { in __ip_append_data()
1240 err = -EMSGSIZE; in __ip_append_data()
1244 __skb_fill_page_desc(skb, i, pfrag->page, in __ip_append_data()
1245 pfrag->offset, 0); in __ip_append_data()
1246 skb_shinfo(skb)->nr_frags = ++i; in __ip_append_data()
1247 get_page(pfrag->page); in __ip_append_data()
1249 copy = min_t(int, copy, pfrag->size - pfrag->offset); in __ip_append_data()
1251 page_address(pfrag->page) + pfrag->offset, in __ip_append_data()
1252 offset, copy, skb->len, skb) < 0) in __ip_append_data()
1255 pfrag->offset += copy; in __ip_append_data()
1256 skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); in __ip_append_data()
1265 length -= copy; in __ip_append_data()
1269 refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc); in __ip_append_data()
1273 err = -EFAULT; in __ip_append_data()
1276 cork->length -= length; in __ip_append_data()
1278 refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc); in __ip_append_data()
1280 atomic_dec(&sk->sk_tskey); in __ip_append_data()
1292 return -EFAULT; in ip_setup_cork()
1294 cork->fragsize = ip_sk_use_pmtu(sk) ? in ip_setup_cork()
1295 dst_mtu(&rt->dst) : READ_ONCE(rt->dst.dev->mtu); in ip_setup_cork()
1297 if (!inetdev_valid_mtu(cork->fragsize)) in ip_setup_cork()
1298 return -ENETUNREACH; in ip_setup_cork()
1303 opt = ipc->opt; in ip_setup_cork()
1305 if (!cork->opt) { in ip_setup_cork()
1306 cork->opt = kmalloc(sizeof(struct ip_options) + 40, in ip_setup_cork()
1307 sk->sk_allocation); in ip_setup_cork()
1308 if (unlikely(!cork->opt)) in ip_setup_cork()
1309 return -ENOBUFS; in ip_setup_cork()
1311 memcpy(cork->opt, &opt->opt, sizeof(struct ip_options) + opt->opt.optlen); in ip_setup_cork()
1312 cork->flags |= IPCORK_OPT; in ip_setup_cork()
1313 cork->addr = ipc->addr; in ip_setup_cork()
1316 cork->gso_size = ipc->gso_size; in ip_setup_cork()
1318 cork->dst = &rt->dst; in ip_setup_cork()
1322 cork->length = 0; in ip_setup_cork()
1323 cork->ttl = ipc->ttl; in ip_setup_cork()
1324 cork->tos = ipc->tos; in ip_setup_cork()
1325 cork->mark = ipc->sockc.mark; in ip_setup_cork()
1326 cork->priority = ipc->priority; in ip_setup_cork()
1327 cork->transmit_time = ipc->sockc.transmit_time; in ip_setup_cork()
1328 cork->tx_flags = 0; in ip_setup_cork()
1329 sock_tx_timestamp(sk, ipc->sockc.tsflags, &cork->tx_flags); in ip_setup_cork()
1338 * non-page data.
1340 * Not only UDP, other transport protocols - e.g. raw sockets - can use
1358 if (skb_queue_empty(&sk->sk_write_queue)) { in ip_append_data()
1359 err = ip_setup_cork(sk, &inet->cork.base, ipc, rtp); in ip_append_data()
1366 return __ip_append_data(sk, fl4, &sk->sk_write_queue, &inet->cork.base, in ip_append_data()
1373 cork->flags &= ~IPCORK_OPT; in ip_cork_release()
1374 kfree(cork->opt); in ip_cork_release()
1375 cork->opt = NULL; in ip_cork_release()
1376 dst_release(cork->dst); in ip_cork_release()
1377 cork->dst = NULL; in ip_cork_release()
1394 struct rtable *rt = dst_rtable(cork->dst); in __ip_make_skb()
1402 tail_skb = &(skb_shinfo(skb)->frag_list); in __ip_make_skb()
1404 /* move skb->data to ip header from ext header */ in __ip_make_skb()
1405 if (skb->data < skb_network_header(skb)) in __ip_make_skb()
1410 tail_skb = &(tmp_skb->next); in __ip_make_skb()
1411 skb->len += tmp_skb->len; in __ip_make_skb()
1412 skb->data_len += tmp_skb->len; in __ip_make_skb()
1413 skb->truesize += tmp_skb->truesize; in __ip_make_skb()
1414 tmp_skb->destructor = NULL; in __ip_make_skb()
1415 tmp_skb->sk = NULL; in __ip_make_skb()
1422 skb->ignore_df = ip_sk_ignore_df(sk); in __ip_make_skb()
1427 pmtudisc = READ_ONCE(inet->pmtudisc); in __ip_make_skb()
1430 (skb->len <= dst_mtu(&rt->dst) && in __ip_make_skb()
1431 ip_dont_fragment(sk, &rt->dst))) in __ip_make_skb()
1434 if (cork->flags & IPCORK_OPT) in __ip_make_skb()
1435 opt = cork->opt; in __ip_make_skb()
1437 if (cork->ttl != 0) in __ip_make_skb()
1438 ttl = cork->ttl; in __ip_make_skb()
1439 else if (rt->rt_type == RTN_MULTICAST) in __ip_make_skb()
1440 ttl = READ_ONCE(inet->mc_ttl); in __ip_make_skb()
1442 ttl = ip_select_ttl(inet, &rt->dst); in __ip_make_skb()
1445 iph->version = 4; in __ip_make_skb()
1446 iph->ihl = 5; in __ip_make_skb()
1447 iph->tos = (cork->tos != -1) ? cork->tos : READ_ONCE(inet->tos); in __ip_make_skb()
1448 iph->frag_off = df; in __ip_make_skb()
1449 iph->ttl = ttl; in __ip_make_skb()
1450 iph->protocol = sk->sk_protocol; in __ip_make_skb()
1455 iph->ihl += opt->optlen >> 2; in __ip_make_skb()
1456 ip_options_build(skb, opt, cork->addr, rt); in __ip_make_skb()
1459 skb->priority = (cork->tos != -1) ? cork->priority: READ_ONCE(sk->sk_priority); in __ip_make_skb()
1460 skb->mark = cork->mark; in __ip_make_skb()
1462 skb_set_delivery_time(skb, cork->transmit_time, SKB_CLOCK_MONOTONIC); in __ip_make_skb()
1464 skb_set_delivery_type_by_clockid(skb, cork->transmit_time, sk->sk_clockid); in __ip_make_skb()
1469 cork->dst = NULL; in __ip_make_skb()
1470 skb_dst_set(skb, &rt->dst); in __ip_make_skb()
1472 if (iph->protocol == IPPROTO_ICMP) { in __ip_make_skb()
1477 * by icmp_hdr(skb)->type. in __ip_make_skb()
1479 if (sk->sk_type == SOCK_RAW && in __ip_make_skb()
1480 !(fl4->flowi4_flags & FLOWI_FLAG_KNOWN_NH)) in __ip_make_skb()
1481 icmp_type = fl4->fl4_icmp_type; in __ip_make_skb()
1483 icmp_type = icmp_hdr(skb)->type; in __ip_make_skb()
1496 err = ip_local_out(net, skb->sk, skb); in ip_send_skb()
1536 __ip_flush_pending_frames(sk, &sk->sk_write_queue, &inet_sk(sk)->cork.base); in ip_flush_pending_frames()
1555 cork->flags = 0; in ip_make_skb()
1556 cork->addr = 0; in ip_make_skb()
1557 cork->opt = NULL; in ip_make_skb()
1563 &current->task_frag, getfrag, in ip_make_skb()
1582 skb->csum = csum_block_add(skb->csum, csum, odd); in ip_reply_glue_bits()
1619 oif = arg->bound_dev_if; in ip_send_unicast_reply()
1620 if (!oif && netif_index_is_l3_master(net, skb->skb_iif)) in ip_send_unicast_reply()
1621 oif = skb->skb_iif; in ip_send_unicast_reply()
1624 IP4_REPLY_MARK(net, skb->mark) ?: sk->sk_mark, in ip_send_unicast_reply()
1625 arg->tos & INET_DSCP_MASK, in ip_send_unicast_reply()
1626 RT_SCOPE_UNIVERSE, ip_hdr(skb)->protocol, in ip_send_unicast_reply()
1629 tcp_hdr(skb)->source, tcp_hdr(skb)->dest, in ip_send_unicast_reply()
1630 arg->uid); in ip_send_unicast_reply()
1636 inet_sk(sk)->tos = arg->tos & ~INET_ECN_MASK; in ip_send_unicast_reply()
1638 sk->sk_protocol = ip_hdr(skb)->protocol; in ip_send_unicast_reply()
1639 sk->sk_bound_dev_if = arg->bound_dev_if; in ip_send_unicast_reply()
1640 sk->sk_sndbuf = READ_ONCE(sysctl_wmem_default); in ip_send_unicast_reply()
1642 err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, in ip_send_unicast_reply()
1649 nskb = skb_peek(&sk->sk_write_queue); in ip_send_unicast_reply()
1651 if (arg->csumoffset >= 0) in ip_send_unicast_reply()
1653 arg->csumoffset) = csum_fold(csum_add(nskb->csum, in ip_send_unicast_reply()
1654 arg->csum)); in ip_send_unicast_reply()
1655 nskb->ip_summed = CHECKSUM_NONE; in ip_send_unicast_reply()
1657 nskb->tstamp_type = SKB_CLOCK_MONOTONIC; in ip_send_unicast_reply()