diff options
-rwxr-xr-x | scripts/vyatta-interfaces.pl | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl index f714aa3c..d0e37a2d 100755 --- a/scripts/vyatta-interfaces.pl +++ b/scripts/vyatta-interfaces.pl @@ -476,17 +476,34 @@ sub set_speed_duplex { my ($intf, $nspeed, $nduplex) = @_; die "Missing --dev argument\n" unless $intf; - # read old values to avoid meaningless speed changes - my ($autoneg, $ospeed, $oduplex) = get_ethtool($intf); + ## if driver virtio, speed and duplex are unknown per default coming fromthe driver itself + ## if that's the case we always run ethtool and set the values + + open(my $ethtool, '-|', "$ETHTOOL -i $dev 2>&1") + or die "ethtool failed: $!\n"; + my $drv = 0; + while (<$ethtool>) + { + chomp; + return if (/^Cannot get device driver settings/); + $drv = 1 if (/^driver:.*/); + last; + } - if (defined($autoneg) && $autoneg == 1) { + if ($drv != 1) + { + # read old values to avoid meaningless speed changes + my ($autoneg, $ospeed, $oduplex) = get_ethtool($intf); - # Device is already in autonegotiation mode - return if ($nspeed eq 'auto'); - } elsif (defined($ospeed) && defined($oduplex)) { + if (defined($autoneg) && $autoneg == 1) { - # Device has explicit speed/duplex but they already match - return if (($nspeed eq $ospeed) && ($nduplex eq $oduplex)); + # Device is already in autonegotiation mode + return if ($nspeed eq 'auto'); + } elsif (defined($ospeed) && defined($oduplex)) { + + # Device has explicit speed/duplex but they already match + return if (($nspeed eq $ospeed) && ($nduplex eq $oduplex)); + } } my $cmd = "$ETHTOOL -s $intf"; |