summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-04-02 16:04:40 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-04-02 16:04:40 -0700
commitac2527611ae57dd54edb2d08e26a2b54aeca9dc4 (patch)
tree82b0eaa35b9e30f7df1c169eaea018924059a119 /scripts
parent35642e2e10aff32335690a5af2710bbb9ec3ea13 (diff)
downloadvyatta-cfg-ac2527611ae57dd54edb2d08e26a2b54aeca9dc4.tar.gz
vyatta-cfg-ac2527611ae57dd54edb2d08e26a2b54aeca9dc4.zip
stop watchlink when address is removed
Kludge to work around address watchlink interaction: remove status file. This should fix bug 2802. There may still be problems when multiple addresses are assigned to an interface. The correct fix is to just get rid of the watchlink process and do the management in kernel or zebra.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-interfaces.pl41
1 files changed, 19 insertions, 22 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index c60288a..01ddd5e 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -325,6 +325,18 @@ sub update_eth_addrs {
exit 1;
}
+sub if_nametoindex {
+ my ($intf) = @_;
+
+ open my $sysfs, "<", "/sys/class/net/$intf/ifindex"
+ || die "Unknown interface $intf";
+ my $ifindex = <$sysfs>;
+ close($sysfs) or die "read sysfs error\n";
+ chomp $ifindex;
+ print "$intf = $ifindex\n";
+ return $ifindex;
+}
+
sub delete_eth_addrs {
my ($addr, $intf) = @_;
@@ -336,8 +348,9 @@ sub delete_eth_addrs {
}
my $version = is_ip_v4_or_v6($addr);
- # If interface has address than delete it
if (is_ip_configured($intf, $addr)) {
+ # Link is up, so just delete address
+ # Zebra is watching for netlink events and will handle it
if ($version == 4) {
exec 'ip', 'addr', 'del', $addr, 'dev', $intf;
} elsif ($version == 6) {
@@ -348,28 +361,12 @@ sub delete_eth_addrs {
die "Can't exec ip";
}
- # 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';
- }
+ # Destroy watchlink's internal status so it doesn't erronously
+ # restore the address when link is restored
+ my $status = '/var/linkstatus/' . if_nametoindex($intf);
+ unlink($status) or die "can't remove $status";
- 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";
+ exit 0;
}
sub update_mac {