From b48fbe95e7e9921c3f718f458d5636e4c3c47999 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 9 Jun 2008 17:00:00 -0700 Subject: Fix use of invalid variable Bugfix: 3334 State of carrier is indeterminate (ie always down), when link is down; so reading sysfs returns -EINVAL. Avoid problem by recoding. --- scripts/vyatta-show-interfaces.pl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-show-interfaces.pl b/scripts/vyatta-show-interfaces.pl index 9046c17..e50c097 100644 --- a/scripts/vyatta-show-interfaces.pl +++ b/scripts/vyatta-show-interfaces.pl @@ -184,23 +184,23 @@ sub get_ipaddr { sub get_state_link { my $intf = shift; - - my $IFF_UP = 0x1; - my ($state, $link); + my $state; + my $link = 'down'; my $flags = get_sysfs_value($intf, 'flags'); - my $carrier = get_sysfs_value($intf, 'carrier'); - chomp $flags; chomp $carrier; + chomp $flags; + my $hex_flags = hex($flags); - if ($hex_flags & $IFF_UP) { - $state = "up"; + if ($hex_flags & 0x1) { # IFF_UP + $state = 'up'; + my $carrier = get_sysfs_value($intf, 'carrier'); + chomp $carrier; + if ($carrier eq '1') { + $link = "up"; + } } else { $state = "admin down"; } - if ($carrier eq "1") { - $link = "up"; - } else { - $link = "down"; - } + return ($state, $link); } -- cgit v1.2.3