From 093cfe75a832c333e83e08bbb37a082e811a9e44 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 9 Jun 2009 14:59:43 -0700 Subject: Fix handling of invalid bonding name Bug 4514 --- scripts/vyatta-show-bonding.pl | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'scripts') diff --git a/scripts/vyatta-show-bonding.pl b/scripts/vyatta-show-bonding.pl index 5b0a314..902be4e 100755 --- a/scripts/vyatta-show-bonding.pl +++ b/scripts/vyatta-show-bonding.pl @@ -81,6 +81,9 @@ sub show_brief { printf $format, 'Interface', 'Mode', 'State', 'Link', 'Slaves'; foreach my $intf (sort @interfaces) { + die "Invalid bonding interface: $intf\n" + unless (-d "/sys/class/net/$intf/bonding" ); + my $mode = get_sysfs_value( $intf, "bonding/mode" ); my ( $name, $num ) = split (/ /, $mode); $mode = $modes[$num] ? $modes[$num] : $name; @@ -98,6 +101,9 @@ sub show { printf $format, "Interface", "RX: bytes", "packets", "TX: bytes", "packets"; foreach my $intf (sort @interfaces) { + die "Invalid bonding interface: $intf\n" + unless (-d "/sys/class/net/$intf/bonding" ); + my @slaves = split( / /, get_sysfs_value( $intf, "bonding/slaves" ) ); printf $format, $intf, get_sysfs_value( $intf, "statistics/rx_bytes" ), get_sysfs_value( $intf, "statistics/rx_packets" ), -- cgit v1.2.3