summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-12-23 10:05:30 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-12-23 10:05:30 -0800
commitd4d66849e389e18de7debb95c7e39a0d17663c30 (patch)
treee5aedc53bf7dfc60af5292524333113e0cd41fca
parenta4edc2d812b0f026f5eda3417acbf181373effa3 (diff)
downloadvyatta-cfg-quagga-d4d66849e389e18de7debb95c7e39a0d17663c30.tar.gz
vyatta-cfg-quagga-d4d66849e389e18de7debb95c7e39a0d17663c30.zip
Handle default of auto
If device doesn't support speed/duplex, then speed = auto which is default is okay.
-rwxr-xr-xscripts/vyatta-interfaces.pl15
1 files changed, 8 insertions, 7 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index d5b0f7d1..3b1473c9 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -558,7 +558,7 @@ sub get_ethtool {
my ($rate, $duplex, $autoneg);
while (<$ethtool>) {
chomp;
- if ( /^\s+Speed:\s([0-9]+)Mb\/s/ ) {
+ if ( /^\s+Speed: ([0-9]+)Mb\/s|^\s+Speed: (Unknown)/ ) {
$rate = $1;
} elsif ( /^\s+Duplex:\s(.*)$/ ) {
$duplex = lc $1;
@@ -575,14 +575,15 @@ sub set_speed_duplex {
die "Missing --dev argument\n" unless $intf;
my ($ospeed, $oduplex, $autoneg) = get_ethtool($intf);
-
- # Don't change settings if already okay.
- if ($autoneg) {
+ unless ($ospeed) {
+ # Device does not support ethtool or does not report speed
+ die "Device $intf does not support setting speed/duplex\n"
+ unless ($nspeed eq 'auto');
+ } elsif ($autoneg) {
+ # Device is in autonegotiation mode
return if ($nspeed eq 'auto');
} else {
- die "Device $intf does not support setting speed/duplex\n"
- unless (defined($ospeed) && defined($oduplex));
-
+ # Device has explicit speed/duplex
return if (($nspeed eq $ospeed) && ($nduplex eq $oduplex));
}