diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 08042a97edf6113ae7e32b1c2649a2be9c280df5..2f75d3d21a580bae9c1437292ff07975024e12d1 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -521,6 +521,7 @@ static void rt6_probe(struct fib6_info *rt) { struct __rt6_probe_work *work = NULL; const struct in6_addr *nh_gw; + unsigned long last_probe; struct neighbour *neigh; struct net_device *dev; struct inet6_dev *idev; @@ -539,6 +540,7 @@ static void rt6_probe(struct fib6_info *rt) nh_gw = &rt->fib6_nh.nh_gw; dev = rt->fib6_nh.nh_dev; rcu_read_lock_bh(); + last_probe = READ_ONCE(rt->last_probe); idev = __in6_dev_get(dev); neigh = __ipv6_neigh_lookup_noref(dev, nh_gw); if (neigh) { @@ -554,13 +556,15 @@ static void rt6_probe(struct fib6_info *rt) __neigh_set_probe_once(neigh); } write_unlock(&neigh->lock); - } else if (time_after(jiffies, rt->last_probe + + } else if (time_after(jiffies, last_probe + idev->cnf.rtr_probe_interval)) { work = kmalloc(sizeof(*work), GFP_ATOMIC); } - if (work) { - rt->last_probe = jiffies; + if (!work || cmpxchg(&rt->last_probe, + last_probe, jiffies) != last_probe) { + kfree(work); + } else { INIT_WORK(&work->work, rt6_probe_deferred); work->target = *nh_gw; dev_hold(dev); @@ -3066,6 +3070,9 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, if (!rt) goto out; +#ifdef CONFIG_IPV6_ROUTER_PREF + rt->last_probe = jiffies; +#endif if (cfg->fc_flags & RTF_ADDRCONF) rt->dst_nocount = true;