2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2018 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # A list of supported device offloading mechanisms
23 # that are being mapped to the ethtool command
24 declare -A SUPPORTED_OFFLOADINGS
=(
25 [generic-receive-offload
]="gro"
26 [generic-segmentation-offload
]="gso"
27 [large-receive-offload
]="lro"
28 [rx-checksumming
]="rx"
30 [tcp-segmentation-offload
]="tso"
31 [tx-checksumming
]="tx"
32 [udp-fragmentation-offload
]="ufo"
35 # These offloadings will automatically be enabled (if supported)
37 generic-receive-offload
38 generic-segmentation-offload
41 tcp-segmentation-offload
43 udp-fragmentation-offload
50 # Enable all offloadings that we consider a good default
52 for offloading
in ${AUTO_OFFLOADINGS[@]}; do
53 offloading_set
"${device}" "${offloading}" "on"
63 local offloading
="${2}"
64 assert isoneof offloading
${!SUPPORTED_OFFLOADINGS[@]}
67 assert isoneof value on off
69 # Translate to ethool option
70 local mode
="${SUPPORTED_OFFLOADINGS[${offloading}]}"
72 error
"Unsupported offloading mode: ${offloading}"
77 if ! cmd_quiet ethtool
--offload "${device}" "${mode}" "${value}"; then
78 log DEBUG
"Could not set ${offloading} on ${device} to ${value}"
82 log DEBUG
"Set ${offloading} on ${device} to ${value}"