Skip to content

Commit d0c082c

Browse files
ebiedermdavem330
authored andcommitted
netns: Delete virtual interfaces during namespace cleanup
When physical devices are inside of network namespace and that network namespace terminates we can not make them go away. We have to keep them and moving them to the initial network namespace is the best we can do. For virtual devices left in a network namespace that is exiting we have no need to preserve them and we now have the infrastructure that allows us to delete them. So delete virtual devices when we exit a network namespace. Keeping the necessary user space clean up after a network namespace exits much more tractable. Acked-by: Daniel Lezcano <[email protected]> Acked-by: Pavel Emelyanov <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 270acef commit d0c082c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/core/dev.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4852,6 +4852,12 @@ static void __net_exit default_device_exit(struct net *net)
48524852
if (dev->features & NETIF_F_NETNS_LOCAL)
48534853
continue;
48544854

4855+
/* Delete virtual devices */
4856+
if (dev->rtnl_link_ops && dev->rtnl_link_ops->dellink) {
4857+
dev->rtnl_link_ops->dellink(dev);
4858+
continue;
4859+
}
4860+
48554861
/* Push remaing network devices to init_net */
48564862
snprintf(fb_name, IFNAMSIZ, "dev%d", dev->ifindex);
48574863
err = dev_change_net_namespace(dev, &init_net, fb_name);

0 commit comments

Comments
 (0)