Add tcpMaxSeg to sockopt (#2002)

This commit is contained in:
xqzr 2023-04-30 08:03:30 +08:00 committed by GitHub
parent 18e5b0963f
commit dd81ad5342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 2 deletions

View file

@ -94,6 +94,13 @@ func applyOutboundSocketOptions(network string, address string, fd uintptr, conf
return newError("failed to set TCP_USER_TIMEOUT", err)
}
}
if config.TcpMaxSeg > 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_MAXSEG, int(config.TcpMaxSeg)); err != nil {
return newError("failed to set TCP_MAXSEG", err)
}
}
}
if config.Tproxy.IsEnabled() {
@ -156,6 +163,12 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig)
return newError("failed to set TCP_USER_TIMEOUT", err)
}
}
if config.TcpMaxSeg > 0 {
if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, unix.TCP_MAXSEG, int(config.TcpMaxSeg)); err != nil {
return newError("failed to set TCP_MAXSEG", err)
}
}
}
if config.Tproxy.IsEnabled() {