gvisor/pkg/tcpip
Bhasker Hariharan 61f6fbd0ce Fix bugs in PickEphemeralPort for TCP.
Netstack always picks a random start point everytime PickEphemeralPort
is called. While this is required for UDP so that DNS requests go
out through a randomized set of ports it is not required for TCP. Infact
Linux explicitly hashes the (srcip, dstip, dstport) and a one time secret
initialized at start of the application to get a random offset. But to
ensure it doesn't start from the same point on every scan it uses a static
hint that is incremented by 2 in every call to pick ephemeral ports.

The reason for 2 is Linux seems to split the port ranges where active connects
seem to use even ones while odd ones are used by listening sockets.

This CL implements a similar strategy where we use a hash + hint to generate
the offset to start the search for a free Ephemeral port.

This ensures that we cycle through the available port space in order for
repeated connects to the same destination and significantly reduces the
chance of picking a recently released port.

PiperOrigin-RevId: 272058370
2019-09-30 13:55:22 -07:00
..
adapters/gonet Remove centralized registration of protocols. 2019-09-25 12:57:05 -07:00
buffer Remove go_test from go_stateify and go_marshal 2019-09-12 15:10:17 -07:00
checker Make UDP traceroute work. 2019-09-03 16:01:17 -07:00
hash/jenkins Remove go_test from go_stateify and go_marshal 2019-09-12 15:10:17 -07:00
header Automated rollback of changelist 268047073 2019-09-17 14:47:09 -07:00
iptables Plumbing for iptables sockopts. 2019-08-02 16:26:48 -07:00
link Allow waiting for LinkEndpoint worker goroutines to finish. 2019-09-20 14:10:02 -07:00
network Remove centralized registration of protocols. 2019-09-25 12:57:05 -07:00
ports Fix bugs in PickEphemeralPort for TCP. 2019-09-30 13:55:22 -07:00
sample Remove centralized registration of protocols. 2019-09-25 12:57:05 -07:00
seqnum Update canonical repository. 2019-06-13 16:50:15 -07:00
stack Fix bugs in PickEphemeralPort for TCP. 2019-09-30 13:55:22 -07:00
transport Fix bugs in PickEphemeralPort for TCP. 2019-09-30 13:55:22 -07:00
BUILD Remove go_test from go_stateify and go_marshal 2019-09-12 15:10:17 -07:00
tcpip.go Implement SO_BINDTODEVICE sockopt 2019-09-27 14:14:04 -07:00
tcpip_test.go Use tcpip.Subnet in tcpip.Route 2019-08-21 15:31:18 -07:00
time.s Change copyright notice to "The gVisor Authors" 2019-04-29 14:26:23 -07:00
time_unsafe.go Add build guard to files using go:linkname 2019-05-30 12:09:39 -07:00