Skip to content

Commit

Permalink
tcpsso: fix when used without -i option
Browse files Browse the repository at this point in the history
Since fdb987b it is not possible anymore to use inp_next
iterator for bound, but unconnected sockets. This applies
to TCP listening sockets. Therefore the metioned commit broke
tcpsso on listening sockets if the -i option was not used.
Fix this by iterating through all endpoints instead of only
through the bound, but unconnected ones.

Reviewed by:		markj
Fixes:			fdb987b ("inpcb: Split PCB hash tables")
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D43353
  • Loading branch information
tuexen committed Jan 10, 2024
1 parent dafd0d6 commit 1372013
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions sys/netinet/in_pcb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2950,25 +2950,22 @@ sysctl_setsockopt(SYSCTL_HANDLER_ARGS, struct inpcbinfo *pcbinfo,
htons(params->sop_inc.inc6_zoneid & 0xffff);
}
#endif
if (params->sop_inc.inc_lport != htons(0)) {
if (params->sop_inc.inc_fport == htons(0))
inpi.hash = INP_PCBHASH_WILD(params->sop_inc.inc_lport,
if (params->sop_inc.inc_lport != htons(0) &&
params->sop_inc.inc_fport != htons(0)) {
#ifdef INET6
if (params->sop_inc.inc_flags & INC_ISIPV6)
inpi.hash = INP6_PCBHASH(
&params->sop_inc.inc6_faddr,
params->sop_inc.inc_lport,
params->sop_inc.inc_fport,
pcbinfo->ipi_hashmask);
else
#ifdef INET6
if (params->sop_inc.inc_flags & INC_ISIPV6)
inpi.hash = INP6_PCBHASH(
&params->sop_inc.inc6_faddr,
params->sop_inc.inc_lport,
params->sop_inc.inc_fport,
pcbinfo->ipi_hashmask);
else
#endif
inpi.hash = INP_PCBHASH(
&params->sop_inc.inc_faddr,
params->sop_inc.inc_lport,
params->sop_inc.inc_fport,
pcbinfo->ipi_hashmask);
inpi.hash = INP_PCBHASH(
&params->sop_inc.inc_faddr,
params->sop_inc.inc_lport,
params->sop_inc.inc_fport,
pcbinfo->ipi_hashmask);
}
while ((inp = inp_next(&inpi)) != NULL)
if (inp->inp_gencnt == params->sop_id) {
Expand Down

0 comments on commit 1372013

Please sign in to comment.