Commit e635b476 authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by Greg Kroah-Hartman

ipv6: correctly add local routes when lo goes up

[ Upstream commit a220445f ]

The goal of the patch is to fix this scenario:
 ip link add dummy1 type dummy
 ip link set dummy1 up
 ip link set lo down ; ip link set lo up

After that sequence, the local route to the link layer address of dummy1 is
not there anymore.

When the loopback is set down, all local routes are deleted by
addrconf_ifdown()/rt6_ifdown(). At this time, the rt6_info entry still
exists, because the corresponding idev has a reference on it. After the rcu
grace period, dst_rcu_free() is called, and thus ___dst_free(), which will
set obsolete to DST_OBSOLETE_DEAD.

In this case, init_loopback() is called before dst_rcu_free(), thus
obsolete is still sets to something <= 0. So, the function doesn't add the
route again. To avoid that race, let's check the rt6 refcnt instead.

Fixes: 25fb6ca4 ("net IPv6 : Fix broken IPv6 routing table after loopback down-up")
Fixes: a881ae1f ("ipv6: don't call addrconf_dst_alloc again when enable lo")
Fixes: 33d99113 ("ipv6: reallocate addrconf router for ipv6 address when lo device up")
Reported-by: default avatarFrancesco Santoro <francesco.santoro@6wind.com>
Reported-by: default avatarSamuel Gauthier <samuel.gauthier@6wind.com>
CC: Balakumaran Kannan <Balakumaran.Kannan@ap.sony.com>
CC: Maruthi Thotad <Maruthi.Thotad@ap.sony.com>
CC: Sabrina Dubroca <sd@queasysnail.net>
CC: Hannes Frederic Sowa <hannes@stressinduktion.org>
CC: Weilong Chen <chenweilong@huawei.com>
CC: Gao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f9d4850a
...@@ -2916,7 +2916,7 @@ static void init_loopback(struct net_device *dev) ...@@ -2916,7 +2916,7 @@ static void init_loopback(struct net_device *dev)
* lo device down, release this obsolete dst and * lo device down, release this obsolete dst and
* reallocate a new router for ifa. * reallocate a new router for ifa.
*/ */
if (sp_ifa->rt->dst.obsolete > 0) { if (!atomic_read(&sp_ifa->rt->rt6i_ref)) {
ip6_rt_put(sp_ifa->rt); ip6_rt_put(sp_ifa->rt);
sp_ifa->rt = NULL; sp_ifa->rt = NULL;
} else { } else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment