From abbdcebc543242862fad0984db2db0a842021917 Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Mon, 8 Mar 2021 20:37:14 -0800 Subject: Implement /proc/sys/net/ipv4/ip_local_port_range Speeds up the socket stress tests by a couple orders of magnitude. PiperOrigin-RevId: 361721050 --- pkg/sentry/socket/hostinet/stack.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'pkg/sentry/socket/hostinet/stack.go') diff --git a/pkg/sentry/socket/hostinet/stack.go b/pkg/sentry/socket/hostinet/stack.go index e6323244c..5bcf92e14 100644 --- a/pkg/sentry/socket/hostinet/stack.go +++ b/pkg/sentry/socket/hostinet/stack.go @@ -504,3 +504,14 @@ func (s *Stack) Forwarding(protocol tcpip.NetworkProtocolNumber) bool { func (s *Stack) SetForwarding(tcpip.NetworkProtocolNumber, bool) error { return syserror.EACCES } + +// PortRange implements inet.Stack.PortRange. +func (*Stack) PortRange() (uint16, uint16) { + // Use the default Linux values per net/ipv4/af_inet.c:inet_init_net(). + return 32768, 28232 +} + +// SetPortRange implements inet.Stack.SetPortRange. +func (*Stack) SetPortRange(start uint16, end uint16) error { + return syserror.EACCES +} -- cgit v1.2.3