mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add support for TCP_USER_TIMEOUT option.
The implementation follows the linux behavior where specifying a TCP_USER_TIMEOUT will cause the resend timer to honor the user specified timeout rather than the default rto based timeout. Further it alters when connections are timedout due to keepalive failures. It does not alter the behavior of when keepalives are sent. This is as per the linux behavior. PiperOrigin-RevId: 285099795
This commit is contained in:
committed by
gVisor bot
parent
1601e78a52
commit
6fc9f0aefd
@@ -1127,6 +1127,18 @@ func getSockOptTCP(t *kernel.Task, ep commonEndpoint, name, outLen int) (interfa
|
||||
|
||||
return int32(time.Duration(v) / time.Second), nil
|
||||
|
||||
case linux.TCP_USER_TIMEOUT:
|
||||
if outLen < sizeOfInt32 {
|
||||
return nil, syserr.ErrInvalidArgument
|
||||
}
|
||||
|
||||
var v tcpip.TCPUserTimeoutOption
|
||||
if err := ep.GetSockOpt(&v); err != nil {
|
||||
return nil, syserr.TranslateNetstackError(err)
|
||||
}
|
||||
|
||||
return int32(time.Duration(v) / time.Millisecond), nil
|
||||
|
||||
case linux.TCP_INFO:
|
||||
var v tcpip.TCPInfoOption
|
||||
if err := ep.GetSockOpt(&v); err != nil {
|
||||
@@ -1563,6 +1575,17 @@ func setSockOptTCP(t *kernel.Task, ep commonEndpoint, name int, optVal []byte) *
|
||||
}
|
||||
return syserr.TranslateNetstackError(ep.SetSockOpt(tcpip.KeepaliveIntervalOption(time.Second * time.Duration(v))))
|
||||
|
||||
case linux.TCP_USER_TIMEOUT:
|
||||
if len(optVal) < sizeOfInt32 {
|
||||
return syserr.ErrInvalidArgument
|
||||
}
|
||||
|
||||
v := int32(usermem.ByteOrder.Uint32(optVal))
|
||||
if v < 0 {
|
||||
return syserr.ErrInvalidArgument
|
||||
}
|
||||
return syserr.TranslateNetstackError(ep.SetSockOpt(tcpip.TCPUserTimeoutOption(time.Millisecond * time.Duration(v))))
|
||||
|
||||
case linux.TCP_CONGESTION:
|
||||
v := tcpip.CongestionControlOption(optVal)
|
||||
if err := ep.SetSockOpt(v); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user