From 0b84adc1dbb527ea7ce39aaa5cd992f09056d07d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 6 Jul 2009 16:46:08 -0700 Subject: Fix error message from show bonding Bug 4628 If bond device has no slaves, then get_sysfs_value will return undefined, instead of empty string. --- scripts/vyatta-show-bonding.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-show-bonding.pl b/scripts/vyatta-show-bonding.pl index 902be4e..62d503e 100755 --- a/scripts/vyatta-show-bonding.pl +++ b/scripts/vyatta-show-bonding.pl @@ -104,13 +104,15 @@ sub show { die "Invalid bonding interface: $intf\n" unless (-d "/sys/class/net/$intf/bonding" ); - my @slaves = split( / /, get_sysfs_value( $intf, "bonding/slaves" ) ); + my $slaves = get_sysfs_value( $intf, "bonding/slaves" ); + next unless $slaves; + printf $format, $intf, get_sysfs_value( $intf, "statistics/rx_bytes" ), get_sysfs_value( $intf, "statistics/rx_packets" ), get_sysfs_value( $intf, "statistics/tx_bytes" ), get_sysfs_value( $intf, "statistics/tx_packets" ); - foreach my $slave (sort @slaves) { + foreach my $slave (sort split( / /, $slaves)) { printf $format, ' ' . $slave, get_sysfs_value( $slave, "statistics/rx_bytes" ), get_sysfs_value( $slave, "statistics/rx_packets" ), -- cgit v1.2.3