In Linux, set up 2 network namespaces, ns1 and ns2. ip netns list can view the 2 network namespaces.
If I move one network device from Linux root namespace to ns1 then from ns1 to ns2, then delete ns2, I expect that the network device can move back to ns1.
The actual result is that eth1 is back to Linux root network namespace. I'm not sure whether it's as expected.
Here is the detail test scenario:
ip netns add ns1ip netns add ns2ip link set eth1 netns ns1ip netns exec ns1 ip link set eth1 netns ns2ip netns del ns2
Expected result: eth1 will be in ns1
Actual result: eth1 is back in Linux root namespace 1
Question: is there any method to realize such scenario to make sure device can be back to ns1 not Linux root network namespace 1?
ip monitor linkto detect the reapparition of the device on the initial net namespace, and immediately cast it to ns1. Interface's name could be different from the former in some cases of renaming or naming conflict.