Skip to content

Commit

Permalink
T600: Virtio network card, no info (maybe not fully supported?)
Browse files Browse the repository at this point in the history
  - 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.
  • Loading branch information
hagbard-01 committed Oct 16, 2018
1 parent b02a111 commit bf7fe3d
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions scripts/vyatta-interfaces.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit bf7fe3d

Please sign in to comment.