diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-06-09 17:00:00 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-06-09 17:01:04 -0700 |
commit | b48fbe95e7e9921c3f718f458d5636e4c3c47999 (patch) | |
tree | 04bb4873db9b3bb814f01cbb7c22b8f47137af46 /scripts | |
parent | c643034649db860ab720fb2ee06dde767f5b8031 (diff) | |
download | vyatta-op-b48fbe95e7e9921c3f718f458d5636e4c3c47999.tar.gz vyatta-op-b48fbe95e7e9921c3f718f458d5636e4c3c47999.zip |
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.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/vyatta-show-interfaces.pl | 24 |
1 files changed, 12 insertions, 12 deletions
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); } |