瀏覽代碼

Increase default mtu to 65535

世界 3 月之前
父節點
當前提交
ae2ecd6002
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      protocol/tun/inbound.go

+ 3 - 1
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,