git: ca4eb3f3989b - main - inpcb: do not set INP_ANONPORT until successful operation

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Wed, 15 Jul 2026 19:08:15 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=ca4eb3f3989b64dc371c2f114eecae28b25a6481

commit ca4eb3f3989b64dc371c2f114eecae28b25a6481
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2026-07-15 18:46:05 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2026-07-15 19:07:48 +0000

    inpcb: do not set INP_ANONPORT until successful operation
---
 sys/netinet6/in6_pcb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 1b55a3425e59..b5859777eee9 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -132,8 +132,6 @@ in6_pcbsetport_locked(struct in6_addr *laddr, struct inpcb *inp,
 	if ((so->so_options & (SO_REUSEADDR|SO_REUSEPORT|SO_REUSEPORT_LB)) == 0)
 		lookupflags = INPLOOKUP_WILDCARD;
 
-	inp->inp_flags |= INP_ANONPORT;
-
 	error = in_pcb_lport(inp, NULL, &lport, cred, lookupflags);
 	if (error != 0)
 		return (error);
@@ -145,6 +143,8 @@ in6_pcbsetport_locked(struct in6_addr *laddr, struct inpcb *inp,
 		return (EAGAIN);
 	}
 
+	inp->inp_flags |= INP_ANONPORT;
+
 	return (0);
 }