1
0
mirror of https://git.FreeBSD.org/src.git synced 2026-06-02 11:24:32 +00:00

inpcb: update inpcb multipath routing information only on success

The in_pcbconnect_setup() function is not supposed to modify inpcb.
It may be entered with read-only lock via UDP path.  Also at this
point we aren't yet sure that the binding is going to be successful.
Thus, update the multipath routing information only at the end of a
succesful in_pcbconnect().

Fixes:	0c325f53f1
This commit is contained in:
Gleb Smirnoff
2025-02-17 15:28:52 -08:00
parent 4f274f849b
commit 24e5c2ee2a
+11 -11
View File
@@ -1121,7 +1121,18 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr_in *sin, struct ucred *cred)
else
in_pcbinshash(inp);
}
#ifdef ROUTE_MPATH
if (CALC_FLOWID_OUTBOUND) {
uint32_t hash_val, hash_type;
hash_val = fib4_calc_software_hash(inp->inp_laddr,
inp->inp_faddr, 0, fport,
inp->inp_socket->so_proto->pr_protocol, &hash_type);
inp->inp_flowid = hash_val;
inp->inp_flowtype = hash_type;
}
#endif
if (anonport)
inp->inp_flags |= INP_ANONPORT;
return (0);
@@ -1377,17 +1388,6 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr_in *sin,
lport = *lportp;
faddr = sin->sin_addr;
fport = sin->sin_port;
#ifdef ROUTE_MPATH
if (CALC_FLOWID_OUTBOUND) {
uint32_t hash_val, hash_type;
hash_val = fib4_calc_software_hash(laddr, faddr, 0, fport,
inp->inp_socket->so_proto->pr_protocol, &hash_type);
inp->inp_flowid = hash_val;
inp->inp_flowtype = hash_type;
}
#endif
if (V_connect_inaddr_wild && !CK_STAILQ_EMPTY(&V_in_ifaddrhead)) {
/*
* If the destination address is INADDR_ANY,