diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-08 11:42:05 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2010-11-08 13:58:48 -0800 |
commit | 80a924e8b4033109b6fa23ceb9811a083c7345e8 (patch) | |
tree | 250b84181b48af3e082e768e52ae6818ef2a56e5 | |
parent | 1df58b23bac61caf78f28f549e180a3189986689 (diff) | |
download | vyatta-cfg-quagga-80a924e8b4033109b6fa23ceb9811a083c7345e8.tar.gz vyatta-cfg-quagga-80a924e8b4033109b6fa23ceb9811a083c7345e8.zip |
Don't produce warnings for drivers that don't support ethtool
Bug 5552
For devices like Xen that don't do ethtool speed/duplex,
allow auto to work but produce error for any other value.
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index c8d6f263..982cf0ee 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -571,10 +571,11 @@ sub show_interfaces { print join(' ', @match), "\n"; } +# Determine current values for speed, duplex and autonegotiation sub get_ethtool { my $dev = shift; - open( my $ethtool, "-|", "$ETHTOOL $dev 2>/dev/null" ) + open( my $ethtool, '-|', "$ETHTOOL $dev 2>&1" ) or die "ethtool failed: $!\n"; # ethtool produces: @@ -589,6 +590,8 @@ sub get_ethtool { my ($rate, $duplex, $autoneg); while (<$ethtool>) { chomp; + return if ( /^Cannot get device settings/ ); + if ( /^\s+Speed: ([0-9]+)Mb\/s|^\s+Speed: (Unknown)/ ) { $rate = $1; } elsif ( /^\s+Duplex:\s(.*)$/ ) { @@ -606,7 +609,16 @@ sub set_speed_duplex { die "Missing --dev argument\n" unless $intf; my ($ospeed, $oduplex, $autoneg) = get_ethtool($intf); - if ($ospeed) { + + # Some devices do not support speed/duplex + unless (defined($ospeed)) { + die "$intf: does not support speed/duplex selection\n" + if ($nspeed ne 'auto' || $nduplex ne 'auto'); + return; + } + + # Check if already the correct settings to avoid flapping link + if ($ospeed ne 'Unknown') { if ($autoneg) { # Device is in autonegotiation mode return if ($nspeed eq 'auto'); |