mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Move SO_SNDBUF to socketops.
This CL moves {S,G}etsockopt of SO_SNDBUF from all endpoints to socketops. For
unix sockets, we do not support setting of this option.
PiperOrigin-RevId: 353871484
This commit is contained in:
committed by
gVisor bot
parent
3946075403
commit
daf0d3f6ca
@@ -846,7 +846,7 @@ func getSockOptSocket(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, fam
|
||||
return nil, syserr.ErrInvalidArgument
|
||||
}
|
||||
|
||||
size, err := ep.GetSockOptInt(tcpip.SendBufferSizeOption)
|
||||
size, err := ep.SocketOptions().GetSendBufferSize()
|
||||
if err != nil {
|
||||
return nil, syserr.TranslateNetstackError(err)
|
||||
}
|
||||
@@ -1615,8 +1615,21 @@ func setSockOptSocket(t *kernel.Task, s socket.SocketOps, ep commonEndpoint, nam
|
||||
return syserr.ErrInvalidArgument
|
||||
}
|
||||
|
||||
family, skType, skProto := s.Type()
|
||||
// TODO(gvisor.dev/issue/5132): We currently do not support
|
||||
// setting this option for unix sockets.
|
||||
if family == linux.AF_UNIX {
|
||||
return nil
|
||||
}
|
||||
|
||||
getBufferLimits := tcpip.GetStackSendBufferLimits
|
||||
if isTCPSocket(skType, skProto) {
|
||||
getBufferLimits = tcp.GetTCPSendBufferLimits
|
||||
}
|
||||
|
||||
v := usermem.ByteOrder.Uint32(optVal)
|
||||
return syserr.TranslateNetstackError(ep.SetSockOptInt(tcpip.SendBufferSizeOption, int(v)))
|
||||
ep.SocketOptions().SetSendBufferSize(int64(v), true, getBufferLimits)
|
||||
return nil
|
||||
|
||||
case linux.SO_RCVBUF:
|
||||
if len(optVal) < sizeOfInt32 {
|
||||
|
||||
Reference in New Issue
Block a user