Date: Sun, 12 Apr 2026 18:35:30 +0000 From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 202370905f11 - main - inpcb: apply smr_advance(9)/smr_wait(9) trick only to reusable sockets Message-ID: <69dbe5f2.3941d.56c71509@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=202370905f11be4e2c7afa18e73d374204fda08e commit 202370905f11be4e2c7afa18e73d374204fda08e Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2026-04-12 18:30:44 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2026-04-12 18:30:44 +0000 inpcb: apply smr_advance(9)/smr_wait(9) trick only to reusable sockets The protocols marked with PR_CONNREQUIRED can never go through pr_connect after being disconnected. This is a tiny improvement of fdb987bebddf0. While here push clearing of the addresses under the same condition. Although this clearing originates from pre-FreeBSD times, it actually makes sense only for protocols that can reconnect. Reviewed by: pouria, markj Differential Revision: https://reviews.freebsd.org/D55661 --- sys/netinet/in_pcb.c | 12 +++++++----- sys/netinet6/in6_pcb.c | 15 ++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index a997c643e8be..98421a7f2232 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1433,11 +1433,13 @@ in_pcbdisconnect(struct inpcb *inp) in_pcbremhash_locked(inp); - /* See the comment in in_pcbinshash(). */ - inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr); - inp->inp_laddr.s_addr = INADDR_ANY; - inp->inp_faddr.s_addr = INADDR_ANY; - inp->inp_fport = 0; + if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) { + /* See the comment in in_pcbinshash(). */ + inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr); + inp->inp_laddr.s_addr = INADDR_ANY; + inp->inp_faddr.s_addr = INADDR_ANY; + inp->inp_fport = 0; + } } #endif /* INET */ diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index f8ce64a65998..2d6e860a72ba 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -510,13 +510,14 @@ in6_pcbdisconnect(struct inpcb *inp) in_pcbremhash_locked(inp); - /* See the comment in in_pcbinshash(). */ - inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr); - - /* XXX-MJ torn writes are visible to SMR lookup */ - memset(&inp->in6p_laddr, 0, sizeof(inp->in6p_laddr)); - memset(&inp->in6p_faddr, 0, sizeof(inp->in6p_faddr)); - inp->inp_fport = 0; + if ((inp->inp_socket->so_proto->pr_flags & PR_CONNREQUIRED) == 0) { + /* See the comment in in_pcbinshash(). */ + inp->inp_smr = smr_advance(inp->inp_pcbinfo->ipi_smr); + /* XXX-MJ torn writes are visible to SMR lookup */ + memset(&inp->in6p_laddr, 0, sizeof(inp->in6p_laddr)); + memset(&inp->in6p_faddr, 0, sizeof(inp->in6p_faddr)); + inp->inp_fport = 0; + } /* clear flowinfo - draft-itojun-ipv6-flowlabel-api-00 */ inp->inp_flow &= ~IPV6_FLOWLABEL_MASK; }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69dbe5f2.3941d.56c71509>
