diff options
author | Michael Tuexen <tuexen@FreeBSD.org> | 2024-01-10 07:33:09 +0000 |
---|---|---|
committer | Michael Tuexen <tuexen@FreeBSD.org> | 2024-01-10 07:33:09 +0000 |
commit | 13720136fbf951a7b472ce086c9cf2de702799ab (patch) | |
tree | 3ce304ab44305731ec598ffb4ebdd6498958738b | |
parent | dafd0d685531e8bc42d51b2128c287137791894b (diff) | |
download | src-13720136fbf951a7b472ce086c9cf2de702799ab.tar.gz src-13720136fbf951a7b472ce086c9cf2de702799ab.zip |
tcpsso: fix when used without -i option
Since fdb987bebddf 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: fdb987bebddf ("inpcb: Split PCB hash tables")
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D43353
-rw-r--r-- | sys/netinet/in_pcb.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index fa0d7309058e..981654577deb 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -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( + ¶ms->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( - ¶ms->sop_inc.inc6_faddr, - params->sop_inc.inc_lport, - params->sop_inc.inc_fport, - pcbinfo->ipi_hashmask); - else #endif - inpi.hash = INP_PCBHASH( - ¶ms->sop_inc.inc_faddr, - params->sop_inc.inc_lport, - params->sop_inc.inc_fport, - pcbinfo->ipi_hashmask); + inpi.hash = INP_PCBHASH( + ¶ms->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) { |