aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2011-02-22 02:54:26 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2011-02-22 02:59:38 +0000
commitdfd42d139357b23fb7629bea3bc39918a660cd4c (patch)
tree2fc48bd0d8b9064ba43a1fc63ee2e5b37affad6a /net
parent22918ccf514a3c10459842f917bf742d7620f031 (diff)
net/ethtool: official interface for changing ethtool params (bug #195479)
Implement a consistent interface for changing ethtool parameters, as suggested in bug 195479. All variable names are based on the long option to ethtool to set each group of parameters. Multiple entries seperated by newlines are permitted for variable values. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Gentoo-Bug: 195479
Diffstat (limited to 'net')
-rw-r--r--net/Makefile.Linux4
-rw-r--r--net/ethtool.sh54
2 files changed, 56 insertions, 2 deletions
diff --git a/net/Makefile.Linux b/net/Makefile.Linux
index 7006d74c..f7fb0870 100644
--- a/net/Makefile.Linux
+++ b/net/Makefile.Linux
@@ -1,7 +1,7 @@
SRCS+= iwconfig.sh.in
INC+= adsl.sh apipa.sh arping.sh bonding.sh br2684ctl.sh bridge.sh \
- ccwgroup.sh clip.sh iproute2.sh ifplugd.sh ip6to4.sh ipppd.sh \
- iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
+ ccwgroup.sh clip.sh ethtool.sh iproute2.sh ifplugd.sh ip6to4.sh \
+ ipppd.sh iwconfig.sh netplugd.sh pppd.sh pump.sh tuntap.sh udhcpc.sh \
vlan.sh
.SUFFIXES: .sh.Linux.in
diff --git a/net/ethtool.sh b/net/ethtool.sh
new file mode 100644
index 00000000..64b44a62
--- /dev/null
+++ b/net/ethtool.sh
@@ -0,0 +1,54 @@
+# Copyright (c) 2011 by Gentoo Foundation
+# All rights reserved. Released under the 2-clause BSD license.
+
+_ethtool() {
+ echo /usr/sbin/ethtool
+}
+
+ethtool_depend()
+{
+ program $(_ethtool)
+ before interface
+}
+
+# This is just to trim whitespace, do not add any quoting!
+_trim() {
+ echo $*
+}
+
+ethtool_pre_start() {
+ local order opt OFS="${OIFS}"
+ eval order=\$ethtool_order_${IFVAR}
+ [ -z "${order}" ] && eval order=\$ethtool_order
+ [ -z "${order}" ] && order="flash change-eeprom change pause coalesce ring offload identify nfc rxfh-indir ntuple"
+ # ethtool options not used: --driver, --register-dump, --eeprom-dump, --negotiate, --test, --statistics
+ eindent
+ for opt in ${order} ; do
+ local args
+ eval args=\$ethtool_${opt//-/_}_${IFVAR}
+
+ # Skip everything if no arguments
+ [ -z "${args}" ] && continue
+
+ # Split on \n
+ local IFS="$__IFS"
+
+ for p in ${args} ; do
+ IFS="${OIFS}"
+ local args_pretty="$(_trim "${p}")"
+ # Do nothing if empty
+ [ -z "${args_prety}" ] && continue
+ args_pretty="--${opt} $IFACE ${args_pretty}"
+ args="--${opt} $IFACE ${args}"
+ ebegin "ethtool ${args_pretty}"
+ $(_ethtool) ${args}
+ rc=$?
+ eend $rc "ethtool exit code $rc"
+ # TODO: ethtool has MANY different exit codes, with no
+ # documentation as to which ones are fatal or not. For now we
+ # simply print the exit code and don't stop the start sequence.
+ done
+ IFS="${OIFS}"
+ done
+ eoutdent
+}