Skip to content

Commit

Permalink
Add offloading again (#3062)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsakalozos authored Apr 19, 2022
1 parent 5a0d224 commit eb95dc1
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions microk8s-resources/wrappers/apiservice-kicker
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand Down Expand Up @@ -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.
#
Expand Down

0 comments on commit eb95dc1

Please sign in to comment.