diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-03-31 16:46:42 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-03-31 16:46:42 -0700 |
commit | 0a350b99308762f1eb180aa47b64db78b3187c7e (patch) | |
tree | be55622561d0d879ded4cb27bac56b281354ef80 | |
parent | c8357d357fdd7e489fd25e76b73839e1b26fdbfa (diff) | |
download | vyatta-cfg-0a350b99308762f1eb180aa47b64db78b3187c7e.tar.gz vyatta-cfg-0a350b99308762f1eb180aa47b64db78b3187c7e.zip |
handle delete address request if address is already removed
Quagga link-detect may have already removed address from interface.
Check for missing address, and if not present just tell vtysh.
This fixes bug 2802
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index e3afe68..c60288a 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -332,18 +332,44 @@ sub delete_eth_addrs { dhcp_release_addr($intf); update_dhcp_client(); system("rm -f /var/lib/dhcp3/dhclient_$intf\_lease"); - return; + exit 0; } my $version = is_ip_v4_or_v6($addr); - if (!defined $version) { - exit 1; + + # If interface has address than delete it + if (is_ip_configured($intf, $addr)) { + if ($version == 4) { + exec 'ip', 'addr', 'del', $addr, 'dev', $intf; + } elsif ($version == 6) { + exec 'ip', '-6', 'addr', 'del', $addr, 'dev', $intf; + } else { + die "Bad ip version"; + } + die "Can't exec ip"; } - if ($version == 4) { - return system("ip addr del $addr dev $intf"); + + # Interface address might have been removed by quagga link going down + # so tell quagga no to restore it on link-detect + my $vtysh; + if ( -x '/usr/bin/vyatta-vtysh' ) { + $vtysh = '/usr/bin/vyatta-vtysh'; + } else { + $vtysh = '/usr/bin/vtysh'; } - if ($version == 6) { - return system("ip -6 addr del $addr dev $intf"); + + my @cmd = (); + if ($version == 4) { + @cmd = ('vtysh', '-c', + "configure terminal; interface $intf; no ip address $intf" ); + } elsif ($version == 6) { + @cmd = ('vtysh', '-c', + "configure terminal; interface $intf; no ip6 address $intf" ); + } else { + die "Bad ip version"; } + exec $vtysh, @cmd; + + die "Can't exec vtysh"; } sub update_mac { |