While reading nexthop_compat_mode, it can be changed concurrently. Thus, we need to add READ_ONCE() to its readers.
Unified · Split
| @@ -1811,7 +1811,7 @@ int fib_dump_info(struct sk_buff *skb, u32 portid, u32 seq, int event, · 1810 unmodified lines | ||
| 1811 | 1811 | goto nla_put_failure; |
| 1812 | 1812 | if (nexthop_is_blackhole(fi->nh)) |
| 1813 | 1813 | rtm->rtm_type = RTN_BLACKHOLE; |
| 1814 | − if (!fi->fib_net->ipv4.sysctl_nexthop_compat_mode) | |
| 1814 | + if (!READ_ONCE(fi->fib_net->ipv4.sysctl_nexthop_compat_mode)) | |
| 1815 | 1815 | goto offload; |
| 1816 | 1816 | } |
| 1817 | 1817 | |
| @@ -1858,7 +1858,7 @@ static void __remove_nexthop_fib(struct net *net, struct nexthop *nh) · 1857 unmodified lines | ||
| 1858 | 1858 | /* __ip6_del_rt does a release, so do a hold here */ |
| 1859 | 1859 | fib6_info_hold(f6i); |
| 1860 | 1860 | ipv6_stub->ip6_del_rt(net, f6i, |
| 1861 | − !net->ipv4.sysctl_nexthop_compat_mode); | |
| 1861 | + !READ_ONCE(net->ipv4.sysctl_nexthop_compat_mode)); | |
| 1862 | 1862 | } |
| 1863 | 1863 | } |
| 1864 | 1864 | |
| @@ -2361,7 +2361,8 @@ out: · 496 unmodified lines | ||
| 2361 | 2361 | if (!rc) { |
| 2362 | 2362 | nh_base_seq_inc(net); |
| 2363 | 2363 | nexthop_notify(RTM_NEWNEXTHOP, new_nh, &cfg->nlinfo); |
| 2364 | − if (replace_notify && net->ipv4.sysctl_nexthop_compat_mode) | |
| 2364 | + if (replace_notify && | |
| 2365 | + READ_ONCE(net->ipv4.sysctl_nexthop_compat_mode)) | |
| 2365 | 2366 | nexthop_replace_notify(net, new_nh, &cfg->nlinfo); |
| 2366 | 2367 | } |
| 2367 | 2368 | |
| @@ -5741,7 +5741,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb, · 5740 unmodified lines | ||
| 5741 | 5741 | if (nexthop_is_blackhole(rt->nh)) |
| 5742 | 5742 | rtm->rtm_type = RTN_BLACKHOLE; |
| 5743 | 5743 | |
| 5744 | − if (net->ipv4.sysctl_nexthop_compat_mode && | |
| 5744 | + if (READ_ONCE(net->ipv4.sysctl_nexthop_compat_mode) && | |
| 5745 | 5745 | rt6_fill_node_nexthop(skb, rt->nh, &nh_flags) < 0) |
| 5746 | 5746 | goto nla_put_failure; |
| 5747 | 5747 | |