From ae2ecd600271e49b5969b78ac1e8a2339ee40f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 12 Jul 2025 14:47:27 +0800 Subject: [PATCH] Increase default mtu to 65535 --- protocol/tun/inbound.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protocol/tun/inbound.go b/protocol/tun/inbound.go index e028a9de..b33a7807 100644 --- a/protocol/tun/inbound.go +++ b/protocol/tun/inbound.go @@ -132,12 +132,13 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo platformInterface := service.FromContext[platform.Interface](ctx) tunMTU := options.MTU + enableGSO := C.IsLinux && options.Stack == "gvisor" && platformInterface == nil && tunMTU > 0 && tunMTU < 49152 if tunMTU == 0 { if platformInterface != nil && platformInterface.UnderNetworkExtension() { // In Network Extension, when MTU exceeds 4064 (4096-UTUN_IF_HEADROOM_SIZE), the performance of tun will drop significantly, which may be a system bug. tunMTU = 4064 } else { - tunMTU = 9000 + tunMTU = 65535 } } var udpTimeout time.Duration @@ -189,6 +190,7 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo tunOptions: tun.Options{ Name: options.InterfaceName, MTU: tunMTU, + GSO: enableGSO, Inet4Address: inet4Address, Inet6Address: inet6Address, AutoRoute: options.AutoRoute,