diff options
author | hagbard <vyosdev@derith.de> | 2018-10-16 11:07:09 -0700 |
---|---|---|
committer | hagbard <vyosdev@derith.de> | 2018-10-16 11:07:09 -0700 |
commit | bf7fe3da15446eef6d5974d26106c130179c32fc (patch) | |
tree | fc940e1865f7a6dc377aa06ff3be1ac19016b73c /scripts/vyatta-interfaces.pl | |
parent | b02a111014a36b29c789506dd2f04bdb183c856e (diff) | |
download | vyatta-cfg-system-bf7fe3da15446eef6d5974d26106c130179c32fc.tar.gz vyatta-cfg-system-bf7fe3da15446eef6d5974d26106c130179c32fc.zip |
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.
Diffstat (limited to 'scripts/vyatta-interfaces.pl')
-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"; |