mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add support for Stack level options.
Linux controls socket send/receive buffers using a few sysctl variables - net.core.rmem_default - net.core.rmem_max - net.core.wmem_max - net.core.wmem_default - net.ipv4.tcp_rmem - net.ipv4.tcp_wmem The first 4 control the default socket buffer sizes for all sockets raw/packet/tcp/udp and also the maximum permitted socket buffer that can be specified in setsockopt(SOL_SOCKET, SO_(RCV|SND)BUF,...). The last two control the TCP auto-tuning limits and override the default specified in rmem_default/wmem_default as well as the max limits. Netstack today only implements tcp_rmem/tcp_wmem and incorrectly uses it to limit the maximum size in setsockopt() as well as uses it for raw/udp sockets. This changelist introduces the other 4 and updates the udp/raw sockets to use the newly introduced variables. The values for min/max match the current tcp_rmem/wmem values and the default value buffers for UDP/RAW sockets is updated to match the linux value of 212KiB up from the really low current value of 32 KiB. Updates #3043 Fixes #3043 PiperOrigin-RevId: 318089805
This commit is contained in:
committed by
gVisor bot
parent
364ac92baf
commit
b070e218c6
@@ -143,7 +143,7 @@ func (s *Stack) AddInterfaceAddr(idx int32, addr inet.InterfaceAddr) error {
|
||||
|
||||
// TCPReceiveBufferSize implements inet.Stack.TCPReceiveBufferSize.
|
||||
func (s *Stack) TCPReceiveBufferSize() (inet.TCPBufferSize, error) {
|
||||
var rs tcpip.StackReceiveBufferSizeOption
|
||||
var rs tcp.ReceiveBufferSizeOption
|
||||
err := s.Stack.TransportProtocolOption(tcp.ProtocolNumber, &rs)
|
||||
return inet.TCPBufferSize{
|
||||
Min: rs.Min,
|
||||
@@ -154,7 +154,7 @@ func (s *Stack) TCPReceiveBufferSize() (inet.TCPBufferSize, error) {
|
||||
|
||||
// SetTCPReceiveBufferSize implements inet.Stack.SetTCPReceiveBufferSize.
|
||||
func (s *Stack) SetTCPReceiveBufferSize(size inet.TCPBufferSize) error {
|
||||
rs := tcpip.StackReceiveBufferSizeOption{
|
||||
rs := tcp.ReceiveBufferSizeOption{
|
||||
Min: size.Min,
|
||||
Default: size.Default,
|
||||
Max: size.Max,
|
||||
@@ -164,7 +164,7 @@ func (s *Stack) SetTCPReceiveBufferSize(size inet.TCPBufferSize) error {
|
||||
|
||||
// TCPSendBufferSize implements inet.Stack.TCPSendBufferSize.
|
||||
func (s *Stack) TCPSendBufferSize() (inet.TCPBufferSize, error) {
|
||||
var ss tcpip.StackSendBufferSizeOption
|
||||
var ss tcp.SendBufferSizeOption
|
||||
err := s.Stack.TransportProtocolOption(tcp.ProtocolNumber, &ss)
|
||||
return inet.TCPBufferSize{
|
||||
Min: ss.Min,
|
||||
@@ -175,7 +175,7 @@ func (s *Stack) TCPSendBufferSize() (inet.TCPBufferSize, error) {
|
||||
|
||||
// SetTCPSendBufferSize implements inet.Stack.SetTCPSendBufferSize.
|
||||
func (s *Stack) SetTCPSendBufferSize(size inet.TCPBufferSize) error {
|
||||
ss := tcpip.StackSendBufferSizeOption{
|
||||
ss := tcp.SendBufferSizeOption{
|
||||
Min: size.Min,
|
||||
Default: size.Default,
|
||||
Max: size.Max,
|
||||
@@ -185,14 +185,14 @@ func (s *Stack) SetTCPSendBufferSize(size inet.TCPBufferSize) error {
|
||||
|
||||
// TCPSACKEnabled implements inet.Stack.TCPSACKEnabled.
|
||||
func (s *Stack) TCPSACKEnabled() (bool, error) {
|
||||
var sack tcpip.StackSACKEnabled
|
||||
var sack tcp.SACKEnabled
|
||||
err := s.Stack.TransportProtocolOption(tcp.ProtocolNumber, &sack)
|
||||
return bool(sack), syserr.TranslateNetstackError(err).ToError()
|
||||
}
|
||||
|
||||
// SetTCPSACKEnabled implements inet.Stack.SetTCPSACKEnabled.
|
||||
func (s *Stack) SetTCPSACKEnabled(enabled bool) error {
|
||||
return syserr.TranslateNetstackError(s.Stack.SetTransportProtocolOption(tcp.ProtocolNumber, tcpip.StackSACKEnabled(enabled))).ToError()
|
||||
return syserr.TranslateNetstackError(s.Stack.SetTransportProtocolOption(tcp.ProtocolNumber, tcp.SACKEnabled(enabled))).ToError()
|
||||
}
|
||||
|
||||
// Statistics implements inet.Stack.Statistics.
|
||||
|
||||
Reference in New Issue
Block a user