From: Michael Tremer Date: Fri, 21 Sep 2018 12:58:39 +0000 (+0200) Subject: ports: ethernet+bonding: Allow to disable all offloading X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=085a89dc375aa0857fba580c1893a224ac445551;p=people%2Fstevee%2Fnetwork.git ports: ethernet+bonding: Allow to disable all offloading Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.offloading b/src/functions/functions.offloading index d59b83af..809093f3 100644 --- a/src/functions/functions.offloading +++ b/src/functions/functions.offloading @@ -83,3 +83,15 @@ offloading_set() { return ${EXIT_OK} } + +offloading_disable_all() { + local device="${1}" + assert isset device + + local offloading + for offloading in ${!SUPPORTED_OFFLOADINGS[@]}; do + offloading_set "${device}" "${offloading}" "off" + done + + return ${EXIT_OK} +} diff --git a/src/hooks/ports/bonding b/src/hooks/ports/bonding index e93c6117..6248cc15 100644 --- a/src/hooks/ports/bonding +++ b/src/hooks/ports/bonding @@ -21,7 +21,7 @@ . /usr/lib/network/header-port -HOOK_SETTINGS="HOOK ADDRESS MIIMON MODE SLAVES" +HOOK_SETTINGS="HOOK ADDRESS MIIMON MODE OFFLOADING SLAVES" SLAVES="" MIIMON=100 @@ -47,6 +47,15 @@ hook_parse_cmdline() { --mode=*) MODE=$(cli_get_val "${1}") ;; + --offloading=*) + OFFLOADING="$(cli_get_val "${1}")" + + if enabled OFFLOADING; then + OFFLOADING="on" + else + OFFLOADING="off" + fi + ;; +*) local slave=$(cli_get_val "${1:1}") @@ -175,8 +184,12 @@ hook_up() { port_settings_read "${port}" ${HOOK_SETTINGS} - # Auto-enable hardware offloading - offloading_auto "${port}" + # Auto-enable or disable hardware offloading + if ! isset OFFLOADING || enabled OFFLOADING; then + offloading_auto "${port}" + else + offloading_disable_all "${port}" + fi # Execute the default action hook_default_up "${port}" diff --git a/src/hooks/ports/ethernet b/src/hooks/ports/ethernet index 823090d7..b782e52f 100644 --- a/src/hooks/ports/ethernet +++ b/src/hooks/ports/ethernet @@ -24,7 +24,7 @@ # DEVICE equals the actual MAC address of the device. # If ADDRESS is set, the device will get ADDRESS set for its MAC address. -HOOK_SETTINGS="HOOK ADDRESS ADVERTISED_LINK_SPEEDS DEVICE MTU" +HOOK_SETTINGS="HOOK ADDRESS ADVERTISED_LINK_SPEEDS DEVICE OFFLOADING MTU" hook_check_settings() { assert ismac DEVICE @@ -78,6 +78,16 @@ hook_parse_cmdline() { fi ;; + --offloading=*) + OFFLOADING="$(cli_get_val "${1}")" + + if enabled OFFLOADING; then + OFFLOADING="on" + else + OFFLOADING="off" + fi + ;; + *) error "Unknown argument: ${1}" return ${EXIT_ERROR} @@ -117,8 +127,12 @@ hook_up() { device_advertise_link_speeds "${port}" ${ADVERTISED_LINK_SPEEDS} fi - # Auto-enable hardware offloading - offloading_auto "${port}" + # Auto-enable or disable hardware offloading + if ! isset OFFLOADING || enabled OFFLOADING; then + offloading_auto "${port}" + else + offloading_disable_all "${port}" + fi # Bring up the device device_set_up "${port}"