diff --git a/microk8s-resources/wrappers/apiservice-kicker b/microk8s-resources/wrappers/apiservice-kicker index 131b111344..790da3bdbb 100755 --- a/microk8s-resources/wrappers/apiservice-kicker +++ b/microk8s-resources/wrappers/apiservice-kicker @@ -24,11 +24,30 @@ fi restart_attempt=0 installed_registry_help=0 nic_name="vxlan.calico" +# This flag is used so we do not perform the offload check every time. +# This check is shown to cause issues on rpi, see +# https://bugs.launchpad.net/ubuntu/+source/linux-raspi/+bug/1955174 +installed_offloading=0 is_nic_available() { ip a show dev $nic_name > /dev/null 2>&1 } +deactivate_offloading() { + ethtool --offload $nic_name rx off tx off +} + +check_offloading() { + # Return an error if at least one offload is enabled (rx or tx) + if ethtool --show-offload $nic_name 2>&1 | grep -E '^.x-checksumming:' | grep -q ': on'; then + return 1 + else + # if offloading is already disabled update the respective flag. + installed_offloading=1 + return 0 + fi +} + while true do if [ $restart_attempt -ge 5 ] @@ -121,6 +140,22 @@ do fi fi + if ! [ -e "${SNAP_DATA}/var/lock/skip-offloading" ] && + [ $installed_offloading -eq 0 ] && + [ -e "${SNAP_DATA}/var/lock/cni-loaded" ] && + is_nic_available && + ! check_offloading + then + echo "Network interface $nic_name found! Disabling offloading on it..." + deactivate_offloading + sleep 2 + if check_offloading; then + echo "Offloading successfully disabled on interface $nic_name" + else + echo "Offloading has not been disabled correctly on interface $nic_name. Please check what happened" + fi + fi + # If no local-registry-hosting documentation has been installed, # install a help guide that points to the microk8s registry docs. #