summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Hendry <jhendry@mintel.com>2014-10-29 16:53:09 +0000
committerDaniil Baturin <daniil@baturin.org>2017-09-14 13:36:44 +0200
commitd1cc811b66c7a53f52bb2580a43a1f8689bb3a9c (patch)
tree673458338ae6f9938374ed33cecfb754088c4996
parent82823175f65ba083270fe51831c023285ca6e6a0 (diff)
downloadvyatta-cfg-system-d1cc811b66c7a53f52bb2580a43a1f8689bb3a9c.tar.gz
vyatta-cfg-system-d1cc811b66c7a53f52bb2580a43a1f8689bb3a9c.zip
Making offload setting changes change on a single option
-rwxr-xr-xscripts/vyatta-interfaces.pl61
-rw-r--r--templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def6
-rw-r--r--templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def6
-rw-r--r--templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def7
-rw-r--r--templates/interfaces/ethernet/node.tag/offload/udp-segmentation-offload/node.def6
5 files changed, 32 insertions, 54 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index c91cc22c..f3792f74 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -50,7 +50,7 @@ my ($dev, $mac, $mac_update);
my %skip_interface;
my ($check_name, $show_names, $vif_name, $warn_name);
my ($check_up, $dhcp_command, $allowed_speed);
-my (@speed_duplex, @addr_commit, @check_speed, @offload_settings);
+my (@speed_duplex, @addr_commit, @check_speed, @offload_option);
sub usage {
print <<EOF;
@@ -62,7 +62,7 @@ Usage: $0 --dev=<interface> --check=<type>
$0 --dev=<interface> --check-speed=speed,duplex
$0 --dev=<interface> --allowed-speed
$0 --dev=<interface> --isup
- $0 --dev=<interface> --offload-settings=tcp,udp,segmentation,recieve
+ $0 --dev=<interface> --offload-settings={tcp,udp,segmentation,receive}={value}
$0 --show=<type>
EOF
exit 1;
@@ -82,7 +82,7 @@ GetOptions("valid-addr-commit=s{,}" => \@addr_commit,
"speed-duplex=s{2}" => \@speed_duplex,
"check-speed=s{2}" => \@check_speed,
"allowed-speed" => \$allowed_speed,
- "offload-settings=s{4}" => \@offload_settings,
+ "offload-settings=s{2}" => \@offload_option,
) or usage();
is_valid_addr_commit($dev, @addr_commit) if (@addr_commit);
@@ -96,7 +96,7 @@ is_up($dev) if ($check_up);
set_speed_duplex($dev, @speed_duplex) if (@speed_duplex);
check_speed_duplex($dev, @check_speed) if (@check_speed);
allowed_speed($dev) if ($allowed_speed);
-set_offload_settings($dev) if (@offload_settings);
+set_offload_setting($dev, @offload_option) if (@offload_option);
exit 0;
sub is_ip_configured {
@@ -575,48 +575,43 @@ sub allowed_speed {
print 'auto ', join(' ', sort keys %speeds), "\n";
}
-sub get_offload_settings {
- my $dev = shift;
+sub get_offload_setting {
+ my ($dev, $option) = @_;
+ my ($val);
open( my $ethtool, '-|', "$ETHTOOL -k $dev 2>&1" ) or die "ethtool failed: $!\n";
-
- my ($tcp, $udp, $segmen, $receive);
-
while (<$ethtool>) {
+ next if ($_ !~ m/$option:/);
chomp;
- my $val = (split(/: /, $_))[1];
-
- if ( /^tcp-segmentation-offload:/ ) {
- $tcp = $val;
- } elsif ( /^udp-fragmentation-offload:/ ) {
- $udp = $val;
- } elsif ( /^generic-segmentation-offload:/ ) {
- $segmen = $val;
- } elsif ( /^generic-receive-offload:/ ) {
- $receive = $val;
- }
+ $val = (split(/: /, $_))[1];
}
-
close $ethtool;
-
- return ($tcp, $udp, $segmen, $receive);
+ return ($val);
}
-sub set_offload_settings {
- my ($intf, $ntcp, $nudp, $nsegmen, $nreceive) = @_;
+sub set_offload_setting {
+ my ($intf, $option, $nvalue) = @_;
die "Missing --dev argument\n" unless $intf;
- ($tcp, $udp, $segmen, $receive) = get_offload_settings($intf);
+ my $ovalue = get_offload_setting($intf, $option);
+ my $args = '';
- my $args;
+ my %ethtool_opts = ( 'generic-receive-offload' => 'gro',
+ 'generic-segmentation-offload' => 'gso',
+ 'tcp-segmentation-offload' => 'tso',
+ 'udp-segmentation-offload' => 'ufo',
+ );
- $args .= " tso $ntcp" if (defined($ntcp) && $ntcp ne $otcp);
- $args .= " ufo $nudp" if (defined($nudp) && $nudp ne $oudp);
- $args .= " gso $nsegmen" if (defined($nsegmen) && $nsegmen ne $osegmen);
- $args .= " gro $nreceive" if (defined($nreceive) && $nreceive ne $oreceive);
+ $args = "$ethtool_opts{$option} $nvalue" if (defined($nvalue) && $nvalue ne $ovalue);
- exec "$ETHTOOL -K $intf $args" if (defined($args));
- die "exec of $ETHTOOL failed: $!";
+ if ($args ne '') {
+ my $cmd = "$ETHTOOL -K $intf $args";
+ system($cmd);
+
+ if ($? >> 8) {
+ die "exec of $ETHTOOL failed: '$cmd'";
+ }
+ }
}
diff --git a/templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def
index 411565ab..4970f2de 100644
--- a/templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def
+++ b/templates/interfaces/ethernet/node.tag/offload/generic-receive-offload/node.def
@@ -12,10 +12,6 @@ val_help: off; Disable generic-receive-offload
syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "$type must be either 'on' or 'off'"
-update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) \
- --offload-settings $VAR(../tcp-segmentation-offload/@) \
- $VAR(../udp-segmentation-offload/@) \
- $VAR(../generic-segmentation-offload/@) \
- $VAR(@)
+update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings generic-receive-offload $VAR(@)
diff --git a/templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def
index 91b1ecf9..727d91ff 100644
--- a/templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def
+++ b/templates/interfaces/ethernet/node.tag/offload/generic-segmentation-offload/node.def
@@ -12,10 +12,6 @@ val_help: off; Disable generic-segmentation-offload
syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "$type must be either 'on' or 'off'"
-update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) \
- --offload-settings $VAR(../tcp-segmentation-offload/@) \
- $VAR(../udp-segmentation-offload/@) \
- $VAR(@) \
- $VAR(../generic-receive-offload/@)
+update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings generic-segmentation-offload $VAR(@)
diff --git a/templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def
index 641c2c8b..4046139c 100644
--- a/templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def
+++ b/templates/interfaces/ethernet/node.tag/offload/tcp-segmentation-offload/node.def
@@ -12,10 +12,5 @@ val_help: off; Disable tcp-segmentation-offload
syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "$type must be either 'on' or 'off'"
-update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) \
- --offload-settings $VAR(@) \
- $VAR(../udp-segmentation-offload/@) \
- $VAR(../generic-segmentation-offload/@) \
- $VAR(../generic-receive-offload/@)
-
+update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings tcp-segmentation-offload $VAR(@)
diff --git a/templates/interfaces/ethernet/node.tag/offload/udp-segmentation-offload/node.def b/templates/interfaces/ethernet/node.tag/offload/udp-segmentation-offload/node.def
index d96b4be5..86a7abe1 100644
--- a/templates/interfaces/ethernet/node.tag/offload/udp-segmentation-offload/node.def
+++ b/templates/interfaces/ethernet/node.tag/offload/udp-segmentation-offload/node.def
@@ -12,10 +12,6 @@ val_help: off; Disable udp-segmentation-offload
syntax:expression: $VAR(@) == "on" || $VAR(@) == "off" ; "$type must be either 'on' or 'off'"
-update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) \
- --offload-settings $VAR(../tcp-segmentation-offload/@) \
- $VAR(@) \
- $VAR(../generic-segmentation-offload/@) \
- $VAR(../generic-receive-offload/@)
+update: sudo /opt/vyatta/sbin/vyatta-interfaces.pl --dev=$VAR(../../@) --offload-settings udp-segmentation-offload $VAR(@)