Set UDP socket buffer sizes to prevent receive overflow

Under high-throughput forwarding, the kernel default 212KB receive
buffer overflows, silently dropping ~11% of UDP datagrams at transit
nodes. Add configurable recv_buf_size and send_buf_size to UdpConfig
(default 2MB each) using socket2 for pre-bind buffer configuration.
Startup log now reports actual buffer sizes granted by the kernel.

Requires net.core.rmem_max >= 2097152 on the host for the full 2MB
to take effect; otherwise the kernel silently clamps.
This commit is contained in:
Johnathan Corgan
2026-02-19 05:51:36 +00:00
parent 8cc9532bad
commit ac82e61c77
7 changed files with 83 additions and 4 deletions
+1
View File
@@ -24,6 +24,7 @@ rtnetlink = "0.14"
tokio = { version = "1", features = ["rt", "macros", "signal", "sync", "net", "time"] }
futures = "0.3"
simple-dns = "0.9"
socket2 = { version = "0.5", features = ["all"] }
[dev-dependencies]
tempfile = "3.15"