| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * INET An implementation of the TCP/IP protocol suite for the LINUX |
|---|
| 3 | 4 | * operating system. INET is implemented using the BSD Socket |
|---|
| .. | .. |
|---|
| 142 | 143 | * |
|---|
| 143 | 144 | */ |
|---|
| 144 | 145 | int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk, |
|---|
| 145 | | - __be32 saddr, __be32 daddr, struct ip_options_rcu *opt) |
|---|
| 146 | + __be32 saddr, __be32 daddr, struct ip_options_rcu *opt, |
|---|
| 147 | + u8 tos) |
|---|
| 146 | 148 | { |
|---|
| 147 | 149 | struct inet_sock *inet = inet_sk(sk); |
|---|
| 148 | 150 | struct rtable *rt = skb_rtable(skb); |
|---|
| .. | .. |
|---|
| 155 | 157 | iph = ip_hdr(skb); |
|---|
| 156 | 158 | iph->version = 4; |
|---|
| 157 | 159 | iph->ihl = 5; |
|---|
| 158 | | - iph->tos = inet->tos; |
|---|
| 160 | + iph->tos = tos; |
|---|
| 159 | 161 | iph->ttl = ip_select_ttl(inet, &rt->dst); |
|---|
| 160 | 162 | iph->daddr = (opt && opt->opt.srr ? opt->opt.faddr : daddr); |
|---|
| 161 | 163 | iph->saddr = saddr; |
|---|
| .. | .. |
|---|
| 196 | 198 | struct net_device *dev = dst->dev; |
|---|
| 197 | 199 | unsigned int hh_len = LL_RESERVED_SPACE(dev); |
|---|
| 198 | 200 | struct neighbour *neigh; |
|---|
| 199 | | - u32 nexthop; |
|---|
| 201 | + bool is_v6gw = false; |
|---|
| 200 | 202 | |
|---|
| 201 | 203 | if (rt->rt_type == RTN_MULTICAST) { |
|---|
| 202 | 204 | IP_UPD_PO_STATS(net, IPSTATS_MIB_OUTMCAST, skb->len); |
|---|
| .. | .. |
|---|
| 221 | 223 | if (lwtunnel_xmit_redirect(dst->lwtstate)) { |
|---|
| 222 | 224 | int res = lwtunnel_xmit(skb); |
|---|
| 223 | 225 | |
|---|
| 224 | | - if (res < 0 || res == LWTUNNEL_XMIT_DONE) |
|---|
| 226 | + if (res != LWTUNNEL_XMIT_CONTINUE) |
|---|
| 225 | 227 | return res; |
|---|
| 226 | 228 | } |
|---|
| 227 | 229 | |
|---|
| 228 | 230 | rcu_read_lock_bh(); |
|---|
| 229 | | - nexthop = (__force u32) rt_nexthop(rt, ip_hdr(skb)->daddr); |
|---|
| 230 | | - neigh = __ipv4_neigh_lookup_noref(dev, nexthop); |
|---|
| 231 | | - if (unlikely(!neigh)) |
|---|
| 232 | | - neigh = __neigh_create(&arp_tbl, &nexthop, dev, false); |
|---|
| 231 | + neigh = ip_neigh_for_gw(rt, skb, &is_v6gw); |
|---|
| 233 | 232 | if (!IS_ERR(neigh)) { |
|---|
| 234 | 233 | int res; |
|---|
| 235 | 234 | |
|---|
| 236 | 235 | sock_confirm_neigh(skb, neigh); |
|---|
| 237 | | - res = neigh_output(neigh, skb); |
|---|
| 238 | | - |
|---|
| 236 | + /* if crossing protocols, can not use the cached header */ |
|---|
| 237 | + res = neigh_output(neigh, skb, is_v6gw); |
|---|
| 239 | 238 | rcu_read_unlock_bh(); |
|---|
| 240 | 239 | return res; |
|---|
| 241 | 240 | } |
|---|
| .. | .. |
|---|
| 250 | 249 | static int ip_finish_output_gso(struct net *net, struct sock *sk, |
|---|
| 251 | 250 | struct sk_buff *skb, unsigned int mtu) |
|---|
| 252 | 251 | { |
|---|
| 252 | + struct sk_buff *segs, *nskb; |
|---|
| 253 | 253 | netdev_features_t features; |
|---|
| 254 | | - struct sk_buff *segs; |
|---|
| 255 | 254 | int ret = 0; |
|---|
| 256 | 255 | |
|---|
| 257 | 256 | /* common case: seglen is <= mtu |
|---|
| .. | .. |
|---|
| 273 | 272 | * insufficent MTU. |
|---|
| 274 | 273 | */ |
|---|
| 275 | 274 | features = netif_skb_features(skb); |
|---|
| 276 | | - BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_SGO_CB_OFFSET); |
|---|
| 275 | + BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_GSO_CB_OFFSET); |
|---|
| 277 | 276 | segs = skb_gso_segment(skb, features & ~NETIF_F_GSO_MASK); |
|---|
| 278 | 277 | if (IS_ERR_OR_NULL(segs)) { |
|---|
| 279 | 278 | kfree_skb(skb); |
|---|
| .. | .. |
|---|
| 282 | 281 | |
|---|
| 283 | 282 | consume_skb(skb); |
|---|
| 284 | 283 | |
|---|
| 285 | | - do { |
|---|
| 286 | | - struct sk_buff *nskb = segs->next; |
|---|
| 284 | + skb_list_walk_safe(segs, segs, nskb) { |
|---|
| 287 | 285 | int err; |
|---|
| 288 | 286 | |
|---|
| 289 | | - segs->next = NULL; |
|---|
| 287 | + skb_mark_not_on_list(segs); |
|---|
| 290 | 288 | err = ip_fragment(net, sk, segs, mtu, ip_finish_output2); |
|---|
| 291 | 289 | |
|---|
| 292 | 290 | if (err && ret == 0) |
|---|
| 293 | 291 | ret = err; |
|---|
| 294 | | - segs = nskb; |
|---|
| 295 | | - } while (segs); |
|---|
| 292 | + } |
|---|
| 296 | 293 | |
|---|
| 297 | 294 | return ret; |
|---|
| 298 | 295 | } |
|---|
| 299 | 296 | |
|---|
| 300 | | -static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb) |
|---|
| 297 | +static int __ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb) |
|---|
| 301 | 298 | { |
|---|
| 302 | 299 | unsigned int mtu; |
|---|
| 303 | | - int ret; |
|---|
| 304 | | - |
|---|
| 305 | | - ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb); |
|---|
| 306 | | - if (ret) { |
|---|
| 307 | | - kfree_skb(skb); |
|---|
| 308 | | - return ret; |
|---|
| 309 | | - } |
|---|
| 310 | 300 | |
|---|
| 311 | 301 | #if defined(CONFIG_NETFILTER) && defined(CONFIG_XFRM) |
|---|
| 312 | 302 | /* Policy lookup after SNAT yielded a new policy */ |
|---|
| .. | .. |
|---|
| 325 | 315 | return ip_finish_output2(net, sk, skb); |
|---|
| 326 | 316 | } |
|---|
| 327 | 317 | |
|---|
| 328 | | -static int ip_mc_finish_output(struct net *net, struct sock *sk, |
|---|
| 329 | | - struct sk_buff *skb) |
|---|
| 318 | +static int ip_finish_output(struct net *net, struct sock *sk, struct sk_buff *skb) |
|---|
| 330 | 319 | { |
|---|
| 331 | 320 | int ret; |
|---|
| 332 | 321 | |
|---|
| 333 | 322 | ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb); |
|---|
| 334 | | - if (ret) { |
|---|
| 323 | + switch (ret) { |
|---|
| 324 | + case NET_XMIT_SUCCESS: |
|---|
| 325 | + return __ip_finish_output(net, sk, skb); |
|---|
| 326 | + case NET_XMIT_CN: |
|---|
| 327 | + return __ip_finish_output(net, sk, skb) ? : ret; |
|---|
| 328 | + default: |
|---|
| 329 | + kfree_skb(skb); |
|---|
| 330 | + return ret; |
|---|
| 331 | + } |
|---|
| 332 | +} |
|---|
| 333 | + |
|---|
| 334 | +static int ip_mc_finish_output(struct net *net, struct sock *sk, |
|---|
| 335 | + struct sk_buff *skb) |
|---|
| 336 | +{ |
|---|
| 337 | + struct rtable *new_rt; |
|---|
| 338 | + bool do_cn = false; |
|---|
| 339 | + int ret, err; |
|---|
| 340 | + |
|---|
| 341 | + ret = BPF_CGROUP_RUN_PROG_INET_EGRESS(sk, skb); |
|---|
| 342 | + switch (ret) { |
|---|
| 343 | + case NET_XMIT_CN: |
|---|
| 344 | + do_cn = true; |
|---|
| 345 | + fallthrough; |
|---|
| 346 | + case NET_XMIT_SUCCESS: |
|---|
| 347 | + break; |
|---|
| 348 | + default: |
|---|
| 335 | 349 | kfree_skb(skb); |
|---|
| 336 | 350 | return ret; |
|---|
| 337 | 351 | } |
|---|
| 338 | 352 | |
|---|
| 339 | | - return dev_loopback_xmit(net, sk, skb); |
|---|
| 353 | + /* Reset rt_iif so that inet_iif() will return skb->skb_iif. Setting |
|---|
| 354 | + * this to non-zero causes ipi_ifindex in in_pktinfo to be overwritten, |
|---|
| 355 | + * see ipv4_pktinfo_prepare(). |
|---|
| 356 | + */ |
|---|
| 357 | + new_rt = rt_dst_clone(net->loopback_dev, skb_rtable(skb)); |
|---|
| 358 | + if (new_rt) { |
|---|
| 359 | + new_rt->rt_iif = 0; |
|---|
| 360 | + skb_dst_drop(skb); |
|---|
| 361 | + skb_dst_set(skb, &new_rt->dst); |
|---|
| 362 | + } |
|---|
| 363 | + |
|---|
| 364 | + err = dev_loopback_xmit(net, sk, skb); |
|---|
| 365 | + return (do_cn && err) ? ret : err; |
|---|
| 340 | 366 | } |
|---|
| 341 | 367 | |
|---|
| 342 | 368 | int ip_mc_output(struct net *net, struct sock *sk, struct sk_buff *skb) |
|---|
| .. | .. |
|---|
| 403 | 429 | |
|---|
| 404 | 430 | int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb) |
|---|
| 405 | 431 | { |
|---|
| 406 | | - struct net_device *dev = skb_dst(skb)->dev; |
|---|
| 432 | + struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev; |
|---|
| 407 | 433 | |
|---|
| 408 | 434 | IP_UPD_PO_STATS(net, IPSTATS_MIB_OUT, skb->len); |
|---|
| 409 | 435 | |
|---|
| .. | .. |
|---|
| 411 | 437 | skb->protocol = htons(ETH_P_IP); |
|---|
| 412 | 438 | |
|---|
| 413 | 439 | return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, |
|---|
| 414 | | - net, sk, skb, NULL, dev, |
|---|
| 440 | + net, sk, skb, indev, dev, |
|---|
| 415 | 441 | ip_finish_output, |
|---|
| 416 | 442 | !(IPCB(skb)->flags & IPSKB_REROUTED)); |
|---|
| 417 | 443 | } |
|---|
| .. | .. |
|---|
| 523 | 549 | } |
|---|
| 524 | 550 | EXPORT_SYMBOL(__ip_queue_xmit); |
|---|
| 525 | 551 | |
|---|
| 552 | +int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl) |
|---|
| 553 | +{ |
|---|
| 554 | + return __ip_queue_xmit(sk, skb, fl, inet_sk(sk)->tos); |
|---|
| 555 | +} |
|---|
| 556 | +EXPORT_SYMBOL(ip_queue_xmit); |
|---|
| 557 | + |
|---|
| 526 | 558 | static void ip_copy_metadata(struct sk_buff *to, struct sk_buff *from) |
|---|
| 527 | 559 | { |
|---|
| 528 | 560 | to->pkt_type = from->pkt_type; |
|---|
| .. | .. |
|---|
| 536 | 568 | |
|---|
| 537 | 569 | skb_copy_hash(to, from); |
|---|
| 538 | 570 | |
|---|
| 539 | | - /* Copy the flags to each fragment. */ |
|---|
| 540 | | - IPCB(to)->flags = IPCB(from)->flags; |
|---|
| 541 | | - |
|---|
| 542 | 571 | #ifdef CONFIG_NET_SCHED |
|---|
| 543 | 572 | to->tc_index = from->tc_index; |
|---|
| 544 | 573 | #endif |
|---|
| 545 | 574 | nf_copy(to, from); |
|---|
| 575 | + skb_ext_copy(to, from); |
|---|
| 546 | 576 | #if IS_ENABLED(CONFIG_IP_VS) |
|---|
| 547 | 577 | to->ipvs_property = from->ipvs_property; |
|---|
| 548 | 578 | #endif |
|---|
| .. | .. |
|---|
| 571 | 601 | return ip_do_fragment(net, sk, skb, output); |
|---|
| 572 | 602 | } |
|---|
| 573 | 603 | |
|---|
| 604 | +void ip_fraglist_init(struct sk_buff *skb, struct iphdr *iph, |
|---|
| 605 | + unsigned int hlen, struct ip_fraglist_iter *iter) |
|---|
| 606 | +{ |
|---|
| 607 | + unsigned int first_len = skb_pagelen(skb); |
|---|
| 608 | + |
|---|
| 609 | + iter->frag = skb_shinfo(skb)->frag_list; |
|---|
| 610 | + skb_frag_list_init(skb); |
|---|
| 611 | + |
|---|
| 612 | + iter->offset = 0; |
|---|
| 613 | + iter->iph = iph; |
|---|
| 614 | + iter->hlen = hlen; |
|---|
| 615 | + |
|---|
| 616 | + skb->data_len = first_len - skb_headlen(skb); |
|---|
| 617 | + skb->len = first_len; |
|---|
| 618 | + iph->tot_len = htons(first_len); |
|---|
| 619 | + iph->frag_off = htons(IP_MF); |
|---|
| 620 | + ip_send_check(iph); |
|---|
| 621 | +} |
|---|
| 622 | +EXPORT_SYMBOL(ip_fraglist_init); |
|---|
| 623 | + |
|---|
| 624 | +void ip_fraglist_prepare(struct sk_buff *skb, struct ip_fraglist_iter *iter) |
|---|
| 625 | +{ |
|---|
| 626 | + unsigned int hlen = iter->hlen; |
|---|
| 627 | + struct iphdr *iph = iter->iph; |
|---|
| 628 | + struct sk_buff *frag; |
|---|
| 629 | + |
|---|
| 630 | + frag = iter->frag; |
|---|
| 631 | + frag->ip_summed = CHECKSUM_NONE; |
|---|
| 632 | + skb_reset_transport_header(frag); |
|---|
| 633 | + __skb_push(frag, hlen); |
|---|
| 634 | + skb_reset_network_header(frag); |
|---|
| 635 | + memcpy(skb_network_header(frag), iph, hlen); |
|---|
| 636 | + iter->iph = ip_hdr(frag); |
|---|
| 637 | + iph = iter->iph; |
|---|
| 638 | + iph->tot_len = htons(frag->len); |
|---|
| 639 | + ip_copy_metadata(frag, skb); |
|---|
| 640 | + iter->offset += skb->len - hlen; |
|---|
| 641 | + iph->frag_off = htons(iter->offset >> 3); |
|---|
| 642 | + if (frag->next) |
|---|
| 643 | + iph->frag_off |= htons(IP_MF); |
|---|
| 644 | + /* Ready, complete checksum */ |
|---|
| 645 | + ip_send_check(iph); |
|---|
| 646 | +} |
|---|
| 647 | +EXPORT_SYMBOL(ip_fraglist_prepare); |
|---|
| 648 | + |
|---|
| 649 | +void ip_frag_init(struct sk_buff *skb, unsigned int hlen, |
|---|
| 650 | + unsigned int ll_rs, unsigned int mtu, bool DF, |
|---|
| 651 | + struct ip_frag_state *state) |
|---|
| 652 | +{ |
|---|
| 653 | + struct iphdr *iph = ip_hdr(skb); |
|---|
| 654 | + |
|---|
| 655 | + state->DF = DF; |
|---|
| 656 | + state->hlen = hlen; |
|---|
| 657 | + state->ll_rs = ll_rs; |
|---|
| 658 | + state->mtu = mtu; |
|---|
| 659 | + |
|---|
| 660 | + state->left = skb->len - hlen; /* Space per frame */ |
|---|
| 661 | + state->ptr = hlen; /* Where to start from */ |
|---|
| 662 | + |
|---|
| 663 | + state->offset = (ntohs(iph->frag_off) & IP_OFFSET) << 3; |
|---|
| 664 | + state->not_last_frag = iph->frag_off & htons(IP_MF); |
|---|
| 665 | +} |
|---|
| 666 | +EXPORT_SYMBOL(ip_frag_init); |
|---|
| 667 | + |
|---|
| 668 | +static void ip_frag_ipcb(struct sk_buff *from, struct sk_buff *to, |
|---|
| 669 | + bool first_frag) |
|---|
| 670 | +{ |
|---|
| 671 | + /* Copy the flags to each fragment. */ |
|---|
| 672 | + IPCB(to)->flags = IPCB(from)->flags; |
|---|
| 673 | + |
|---|
| 674 | + /* ANK: dirty, but effective trick. Upgrade options only if |
|---|
| 675 | + * the segment to be fragmented was THE FIRST (otherwise, |
|---|
| 676 | + * options are already fixed) and make it ONCE |
|---|
| 677 | + * on the initial skb, so that all the following fragments |
|---|
| 678 | + * will inherit fixed options. |
|---|
| 679 | + */ |
|---|
| 680 | + if (first_frag) |
|---|
| 681 | + ip_options_fragment(from); |
|---|
| 682 | +} |
|---|
| 683 | + |
|---|
| 684 | +struct sk_buff *ip_frag_next(struct sk_buff *skb, struct ip_frag_state *state) |
|---|
| 685 | +{ |
|---|
| 686 | + unsigned int len = state->left; |
|---|
| 687 | + struct sk_buff *skb2; |
|---|
| 688 | + struct iphdr *iph; |
|---|
| 689 | + |
|---|
| 690 | + len = state->left; |
|---|
| 691 | + /* IF: it doesn't fit, use 'mtu' - the data space left */ |
|---|
| 692 | + if (len > state->mtu) |
|---|
| 693 | + len = state->mtu; |
|---|
| 694 | + /* IF: we are not sending up to and including the packet end |
|---|
| 695 | + then align the next start on an eight byte boundary */ |
|---|
| 696 | + if (len < state->left) { |
|---|
| 697 | + len &= ~7; |
|---|
| 698 | + } |
|---|
| 699 | + |
|---|
| 700 | + /* Allocate buffer */ |
|---|
| 701 | + skb2 = alloc_skb(len + state->hlen + state->ll_rs, GFP_ATOMIC); |
|---|
| 702 | + if (!skb2) |
|---|
| 703 | + return ERR_PTR(-ENOMEM); |
|---|
| 704 | + |
|---|
| 705 | + /* |
|---|
| 706 | + * Set up data on packet |
|---|
| 707 | + */ |
|---|
| 708 | + |
|---|
| 709 | + ip_copy_metadata(skb2, skb); |
|---|
| 710 | + skb_reserve(skb2, state->ll_rs); |
|---|
| 711 | + skb_put(skb2, len + state->hlen); |
|---|
| 712 | + skb_reset_network_header(skb2); |
|---|
| 713 | + skb2->transport_header = skb2->network_header + state->hlen; |
|---|
| 714 | + |
|---|
| 715 | + /* |
|---|
| 716 | + * Charge the memory for the fragment to any owner |
|---|
| 717 | + * it might possess |
|---|
| 718 | + */ |
|---|
| 719 | + |
|---|
| 720 | + if (skb->sk) |
|---|
| 721 | + skb_set_owner_w(skb2, skb->sk); |
|---|
| 722 | + |
|---|
| 723 | + /* |
|---|
| 724 | + * Copy the packet header into the new buffer. |
|---|
| 725 | + */ |
|---|
| 726 | + |
|---|
| 727 | + skb_copy_from_linear_data(skb, skb_network_header(skb2), state->hlen); |
|---|
| 728 | + |
|---|
| 729 | + /* |
|---|
| 730 | + * Copy a block of the IP datagram. |
|---|
| 731 | + */ |
|---|
| 732 | + if (skb_copy_bits(skb, state->ptr, skb_transport_header(skb2), len)) |
|---|
| 733 | + BUG(); |
|---|
| 734 | + state->left -= len; |
|---|
| 735 | + |
|---|
| 736 | + /* |
|---|
| 737 | + * Fill in the new header fields. |
|---|
| 738 | + */ |
|---|
| 739 | + iph = ip_hdr(skb2); |
|---|
| 740 | + iph->frag_off = htons((state->offset >> 3)); |
|---|
| 741 | + if (state->DF) |
|---|
| 742 | + iph->frag_off |= htons(IP_DF); |
|---|
| 743 | + |
|---|
| 744 | + /* |
|---|
| 745 | + * Added AC : If we are fragmenting a fragment that's not the |
|---|
| 746 | + * last fragment then keep MF on each bit |
|---|
| 747 | + */ |
|---|
| 748 | + if (state->left > 0 || state->not_last_frag) |
|---|
| 749 | + iph->frag_off |= htons(IP_MF); |
|---|
| 750 | + state->ptr += len; |
|---|
| 751 | + state->offset += len; |
|---|
| 752 | + |
|---|
| 753 | + iph->tot_len = htons(len + state->hlen); |
|---|
| 754 | + |
|---|
| 755 | + ip_send_check(iph); |
|---|
| 756 | + |
|---|
| 757 | + return skb2; |
|---|
| 758 | +} |
|---|
| 759 | +EXPORT_SYMBOL(ip_frag_next); |
|---|
| 760 | + |
|---|
| 574 | 761 | /* |
|---|
| 575 | 762 | * This IP datagram is too large to be sent in one piece. Break it up into |
|---|
| 576 | 763 | * smaller pieces (each of size equal to IP header plus |
|---|
| .. | .. |
|---|
| 582 | 769 | int (*output)(struct net *, struct sock *, struct sk_buff *)) |
|---|
| 583 | 770 | { |
|---|
| 584 | 771 | struct iphdr *iph; |
|---|
| 585 | | - int ptr; |
|---|
| 586 | 772 | struct sk_buff *skb2; |
|---|
| 587 | | - unsigned int mtu, hlen, left, len, ll_rs; |
|---|
| 588 | | - int offset; |
|---|
| 589 | | - __be16 not_last_frag; |
|---|
| 590 | 773 | struct rtable *rt = skb_rtable(skb); |
|---|
| 774 | + unsigned int mtu, hlen, ll_rs; |
|---|
| 775 | + struct ip_fraglist_iter iter; |
|---|
| 776 | + ktime_t tstamp = skb->tstamp; |
|---|
| 777 | + struct ip_frag_state state; |
|---|
| 591 | 778 | int err = 0; |
|---|
| 592 | 779 | |
|---|
| 593 | 780 | /* for offloaded checksums cleanup checksum before fragmentation */ |
|---|
| .. | .. |
|---|
| 652 | 839 | } |
|---|
| 653 | 840 | |
|---|
| 654 | 841 | /* Everything is OK. Generate! */ |
|---|
| 655 | | - |
|---|
| 656 | | - err = 0; |
|---|
| 657 | | - offset = 0; |
|---|
| 658 | | - frag = skb_shinfo(skb)->frag_list; |
|---|
| 659 | | - skb_frag_list_init(skb); |
|---|
| 660 | | - skb->data_len = first_len - skb_headlen(skb); |
|---|
| 661 | | - skb->len = first_len; |
|---|
| 662 | | - iph->tot_len = htons(first_len); |
|---|
| 663 | | - iph->frag_off = htons(IP_MF); |
|---|
| 664 | | - ip_send_check(iph); |
|---|
| 842 | + ip_fraglist_init(skb, iph, hlen, &iter); |
|---|
| 665 | 843 | |
|---|
| 666 | 844 | for (;;) { |
|---|
| 667 | 845 | /* Prepare header of the next frame, |
|---|
| 668 | 846 | * before previous one went down. */ |
|---|
| 669 | | - if (frag) { |
|---|
| 670 | | - frag->ip_summed = CHECKSUM_NONE; |
|---|
| 671 | | - skb_reset_transport_header(frag); |
|---|
| 672 | | - __skb_push(frag, hlen); |
|---|
| 673 | | - skb_reset_network_header(frag); |
|---|
| 674 | | - memcpy(skb_network_header(frag), iph, hlen); |
|---|
| 675 | | - iph = ip_hdr(frag); |
|---|
| 676 | | - iph->tot_len = htons(frag->len); |
|---|
| 677 | | - ip_copy_metadata(frag, skb); |
|---|
| 678 | | - if (offset == 0) |
|---|
| 679 | | - ip_options_fragment(frag); |
|---|
| 680 | | - offset += skb->len - hlen; |
|---|
| 681 | | - iph->frag_off = htons(offset>>3); |
|---|
| 682 | | - if (frag->next) |
|---|
| 683 | | - iph->frag_off |= htons(IP_MF); |
|---|
| 684 | | - /* Ready, complete checksum */ |
|---|
| 685 | | - ip_send_check(iph); |
|---|
| 847 | + if (iter.frag) { |
|---|
| 848 | + bool first_frag = (iter.offset == 0); |
|---|
| 849 | + |
|---|
| 850 | + IPCB(iter.frag)->flags = IPCB(skb)->flags; |
|---|
| 851 | + ip_fraglist_prepare(skb, &iter); |
|---|
| 852 | + if (first_frag && IPCB(skb)->opt.optlen) { |
|---|
| 853 | + /* ipcb->opt is not populated for frags |
|---|
| 854 | + * coming from __ip_make_skb(), |
|---|
| 855 | + * ip_options_fragment() needs optlen |
|---|
| 856 | + */ |
|---|
| 857 | + IPCB(iter.frag)->opt.optlen = |
|---|
| 858 | + IPCB(skb)->opt.optlen; |
|---|
| 859 | + ip_options_fragment(iter.frag); |
|---|
| 860 | + ip_send_check(iter.iph); |
|---|
| 861 | + } |
|---|
| 686 | 862 | } |
|---|
| 687 | 863 | |
|---|
| 864 | + skb->tstamp = tstamp; |
|---|
| 688 | 865 | err = output(net, sk, skb); |
|---|
| 689 | 866 | |
|---|
| 690 | 867 | if (!err) |
|---|
| 691 | 868 | IP_INC_STATS(net, IPSTATS_MIB_FRAGCREATES); |
|---|
| 692 | | - if (err || !frag) |
|---|
| 869 | + if (err || !iter.frag) |
|---|
| 693 | 870 | break; |
|---|
| 694 | 871 | |
|---|
| 695 | | - skb = frag; |
|---|
| 696 | | - frag = skb->next; |
|---|
| 697 | | - skb->next = NULL; |
|---|
| 872 | + skb = ip_fraglist_next(&iter); |
|---|
| 698 | 873 | } |
|---|
| 699 | 874 | |
|---|
| 700 | 875 | if (err == 0) { |
|---|
| .. | .. |
|---|
| 702 | 877 | return 0; |
|---|
| 703 | 878 | } |
|---|
| 704 | 879 | |
|---|
| 705 | | - while (frag) { |
|---|
| 706 | | - skb = frag->next; |
|---|
| 707 | | - kfree_skb(frag); |
|---|
| 708 | | - frag = skb; |
|---|
| 709 | | - } |
|---|
| 880 | + kfree_skb_list(iter.frag); |
|---|
| 881 | + |
|---|
| 710 | 882 | IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS); |
|---|
| 711 | 883 | return err; |
|---|
| 712 | 884 | |
|---|
| .. | .. |
|---|
| 721 | 893 | } |
|---|
| 722 | 894 | |
|---|
| 723 | 895 | slow_path: |
|---|
| 724 | | - iph = ip_hdr(skb); |
|---|
| 725 | | - |
|---|
| 726 | | - left = skb->len - hlen; /* Space per frame */ |
|---|
| 727 | | - ptr = hlen; /* Where to start from */ |
|---|
| 728 | | - |
|---|
| 729 | 896 | /* |
|---|
| 730 | 897 | * Fragment the datagram. |
|---|
| 731 | 898 | */ |
|---|
| 732 | 899 | |
|---|
| 733 | | - offset = (ntohs(iph->frag_off) & IP_OFFSET) << 3; |
|---|
| 734 | | - not_last_frag = iph->frag_off & htons(IP_MF); |
|---|
| 900 | + ip_frag_init(skb, hlen, ll_rs, mtu, IPCB(skb)->flags & IPSKB_FRAG_PMTU, |
|---|
| 901 | + &state); |
|---|
| 735 | 902 | |
|---|
| 736 | 903 | /* |
|---|
| 737 | 904 | * Keep copying data until we run out. |
|---|
| 738 | 905 | */ |
|---|
| 739 | 906 | |
|---|
| 740 | | - while (left > 0) { |
|---|
| 741 | | - len = left; |
|---|
| 742 | | - /* IF: it doesn't fit, use 'mtu' - the data space left */ |
|---|
| 743 | | - if (len > mtu) |
|---|
| 744 | | - len = mtu; |
|---|
| 745 | | - /* IF: we are not sending up to and including the packet end |
|---|
| 746 | | - then align the next start on an eight byte boundary */ |
|---|
| 747 | | - if (len < left) { |
|---|
| 748 | | - len &= ~7; |
|---|
| 749 | | - } |
|---|
| 907 | + while (state.left > 0) { |
|---|
| 908 | + bool first_frag = (state.offset == 0); |
|---|
| 750 | 909 | |
|---|
| 751 | | - /* Allocate buffer */ |
|---|
| 752 | | - skb2 = alloc_skb(len + hlen + ll_rs, GFP_ATOMIC); |
|---|
| 753 | | - if (!skb2) { |
|---|
| 754 | | - err = -ENOMEM; |
|---|
| 910 | + skb2 = ip_frag_next(skb, &state); |
|---|
| 911 | + if (IS_ERR(skb2)) { |
|---|
| 912 | + err = PTR_ERR(skb2); |
|---|
| 755 | 913 | goto fail; |
|---|
| 756 | 914 | } |
|---|
| 757 | | - |
|---|
| 758 | | - /* |
|---|
| 759 | | - * Set up data on packet |
|---|
| 760 | | - */ |
|---|
| 761 | | - |
|---|
| 762 | | - ip_copy_metadata(skb2, skb); |
|---|
| 763 | | - skb_reserve(skb2, ll_rs); |
|---|
| 764 | | - skb_put(skb2, len + hlen); |
|---|
| 765 | | - skb_reset_network_header(skb2); |
|---|
| 766 | | - skb2->transport_header = skb2->network_header + hlen; |
|---|
| 767 | | - |
|---|
| 768 | | - /* |
|---|
| 769 | | - * Charge the memory for the fragment to any owner |
|---|
| 770 | | - * it might possess |
|---|
| 771 | | - */ |
|---|
| 772 | | - |
|---|
| 773 | | - if (skb->sk) |
|---|
| 774 | | - skb_set_owner_w(skb2, skb->sk); |
|---|
| 775 | | - |
|---|
| 776 | | - /* |
|---|
| 777 | | - * Copy the packet header into the new buffer. |
|---|
| 778 | | - */ |
|---|
| 779 | | - |
|---|
| 780 | | - skb_copy_from_linear_data(skb, skb_network_header(skb2), hlen); |
|---|
| 781 | | - |
|---|
| 782 | | - /* |
|---|
| 783 | | - * Copy a block of the IP datagram. |
|---|
| 784 | | - */ |
|---|
| 785 | | - if (skb_copy_bits(skb, ptr, skb_transport_header(skb2), len)) |
|---|
| 786 | | - BUG(); |
|---|
| 787 | | - left -= len; |
|---|
| 788 | | - |
|---|
| 789 | | - /* |
|---|
| 790 | | - * Fill in the new header fields. |
|---|
| 791 | | - */ |
|---|
| 792 | | - iph = ip_hdr(skb2); |
|---|
| 793 | | - iph->frag_off = htons((offset >> 3)); |
|---|
| 794 | | - |
|---|
| 795 | | - if (IPCB(skb)->flags & IPSKB_FRAG_PMTU) |
|---|
| 796 | | - iph->frag_off |= htons(IP_DF); |
|---|
| 797 | | - |
|---|
| 798 | | - /* ANK: dirty, but effective trick. Upgrade options only if |
|---|
| 799 | | - * the segment to be fragmented was THE FIRST (otherwise, |
|---|
| 800 | | - * options are already fixed) and make it ONCE |
|---|
| 801 | | - * on the initial skb, so that all the following fragments |
|---|
| 802 | | - * will inherit fixed options. |
|---|
| 803 | | - */ |
|---|
| 804 | | - if (offset == 0) |
|---|
| 805 | | - ip_options_fragment(skb); |
|---|
| 806 | | - |
|---|
| 807 | | - /* |
|---|
| 808 | | - * Added AC : If we are fragmenting a fragment that's not the |
|---|
| 809 | | - * last fragment then keep MF on each bit |
|---|
| 810 | | - */ |
|---|
| 811 | | - if (left > 0 || not_last_frag) |
|---|
| 812 | | - iph->frag_off |= htons(IP_MF); |
|---|
| 813 | | - ptr += len; |
|---|
| 814 | | - offset += len; |
|---|
| 915 | + ip_frag_ipcb(skb, skb2, first_frag); |
|---|
| 815 | 916 | |
|---|
| 816 | 917 | /* |
|---|
| 817 | 918 | * Put this fragment into the sending queue. |
|---|
| 818 | 919 | */ |
|---|
| 819 | | - iph->tot_len = htons(len + hlen); |
|---|
| 820 | | - |
|---|
| 821 | | - ip_send_check(iph); |
|---|
| 822 | | - |
|---|
| 920 | + skb2->tstamp = tstamp; |
|---|
| 823 | 921 | err = output(net, sk, skb2); |
|---|
| 824 | 922 | if (err) |
|---|
| 825 | 923 | goto fail; |
|---|
| .. | .. |
|---|
| 877 | 975 | unsigned int flags) |
|---|
| 878 | 976 | { |
|---|
| 879 | 977 | struct inet_sock *inet = inet_sk(sk); |
|---|
| 978 | + struct ubuf_info *uarg = NULL; |
|---|
| 880 | 979 | struct sk_buff *skb; |
|---|
| 881 | 980 | |
|---|
| 882 | 981 | struct ip_options *opt = cork->opt; |
|---|
| .. | .. |
|---|
| 890 | 989 | int csummode = CHECKSUM_NONE; |
|---|
| 891 | 990 | struct rtable *rt = (struct rtable *)cork->dst; |
|---|
| 892 | 991 | unsigned int wmem_alloc_delta = 0; |
|---|
| 992 | + bool paged, extra_uref = false; |
|---|
| 893 | 993 | u32 tskey = 0; |
|---|
| 894 | | - bool paged; |
|---|
| 895 | 994 | |
|---|
| 896 | 995 | skb = skb_peek_tail(queue); |
|---|
| 897 | 996 | |
|---|
| .. | .. |
|---|
| 907 | 1006 | |
|---|
| 908 | 1007 | fragheaderlen = sizeof(struct iphdr) + (opt ? opt->optlen : 0); |
|---|
| 909 | 1008 | maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen; |
|---|
| 910 | | - maxnonfragsize = ip_sk_ignore_df(sk) ? 0xFFFF : mtu; |
|---|
| 1009 | + maxnonfragsize = ip_sk_ignore_df(sk) ? IP_MAX_MTU : mtu; |
|---|
| 911 | 1010 | |
|---|
| 912 | 1011 | if (cork->length + length > maxnonfragsize - fragheaderlen) { |
|---|
| 913 | 1012 | ip_local_error(sk, EMSGSIZE, fl4->daddr, inet->inet_dport, |
|---|
| .. | .. |
|---|
| 925 | 1024 | (!(flags & MSG_MORE) || cork->gso_size) && |
|---|
| 926 | 1025 | (!exthdrlen || (rt->dst.dev->features & NETIF_F_HW_ESP_TX_CSUM))) |
|---|
| 927 | 1026 | csummode = CHECKSUM_PARTIAL; |
|---|
| 1027 | + |
|---|
| 1028 | + if (flags & MSG_ZEROCOPY && length && sock_flag(sk, SOCK_ZEROCOPY)) { |
|---|
| 1029 | + uarg = sock_zerocopy_realloc(sk, length, skb_zcopy(skb)); |
|---|
| 1030 | + if (!uarg) |
|---|
| 1031 | + return -ENOBUFS; |
|---|
| 1032 | + extra_uref = !skb_zcopy(skb); /* only ref on new uarg */ |
|---|
| 1033 | + if (rt->dst.dev->features & NETIF_F_SG && |
|---|
| 1034 | + csummode == CHECKSUM_PARTIAL) { |
|---|
| 1035 | + paged = true; |
|---|
| 1036 | + } else { |
|---|
| 1037 | + uarg->zerocopy = 0; |
|---|
| 1038 | + skb_zcopy_set(skb, uarg, &extra_uref); |
|---|
| 1039 | + } |
|---|
| 1040 | + } |
|---|
| 928 | 1041 | |
|---|
| 929 | 1042 | cork->length += length; |
|---|
| 930 | 1043 | |
|---|
| .. | .. |
|---|
| 1015 | 1128 | skb->csum = 0; |
|---|
| 1016 | 1129 | skb_reserve(skb, hh_len); |
|---|
| 1017 | 1130 | |
|---|
| 1018 | | - /* only the initial fragment is time stamped */ |
|---|
| 1019 | | - skb_shinfo(skb)->tx_flags = cork->tx_flags; |
|---|
| 1020 | | - cork->tx_flags = 0; |
|---|
| 1021 | | - skb_shinfo(skb)->tskey = tskey; |
|---|
| 1022 | | - tskey = 0; |
|---|
| 1023 | | - |
|---|
| 1024 | 1131 | /* |
|---|
| 1025 | 1132 | * Find where to start putting bytes. |
|---|
| 1026 | 1133 | */ |
|---|
| .. | .. |
|---|
| 1033 | 1140 | if (fraggap) { |
|---|
| 1034 | 1141 | skb->csum = skb_copy_and_csum_bits( |
|---|
| 1035 | 1142 | skb_prev, maxfraglen, |
|---|
| 1036 | | - data + transhdrlen, fraggap, 0); |
|---|
| 1143 | + data + transhdrlen, fraggap); |
|---|
| 1037 | 1144 | skb_prev->csum = csum_sub(skb_prev->csum, |
|---|
| 1038 | 1145 | skb->csum); |
|---|
| 1039 | 1146 | data += fraggap; |
|---|
| .. | .. |
|---|
| 1052 | 1159 | transhdrlen = 0; |
|---|
| 1053 | 1160 | exthdrlen = 0; |
|---|
| 1054 | 1161 | csummode = CHECKSUM_NONE; |
|---|
| 1162 | + |
|---|
| 1163 | + /* only the initial fragment is time stamped */ |
|---|
| 1164 | + skb_shinfo(skb)->tx_flags = cork->tx_flags; |
|---|
| 1165 | + cork->tx_flags = 0; |
|---|
| 1166 | + skb_shinfo(skb)->tskey = tskey; |
|---|
| 1167 | + tskey = 0; |
|---|
| 1168 | + skb_zcopy_set(skb, uarg, &extra_uref); |
|---|
| 1055 | 1169 | |
|---|
| 1056 | 1170 | if ((flags & MSG_CONFIRM) && !skb_prev) |
|---|
| 1057 | 1171 | skb_set_dst_pending_confirm(skb, 1); |
|---|
| .. | .. |
|---|
| 1082 | 1196 | err = -EFAULT; |
|---|
| 1083 | 1197 | goto error; |
|---|
| 1084 | 1198 | } |
|---|
| 1085 | | - } else { |
|---|
| 1199 | + } else if (!uarg || !uarg->zerocopy) { |
|---|
| 1086 | 1200 | int i = skb_shinfo(skb)->nr_frags; |
|---|
| 1087 | 1201 | |
|---|
| 1088 | 1202 | err = -ENOMEM; |
|---|
| .. | .. |
|---|
| 1112 | 1226 | skb->data_len += copy; |
|---|
| 1113 | 1227 | skb->truesize += copy; |
|---|
| 1114 | 1228 | wmem_alloc_delta += copy; |
|---|
| 1229 | + } else { |
|---|
| 1230 | + err = skb_zerocopy_iter_dgram(skb, from, copy); |
|---|
| 1231 | + if (err < 0) |
|---|
| 1232 | + goto error; |
|---|
| 1115 | 1233 | } |
|---|
| 1116 | 1234 | offset += copy; |
|---|
| 1117 | 1235 | length -= copy; |
|---|
| .. | .. |
|---|
| 1124 | 1242 | error_efault: |
|---|
| 1125 | 1243 | err = -EFAULT; |
|---|
| 1126 | 1244 | error: |
|---|
| 1245 | + if (uarg) |
|---|
| 1246 | + sock_zerocopy_put_abort(uarg, extra_uref); |
|---|
| 1127 | 1247 | cork->length -= length; |
|---|
| 1128 | 1248 | IP_INC_STATS(sock_net(sk), IPSTATS_MIB_OUTDISCARDS); |
|---|
| 1129 | 1249 | refcount_add(wmem_alloc_delta, &sk->sk_wmem_alloc); |
|---|
| .. | .. |
|---|
| 1171 | 1291 | cork->length = 0; |
|---|
| 1172 | 1292 | cork->ttl = ipc->ttl; |
|---|
| 1173 | 1293 | cork->tos = ipc->tos; |
|---|
| 1294 | + cork->mark = ipc->sockc.mark; |
|---|
| 1174 | 1295 | cork->priority = ipc->priority; |
|---|
| 1175 | 1296 | cork->transmit_time = ipc->sockc.transmit_time; |
|---|
| 1176 | 1297 | cork->tx_flags = 0; |
|---|
| .. | .. |
|---|
| 1244 | 1365 | if (cork->flags & IPCORK_OPT) |
|---|
| 1245 | 1366 | opt = cork->opt; |
|---|
| 1246 | 1367 | |
|---|
| 1247 | | - if (!(rt->dst.dev->features&NETIF_F_SG)) |
|---|
| 1368 | + if (!(rt->dst.dev->features & NETIF_F_SG)) |
|---|
| 1248 | 1369 | return -EOPNOTSUPP; |
|---|
| 1249 | 1370 | |
|---|
| 1250 | 1371 | hh_len = LL_RESERVED_SPACE(rt->dst.dev); |
|---|
| .. | .. |
|---|
| 1304 | 1425 | skb->csum = skb_copy_and_csum_bits(skb_prev, |
|---|
| 1305 | 1426 | maxfraglen, |
|---|
| 1306 | 1427 | skb_transport_header(skb), |
|---|
| 1307 | | - fraggap, 0); |
|---|
| 1428 | + fraggap); |
|---|
| 1308 | 1429 | skb_prev->csum = csum_sub(skb_prev->csum, |
|---|
| 1309 | 1430 | skb->csum); |
|---|
| 1310 | 1431 | pskb_trim_unique(skb_prev, maxfraglen); |
|---|
| .. | .. |
|---|
| 1429 | 1550 | ip_select_ident(net, skb, sk); |
|---|
| 1430 | 1551 | |
|---|
| 1431 | 1552 | if (opt) { |
|---|
| 1432 | | - iph->ihl += opt->optlen>>2; |
|---|
| 1553 | + iph->ihl += opt->optlen >> 2; |
|---|
| 1433 | 1554 | ip_options_build(skb, opt, cork->addr, rt, 0); |
|---|
| 1434 | 1555 | } |
|---|
| 1435 | 1556 | |
|---|
| 1436 | 1557 | skb->priority = (cork->tos != -1) ? cork->priority: sk->sk_priority; |
|---|
| 1437 | | - skb->mark = sk->sk_mark; |
|---|
| 1558 | + skb->mark = cork->mark; |
|---|
| 1438 | 1559 | skb->tstamp = cork->transmit_time; |
|---|
| 1439 | 1560 | /* |
|---|
| 1440 | 1561 | * Steal rt from cork.dst to avoid a pair of atomic_inc/atomic_dec |
|---|
| .. | .. |
|---|
| 1443 | 1564 | cork->dst = NULL; |
|---|
| 1444 | 1565 | skb_dst_set(skb, &rt->dst); |
|---|
| 1445 | 1566 | |
|---|
| 1446 | | - if (iph->protocol == IPPROTO_ICMP) |
|---|
| 1447 | | - icmp_out_count(net, ((struct icmphdr *) |
|---|
| 1448 | | - skb_transport_header(skb))->type); |
|---|
| 1567 | + if (iph->protocol == IPPROTO_ICMP) { |
|---|
| 1568 | + u8 icmp_type; |
|---|
| 1569 | + |
|---|
| 1570 | + /* For such sockets, transhdrlen is zero when do ip_append_data(), |
|---|
| 1571 | + * so icmphdr does not in skb linear region and can not get icmp_type |
|---|
| 1572 | + * by icmp_hdr(skb)->type. |
|---|
| 1573 | + */ |
|---|
| 1574 | + if (sk->sk_type == SOCK_RAW && !inet_sk(sk)->hdrincl) |
|---|
| 1575 | + icmp_type = fl4->fl4_icmp_type; |
|---|
| 1576 | + else |
|---|
| 1577 | + icmp_type = icmp_hdr(skb)->type; |
|---|
| 1578 | + icmp_out_count(net, icmp_type); |
|---|
| 1579 | + } |
|---|
| 1449 | 1580 | |
|---|
| 1450 | 1581 | ip_cork_release(cork); |
|---|
| 1451 | 1582 | out: |
|---|
| .. | .. |
|---|
| 1541 | 1672 | { |
|---|
| 1542 | 1673 | __wsum csum; |
|---|
| 1543 | 1674 | |
|---|
| 1544 | | - csum = csum_partial_copy_nocheck(dptr+offset, to, len, 0); |
|---|
| 1675 | + csum = csum_partial_copy_nocheck(dptr+offset, to, len); |
|---|
| 1545 | 1676 | skb->csum = csum_block_add(skb->csum, csum, odd); |
|---|
| 1546 | 1677 | return 0; |
|---|
| 1547 | 1678 | } |
|---|
| .. | .. |
|---|
| 1554 | 1685 | const struct ip_options *sopt, |
|---|
| 1555 | 1686 | __be32 daddr, __be32 saddr, |
|---|
| 1556 | 1687 | const struct ip_reply_arg *arg, |
|---|
| 1557 | | - unsigned int len) |
|---|
| 1688 | + unsigned int len, u64 transmit_time) |
|---|
| 1558 | 1689 | { |
|---|
| 1559 | 1690 | struct ip_options_data replyopts; |
|---|
| 1560 | 1691 | struct ipcm_cookie ipc; |
|---|
| .. | .. |
|---|
| 1570 | 1701 | |
|---|
| 1571 | 1702 | ipcm_init(&ipc); |
|---|
| 1572 | 1703 | ipc.addr = daddr; |
|---|
| 1704 | + ipc.sockc.transmit_time = transmit_time; |
|---|
| 1573 | 1705 | |
|---|
| 1574 | 1706 | if (replyopts.opt.opt.optlen) { |
|---|
| 1575 | 1707 | ipc.opt = &replyopts.opt; |
|---|
| .. | .. |
|---|
| 1590 | 1722 | daddr, saddr, |
|---|
| 1591 | 1723 | tcp_hdr(skb)->source, tcp_hdr(skb)->dest, |
|---|
| 1592 | 1724 | arg->uid); |
|---|
| 1593 | | - security_skb_classify_flow(skb, flowi4_to_flowi(&fl4)); |
|---|
| 1725 | + security_skb_classify_flow(skb, flowi4_to_flowi_common(&fl4)); |
|---|
| 1594 | 1726 | rt = ip_route_output_key(net, &fl4); |
|---|
| 1595 | 1727 | if (IS_ERR(rt)) |
|---|
| 1596 | 1728 | return; |
|---|
| 1597 | 1729 | |
|---|
| 1598 | 1730 | inet_sk(sk)->tos = arg->tos & ~INET_ECN_MASK; |
|---|
| 1599 | 1731 | |
|---|
| 1600 | | - sk->sk_priority = skb->priority; |
|---|
| 1601 | 1732 | sk->sk_protocol = ip_hdr(skb)->protocol; |
|---|
| 1602 | 1733 | sk->sk_bound_dev_if = arg->bound_dev_if; |
|---|
| 1603 | | - sk->sk_sndbuf = sysctl_wmem_default; |
|---|
| 1604 | | - sk->sk_mark = fl4.flowi4_mark; |
|---|
| 1734 | + sk->sk_sndbuf = READ_ONCE(sysctl_wmem_default); |
|---|
| 1735 | + ipc.sockc.mark = fl4.flowi4_mark; |
|---|
| 1605 | 1736 | err = ip_append_data(sk, &fl4, ip_reply_glue_bits, arg->iov->iov_base, |
|---|
| 1606 | 1737 | len, 0, &ipc, &rt, MSG_DONTWAIT); |
|---|
| 1607 | 1738 | if (unlikely(err)) { |
|---|