From 8a2de9b1b58d102d1967f62552f3194596236154 Mon Sep 17 00:00:00 2001 From: Ryan Huber Date: Sun, 11 Oct 2026 00:30:07 -0400 Subject: [PATCH] examples: set socket buffers and raise tun tx_queue (#1928) * examples: set socket buffers and raise tun tx_queue * examples: use the default tcp max window for socket buffers * examples: note buffers are linux only, clarify tx_queue default * tun: default tx_queue to 5000 --- examples/config.yml | 10 +++++----- overlay/tun.go | 2 +- overlay/tun_linux.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/config.yml b/examples/config.yml index 987ef90e..0d1a9180 100644 --- a/examples/config.yml +++ b/examples/config.yml @@ -135,12 +135,12 @@ listen: # superpacket, so the receive scratch is batch * 64KiB per listening socket (~4MiB per routine at the # default of 64). Lower this to trade peak per-syscall throughput for memory on constrained hosts. #batch: 64 - # Configure socket buffers for the udp side (outside), leave unset to use the system defaults. Values will be doubled by the kernel + # Linux only. Configure socket buffers for the udp side (outside), leave unset to use the system defaults. Values will be doubled by the kernel # Default is net.core.rmem_default and net.core.wmem_default (/proc/sys/net/core/rmem_default and /proc/sys/net/core/rmem_default) # Maximum is limited by memory in the system, SO_RCVBUFFORCE and SO_SNDBUFFORCE is used to avoid having to raise the system wide # max, net.core.rmem_max and net.core.wmem_max - #read_buffer: 10485760 - #write_buffer: 10485760 + read_buffer: 3412512 + write_buffer: 3412512 # On Windows only # When true, Nebula installs a WFP (Windows Filtering Platform) PERMIT filter scoped to UDP at the listener port. @@ -262,8 +262,8 @@ tun: drop_local_broadcast: false # Toggles forwarding of multicast packets drop_multicast: false - # Sets the transmit queue length, if you notice lots of transmit drops on the tun it may help to raise this number. Default is 500 - tx_queue: 500 + # Sets the transmit queue length, if you notice lots of transmit drops on the tun it may help to raise this number. Default is 5000 + tx_queue: 5000 # Default MTU for every packet, safe setting is (and the default) 1300 for internet based traffic # Anything above 8937, here or on a route below, is capped to 8937 with a warning mtu: 1300 diff --git a/overlay/tun.go b/overlay/tun.go index eb994341..0ba130b6 100644 --- a/overlay/tun.go +++ b/overlay/tun.go @@ -43,7 +43,7 @@ type DeviceFactory func(c *config.C, l *slog.Logger, vpnNetworks []netip.Prefix, func NewDeviceFromConfig(c *config.C, l *slog.Logger, vpnNetworks []netip.Prefix, routines int) (Device, error) { switch { case c.GetBool("tun.disabled", false): - tun := newDisabledTun(vpnNetworks, c.GetInt("tun.tx_queue", 500), c.GetBool("stats.message_metrics", false), l) + tun := newDisabledTun(vpnNetworks, c.GetInt("tun.tx_queue", 5000), c.GetBool("stats.message_metrics", false), l) return tun, nil default: diff --git a/overlay/tun_linux.go b/overlay/tun_linux.go index b5e0a675..5e27ad9b 100644 --- a/overlay/tun_linux.go +++ b/overlay/tun_linux.go @@ -221,7 +221,7 @@ func newTunGeneric(c *config.C, l *slog.Logger, fd int, vnetHdr bool, offloadFla vnetHdr: vnetHdr, offloadFlags: offloadFlags, vpnNetworks: vpnNetworks, - TXQueueLen: c.GetInt("tun.tx_queue", 500), + TXQueueLen: c.GetInt("tun.tx_queue", 5000), useSystemRoutes: c.GetBool("tun.use_system_route_table", false), useSystemRoutesBufferSize: c.GetInt("tun.use_system_route_table_buffer_size", 0), routesFromSystem: map[netip.Prefix]routing.Gateways{},