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 | goto nla_put_failure; | 1811 | goto nla_put_failure; |
| 1812 | if (nexthop_is_blackhole(fi->nh)) | 1812 | if (nexthop_is_blackhole(fi->nh)) |
| 1813 | rtm->rtm_type = RTN_BLACKHOLE; | 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 | goto offload; | 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 | /* __ip6_del_rt does a release, so do a hold here */ | 1858 | /* __ip6_del_rt does a release, so do a hold here */ |
| 1859 | fib6_info_hold(f6i); | 1859 | fib6_info_hold(f6i); |
| 1860 | ipv6_stub->ip6_del_rt(net, f6i, | 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 | if (!rc) { | 2361 | if (!rc) { |
| 2362 | nh_base_seq_inc(net); | 2362 | nh_base_seq_inc(net); |
| 2363 | nexthop_notify(RTM_NEWNEXTHOP, new_nh, &cfg->nlinfo); | 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 | nexthop_replace_notify(net, new_nh, &cfg->nlinfo); | 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 | if (nexthop_is_blackhole(rt->nh)) | 5741 | if (nexthop_is_blackhole(rt->nh)) |
| 5742 | rtm->rtm_type = RTN_BLACKHOLE; | 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 | rt6_fill_node_nexthop(skb, rt->nh, &nh_flags) < 0) | 5745 | rt6_fill_node_nexthop(skb, rt->nh, &nh_flags) < 0) |
| 5746 | goto nla_put_failure; | 5746 | goto nla_put_failure; |
| 5747 | 5747 | ||