diff --git a/rootfs/etc/network/if-up.d/dietpi-disable_offload b/rootfs/etc/network/if-up.d/dietpi-disable_offload new file mode 100644 index 0000000000..aa83386656 --- /dev/null +++ b/rootfs/etc/network/if-up.d/dietpi-disable_offload @@ -0,0 +1,53 @@ +#!/bin/bash +{ + #//////////////////////////////////// + # dietpi-disable_offload + # + #//////////////////////////////////// + # Created by Daniel Knight + # Based on original fix & code by @carlosedp: https://github.com/Fourdee/DietPi/issues/2028#issue-352323603 + # + #//////////////////////////////////// + # + # Info: + # - Sets TCP/UDP offloading disabled for the required devices, which are prone to retransmissions and reset errors. + # - Currently known: RK3399/rock64 + # + # Exit codes: + # - 1=failure + # ethtool does not exist + # Failed to set ethtool to flagged devices + # - 0=ok + # + #//////////////////////////////////// + + #/////////////////////////////////////////////////////////////////////////////////// + # Globals + #/////////////////////////////////////////////////////////////////////////////////// + CMD=$(which ethtool) + EXIT_CODE=1 + + #/////////////////////////////////////////////////////////////////////////////////// + # Main Loop + #/////////////////////////////////////////////////////////////////////////////////// + #----------------------------------------------------------------------------------- + #Ethtool exists? + if [[ $CMD ]]; then + + EXIT_CODE=0 #Set success for all devices by default + + if [[ -d /sys/devices/platform/fe300000.ethernet/net/$IFACE || + -d /sys/devices/platform/ff540000.eth/net/$IFACE || + -d /sys/devices/platform/ff540000.ethernet/net/$IFACE ]]; then + + $CMD -K $IFACE rx off tx off + EXIT_CODE=$? #Update exit code once applied + + fi + + fi + #----------------------------------------------------------------------------------- + exit $EXIT_CODE + #----------------------------------------------------------------------------------- + +} \ No newline at end of file