From: Felix Fietkau Date: Mon, 29 Aug 2022 11:08:29 +0000 (+0200) Subject: scripts/update-cmd.pl: reorder add/remove calls to better deal with dynamic changes X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b75791a6db2560f4e73d092aaf2e2601c39eee6e;p=project%2Funetd.git scripts/update-cmd.pl: reorder add/remove calls to better deal with dynamic changes Signed-off-by: Felix Fietkau --- diff --git a/scripts/update-cmd.pl b/scripts/update-cmd.pl index 37d0b11..1456533 100755 --- a/scripts/update-cmd.pl +++ b/scripts/update-cmd.pl @@ -132,13 +132,13 @@ sub set_active_data_linux($$$) { foreach my $ip (keys %{$delete->{ipaddr}}) { cmd("ip a d $ip dev $ifname"); } - foreach my $ip (keys %{$add->{ipaddr}}) { - cmd("ip a a $ip dev $ifname"); - } - foreach my $route (keys %{$delete->{route}}) { cmd("ip r d $route dev $ifname"); } + + foreach my $ip (keys %{$add->{ipaddr}}) { + cmd("ip a a $ip dev $ifname"); + } foreach my $route (keys %{$add->{route}}) { cmd("ip r a $route dev $ifname"); } @@ -157,6 +157,13 @@ sub set_active_data_darwin($$$) { cmd("ifconfig $ifname delete $ip"); } } + foreach my $route (keys %{$delete->{route}}) { + if ($route =~ /:/) { + cmd("route delete -inet6 $route -iface $ifname"); + } else { + cmd("route delete -inet $route -iface $ifname"); + } + } foreach my $ip (keys %{$add->{ipaddr}}) { my @ip = split /\//, $ip; @@ -166,13 +173,6 @@ sub set_active_data_darwin($$$) { cmd("ifconfig $ifname add $ip[0]/$ip[1] $ip[0]"); } } - foreach my $route (keys %{$delete->{route}}) { - if ($route =~ /:/) { - cmd("route delete -inet6 $route -iface $ifname"); - } else { - cmd("route delete -inet $route -iface $ifname"); - } - } foreach my $route (keys %{$add->{route}}) { if ($route =~ /:/) { cmd("route add -inet6 $route -iface $ifname");