Commit e332bc67 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

ipv6: Don't call with rt6_uncached_list_flush_dev

As originally written rt6_uncached_list_flush_dev makes no sense when
called with dev == NULL as it attempts to flush all uncached routes
regardless of network namespace when dev == NULL.  Which is simply
incorrect behavior.

Furthermore at the point rt6_ifdown is called with dev == NULL no more
network devices exist in the network namespace so even if the code in
rt6_uncached_list_flush_dev were to attempt something sensible it
would be meaningless.

Therefore remove support in rt6_uncached_list_flush_dev for handling
network devices where dev == NULL, and only call rt6_uncached_list_flush_dev
 when rt6_ifdown is called with a network device.

Fixes: 8d0b94af ("ipv6: Keep track of DST_NOCACHE routes in case of iface down/unregister")
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Reviewed-by: default avatarMartin KaFai Lau <kafai@fb.com>
Tested-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 87aaf2ca
...@@ -142,6 +142,9 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev) ...@@ -142,6 +142,9 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev)
struct net_device *loopback_dev = net->loopback_dev; struct net_device *loopback_dev = net->loopback_dev;
int cpu; int cpu;
if (dev == loopback_dev)
return;
for_each_possible_cpu(cpu) { for_each_possible_cpu(cpu) {
struct uncached_list *ul = per_cpu_ptr(&rt6_uncached_list, cpu); struct uncached_list *ul = per_cpu_ptr(&rt6_uncached_list, cpu);
struct rt6_info *rt; struct rt6_info *rt;
...@@ -151,14 +154,12 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev) ...@@ -151,14 +154,12 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev)
struct inet6_dev *rt_idev = rt->rt6i_idev; struct inet6_dev *rt_idev = rt->rt6i_idev;
struct net_device *rt_dev = rt->dst.dev; struct net_device *rt_dev = rt->dst.dev;
if (rt_idev && (rt_idev->dev == dev || !dev) && if (rt_idev->dev == dev) {
rt_idev->dev != loopback_dev) {
rt->rt6i_idev = in6_dev_get(loopback_dev); rt->rt6i_idev = in6_dev_get(loopback_dev);
in6_dev_put(rt_idev); in6_dev_put(rt_idev);
} }
if (rt_dev && (rt_dev == dev || !dev) && if (rt_dev == dev) {
rt_dev != loopback_dev) {
rt->dst.dev = loopback_dev; rt->dst.dev = loopback_dev;
dev_hold(rt->dst.dev); dev_hold(rt->dst.dev);
dev_put(rt_dev); dev_put(rt_dev);
...@@ -2622,6 +2623,7 @@ void rt6_ifdown(struct net *net, struct net_device *dev) ...@@ -2622,6 +2623,7 @@ void rt6_ifdown(struct net *net, struct net_device *dev)
fib6_clean_all(net, fib6_ifdown, &adn); fib6_clean_all(net, fib6_ifdown, &adn);
icmp6_clean_all(fib6_ifdown, &adn); icmp6_clean_all(fib6_ifdown, &adn);
if (dev)
rt6_uncached_list_flush_dev(net, dev); rt6_uncached_list_flush_dev(net, dev);
} }
......
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