diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4 --- a/share/man/man4/tcp.4 +++ b/share/man/man4/tcp.4 @@ -34,7 +34,7 @@ .\" From: @(#)tcp.4 8.1 (Berkeley) 6/5/93 .\" $FreeBSD$ .\" -.Dd November 7, 2022 +.Dd February 3, 2023 .Dt TCP 4 .Os .Sh NAME @@ -843,10 +843,6 @@ Initial .Tn TCP receive window (buffer size). -.It Va require_unique_port -Require unique ephemeral port for outgoing connections; -otherwise, the 4-tuple of local and remote ports and addresses must be unique. -Requiring a unique port limits the number of outgoing connections. .It Va rexmit_drop_options Drop TCP options from third and later retransmitted SYN segments of a connection. diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -131,16 +131,6 @@ static int tcp_pru_options_support(struct tcpcb *tp, int flags); -/* - * tcp_require_unique port requires a globally-unique source port for each - * outgoing connection. The default is to require the 4-tuple to be unique. - */ -VNET_DEFINE(int, tcp_require_unique_port) = 0; -SYSCTL_INT(_net_inet_tcp, OID_AUTO, require_unique_port, - CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(tcp_require_unique_port), 0, - "Require globally-unique ephemeral port for outgoing connections"); -#define V_tcp_require_unique_port VNET(tcp_require_unique_port) - /* * TCP attaches to socket via pru_attach(), reserving space, * and an internet control block. @@ -1421,14 +1411,8 @@ NET_EPOCH_ASSERT(); INP_WLOCK_ASSERT(inp); - INP_HASH_WLOCK(&V_tcbinfo); - - if (V_tcp_require_unique_port && inp->inp_lport == 0) { - error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); - if (error) - goto out; - } + INP_HASH_WLOCK(&V_tcbinfo); /* * Cannot simply call in_pcbconnect, because there might be an * earlier incarnation of this same connection still in @@ -1490,17 +1474,12 @@ int error; INP_WLOCK_ASSERT(inp); - INP_HASH_WLOCK(&V_tcbinfo); - if (V_tcp_require_unique_port && inp->inp_lport == 0) { - error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); - if (error) - goto out; - } + INP_HASH_WLOCK(&V_tcbinfo); error = in6_pcbconnect(inp, nam, td->td_ucred); - if (error != 0) - goto out; INP_HASH_WUNLOCK(&V_tcbinfo); + if (error != 0) + return (error); /* Compute window scaling to request. */ while (tp->request_r_scale < TCP_MAX_WINSHIFT && @@ -1515,11 +1494,7 @@ tp->ts_offset = tcp_new_ts_offset(&inp->inp_inc); tcp_sendseqinit(tp); - return 0; - -out: - INP_HASH_WUNLOCK(&V_tcbinfo); - return error; + return (0); } #endif /* INET6 */