Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failsafe enabling of UDP GRO for forwarding #370

Merged
merged 7 commits into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions tailscale/rootfs/etc/s6-overlay/s6-rc.d/post-tailscaled/run
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,6 @@ declare login_server
declare tags
declare keyexpiry

# Linux optimizations for subnet routers and exit nodes
# Based on: https://tailscale.com/kb/1320/performance-best-practices#linux-optimizations-for-subnet-routers-and-exit-nodes
# Note: Changes made via ethtool are not persistent and will be lost after the machine shuts down
# Note: Executing it before "tailscale up" to avoid warning messages
for interface in $( \
{ ip -4 route show 0/0; ip -6 route show ::/0; } \
| { grep -E '^default\svia\s\S+\sdev\s\S+' || true ;} \
| cut -f5 -d' ' \
| sort -u)
do
bashio::log.info "Allow UDP GRO for forwarding on ${interface}"
ethtool -K "${interface}" rx-udp-gro-forwarding on rx-gro-list off
done

# Default options
options+=(--hostname "$(bashio::info.hostname)")

Expand Down Expand Up @@ -124,6 +110,21 @@ done

bashio::log.info "Tailscale is running"

# Linux optimizations for subnet routers and exit nodes
# Based on: https://tailscale.com/kb/1320/performance-best-practices#linux-optimizations-for-subnet-routers-and-exit-nodes
# Note: Changes made via ethtool are not persistent and will be lost after the machine shuts down
if interface=$( \
curl -sf --unix-socket /var/run/tailscale/tailscaled.sock http://local-tailscaled.sock/localapi/v0/check-udp-gro-forwarding \
| jq -rc '.Warning' \
| sed -nr 's/^UDP GRO forwarding is suboptimally configured on (\S+),.*$/\1/p') \
&& bashio::var.has_value "${interface}";
then
bashio::log.info "Enabling UDP GRO for forwarding on ${interface}"
if ! ethtool -K "${interface}" rx-udp-gro-forwarding on rx-gro-list off; then
bashio::log.warning "Enabling UDP GRO failed"
fi
fi

# Delete previously created persistent tailscale serve configuration ONCE
# After add-on's serve (proxy and funnel) service is a longrun service, we do not modify the serve state permanently
# This step can be removed in a later version with the file in the data folder also
Expand Down