On 02.03.2021 13:24:23, Martin Willi wrote: > When a non-initial netns is destroyed, the usual policy is to delete > all virtual network interfaces contained, but move physical interfaces > back to the initial netns. This keeps the physical interface visible > on the system. > > CAN devices are somewhat special, as they define rtnl_link_ops even > if they are physical devices. If a CAN interface is moved into a > non-initial netns, destroying that netns lets the interface vanish > instead of moving it back to the initial netns. default_device_exit() > skips CAN interfaces due to having rtnl_link_ops set. Reproducer: > > ip netns add foo > ip link set can0 netns foo > ip netns delete foo > > WARNING: CPU: 1 PID: 84 at net/core/dev.c:11030 ops_exit_list+0x38/0x60 > CPU: 1 PID: 84 Comm: kworker/u4:2 Not tainted 5.10.19 #1 > Workqueue: netns cleanup_net > [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [] (show_stack) from [] (dump_stack+0x94/0xa8) > [] (dump_stack) from [] (__warn+0xb8/0x114) > [] (__warn) from [] (warn_slowpath_fmt+0x7c/0xac) > [] (warn_slowpath_fmt) from [] (ops_exit_list+0x38/0x60) > [] (ops_exit_list) from [] (cleanup_net+0x230/0x380) > [] (cleanup_net) from [] (process_one_work+0x1d8/0x438) > [] (process_one_work) from [] (worker_thread+0x64/0x5a8) > [] (worker_thread) from [] (kthread+0x148/0x14c) > [] (kthread) from [] (ret_from_fork+0x14/0x2c) > > To properly restore physical CAN devices to the initial netns on owning > netns exit, introduce a flag on rtnl_link_ops that can be set by drivers. > For CAN devices setting this flag, default_device_exit() considers them > non-virtual, applying the usual namespace move. > > The issue was introduced in the commit mentioned below, as at that time > CAN devices did not have a dellink() operation. > > Fixes: e008b5fc8dc7 ("net: Simplfy default_device_exit and improve batching.") > Signed-off-by: Martin Willi applied to linux-can/testing Thanks, Marc -- Pengutronix e.K. | Marc Kleine-Budde | Embedded Linux | https://www.pengutronix.de | Vertretung West/Dortmund | Phone: +49-231-2826-924 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |