Skip to content

Instantly share code, notes, and snippets.

@lzlrd
Last active November 25, 2025 12:27
Show Gist options
  • Select an option

  • Save lzlrd/22c655e5f05533eb61d4a63e40aadf22 to your computer and use it in GitHub Desktop.

Select an option

Save lzlrd/22c655e5f05533eb61d4a63e40aadf22 to your computer and use it in GitHub Desktop.
#! /usr/bin/env bash
# For OpenWrt hotplug.d Scripts
if [ -n "$ACTION" ]; then
if [ "$ACTION" = "add" ] || [ "$ACTION" = "ifup" ]; then
:
else
exit 0
fi
fi
# Disable on Routers, Enable Elsewhere
lroDisable=false
rxGroListDisable=true
txNocacheCopyDisable=true
# For OpenWrt hotplug.d Scripts
if [ -n "$DEVICE" ] || [ -n "$DEVICENAME" ]; then
echo "[ethtool-offload] Enabling offloading on the following interfaces: $DEVICE $DEVICENAME."
interfaces="$DEVICE $DEVICENAME"
else
if [ $# -eq 0 ]; then
echo "[ethtool-offload] Enabling offloading on all interfaces."
interfaces="$(ip -o link show | awk -F': ' '{print $2}' | grep -v "lo" | sed 's/@.*$//')"
else
echo "[ethtool-offload] Enabling offloading on the following interfaces: $@."
interfaces="$@"
fi
fi
for i in $interfaces; do
ethtool --offload "$i" rx on tx on sg on tso on ufo on gso on gro on lro on rxvlan on txvlan on ntuple on rxhash on rx-udp-gro-forwarding on
if [ "$lroDisable" = true ]; then
echo "[ethtool-offload] Disabling lro on $i..."
echo "[ethtool-offload] See https://serverfault.com/a/806454 for more information."
ethtool -K "$i" "lro" off
fi
if [ "$rxGroListDisable" = true ]; then
echo "[ethtool-offload] Disabling rx-gro-list on $i..."
echo "[ethtool-offload] See https://tailscale.com/blog/quic-udp-throughput for more information."
ethtool -K "$i" "rx-gro-list" off
fi
if [ "$txNocacheCopyDisable" = true ]; then
echo "[ethtool-offload] Disabling tx-nocache-copy on $i..."
echo "[ethtool-offload] See https://enterprise-support.nvidia.com/s/article/how-to-bypass-local-cache--disable-tx-nocache-copy-x for more information."
ethtool -K "$i" "tx-nocache-copy" off
fi
done
ACTION=="add|bind", SUBSYSTEM=="net", RUN+="/usr/local/sbin/ethtool-offload %k"
ACTION=="change", SUBSYSTEM=="net", ATTR{operstate}=="up", RUN+="/usr/local/sbin/ethtool-offload %k"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment