git: 452187b61147 - main - inpcb: in_pcbinshash() now can't fail on connect(2)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 07 Mar 2025 07:00:56 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=452187b611470a827215e9cd103a5616b8610662
commit 452187b611470a827215e9cd103a5616b8610662
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-03-07 06:59:40 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-03-07 06:59:40 +0000
inpcb: in_pcbinshash() now can't fail on connect(2)
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D49152
---
sys/netinet/in_pcb.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 08097ea8c1b9..8a99297f3818 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1178,27 +1178,19 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr_in *sin, struct ucred *cred)
else
lport = inp->inp_lport;
+ MPASS(!in_nullhost(inp->inp_laddr) || inp->inp_lport != 0 ||
+ !(inp->inp_flags & INP_INHASHLIST));
+
inp->inp_faddr = faddr;
inp->inp_fport = sin->sin_port;
+ inp->inp_laddr = laddr;
+ inp->inp_lport = lport;
- /* Do the initial binding of the local address if required. */
- if (inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0) {
- inp->inp_lport = lport;
- inp->inp_laddr = laddr;
- if (in_pcbinshash(inp) != 0) {
- inp->inp_laddr.s_addr = inp->inp_faddr.s_addr =
- INADDR_ANY;
- inp->inp_lport = inp->inp_fport = 0;
- return (EAGAIN);
- }
- } else {
- inp->inp_lport = lport;
- inp->inp_laddr = laddr;
- if ((inp->inp_flags & INP_INHASHLIST) != 0)
- in_pcbrehash(inp);
- else
- in_pcbinshash(inp);
- }
+ if ((inp->inp_flags & INP_INHASHLIST) == 0) {
+ error = in_pcbinshash(inp);
+ MPASS(error == 0);
+ } else
+ in_pcbrehash(inp);
#ifdef ROUTE_MPATH
if (CALC_FLOWID_OUTBOUND) {
uint32_t hash_val, hash_type;