Skip to content

Update mxrouter #351

Merged
merged 3 commits into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions mxrouter/mxrouterctl
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ sub radvd {
}

our $want_if;
our $want_veth;

our $DHCRELAY_FORWARD;
our %DHCRELAY_IF;
Expand Down Expand Up @@ -483,11 +484,12 @@ sub start {

netif_is_up('lo') or sys('ip link set lo up');

for my $dev (keys %$want_if) {
for my $dev (keys %$want_if, keys %$want_veth) {
netif_is_up($dev) or sys('ip','link','set',$dev,'up');
}

my ($have_vlan)=read_active_vlans();
delete $have_vlan->{$_} for keys %$want_if; # vlan interfaces created in main and moved via interaface()
my ($new_vlan,$del_vlan)=({},{},{},{});

for (keys %$want_vlan) {
Expand Down Expand Up @@ -525,10 +527,10 @@ sub start {
unless exists $want_route->{$_};
}

unless (get_ipv6_forwarding()>0) {
warn "enable IPV6 forwarding\n" unless $opt_quiet;
set_ipv6_forwarding(1);
}
# unless (get_ipv6_forwarding()>0) {
# warn "enable IPV6 forwarding\n" unless $opt_quiet;
# set_ipv6_forwarding(1);
# }

unless (get_ipv4_routing()>0) {
warn "enable IPV4 routing\n" unless $opt_quiet;
Expand Down Expand Up @@ -621,6 +623,11 @@ sub interface {
$want_if->{$dev}=1;
}

sub veth {
my ($dev) = @_;
$want_veth->{$dev} = 1;
}

my @SAVED_ARGV=@ARGV;

GetOptions(OPTIONS) or die USAGE;
Expand Down Expand Up @@ -775,6 +782,10 @@ if (!$opt_this_ns) {
for my $dev (sort keys %$want_if) {
move_dev_into_ns($dev,$NETNS);
}
for my $dev (sort keys %$want_veth) {
sys('ip', 'link', 'add', $dev, 'type', 'veth', 'peer', 'name', $dev, 'netns', $NETNS);
sys('ip', 'link', 'set', $dev, 'up');
}
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