Skip to content

Commit

Permalink
mxrouterctl: Fix startup: Don't move lo
Browse files Browse the repository at this point in the history
Make the code, which moves/creates interface in 'start' the same as the
code in 'restart'. Most importantly this avoids `mxrouterctl start` to
attempt to move 'lo' into the new namespaces.

    root@jabberwocky:/etc/local/mxrouter# mxrouterctl start
    ip netns add MXR
    ip link set lo netns MXR
    RTNETLINK answers: Invalid argument
    previous command failed with exit status 2

Fixes da35f49 ("mxrouterctl: Handle interface changes on reload")
  • Loading branch information
donald committed Feb 15, 2024
1 parent 0def90b commit b571970
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions mxrouter/mxrouterctl
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit b571970

Please sign in to comment.