mirror of
https://github.com/SagerNet/sing-box.git
synced 2025-07-22 22:14:09 +08:00
Increase default mtu to 65535
This commit is contained in:
parent
0098a2adc5
commit
ae2ecd6002
@ -132,12 +132,13 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
|||||||
|
|
||||||
platformInterface := service.FromContext[platform.Interface](ctx)
|
platformInterface := service.FromContext[platform.Interface](ctx)
|
||||||
tunMTU := options.MTU
|
tunMTU := options.MTU
|
||||||
|
enableGSO := C.IsLinux && options.Stack == "gvisor" && platformInterface == nil && tunMTU > 0 && tunMTU < 49152
|
||||||
if tunMTU == 0 {
|
if tunMTU == 0 {
|
||||||
if platformInterface != nil && platformInterface.UnderNetworkExtension() {
|
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.
|
// 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
|
tunMTU = 4064
|
||||||
} else {
|
} else {
|
||||||
tunMTU = 9000
|
tunMTU = 65535
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var udpTimeout time.Duration
|
var udpTimeout time.Duration
|
||||||
@ -189,6 +190,7 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
|
|||||||
tunOptions: tun.Options{
|
tunOptions: tun.Options{
|
||||||
Name: options.InterfaceName,
|
Name: options.InterfaceName,
|
||||||
MTU: tunMTU,
|
MTU: tunMTU,
|
||||||
|
GSO: enableGSO,
|
||||||
Inet4Address: inet4Address,
|
Inet4Address: inet4Address,
|
||||||
Inet6Address: inet6Address,
|
Inet6Address: inet6Address,
|
||||||
AutoRoute: options.AutoRoute,
|
AutoRoute: options.AutoRoute,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user