From bf7fe3da15446eef6d5974d26106c130179c32fc Mon Sep 17 00:00:00 2001 From: hagbard Date: Tue, 16 Oct 2018 11:07:09 -0700 Subject: T600: Virtio network card, no info (maybe not fully supported?) - set_speed_duplex checks for the existing values (again) and only issues ethtool if they differ. virtio_net returns 'unknown' therefore the settings have been applied only every 2nd commit. --- scripts/vyatta-interfaces.pl | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'scripts') 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"; -- cgit v1.2.3