]> git.ipfire.org Git - people/stevee/network.git/commitdiff
ports: ethernet+bonding: Allow to disable all offloading
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Sep 2018 12:58:39 +0000 (14:58 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Sep 2018 12:58:39 +0000 (14:58 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.offloading
src/hooks/ports/bonding
src/hooks/ports/ethernet

index d59b83af072775a47ae38e7bc3da5a4445c177be..809093f35f92d437c3149e08745bf4ed0860f1b9 100644 (file)
@@ -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}
+}
index e93c6117ef00fe54cc9764d5cc18c247285b84a9..6248cc15d4adb895bf9d54feffbe91326680f2f8 100644 (file)
@@ -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}"
index 823090d78a2a953bc1ff853f7732f2de5e304ff4..b782e52fe2f8ff2cff11642be7e2ddab29a6a462 100644 (file)
@@ -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}"