diff --git a/mxrouter/mxrouterctl b/mxrouter/mxrouterctl index 4105180..f333ddd 100755 --- a/mxrouter/mxrouterctl +++ b/mxrouter/mxrouterctl @@ -808,13 +808,17 @@ if (!$opt_this_ns) { have_netns($NETNS) and die "already running (network namespace $NETNS already exists)\n"; create_netns($NETNS); - for my $dev (sort keys %$want_if) { - move_dev_into_ns($dev,$NETNS); - } for my $dev (sort keys %$want_veth) { + -d "/sys/class/net/$dev" and next; sys('ip', 'link', 'add', $dev, 'type', 'veth', 'peer', 'name', $dev, 'netns', $NETNS); sys('ip', 'link', 'set', $dev, 'up'); } + # move interfaces which are still in the init namespace + # ignore veth devices and lo, which exists in both namespaces + for my $dev (sort keys %$want_if) { + $dev eq 'lo' || $want_veth->{$dev} and next; + -d "/sys/class/net/$dev" and sys('ip', 'link', 'set', $dev, 'netns', $NETNS); + } system('ip','netns','exec',$NETNS,$0,'--this-ns',@SAVED_ARGV) and exit 1; } elsif ($cmd eq 'stop') { have_netns($NETNS) or die "not running (network namespace $NETNS does not exist)\n";