Skip to content

Commit e332bc6

Browse files
ebiedermdavem330
authored andcommitted
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: 8d0b94a ("ipv6: Keep track of DST_NOCACHE routes in case of iface down/unregister") Signed-off-by: "Eric W. Biederman" <[email protected]> Reviewed-by: Martin KaFai Lau <[email protected]> Tested-by: Martin KaFai Lau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 87aaf2c commit e332bc6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

net/ipv6/route.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev)
142142
struct net_device *loopback_dev = net->loopback_dev;
143143
int cpu;
144144

145+
if (dev == loopback_dev)
146+
return;
147+
145148
for_each_possible_cpu(cpu) {
146149
struct uncached_list *ul = per_cpu_ptr(&rt6_uncached_list, cpu);
147150
struct rt6_info *rt;
@@ -151,14 +154,12 @@ static void rt6_uncached_list_flush_dev(struct net *net, struct net_device *dev)
151154
struct inet6_dev *rt_idev = rt->rt6i_idev;
152155
struct net_device *rt_dev = rt->dst.dev;
153156

154-
if (rt_idev && (rt_idev->dev == dev || !dev) &&
155-
rt_idev->dev != loopback_dev) {
157+
if (rt_idev->dev == dev) {
156158
rt->rt6i_idev = in6_dev_get(loopback_dev);
157159
in6_dev_put(rt_idev);
158160
}
159161

160-
if (rt_dev && (rt_dev == dev || !dev) &&
161-
rt_dev != loopback_dev) {
162+
if (rt_dev == dev) {
162163
rt->dst.dev = loopback_dev;
163164
dev_hold(rt->dst.dev);
164165
dev_put(rt_dev);
@@ -2622,7 +2623,8 @@ void rt6_ifdown(struct net *net, struct net_device *dev)
26222623

26232624
fib6_clean_all(net, fib6_ifdown, &adn);
26242625
icmp6_clean_all(fib6_ifdown, &adn);
2625-
rt6_uncached_list_flush_dev(net, dev);
2626+
if (dev)
2627+
rt6_uncached_list_flush_dev(net, dev);
26262628
}
26272629

26282630
struct rt6_mtu_change_arg {

0 commit comments

Comments
 (0)