git: 76f1499ff5e7 - main - tcp: retire net.inet.tcp.tcp_require_unique_port
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 Feb 2023 19:34:18 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=76f1499ff5e7b6a2d558d8cb576de5f77b35a7dc
commit 76f1499ff5e7b6a2d558d8cb576de5f77b35a7dc
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2023-02-03 19:33:35 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2023-02-03 19:33:35 +0000
tcp: retire net.inet.tcp.tcp_require_unique_port
It was a safe belt just in case if the new port allocation
behaviour introduced in 25102351509 would cause a problem.
Reviewed by: markj, rscheff, tuexen
Differential revision: https://reviews.freebsd.org/D38353
---
share/man/man4/tcp.4 | 6 +-----
sys/netinet/tcp_usrreq.c | 35 +++++------------------------------
2 files changed, 6 insertions(+), 35 deletions(-)
diff --git a/share/man/man4/tcp.4 b/share/man/man4/tcp.4
index dea7da9054d0..ce27705f7eda 100644
--- 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 @@ Maximum size of automatic receive buffer.
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
index 47e635ba1faa..8cc5894171de 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -131,16 +131,6 @@ static void tcp_fill_info(struct tcpcb *, struct tcp_info *);
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 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
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 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
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 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td)
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 */