Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'net-add-data-race-annotations-around-dst-fields'

Eric Dumazet says:

====================
net: add data-race annotations around dst fields

Add annotations around various dst fields, which can change under us.

Add four helpers to prepare better dst->dev protection,
and start using them. More to come later.

v1: https://lore.kernel.org/20250627112526.3615031-1-edumazet@google.com
====================

Link: https://patch.msgid.link/20250630121934.3399505-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+242 -202
+30 -8
include/net/dst.h
··· 240 240 241 241 static inline void dst_use_noref(struct dst_entry *dst, unsigned long time) 242 242 { 243 - if (unlikely(time != dst->lastuse)) { 243 + if (unlikely(time != READ_ONCE(dst->lastuse))) { 244 244 dst->__use++; 245 - dst->lastuse = time; 245 + WRITE_ONCE(dst->lastuse, time); 246 246 } 247 247 } 248 248 ··· 431 431 432 432 static inline void dst_set_expires(struct dst_entry *dst, int timeout) 433 433 { 434 - unsigned long expires = jiffies + timeout; 434 + unsigned long old, expires = jiffies + timeout; 435 435 436 436 if (expires == 0) 437 437 expires = 1; 438 438 439 - if (dst->expires == 0 || time_before(expires, dst->expires)) 440 - dst->expires = expires; 439 + old = READ_ONCE(dst->expires); 440 + 441 + if (!old || time_before(expires, old)) 442 + WRITE_ONCE(dst->expires, expires); 441 443 } 442 444 443 445 static inline unsigned int dst_dev_overhead(struct dst_entry *dst, ··· 458 456 /* Output packet to network from transport. */ 459 457 static inline int dst_output(struct net *net, struct sock *sk, struct sk_buff *skb) 460 458 { 461 - return INDIRECT_CALL_INET(skb_dst(skb)->output, 459 + return INDIRECT_CALL_INET(READ_ONCE(skb_dst(skb)->output), 462 460 ip6_output, ip_output, 463 461 net, sk, skb); 464 462 } ··· 468 466 /* Input packet from network to transport. */ 469 467 static inline int dst_input(struct sk_buff *skb) 470 468 { 471 - return INDIRECT_CALL_INET(skb_dst(skb)->input, 469 + return INDIRECT_CALL_INET(READ_ONCE(skb_dst(skb)->input), 472 470 ip6_input, ip_local_deliver, skb); 473 471 } 474 472 ··· 478 476 u32)); 479 477 static inline struct dst_entry *dst_check(struct dst_entry *dst, u32 cookie) 480 478 { 481 - if (dst->obsolete) 479 + if (READ_ONCE(dst->obsolete)) 482 480 dst = INDIRECT_CALL_INET(dst->ops->check, ip6_dst_check, 483 481 ipv4_dst_check, dst, cookie); 484 482 return dst; ··· 561 559 562 560 if (dst && dst->ops->update_pmtu) 563 561 dst->ops->update_pmtu(dst, NULL, skb, mtu, false); 562 + } 563 + 564 + static inline struct net_device *dst_dev(const struct dst_entry *dst) 565 + { 566 + return READ_ONCE(dst->dev); 567 + } 568 + 569 + static inline struct net_device *skb_dst_dev(const struct sk_buff *skb) 570 + { 571 + return dst_dev(skb_dst(skb)); 572 + } 573 + 574 + static inline struct net *skb_dst_dev_net(const struct sk_buff *skb) 575 + { 576 + return dev_net(skb_dst_dev(skb)); 577 + } 578 + 579 + static inline struct net *skb_dst_dev_net_rcu(const struct sk_buff *skb) 580 + { 581 + return dev_net_rcu(skb_dst_dev(skb)); 564 582 } 565 583 566 584 struct dst_entry *dst_blackhole_check(struct dst_entry *dst, u32 cookie);
+1 -1
include/net/inet6_hashtables.h
··· 150 150 int iif, int sdif, 151 151 bool *refcounted) 152 152 { 153 - struct net *net = dev_net_rcu(skb_dst(skb)->dev); 153 + struct net *net = skb_dst_dev_net_rcu(skb); 154 154 const struct ipv6hdr *ip6h = ipv6_hdr(skb); 155 155 struct sock *sk; 156 156
+1 -1
include/net/inet_hashtables.h
··· 481 481 const int sdif, 482 482 bool *refcounted) 483 483 { 484 - struct net *net = dev_net_rcu(skb_dst(skb)->dev); 484 + struct net *net = skb_dst_dev_net_rcu(skb); 485 485 const struct iphdr *iph = ip_hdr(skb); 486 486 struct sock *sk; 487 487
+7 -6
include/net/ip.h
··· 472 472 473 473 rcu_read_lock(); 474 474 475 - net = dev_net_rcu(dst->dev); 475 + net = dev_net_rcu(dst_dev(dst)); 476 476 if (READ_ONCE(net->ipv4.sysctl_ip_fwd_use_pmtu) || 477 477 ip_mtu_locked(dst) || 478 478 !forwarding) { 479 479 mtu = rt->rt_pmtu; 480 - if (mtu && time_before(jiffies, rt->dst.expires)) 480 + if (mtu && time_before(jiffies, READ_ONCE(rt->dst.expires))) 481 481 goto out; 482 482 } 483 483 ··· 486 486 if (mtu) 487 487 goto out; 488 488 489 - mtu = READ_ONCE(dst->dev->mtu); 489 + mtu = READ_ONCE(dst_dev(dst)->mtu); 490 490 491 491 if (unlikely(ip_mtu_locked(dst))) { 492 492 if (rt->rt_uses_gateway && mtu > 576) ··· 506 506 static inline unsigned int ip_skb_dst_mtu(struct sock *sk, 507 507 const struct sk_buff *skb) 508 508 { 509 + const struct dst_entry *dst = skb_dst(skb); 509 510 unsigned int mtu; 510 511 511 512 if (!sk || !sk_fullsock(sk) || ip_sk_use_pmtu(sk)) { 512 513 bool forwarding = IPCB(skb)->flags & IPSKB_FORWARDED; 513 514 514 - return ip_dst_mtu_maybe_forward(skb_dst(skb), forwarding); 515 + return ip_dst_mtu_maybe_forward(dst, forwarding); 515 516 } 516 517 517 - mtu = min(READ_ONCE(skb_dst(skb)->dev->mtu), IP_MAX_MTU); 518 - return mtu - lwtunnel_headroom(skb_dst(skb)->lwtstate, mtu); 518 + mtu = min(READ_ONCE(dst_dev(dst)->mtu), IP_MAX_MTU); 519 + return mtu - lwtunnel_headroom(dst->lwtstate, mtu); 519 520 } 520 521 521 522 struct dst_metrics *ip_fib_metrics_init(struct nlattr *fc_mx, int fc_mx_len,
+2 -2
include/net/ip6_route.h
··· 274 274 unsigned int mtu; 275 275 276 276 if (np && READ_ONCE(np->pmtudisc) >= IPV6_PMTUDISC_PROBE) { 277 - mtu = READ_ONCE(dst->dev->mtu); 277 + mtu = READ_ONCE(dst_dev(dst)->mtu); 278 278 mtu -= lwtunnel_headroom(dst->lwtstate, mtu); 279 279 } else { 280 280 mtu = dst_mtu(dst); ··· 337 337 338 338 mtu = IPV6_MIN_MTU; 339 339 rcu_read_lock(); 340 - idev = __in6_dev_get(dst->dev); 340 + idev = __in6_dev_get(dst_dev(dst)); 341 341 if (idev) 342 342 mtu = READ_ONCE(idev->cnf.mtu6); 343 343 rcu_read_unlock();
+1 -1
include/net/ip6_tunnel.h
··· 159 159 memset(skb->cb, 0, sizeof(struct inet6_skb_parm)); 160 160 IP6CB(skb)->flags = ip6cb_flags; 161 161 pkt_len = skb->len - skb_inner_network_offset(skb); 162 - err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb); 162 + err = ip6_local_out(skb_dst_dev_net(skb), sk, skb); 163 163 164 164 if (dev) { 165 165 if (unlikely(net_xmit_eval(err)))
+4 -4
include/net/lwtunnel.h
··· 138 138 static inline void lwtunnel_set_redirect(struct dst_entry *dst) 139 139 { 140 140 if (lwtunnel_output_redirect(dst->lwtstate)) { 141 - dst->lwtstate->orig_output = dst->output; 142 - dst->output = lwtunnel_output; 141 + dst->lwtstate->orig_output = READ_ONCE(dst->output); 142 + WRITE_ONCE(dst->output, lwtunnel_output); 143 143 } 144 144 if (lwtunnel_input_redirect(dst->lwtstate)) { 145 - dst->lwtstate->orig_input = dst->input; 146 - dst->input = lwtunnel_input; 145 + dst->lwtstate->orig_input = READ_ONCE(dst->input); 146 + WRITE_ONCE(dst->input, lwtunnel_input); 147 147 } 148 148 } 149 149 #else
+1 -1
include/net/route.h
··· 390 390 const struct net *net; 391 391 392 392 rcu_read_lock(); 393 - net = dev_net_rcu(dst->dev); 393 + net = dev_net_rcu(dst_dev(dst)); 394 394 hoplimit = READ_ONCE(net->ipv4.sysctl_ip_default_ttl); 395 395 rcu_read_unlock(); 396 396 }
+5 -5
net/core/dst.c
··· 145 145 { 146 146 struct net_device *dev = dst->dev; 147 147 148 - dst->obsolete = DST_OBSOLETE_DEAD; 148 + WRITE_ONCE(dst->obsolete, DST_OBSOLETE_DEAD); 149 149 if (dst->ops->ifdown) 150 150 dst->ops->ifdown(dst, dev); 151 - dst->input = dst_discard; 152 - dst->output = dst_discard_out; 153 - dst->dev = blackhole_netdev; 151 + WRITE_ONCE(dst->input, dst_discard); 152 + WRITE_ONCE(dst->output, dst_discard_out); 153 + WRITE_ONCE(dst->dev, blackhole_netdev); 154 154 netdev_ref_replace(dev, blackhole_netdev, &dst->dev_tracker, 155 155 GFP_ATOMIC); 156 156 } ··· 263 263 { 264 264 unsigned int mtu = dst_metric_raw(dst, RTAX_MTU); 265 265 266 - return mtu ? : dst->dev->mtu; 266 + return mtu ? : dst_dev(dst)->mtu; 267 267 } 268 268 EXPORT_SYMBOL_GPL(dst_blackhole_mtu); 269 269
+1 -1
net/core/dst_cache.c
··· 52 52 53 53 if (unlikely(!time_after(idst->refresh_ts, 54 54 READ_ONCE(dst_cache->reset_ts)) || 55 - (dst->obsolete && !dst->ops->check(dst, idst->cookie)))) { 55 + (READ_ONCE(dst->obsolete) && !dst->ops->check(dst, idst->cookie)))) { 56 56 dst_cache_per_cpu_dst_set(idst, NULL, 0); 57 57 dst_release(dst); 58 58 goto fail;
+2 -1
net/core/neighbour.c
··· 1428 1428 * we can reinject the packet there. 1429 1429 */ 1430 1430 n2 = NULL; 1431 - if (dst && dst->obsolete != DST_OBSOLETE_DEAD) { 1431 + if (dst && 1432 + READ_ONCE(dst->obsolete) != DST_OBSOLETE_DEAD) { 1432 1433 n2 = dst_neigh_lookup_skb(dst, skb); 1433 1434 if (n2) 1434 1435 n1 = n2;
+3 -1
net/core/rtnetlink.c
··· 1026 1026 .rta_error = error, 1027 1027 .rta_id = id, 1028 1028 }; 1029 + unsigned long delta; 1029 1030 1030 1031 if (dst) { 1031 - ci.rta_lastuse = jiffies_delta_to_clock_t(jiffies - dst->lastuse); 1032 + delta = jiffies - READ_ONCE(dst->lastuse); 1033 + ci.rta_lastuse = jiffies_delta_to_clock_t(delta); 1032 1034 ci.rta_used = dst->__use; 1033 1035 ci.rta_clntref = rcuref_read(&dst->__rcuref); 1034 1036 }
+6 -6
net/core/sock.c
··· 602 602 { 603 603 struct dst_entry *dst = __sk_dst_get(sk); 604 604 605 - if (dst && dst->obsolete && 605 + if (dst && READ_ONCE(dst->obsolete) && 606 606 INDIRECT_CALL_INET(dst->ops->check, ip6_dst_check, ipv4_dst_check, 607 607 dst, cookie) == NULL) { 608 608 sk_tx_queue_clear(sk); ··· 620 620 { 621 621 struct dst_entry *dst = sk_dst_get(sk); 622 622 623 - if (dst && dst->obsolete && 623 + if (dst && READ_ONCE(dst->obsolete) && 624 624 INDIRECT_CALL_INET(dst->ops->check, ip6_dst_check, ipv4_dst_check, 625 625 dst, cookie) == NULL) { 626 626 sk_dst_reset(sk); ··· 2588 2588 !ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr)); 2589 2589 #endif 2590 2590 /* pairs with the WRITE_ONCE() in netif_set_gso(_ipv4)_max_size() */ 2591 - max_size = is_ipv6 ? READ_ONCE(dst->dev->gso_max_size) : 2592 - READ_ONCE(dst->dev->gso_ipv4_max_size); 2591 + max_size = is_ipv6 ? READ_ONCE(dst_dev(dst)->gso_max_size) : 2592 + READ_ONCE(dst_dev(dst)->gso_ipv4_max_size); 2593 2593 if (max_size > GSO_LEGACY_MAX_SIZE && !sk_is_tcp(sk)) 2594 2594 max_size = GSO_LEGACY_MAX_SIZE; 2595 2595 ··· 2600 2600 { 2601 2601 u32 max_segs = 1; 2602 2602 2603 - sk->sk_route_caps = dst->dev->features; 2603 + sk->sk_route_caps = dst_dev(dst)->features; 2604 2604 if (sk_is_tcp(sk)) { 2605 2605 struct inet_connection_sock *icsk = inet_csk(sk); 2606 2606 ··· 2618 2618 sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM; 2619 2619 sk->sk_gso_max_size = sk_dst_gso_max_size(sk, dst); 2620 2620 /* pairs with the WRITE_ONCE() in netif_set_gso_max_segs() */ 2621 - max_segs = max_t(u32, READ_ONCE(dst->dev->gso_max_segs), 1); 2621 + max_segs = max_t(u32, READ_ONCE(dst_dev(dst)->gso_max_segs), 1); 2622 2622 } 2623 2623 } 2624 2624 sk->sk_gso_max_segs = max_segs;
+1 -1
net/ipv4/datagram.c
··· 109 109 rcu_read_lock(); 110 110 111 111 dst = __sk_dst_get(sk); 112 - if (!dst || !dst->obsolete || dst->ops->check(dst, 0)) { 112 + if (!dst || !READ_ONCE(dst->obsolete) || dst->ops->check(dst, 0)) { 113 113 rcu_read_unlock(); 114 114 return; 115 115 }
+13 -11
net/ipv4/icmp.c
··· 311 311 { 312 312 struct dst_entry *dst = &rt->dst; 313 313 struct inet_peer *peer; 314 + struct net_device *dev; 314 315 bool rc = true; 315 316 316 317 if (!apply_ratelimit) 317 318 return true; 318 319 319 320 /* No rate limit on loopback */ 320 - if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) 321 + dev = dst_dev(dst); 322 + if (dev && (dev->flags & IFF_LOOPBACK)) 321 323 goto out; 322 324 323 325 rcu_read_lock(); 324 326 peer = inet_getpeer_v4(net->ipv4.peers, fl4->daddr, 325 - l3mdev_master_ifindex_rcu(dst->dev)); 327 + l3mdev_master_ifindex_rcu(dev)); 326 328 rc = inet_peer_xrlim_allow(peer, 327 329 READ_ONCE(net->ipv4.sysctl_icmp_ratelimit)); 328 330 rcu_read_unlock(); ··· 468 466 */ 469 467 static struct net_device *icmp_get_route_lookup_dev(struct sk_buff *skb) 470 468 { 471 - struct net_device *route_lookup_dev = NULL; 469 + struct net_device *dev = skb->dev; 470 + const struct dst_entry *dst; 472 471 473 - if (skb->dev) 474 - route_lookup_dev = skb->dev; 475 - else if (skb_dst(skb)) 476 - route_lookup_dev = skb_dst(skb)->dev; 477 - return route_lookup_dev; 472 + if (dev) 473 + return dev; 474 + dst = skb_dst(skb); 475 + return dst ? dst_dev(dst) : NULL; 478 476 } 479 477 480 478 static struct rtable *icmp_route_lookup(struct net *net, struct flowi4 *fl4, ··· 871 869 struct net *net; 872 870 u32 info = 0; 873 871 874 - net = dev_net_rcu(skb_dst(skb)->dev); 872 + net = skb_dst_dev_net_rcu(skb); 875 873 876 874 /* 877 875 * Incomplete header ? ··· 1014 1012 struct icmp_bxm icmp_param; 1015 1013 struct net *net; 1016 1014 1017 - net = dev_net_rcu(skb_dst(skb)->dev); 1015 + net = skb_dst_dev_net_rcu(skb); 1018 1016 /* should there be an ICMP stat for ignored echos? */ 1019 1017 if (READ_ONCE(net->ipv4.sysctl_icmp_echo_ignore_all)) 1020 1018 return SKB_NOT_DROPPED_YET; ··· 1184 1182 return SKB_NOT_DROPPED_YET; 1185 1183 1186 1184 out_err: 1187 - __ICMP_INC_STATS(dev_net_rcu(skb_dst(skb)->dev), ICMP_MIB_INERRORS); 1185 + __ICMP_INC_STATS(skb_dst_dev_net_rcu(skb), ICMP_MIB_INERRORS); 1188 1186 return SKB_DROP_REASON_PKT_TOO_SMALL; 1189 1187 } 1190 1188
+1 -1
net/ipv4/igmp.c
··· 427 427 428 428 pig->csum = ip_compute_csum(igmp_hdr(skb), igmplen); 429 429 430 - return ip_local_out(dev_net(skb_dst(skb)->dev), skb->sk, skb); 430 + return ip_local_out(skb_dst_dev_net(skb), skb->sk, skb); 431 431 } 432 432 433 433 static int grec_size(struct ip_mc_list *pmc, int type, int gdel, int sdel)
+1 -1
net/ipv4/ip_fragment.c
··· 476 476 /* Process an incoming IP datagram fragment. */ 477 477 int ip_defrag(struct net *net, struct sk_buff *skb, u32 user) 478 478 { 479 - struct net_device *dev = skb->dev ? : skb_dst(skb)->dev; 479 + struct net_device *dev = skb->dev ? : skb_dst_dev(skb); 480 480 int vif = l3mdev_master_ifindex_rcu(dev); 481 481 struct ipq *qp; 482 482
+3 -3
net/ipv4/ip_output.c
··· 116 116 skb->protocol = htons(ETH_P_IP); 117 117 118 118 return nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, 119 - net, sk, skb, NULL, skb_dst(skb)->dev, 119 + net, sk, skb, NULL, skb_dst_dev(skb), 120 120 dst_output); 121 121 } 122 122 ··· 199 199 { 200 200 struct dst_entry *dst = skb_dst(skb); 201 201 struct rtable *rt = dst_rtable(dst); 202 - struct net_device *dev = dst->dev; 202 + struct net_device *dev = dst_dev(dst); 203 203 unsigned int hh_len = LL_RESERVED_SPACE(dev); 204 204 struct neighbour *neigh; 205 205 bool is_v6gw = false; ··· 425 425 426 426 int ip_output(struct net *net, struct sock *sk, struct sk_buff *skb) 427 427 { 428 - struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev; 428 + struct net_device *dev = skb_dst_dev(skb), *indev = skb->dev; 429 429 430 430 skb->dev = dev; 431 431 skb->protocol = htons(ETH_P_IP);
+2 -2
net/ipv4/ip_vti.c
··· 229 229 goto tx_error_icmp; 230 230 } 231 231 232 - tdev = dst->dev; 232 + tdev = dst_dev(dst); 233 233 234 234 if (tdev == dev) { 235 235 dst_release(dst); ··· 259 259 xmit: 260 260 skb_scrub_packet(skb, !net_eq(tunnel->net, dev_net(dev))); 261 261 skb_dst_set(skb, dst); 262 - skb->dev = skb_dst(skb)->dev; 262 + skb->dev = skb_dst_dev(skb); 263 263 264 264 err = dst_output(tunnel->net, skb->sk, skb); 265 265 if (net_xmit_eval(err) == 0)
+2 -2
net/ipv4/netfilter.c
··· 20 20 /* route_me_harder function, used by iptable_nat, iptable_mangle + ip_queue */ 21 21 int ip_route_me_harder(struct net *net, struct sock *sk, struct sk_buff *skb, unsigned int addr_type) 22 22 { 23 + struct net_device *dev = skb_dst_dev(skb); 23 24 const struct iphdr *iph = ip_hdr(skb); 24 25 struct rtable *rt; 25 26 struct flowi4 fl4 = {}; 26 27 __be32 saddr = iph->saddr; 27 28 __u8 flags; 28 - struct net_device *dev = skb_dst(skb)->dev; 29 29 struct flow_keys flkeys; 30 30 unsigned int hh_len; 31 31 ··· 74 74 #endif 75 75 76 76 /* Change in oif may mean change in hh_len. */ 77 - hh_len = skb_dst(skb)->dev->hard_header_len; 77 + hh_len = skb_dst_dev(skb)->hard_header_len; 78 78 if (skb_headroom(skb) < hh_len && 79 79 pskb_expand_head(skb, HH_DATA_ALIGN(hh_len - skb_headroom(skb)), 80 80 0, GFP_ATOMIC))
+18 -16
net/ipv4/route.c
··· 413 413 const void *daddr) 414 414 { 415 415 const struct rtable *rt = container_of(dst, struct rtable, dst); 416 - struct net_device *dev = dst->dev; 416 + struct net_device *dev = dst_dev(dst); 417 417 struct neighbour *n; 418 418 419 419 rcu_read_lock(); ··· 440 440 static void ipv4_confirm_neigh(const struct dst_entry *dst, const void *daddr) 441 441 { 442 442 const struct rtable *rt = container_of(dst, struct rtable, dst); 443 - struct net_device *dev = dst->dev; 443 + struct net_device *dev = dst_dev(dst); 444 444 const __be32 *pkey = daddr; 445 445 446 446 if (rt->rt_gw_family == AF_INET) { ··· 717 717 */ 718 718 rt = rcu_dereference(nhc->nhc_rth_input); 719 719 if (rt) 720 - rt->dst.obsolete = DST_OBSOLETE_KILL; 720 + WRITE_ONCE(rt->dst.obsolete, DST_OBSOLETE_KILL); 721 721 722 722 for_each_possible_cpu(i) { 723 723 struct rtable __rcu **prt; ··· 725 725 prt = per_cpu_ptr(nhc->nhc_pcpu_rth_output, i); 726 726 rt = rcu_dereference(*prt); 727 727 if (rt) 728 - rt->dst.obsolete = DST_OBSOLETE_KILL; 728 + WRITE_ONCE(rt->dst.obsolete, DST_OBSOLETE_KILL); 729 729 } 730 730 } 731 731 ··· 797 797 jiffies + ip_rt_gc_timeout); 798 798 } 799 799 if (kill_route) 800 - rt->dst.obsolete = DST_OBSOLETE_KILL; 800 + WRITE_ONCE(rt->dst.obsolete, DST_OBSOLETE_KILL); 801 801 call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, n); 802 802 } 803 803 neigh_release(n); ··· 842 842 { 843 843 struct rtable *rt = dst_rtable(dst); 844 844 845 - if ((dst->obsolete > 0) || 845 + if ((READ_ONCE(dst->obsolete) > 0) || 846 846 (rt->rt_flags & RTCF_REDIRECTED) || 847 - rt->dst.expires) 847 + READ_ONCE(rt->dst.expires)) 848 848 sk_dst_reset(sk); 849 849 } 850 850 ··· 1026 1026 return; 1027 1027 1028 1028 rcu_read_lock(); 1029 - net = dev_net_rcu(dst->dev); 1029 + net = dev_net_rcu(dst_dev(dst)); 1030 1030 if (mtu < net->ipv4.ip_rt_min_pmtu) { 1031 1031 lock = true; 1032 1032 mtu = min(old_mtu, net->ipv4.ip_rt_min_pmtu); 1033 1033 } 1034 1034 1035 1035 if (rt->rt_pmtu == mtu && !lock && 1036 - time_before(jiffies, dst->expires - net->ipv4.ip_rt_mtu_expires / 2)) 1036 + time_before(jiffies, READ_ONCE(dst->expires) - 1037 + net->ipv4.ip_rt_mtu_expires / 2)) 1037 1038 goto out; 1038 1039 1039 1040 if (fib_lookup(net, fl4, &res, 0) == 0) { ··· 1137 1136 __build_flow_key(net, &fl4, sk, iph, 0, 0, 0, 0, 0); 1138 1137 1139 1138 rt = dst_rtable(odst); 1140 - if (odst->obsolete && !odst->ops->check(odst, 0)) { 1139 + if (READ_ONCE(odst->obsolete) && !odst->ops->check(odst, 0)) { 1141 1140 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); 1142 1141 if (IS_ERR(rt)) 1143 1142 goto out; ··· 1212 1211 * this is indicated by setting obsolete to DST_OBSOLETE_KILL or 1213 1212 * DST_OBSOLETE_DEAD. 1214 1213 */ 1215 - if (dst->obsolete != DST_OBSOLETE_FORCE_CHK || rt_is_expired(rt)) 1214 + if (READ_ONCE(dst->obsolete) != DST_OBSOLETE_FORCE_CHK || 1215 + rt_is_expired(rt)) 1216 1216 return NULL; 1217 1217 return dst; 1218 1218 } ··· 1326 1324 struct net *net; 1327 1325 1328 1326 rcu_read_lock(); 1329 - net = dev_net_rcu(dst->dev); 1327 + net = dev_net_rcu(dst_dev(dst)); 1330 1328 advmss = max_t(unsigned int, ipv4_mtu(dst) - header_size, 1331 1329 net->ipv4.ip_rt_min_advmss); 1332 1330 rcu_read_unlock(); ··· 1573 1571 static bool rt_cache_valid(const struct rtable *rt) 1574 1572 { 1575 1573 return rt && 1576 - rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && 1574 + READ_ONCE(rt->dst.obsolete) == DST_OBSOLETE_FORCE_CHK && 1577 1575 !rt_is_expired(rt); 1578 1576 } 1579 1577 ··· 1687 1685 else if (rt->rt_gw_family == AF_INET6) 1688 1686 new_rt->rt_gw6 = rt->rt_gw6; 1689 1687 1690 - new_rt->dst.input = rt->dst.input; 1691 - new_rt->dst.output = rt->dst.output; 1688 + new_rt->dst.input = READ_ONCE(rt->dst.input); 1689 + new_rt->dst.output = READ_ONCE(rt->dst.output); 1692 1690 new_rt->dst.error = rt->dst.error; 1693 1691 new_rt->dst.lastuse = jiffies; 1694 1692 new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate); ··· 3011 3009 } 3012 3010 } 3013 3011 3014 - expires = rt->dst.expires; 3012 + expires = READ_ONCE(rt->dst.expires); 3015 3013 if (expires) { 3016 3014 unsigned long now = jiffies; 3017 3015
+3 -1
net/ipv4/tcp_fastopen.c
··· 559 559 void tcp_fastopen_active_disable_ofo_check(struct sock *sk) 560 560 { 561 561 struct tcp_sock *tp = tcp_sk(sk); 562 + struct net_device *dev; 562 563 struct dst_entry *dst; 563 564 struct sk_buff *skb; 564 565 ··· 577 576 } else if (tp->syn_fastopen_ch && 578 577 atomic_read(&sock_net(sk)->ipv4.tfo_active_disable_times)) { 579 578 dst = sk_dst_get(sk); 580 - if (!(dst && dst->dev && (dst->dev->flags & IFF_LOOPBACK))) 579 + dev = dst ? dst_dev(dst) : NULL; 580 + if (!(dev && (dev->flags & IFF_LOOPBACK))) 581 581 atomic_set(&sock_net(sk)->ipv4.tfo_active_disable_times, 0); 582 582 dst_release(dst); 583 583 }
+1 -1
net/ipv4/tcp_ipv4.c
··· 788 788 arg.iov[0].iov_base = (unsigned char *)&rep; 789 789 arg.iov[0].iov_len = sizeof(rep.th); 790 790 791 - net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); 791 + net = sk ? sock_net(sk) : skb_dst_dev_net_rcu(skb); 792 792 793 793 /* Invalid TCP option size or twice included auth */ 794 794 if (tcp_parse_auth_options(tcp_hdr(skb), &md5_hash_location, &aoh))
+4 -4
net/ipv4/tcp_metrics.c
··· 166 166 unsigned int hash) 167 167 { 168 168 struct tcp_metrics_block *tm; 169 - struct net *net; 170 169 bool reclaim = false; 170 + struct net *net; 171 171 172 172 spin_lock_bh(&tcp_metrics_lock); 173 - net = dev_net_rcu(dst->dev); 173 + net = dev_net_rcu(dst_dev(dst)); 174 174 175 175 /* While waiting for the spin-lock the cache might have been populated 176 176 * with this entry and so we have to check again. ··· 273 273 return NULL; 274 274 } 275 275 276 - net = dev_net_rcu(dst->dev); 276 + net = dev_net_rcu(dst_dev(dst)); 277 277 hash ^= net_hash_mix(net); 278 278 hash = hash_32(hash, tcp_metrics_hash_log); 279 279 ··· 318 318 else 319 319 return NULL; 320 320 321 - net = dev_net_rcu(dst->dev); 321 + net = dev_net_rcu(dst_dev(dst)); 322 322 hash ^= net_hash_mix(net); 323 323 hash = hash_32(hash, tcp_metrics_hash_log); 324 324
+1 -1
net/ipv4/xfrm4_output.c
··· 31 31 int xfrm4_output(struct net *net, struct sock *sk, struct sk_buff *skb) 32 32 { 33 33 return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, 34 - net, sk, skb, skb->dev, skb_dst(skb)->dev, 34 + net, sk, skb, skb->dev, skb_dst_dev(skb), 35 35 __xfrm4_output, 36 36 !(IPCB(skb)->flags & IPSKB_REROUTED)); 37 37 }
+1 -1
net/ipv6/datagram.c
··· 127 127 128 128 rcu_read_lock(); 129 129 dst = __sk_dst_get(sk); 130 - if (!dst || !dst->obsolete || 130 + if (!dst || !READ_ONCE(dst->obsolete) || 131 131 dst->ops->check(dst, inet6_sk(sk)->dst_cookie)) { 132 132 rcu_read_unlock(); 133 133 return;
+5 -5
net/ipv6/exthdrs.c
··· 306 306 if (!pskb_may_pull(skb, skb_transport_offset(skb) + 8) || 307 307 !pskb_may_pull(skb, (skb_transport_offset(skb) + 308 308 ((skb_transport_header(skb)[1] + 1) << 3)))) { 309 - __IP6_INC_STATS(dev_net(dst->dev), idev, 309 + __IP6_INC_STATS(dev_net(dst_dev(dst)), idev, 310 310 IPSTATS_MIB_INHDRERRORS); 311 311 fail_and_free: 312 312 kfree_skb(skb); ··· 460 460 return -1; 461 461 } 462 462 463 - if (skb_dst(skb)->dev->flags & IFF_LOOPBACK) { 463 + if (skb_dst_dev(skb)->flags & IFF_LOOPBACK) { 464 464 if (ipv6_hdr(skb)->hop_limit <= 1) { 465 465 __IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS); 466 466 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ··· 621 621 return -1; 622 622 } 623 623 624 - if (skb_dst(skb)->dev->flags & IFF_LOOPBACK) { 624 + if (skb_dst_dev(skb)->flags & IFF_LOOPBACK) { 625 625 if (ipv6_hdr(skb)->hop_limit <= 1) { 626 626 __IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS); 627 627 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ··· 783 783 kfree_skb(skb); 784 784 return -1; 785 785 } 786 - if (!ipv6_chk_home_addr(dev_net(skb_dst(skb)->dev), addr)) { 786 + if (!ipv6_chk_home_addr(skb_dst_dev_net(skb), addr)) { 787 787 __IP6_INC_STATS(net, idev, IPSTATS_MIB_INADDRERRORS); 788 788 kfree_skb(skb); 789 789 return -1; ··· 809 809 return -1; 810 810 } 811 811 812 - if (skb_dst(skb)->dev->flags&IFF_LOOPBACK) { 812 + if (skb_dst_dev(skb)->flags & IFF_LOOPBACK) { 813 813 if (ipv6_hdr(skb)->hop_limit <= 1) { 814 814 __IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS); 815 815 icmpv6_send(skb, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT,
+3 -1
net/ipv6/icmp.c
··· 196 196 struct flowi6 *fl6, bool apply_ratelimit) 197 197 { 198 198 struct net *net = sock_net(sk); 199 + struct net_device *dev; 199 200 struct dst_entry *dst; 200 201 bool res = false; 201 202 ··· 209 208 * this lookup should be more aggressive (not longer than timeout). 210 209 */ 211 210 dst = ip6_route_output(net, sk, fl6); 211 + dev = dst_dev(dst); 212 212 if (dst->error) { 213 213 IP6_INC_STATS(net, ip6_dst_idev(dst), 214 214 IPSTATS_MIB_OUTNOROUTES); 215 - } else if (dst->dev && (dst->dev->flags&IFF_LOOPBACK)) { 215 + } else if (dev && (dev->flags & IFF_LOOPBACK)) { 216 216 res = true; 217 217 } else { 218 218 struct rt6_info *rt = dst_rt6_info(dst);
+1 -1
net/ipv6/ila/ila_lwt.c
··· 70 70 */ 71 71 72 72 memset(&fl6, 0, sizeof(fl6)); 73 - fl6.flowi6_oif = orig_dst->dev->ifindex; 73 + fl6.flowi6_oif = dst_dev(orig_dst)->ifindex; 74 74 fl6.flowi6_iif = LOOPBACK_IFINDEX; 75 75 fl6.daddr = *rt6_nexthop(dst_rt6_info(orig_dst), 76 76 &ip6h->daddr);
+9 -8
net/ipv6/ioam6.c
··· 696 696 struct ioam6_schema *sc, 697 697 u8 sclen, bool is_input) 698 698 { 699 + struct net_device *dev = skb_dst_dev(skb); 699 700 struct timespec64 ts; 700 701 ktime_t tstamp; 701 702 u64 raw64; ··· 713 712 if (is_input) 714 713 byte--; 715 714 716 - raw32 = dev_net(skb_dst(skb)->dev)->ipv6.sysctl.ioam6_id; 715 + raw32 = dev_net(dev)->ipv6.sysctl.ioam6_id; 717 716 718 717 *(__be32 *)data = cpu_to_be32((byte << 24) | raw32); 719 718 data += sizeof(__be32); ··· 729 728 *(__be16 *)data = cpu_to_be16(raw16); 730 729 data += sizeof(__be16); 731 730 732 - if (skb_dst(skb)->dev->flags & IFF_LOOPBACK) 731 + if (dev->flags & IFF_LOOPBACK) 733 732 raw16 = IOAM6_U16_UNAVAILABLE; 734 733 else 735 - raw16 = (__force u16)READ_ONCE(__in6_dev_get(skb_dst(skb)->dev)->cnf.ioam6_id); 734 + raw16 = (__force u16)READ_ONCE(__in6_dev_get(dev)->cnf.ioam6_id); 736 735 737 736 *(__be16 *)data = cpu_to_be16(raw16); 738 737 data += sizeof(__be16); ··· 784 783 struct Qdisc *qdisc; 785 784 __u32 qlen, backlog; 786 785 787 - if (skb_dst(skb)->dev->flags & IFF_LOOPBACK) { 786 + if (dev->flags & IFF_LOOPBACK) { 788 787 *(__be32 *)data = cpu_to_be32(IOAM6_U32_UNAVAILABLE); 789 788 } else { 790 - queue = skb_get_tx_queue(skb_dst(skb)->dev, skb); 789 + queue = skb_get_tx_queue(dev, skb); 791 790 qdisc = rcu_dereference(queue->qdisc); 792 791 qdisc_qstats_qlen_backlog(qdisc, &qlen, &backlog); 793 792 ··· 808 807 if (is_input) 809 808 byte--; 810 809 811 - raw64 = dev_net(skb_dst(skb)->dev)->ipv6.sysctl.ioam6_id_wide; 810 + raw64 = dev_net(dev)->ipv6.sysctl.ioam6_id_wide; 812 811 813 812 *(__be64 *)data = cpu_to_be64(((u64)byte << 56) | raw64); 814 813 data += sizeof(__be64); ··· 824 823 *(__be32 *)data = cpu_to_be32(raw32); 825 824 data += sizeof(__be32); 826 825 827 - if (skb_dst(skb)->dev->flags & IFF_LOOPBACK) 826 + if (dev->flags & IFF_LOOPBACK) 828 827 raw32 = IOAM6_U32_UNAVAILABLE; 829 828 else 830 - raw32 = READ_ONCE(__in6_dev_get(skb_dst(skb)->dev)->cnf.ioam6_id_wide); 829 + raw32 = READ_ONCE(__in6_dev_get(dev)->cnf.ioam6_id_wide); 831 830 832 831 *(__be32 *)data = cpu_to_be32(raw32); 833 832 data += sizeof(__be32);
+2 -2
net/ipv6/ioam6_iptunnel.c
··· 335 335 if (has_tunsrc) 336 336 memcpy(&hdr->saddr, tunsrc, sizeof(*tunsrc)); 337 337 else 338 - ipv6_dev_get_saddr(net, dst->dev, &hdr->daddr, 338 + ipv6_dev_get_saddr(net, dst_dev(dst), &hdr->daddr, 339 339 IPV6_PREFER_SRC_PUBLIC, &hdr->saddr); 340 340 341 341 skb_postpush_rcsum(skb, hdr, len); ··· 442 442 dst_cache_set_ip6(&ilwt->cache, dst, &fl6.saddr); 443 443 local_bh_enable(); 444 444 445 - err = skb_cow_head(skb, LL_RESERVED_SPACE(dst->dev)); 445 + err = skb_cow_head(skb, LL_RESERVED_SPACE(dst_dev(dst))); 446 446 if (unlikely(err)) 447 447 goto drop; 448 448 }
+5 -3
net/ipv6/ip6_gre.c
··· 1085 1085 htonl(atomic_fetch_inc(&t->o_seqno))); 1086 1086 1087 1087 /* TooBig packet may have updated dst->dev's mtu */ 1088 - if (!t->parms.collect_md && dst && dst_mtu(dst) > dst->dev->mtu) 1089 - dst->ops->update_pmtu(dst, NULL, skb, dst->dev->mtu, false); 1090 - 1088 + if (!t->parms.collect_md && dst) { 1089 + mtu = READ_ONCE(dst_dev(dst)->mtu); 1090 + if (dst_mtu(dst) > mtu) 1091 + dst->ops->update_pmtu(dst, NULL, skb, mtu, false); 1092 + } 1091 1093 err = ip6_tnl_xmit(skb, dev, dsfield, &fl6, encap_limit, &mtu, 1092 1094 NEXTHDR_GRE); 1093 1095 if (err != 0) {
+14 -19
net/ipv6/ip6_input.c
··· 187 187 * arrived via the sending interface (ethX), because of the 188 188 * nature of scoping architecture. --yoshfuji 189 189 */ 190 - IP6CB(skb)->iif = skb_valid_dst(skb) ? ip6_dst_idev(skb_dst(skb))->dev->ifindex : dev->ifindex; 190 + IP6CB(skb)->iif = skb_valid_dst(skb) ? 191 + ip6_dst_idev(skb_dst(skb))->dev->ifindex : 192 + dev->ifindex; 191 193 192 194 if (unlikely(!pskb_may_pull(skb, sizeof(*hdr)))) 193 195 goto err; ··· 501 499 502 500 int ip6_mc_input(struct sk_buff *skb) 503 501 { 502 + struct net_device *dev = skb->dev; 504 503 int sdif = inet6_sdif(skb); 505 504 const struct ipv6hdr *hdr; 506 - struct net_device *dev; 507 505 bool deliver; 508 506 509 - __IP6_UPD_PO_STATS(dev_net(skb_dst(skb)->dev), 510 - __in6_dev_get_safely(skb->dev), IPSTATS_MIB_INMCAST, 511 - skb->len); 507 + __IP6_UPD_PO_STATS(skb_dst_dev_net_rcu(skb), 508 + __in6_dev_get_safely(dev), IPSTATS_MIB_INMCAST, 509 + skb->len); 512 510 513 511 /* skb->dev passed may be master dev for vrfs. */ 514 512 if (sdif) { 515 - rcu_read_lock(); 516 - dev = dev_get_by_index_rcu(dev_net(skb->dev), sdif); 513 + dev = dev_get_by_index_rcu(dev_net_rcu(dev), sdif); 517 514 if (!dev) { 518 - rcu_read_unlock(); 519 515 kfree_skb(skb); 520 516 return -ENODEV; 521 517 } 522 - } else { 523 - dev = skb->dev; 524 518 } 525 519 526 520 hdr = ipv6_hdr(skb); 527 521 deliver = ipv6_chk_mcast_addr(dev, &hdr->daddr, NULL); 528 - if (sdif) 529 - rcu_read_unlock(); 530 522 531 523 #ifdef CONFIG_IPV6_MROUTE 532 524 /* 533 525 * IPv6 multicast router mode is now supported ;) 534 526 */ 535 - if (atomic_read(&dev_net(skb->dev)->ipv6.devconf_all->mc_forwarding) && 527 + if (atomic_read(&dev_net_rcu(skb->dev)->ipv6.devconf_all->mc_forwarding) && 536 528 !(ipv6_addr_type(&hdr->daddr) & 537 529 (IPV6_ADDR_LOOPBACK|IPV6_ADDR_LINKLOCAL)) && 538 530 likely(!(IP6CB(skb)->flags & IP6SKB_FORWARDED))) { ··· 567 571 /* unknown RA - process it normally */ 568 572 } 569 573 570 - if (deliver) 574 + if (deliver) { 571 575 skb2 = skb_clone(skb, GFP_ATOMIC); 572 - else { 576 + } else { 573 577 skb2 = skb; 574 578 skb = NULL; 575 579 } 576 580 577 - if (skb2) { 581 + if (skb2) 578 582 ip6_mr_input(skb2); 579 - } 580 583 } 581 584 out: 582 585 #endif 583 - if (likely(deliver)) 586 + if (likely(deliver)) { 584 587 ip6_input(skb); 585 - else { 588 + } else { 586 589 /* discard */ 587 590 kfree_skb(skb); 588 591 }
+13 -11
net/ipv6/ip6_output.c
··· 60 60 static int ip6_finish_output2(struct net *net, struct sock *sk, struct sk_buff *skb) 61 61 { 62 62 struct dst_entry *dst = skb_dst(skb); 63 - struct net_device *dev = dst->dev; 63 + struct net_device *dev = dst_dev(dst); 64 64 struct inet6_dev *idev = ip6_dst_idev(dst); 65 65 unsigned int hh_len = LL_RESERVED_SPACE(dev); 66 66 const struct in6_addr *daddr, *nexthop; ··· 232 232 233 233 int ip6_output(struct net *net, struct sock *sk, struct sk_buff *skb) 234 234 { 235 - struct net_device *dev = skb_dst(skb)->dev, *indev = skb->dev; 236 - struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); 235 + struct dst_entry *dst = skb_dst(skb); 236 + struct net_device *dev = dst_dev(dst), *indev = skb->dev; 237 + struct inet6_dev *idev = ip6_dst_idev(dst); 237 238 238 239 skb->protocol = htons(ETH_P_IPV6); 239 240 skb->dev = dev; ··· 272 271 const struct ipv6_pinfo *np = inet6_sk(sk); 273 272 struct in6_addr *first_hop = &fl6->daddr; 274 273 struct dst_entry *dst = skb_dst(skb); 275 - struct net_device *dev = dst->dev; 274 + struct net_device *dev = dst_dev(dst); 276 275 struct inet6_dev *idev = ip6_dst_idev(dst); 277 276 struct hop_jumbo_hdr *hop_jumbo; 278 277 int hoplen = sizeof(*hop_jumbo); ··· 504 503 struct dst_entry *dst = skb_dst(skb); 505 504 struct ipv6hdr *hdr = ipv6_hdr(skb); 506 505 struct inet6_skb_parm *opt = IP6CB(skb); 507 - struct net *net = dev_net(dst->dev); 506 + struct net *net = dev_net(dst_dev(dst)); 507 + struct net_device *dev; 508 508 struct inet6_dev *idev; 509 509 SKB_DR(reason); 510 510 u32 mtu; ··· 593 591 goto drop; 594 592 } 595 593 dst = skb_dst(skb); 596 - 594 + dev = dst_dev(dst); 597 595 /* IPv6 specs say nothing about it, but it is clear that we cannot 598 596 send redirects to source routed frames. 599 597 We don't send redirects to frames decapsulated from IPsec. 600 598 */ 601 - if (IP6CB(skb)->iif == dst->dev->ifindex && 599 + if (IP6CB(skb)->iif == dev->ifindex && 602 600 opt->srcrt == 0 && !skb_sec_path(skb)) { 603 601 struct in6_addr *target = NULL; 604 602 struct inet_peer *peer; ··· 646 644 647 645 if (ip6_pkt_too_big(skb, mtu)) { 648 646 /* Again, force OUTPUT device used as source address */ 649 - skb->dev = dst->dev; 647 + skb->dev = dev; 650 648 icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); 651 649 __IP6_INC_STATS(net, idev, IPSTATS_MIB_INTOOBIGERRORS); 652 650 __IP6_INC_STATS(net, ip6_dst_idev(dst), ··· 655 653 return -EMSGSIZE; 656 654 } 657 655 658 - if (skb_cow(skb, dst->dev->hard_header_len)) { 656 + if (skb_cow(skb, dev->hard_header_len)) { 659 657 __IP6_INC_STATS(net, ip6_dst_idev(dst), 660 658 IPSTATS_MIB_OUTDISCARDS); 661 659 goto drop; ··· 668 666 hdr->hop_limit--; 669 667 670 668 return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, 671 - net, NULL, skb, skb->dev, dst->dev, 669 + net, NULL, skb, skb->dev, dev, 672 670 ip6_forward_finish); 673 671 674 672 error: ··· 1095 1093 #ifdef CONFIG_IPV6_SUBTREES 1096 1094 ip6_rt_check(&rt->rt6i_src, &fl6->saddr, np->saddr_cache) || 1097 1095 #endif 1098 - (fl6->flowi6_oif && fl6->flowi6_oif != dst->dev->ifindex)) { 1096 + (fl6->flowi6_oif && fl6->flowi6_oif != dst_dev(dst)->ifindex)) { 1099 1097 dst_release(dst); 1100 1098 dst = NULL; 1101 1099 }
+3 -3
net/ipv6/ip6_tunnel.c
··· 632 632 } else { 633 633 if (ip_route_input(skb2, eiph->daddr, eiph->saddr, 634 634 ip4h_dscp(eiph), skb2->dev) || 635 - skb_dst(skb2)->dev->type != ARPHRD_TUNNEL6) 635 + skb_dst_dev(skb2)->type != ARPHRD_TUNNEL6) 636 636 goto out; 637 637 } 638 638 ··· 1179 1179 ndst = dst; 1180 1180 } 1181 1181 1182 - tdev = dst->dev; 1182 + tdev = dst_dev(dst); 1183 1183 1184 1184 if (tdev == dev) { 1185 1185 DEV_STATS_INC(dev, collisions); ··· 1255 1255 /* Calculate max headroom for all the headers and adjust 1256 1256 * needed_headroom if necessary. 1257 1257 */ 1258 - max_headroom = LL_RESERVED_SPACE(dst->dev) + sizeof(struct ipv6hdr) 1258 + max_headroom = LL_RESERVED_SPACE(tdev) + sizeof(struct ipv6hdr) 1259 1259 + dst->header_len + t->hlen; 1260 1260 if (max_headroom > READ_ONCE(dev->needed_headroom)) 1261 1261 WRITE_ONCE(dev->needed_headroom, max_headroom);
+1 -1
net/ipv6/ip6_udp_tunnel.c
··· 168 168 netdev_dbg(dev, "no route to %pI6\n", &fl6.daddr); 169 169 return ERR_PTR(-ENETUNREACH); 170 170 } 171 - if (dst->dev == dev) { /* is this necessary? */ 171 + if (dst_dev(dst) == dev) { /* is this necessary? */ 172 172 netdev_dbg(dev, "circular route to %pI6\n", &fl6.daddr); 173 173 dst_release(dst); 174 174 return ERR_PTR(-ELOOP);
+2 -2
net/ipv6/ip6_vti.c
··· 497 497 (const struct in6_addr *)&x->id.daddr)) 498 498 goto tx_err_link_failure; 499 499 500 - tdev = dst->dev; 500 + tdev = dst_dev(dst); 501 501 502 502 if (tdev == dev) { 503 503 DEV_STATS_INC(dev, collisions); ··· 529 529 xmit: 530 530 skb_scrub_packet(skb, !net_eq(t->net, dev_net(dev))); 531 531 skb_dst_set(skb, dst); 532 - skb->dev = skb_dst(skb)->dev; 532 + skb->dev = dst_dev(dst); 533 533 534 534 err = dst_output(t->net, skb->sk, skb); 535 535 if (net_xmit_eval(err) == 0)
+4 -5
net/ipv6/ip6mr.c
··· 2301 2301 2302 2302 int ip6_mr_input(struct sk_buff *skb) 2303 2303 { 2304 + struct net_device *dev = skb->dev; 2305 + struct net *net = dev_net_rcu(dev); 2304 2306 struct mfc6_cache *cache; 2305 - struct net *net = dev_net(skb->dev); 2306 2307 struct mr_table *mrt; 2307 2308 struct flowi6 fl6 = { 2308 - .flowi6_iif = skb->dev->ifindex, 2309 + .flowi6_iif = dev->ifindex, 2309 2310 .flowi6_mark = skb->mark, 2310 2311 }; 2311 2312 int err; 2312 - struct net_device *dev; 2313 2313 2314 2314 /* skb->dev passed in is the master dev for vrfs. 2315 2315 * Get the proper interface that does have a vif associated with it. 2316 2316 */ 2317 - dev = skb->dev; 2318 - if (netif_is_l3_master(skb->dev)) { 2317 + if (netif_is_l3_master(dev)) { 2319 2318 dev = dev_get_by_index_rcu(net, IPCB(skb)->iif); 2320 2319 if (!dev) { 2321 2320 kfree_skb(skb);
+4 -2
net/ipv6/ndisc.c
··· 473 473 { 474 474 struct icmp6hdr *icmp6h = icmp6_hdr(skb); 475 475 struct dst_entry *dst = skb_dst(skb); 476 + struct net_device *dev; 476 477 struct inet6_dev *idev; 477 478 struct net *net; 478 479 struct sock *sk; ··· 508 507 509 508 ip6_nd_hdr(skb, saddr, daddr, READ_ONCE(inet6_sk(sk)->hop_limit), skb->len); 510 509 511 - idev = __in6_dev_get(dst->dev); 510 + dev = dst_dev(dst); 511 + idev = __in6_dev_get(dev); 512 512 IP6_INC_STATS(net, idev, IPSTATS_MIB_OUTREQUESTS); 513 513 514 514 err = NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, 515 - net, sk, skb, NULL, dst->dev, 515 + net, sk, skb, NULL, dev, 516 516 dst_output); 517 517 if (!err) { 518 518 ICMP6MSGOUT_INC_STATS(net, idev, type);
+2 -2
net/ipv6/netfilter.c
··· 24 24 { 25 25 const struct ipv6hdr *iph = ipv6_hdr(skb); 26 26 struct sock *sk = sk_to_full_sk(sk_partial); 27 - struct net_device *dev = skb_dst(skb)->dev; 27 + struct net_device *dev = skb_dst_dev(skb); 28 28 struct flow_keys flkeys; 29 29 unsigned int hh_len; 30 30 struct dst_entry *dst; ··· 72 72 #endif 73 73 74 74 /* Change in oif may mean change in hh_len. */ 75 - hh_len = skb_dst(skb)->dev->hard_header_len; 75 + hh_len = skb_dst_dev(skb)->hard_header_len; 76 76 if (skb_headroom(skb) < hh_len && 77 77 pskb_expand_head(skb, HH_DATA_ALIGN(hh_len - skb_headroom(skb)), 78 78 0, GFP_ATOMIC))
+1 -1
net/ipv6/netfilter/nf_dup_ipv6.c
··· 38 38 } 39 39 skb_dst_drop(skb); 40 40 skb_dst_set(skb, dst); 41 - skb->dev = dst->dev; 41 + skb->dev = dst_dev(dst); 42 42 skb->protocol = htons(ETH_P_IPV6); 43 43 44 44 return true;
+1 -1
net/ipv6/netfilter/nf_reject_ipv6.c
··· 300 300 skb_dst_set(oldskb, dst); 301 301 } 302 302 303 - fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst(oldskb)->dev); 303 + fl6.flowi6_oif = l3mdev_master_ifindex(skb_dst_dev(oldskb)); 304 304 fl6.flowi6_mark = IP6_REPLY_MARK(net, oldskb->mark); 305 305 security_skb_classify_flow(oldskb, flowi6_to_flowi_common(&fl6)); 306 306 dst = ip6_route_output(net, NULL, &fl6);
+2 -2
net/ipv6/output_core.c
··· 105 105 { 106 106 int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT); 107 107 if (hoplimit == 0) { 108 - struct net_device *dev = dst->dev; 108 + struct net_device *dev = dst_dev(dst); 109 109 struct inet6_dev *idev; 110 110 111 111 rcu_read_lock(); ··· 141 141 skb->protocol = htons(ETH_P_IPV6); 142 142 143 143 return nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, 144 - net, sk, skb, NULL, skb_dst(skb)->dev, 144 + net, sk, skb, NULL, skb_dst_dev(skb), 145 145 dst_output); 146 146 } 147 147 EXPORT_SYMBOL_GPL(__ip6_local_out);
+5 -5
net/ipv6/reassembly.c
··· 104 104 return container_of(q, struct frag_queue, q); 105 105 } 106 106 107 - static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, 107 + static int ip6_frag_queue(struct net *net, 108 + struct frag_queue *fq, struct sk_buff *skb, 108 109 struct frag_hdr *fhdr, int nhoff, 109 110 u32 *prob_offset, int *refs) 110 111 { 111 - struct net *net = dev_net(skb_dst(skb)->dev); 112 112 int offset, end, fragsize; 113 113 struct sk_buff *prev_tail; 114 114 struct net_device *dev; ··· 324 324 325 325 static int ipv6_frag_rcv(struct sk_buff *skb) 326 326 { 327 + const struct ipv6hdr *hdr = ipv6_hdr(skb); 328 + struct net *net = skb_dst_dev_net(skb); 327 329 struct frag_hdr *fhdr; 328 330 struct frag_queue *fq; 329 - const struct ipv6hdr *hdr = ipv6_hdr(skb); 330 - struct net *net = dev_net(skb_dst(skb)->dev); 331 331 u8 nexthdr; 332 332 int iif; 333 333 ··· 384 384 spin_lock(&fq->q.lock); 385 385 386 386 fq->iif = iif; 387 - ret = ip6_frag_queue(fq, skb, fhdr, IP6CB(skb)->nhoff, 387 + ret = ip6_frag_queue(net, fq, skb, fhdr, IP6CB(skb)->nhoff, 388 388 &prob_offset, &refs); 389 389 390 390 spin_unlock(&fq->q.lock);
+26 -23
net/ipv6/route.c
··· 228 228 const struct rt6_info *rt = dst_rt6_info(dst); 229 229 230 230 return ip6_neigh_lookup(rt6_nexthop(rt, &in6addr_any), 231 - dst->dev, skb, daddr); 231 + dst_dev(dst), skb, daddr); 232 232 } 233 233 234 234 static void ip6_confirm_neigh(const struct dst_entry *dst, const void *daddr) 235 235 { 236 236 const struct rt6_info *rt = dst_rt6_info(dst); 237 - struct net_device *dev = dst->dev; 237 + struct net_device *dev = dst_dev(dst); 238 238 239 239 daddr = choose_neigh_daddr(rt6_nexthop(rt, &in6addr_any), NULL, daddr); 240 240 if (!daddr) ··· 391 391 static bool __rt6_check_expired(const struct rt6_info *rt) 392 392 { 393 393 if (rt->rt6i_flags & RTF_EXPIRES) 394 - return time_after(jiffies, rt->dst.expires); 395 - else 396 - return false; 394 + return time_after(jiffies, READ_ONCE(rt->dst.expires)); 395 + return false; 397 396 } 398 397 399 398 static bool rt6_check_expired(const struct rt6_info *rt) ··· 402 403 from = rcu_dereference(rt->from); 403 404 404 405 if (rt->rt6i_flags & RTF_EXPIRES) { 405 - if (time_after(jiffies, rt->dst.expires)) 406 + if (time_after(jiffies, READ_ONCE(rt->dst.expires))) 406 407 return true; 407 408 } else if (from) { 408 - return rt->dst.obsolete != DST_OBSOLETE_FORCE_CHK || 409 + return READ_ONCE(rt->dst.obsolete) != DST_OBSOLETE_FORCE_CHK || 409 410 fib6_check_expired(from); 410 411 } 411 412 return false; ··· 2133 2134 * expired, independently from their aging, as per RFC 8201 section 4 2134 2135 */ 2135 2136 if (!(rt->rt6i_flags & RTF_EXPIRES)) { 2136 - if (time_after_eq(now, rt->dst.lastuse + gc_args->timeout)) { 2137 + if (time_after_eq(now, READ_ONCE(rt->dst.lastuse) + 2138 + gc_args->timeout)) { 2137 2139 pr_debug("aging clone %p\n", rt); 2138 2140 rt6_remove_exception(bucket, rt6_ex); 2139 2141 return; 2140 2142 } 2141 - } else if (time_after(jiffies, rt->dst.expires)) { 2143 + } else if (time_after(jiffies, READ_ONCE(rt->dst.expires))) { 2142 2144 pr_debug("purging expired route %p\n", rt); 2143 2145 rt6_remove_exception(bucket, rt6_ex); 2144 2146 return; ··· 2777 2777 u32 cookie) 2778 2778 { 2779 2779 if (!__rt6_check_expired(rt) && 2780 - rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && 2780 + READ_ONCE(rt->dst.obsolete) == DST_OBSOLETE_FORCE_CHK && 2781 2781 fib6_check(from, cookie)) 2782 2782 return &rt->dst; 2783 - else 2784 - return NULL; 2783 + return NULL; 2785 2784 } 2786 2785 2787 2786 INDIRECT_CALLABLE_SCOPE struct dst_entry *ip6_dst_check(struct dst_entry *dst, ··· 2870 2871 rcu_read_lock(); 2871 2872 from = rcu_dereference(rt0->from); 2872 2873 if (from) 2873 - rt0->dst.expires = from->expires; 2874 + WRITE_ONCE(rt0->dst.expires, from->expires); 2874 2875 rcu_read_unlock(); 2875 2876 } 2876 2877 ··· 2943 2944 2944 2945 if (res.f6i->nh) { 2945 2946 struct fib6_nh_match_arg arg = { 2946 - .dev = dst->dev, 2947 + .dev = dst_dev(dst), 2947 2948 .gw = &rt6->rt6i_gateway, 2948 2949 }; 2949 2950 ··· 3013 3014 sk_uid(sk)); 3014 3015 3015 3016 dst = __sk_dst_get(sk); 3016 - if (!dst || !dst->obsolete || 3017 + if (!dst || !READ_ONCE(dst->obsolete) || 3017 3018 dst->ops->check(dst, inet6_sk(sk)->dst_cookie)) 3018 3019 return; 3019 3020 ··· 3238 3239 3239 3240 static unsigned int ip6_default_advmss(const struct dst_entry *dst) 3240 3241 { 3241 - struct net_device *dev = dst->dev; 3242 + struct net_device *dev = dst_dev(dst); 3242 3243 unsigned int mtu = dst_mtu(dst); 3243 3244 struct net *net; 3244 3245 ··· 4301 4302 4302 4303 if (res.f6i->nh) { 4303 4304 struct fib6_nh_match_arg arg = { 4304 - .dev = dst->dev, 4305 + .dev = dst_dev(dst), 4305 4306 .gw = &rt->rt6i_gateway, 4306 4307 }; 4307 4308 ··· 4587 4588 static int ip6_pkt_drop(struct sk_buff *skb, u8 code, int ipstats_mib_noroutes) 4588 4589 { 4589 4590 struct dst_entry *dst = skb_dst(skb); 4590 - struct net *net = dev_net(dst->dev); 4591 + struct net_device *dev = dst_dev(dst); 4592 + struct net *net = dev_net(dev); 4591 4593 struct inet6_dev *idev; 4592 4594 SKB_DR(reason); 4593 4595 int type; 4594 4596 4595 4597 if (netif_is_l3_master(skb->dev) || 4596 - dst->dev == net->loopback_dev) 4598 + dev == net->loopback_dev) 4597 4599 idev = __in6_dev_get_safely(dev_get_by_index_rcu(net, IP6CB(skb)->iif)); 4598 4600 else 4599 4601 idev = ip6_dst_idev(dst); ··· 4631 4631 4632 4632 static int ip6_pkt_discard_out(struct net *net, struct sock *sk, struct sk_buff *skb) 4633 4633 { 4634 - skb->dev = skb_dst(skb)->dev; 4634 + skb->dev = skb_dst_dev(skb); 4635 4635 return ip6_pkt_drop(skb, ICMPV6_NOROUTE, IPSTATS_MIB_OUTNOROUTES); 4636 4636 } 4637 4637 ··· 4642 4642 4643 4643 static int ip6_pkt_prohibit_out(struct net *net, struct sock *sk, struct sk_buff *skb) 4644 4644 { 4645 - skb->dev = skb_dst(skb)->dev; 4645 + skb->dev = skb_dst_dev(skb); 4646 4646 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES); 4647 4647 } 4648 4648 ··· 5845 5845 * each as a nexthop within RTA_MULTIPATH. 5846 5846 */ 5847 5847 if (rt6) { 5848 + struct net_device *dev; 5849 + 5848 5850 if (rt6_flags & RTF_GATEWAY && 5849 5851 nla_put_in6_addr(skb, RTA_GATEWAY, &rt6->rt6i_gateway)) 5850 5852 goto nla_put_failure; 5851 5853 5852 - if (dst->dev && nla_put_u32(skb, RTA_OIF, dst->dev->ifindex)) 5854 + dev = dst_dev(dst); 5855 + if (dev && nla_put_u32(skb, RTA_OIF, dev->ifindex)) 5853 5856 goto nla_put_failure; 5854 5857 5855 5858 if (lwtunnel_fill_encap(skb, dst->lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0) ··· 5907 5904 } 5908 5905 5909 5906 if (rt6_flags & RTF_EXPIRES) { 5910 - expires = dst ? dst->expires : rt->expires; 5907 + expires = dst ? READ_ONCE(dst->expires) : rt->expires; 5911 5908 expires -= jiffies; 5912 5909 } 5913 5910
+2 -2
net/ipv6/rpl_iptunnel.c
··· 242 242 local_bh_enable(); 243 243 } 244 244 245 - err = skb_cow_head(skb, LL_RESERVED_SPACE(dst->dev)); 245 + err = skb_cow_head(skb, LL_RESERVED_SPACE(dst_dev(dst))); 246 246 if (unlikely(err)) 247 247 goto drop; 248 248 } ··· 297 297 local_bh_enable(); 298 298 } 299 299 300 - err = skb_cow_head(skb, LL_RESERVED_SPACE(dst->dev)); 300 + err = skb_cow_head(skb, LL_RESERVED_SPACE(dst_dev(dst))); 301 301 if (unlikely(err)) 302 302 goto drop; 303 303 } else {
+14 -12
net/ipv6/seg6_iptunnel.c
··· 128 128 int proto, struct dst_entry *cache_dst) 129 129 { 130 130 struct dst_entry *dst = skb_dst(skb); 131 - struct net *net = dev_net(dst->dev); 131 + struct net_device *dev = dst_dev(dst); 132 + struct net *net = dev_net(dev); 132 133 struct ipv6hdr *hdr, *inner_hdr; 133 134 struct ipv6_sr_hdr *isrh; 134 135 int hdrlen, tot_len, err; ··· 182 181 isrh->nexthdr = proto; 183 182 184 183 hdr->daddr = isrh->segments[isrh->first_segment]; 185 - set_tun_src(net, dst->dev, &hdr->daddr, &hdr->saddr); 184 + set_tun_src(net, dev, &hdr->daddr, &hdr->saddr); 186 185 187 186 #ifdef CONFIG_IPV6_SEG6_HMAC 188 187 if (sr_has_hmac(isrh)) { ··· 213 212 { 214 213 __u8 first_seg = osrh->first_segment; 215 214 struct dst_entry *dst = skb_dst(skb); 216 - struct net *net = dev_net(dst->dev); 215 + struct net_device *dev = dst_dev(dst); 216 + struct net *net = dev_net(dev); 217 217 struct ipv6hdr *hdr, *inner_hdr; 218 218 int hdrlen = ipv6_optlen(osrh); 219 219 int red_tlv_offset, tlv_offset; ··· 272 270 if (skip_srh) { 273 271 hdr->nexthdr = proto; 274 272 275 - set_tun_src(net, dst->dev, &hdr->daddr, &hdr->saddr); 273 + set_tun_src(net, dev, &hdr->daddr, &hdr->saddr); 276 274 goto out; 277 275 } 278 276 ··· 308 306 309 307 srcaddr: 310 308 isrh->nexthdr = proto; 311 - set_tun_src(net, dst->dev, &hdr->daddr, &hdr->saddr); 309 + set_tun_src(net, dev, &hdr->daddr, &hdr->saddr); 312 310 313 311 #ifdef CONFIG_IPV6_SEG6_HMAC 314 312 if (unlikely(!skip_srh && sr_has_hmac(isrh))) { ··· 364 362 365 363 #ifdef CONFIG_IPV6_SEG6_HMAC 366 364 if (sr_has_hmac(isrh)) { 367 - struct net *net = dev_net(skb_dst(skb)->dev); 365 + struct net *net = skb_dst_dev_net(skb); 368 366 369 367 err = seg6_push_hmac(net, &hdr->saddr, isrh); 370 368 if (unlikely(err)) ··· 509 507 local_bh_enable(); 510 508 } 511 509 512 - err = skb_cow_head(skb, LL_RESERVED_SPACE(dst->dev)); 510 + err = skb_cow_head(skb, LL_RESERVED_SPACE(dst_dev(dst))); 513 511 if (unlikely(err)) 514 512 goto drop; 515 513 } else { ··· 520 518 if (static_branch_unlikely(&nf_hooks_lwtunnel_enabled)) 521 519 return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, 522 520 dev_net(skb->dev), NULL, skb, NULL, 523 - skb_dst(skb)->dev, seg6_input_finish); 521 + skb_dst_dev(skb), seg6_input_finish); 524 522 525 523 return seg6_input_finish(dev_net(skb->dev), NULL, skb); 526 524 drop: ··· 530 528 531 529 static int seg6_input_nf(struct sk_buff *skb) 532 530 { 533 - struct net_device *dev = skb_dst(skb)->dev; 531 + struct net_device *dev = skb_dst_dev(skb); 534 532 struct net *net = dev_net(skb->dev); 535 533 536 534 switch (skb->protocol) { ··· 595 593 local_bh_enable(); 596 594 } 597 595 598 - err = skb_cow_head(skb, LL_RESERVED_SPACE(dst->dev)); 596 + err = skb_cow_head(skb, LL_RESERVED_SPACE(dst_dev(dst))); 599 597 if (unlikely(err)) 600 598 goto drop; 601 599 } ··· 605 603 606 604 if (static_branch_unlikely(&nf_hooks_lwtunnel_enabled)) 607 605 return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, sk, skb, 608 - NULL, skb_dst(skb)->dev, dst_output); 606 + NULL, dst_dev(dst), dst_output); 609 607 610 608 return dst_output(net, sk, skb); 611 609 drop: ··· 616 614 617 615 static int seg6_output_nf(struct net *net, struct sock *sk, struct sk_buff *skb) 618 616 { 619 - struct net_device *dev = skb_dst(skb)->dev; 617 + struct net_device *dev = skb_dst_dev(skb); 620 618 621 619 switch (skb->protocol) { 622 620 case htons(ETH_P_IP):
+1 -1
net/ipv6/seg6_local.c
··· 313 313 if (!local_delivery) 314 314 dev_flags |= IFF_LOOPBACK; 315 315 316 - if (dst && (dst->dev->flags & dev_flags) && !dst->error) { 316 + if (dst && (dst_dev(dst)->flags & dev_flags) && !dst->error) { 317 317 dst_release(dst); 318 318 dst = NULL; 319 319 }
+2 -2
net/ipv6/tcp_ipv6.c
··· 868 868 int oif, int rst, u8 tclass, __be32 label, 869 869 u32 priority, u32 txhash, struct tcp_key *key) 870 870 { 871 - struct net *net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); 871 + struct net *net = sk ? sock_net(sk) : skb_dst_dev_net_rcu(skb); 872 872 unsigned int tot_len = sizeof(struct tcphdr); 873 873 struct sock *ctl_sk = net->ipv6.tcp_sk; 874 874 const struct tcphdr *th = tcp_hdr(skb); ··· 1043 1043 if (!sk && !ipv6_unicast_destination(skb)) 1044 1044 return; 1045 1045 1046 - net = sk ? sock_net(sk) : dev_net_rcu(skb_dst(skb)->dev); 1046 + net = sk ? sock_net(sk) : skb_dst_dev_net_rcu(skb); 1047 1047 /* Invalid TCP option size or twice included auth */ 1048 1048 if (tcp_parse_auth_options(th, &md5_hash_location, &aoh)) 1049 1049 return;
+1 -1
net/ipv6/xfrm6_output.c
··· 106 106 int xfrm6_output(struct net *net, struct sock *sk, struct sk_buff *skb) 107 107 { 108 108 return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING, 109 - net, sk, skb, skb->dev, skb_dst(skb)->dev, 109 + net, sk, skb, skb->dev, skb_dst_dev(skb), 110 110 __xfrm6_output, 111 111 !(IP6CB(skb)->flags & IP6SKB_REROUTED)); 112 112 }
+1 -1
net/netfilter/ipvs/ip_vs_xmit.c
··· 97 97 if (!dest_dst) 98 98 return NULL; 99 99 dst = dest_dst->dst_cache; 100 - if (dst->obsolete && 100 + if (READ_ONCE(dst->obsolete) && 101 101 dst->ops->check(dst, dest_dst->dst_cookie) == NULL) 102 102 return NULL; 103 103 return dest_dst;
+1 -1
net/sctp/transport.c
··· 240 240 void sctp_transport_pmtu(struct sctp_transport *transport, struct sock *sk) 241 241 { 242 242 /* If we don't have a fresh route, look one up */ 243 - if (!transport->dst || transport->dst->obsolete) { 243 + if (!transport->dst || READ_ONCE(transport->dst->obsolete)) { 244 244 sctp_transport_dst_release(transport); 245 245 transport->af_specific->get_dst(transport, &transport->saddr, 246 246 &transport->fl, sk);
+2 -2
net/xfrm/xfrm_policy.c
··· 3925 3925 * This will force stale_bundle() to fail on any xdst bundle with 3926 3926 * this dst linked in it. 3927 3927 */ 3928 - if (dst->obsolete < 0 && !stale_bundle(dst)) 3928 + if (READ_ONCE(dst->obsolete) < 0 && !stale_bundle(dst)) 3929 3929 return dst; 3930 3930 3931 3931 return NULL; ··· 3953 3953 3954 3954 static void xfrm_negative_advice(struct sock *sk, struct dst_entry *dst) 3955 3955 { 3956 - if (dst->obsolete) 3956 + if (READ_ONCE(dst->obsolete)) 3957 3957 sk_dst_reset(sk); 3958 3958 } 3959 3959