From b95e989f070d017be346d1fb6753649b864cb1eb Mon Sep 17 00:00:00 2001 From: Emeric Brun Date: Wed, 6 Mar 2019 14:50:21 +0100 Subject: network: support fctl option to force flow control. Available values are {auto|both|rx|tx|none}. This option make init init script performs a ethtool -A with according parameters on the given iface. --- sbin/init.d/network | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sbin/init.d/network b/sbin/init.d/network index 4e9d2f3..bd72f0f 100755 --- a/sbin/init.d/network +++ b/sbin/init.d/network @@ -8,6 +8,7 @@ # speed {10|100|1000} # duplex {half|full} # auto {on|off} +# fctl {auto|both|rx|tx|none} # slave ... # modprobe [module [module_options]] # lladdr @@ -46,6 +47,7 @@ option media standard_option option duplex standard_option option speed standard_option option auto standard_option +option fctl standard_option option master_type standard_option option bonding option_bonding option slave multiple_option @@ -76,6 +78,7 @@ function do_help { echo " - ip6 addr , route <-|gwv6> []" echo " - media auto|{full|fdx|100full|100fdx}|{half|hdx|100half|100hdx}" echo " - duplex {half|full} ; speed {10|100|1000} ; auto {on|off}" + echo " - fctl {auto|both|rx|tx|none}" echo " - slave " echo " - bridge ; bridge_stp {on|off}" echo " - sysctl =" @@ -137,6 +140,26 @@ function set_media2 { /sbin/ethtool -s $1 ${4:+autoneg $4} ${speed:+speed $speed} ${duplex:+duplex $duplex} } +function set_fctl { + case "$2" in + both) + /sbin/ethtool -A $1 autoneg off rx on tx on >/dev/null 2>&1 + ;; + rx) + /sbin/ethtool -A $1 autoneg off rx on tx off >/dev/null 2>&1 + ;; + tx) + /sbin/ethtool -A $1 autoneg off rx off tx on >/dev/null 2>&1 + ;; + none) + /sbin/ethtool -A $1 autoneg off rx off tx off >/dev/null 2>&1 + ;; + auto) + /sbin/ethtool -A $1 autoneg on rx on tx on >/dev/null 2>&1 + ;; + esac +} + function fct_begin_section { addr_list=( ) addr6_list=( ) @@ -541,6 +564,11 @@ function do_start { echo " ==> Link configuration changed for interface $instname" fi + if [ -n "$opt_fctl" ]; then + set_fctl "$instname" "$opt_fctl" + echo " ==> Flow control management set to '$opt_fctl' for interface $instname" + fi + if [ ${#opt_slave[*]} -gt 0 ]; then for arg in ${opt_slave[*]}; do if ( ! $0 status "$arg" && ! $0 start "$arg" ) >/dev/null 2>&1; then -- 2.28.0