mirror of
https://github.com/opnsense/src.git
synced 2026-06-22 23:19:17 -04:00
Suppose a thread is adds a socket to an existing TCP lbgroup that is actively accepting connections. It has to do the following operations: 1. set SO_REUSEPORT_LB on the socket 2. bind() the socket to the shared address/port 3. call listen() Step 2 makes the inpcb visible to incoming connection requests. However, at this point the inpcb cannot accept new connections. If in_pcblookup() matches it, the remote end will see ECONNREFUSED even when other listening sockets are present in the lbgroup. This means that dynamically adding inpcbs to an lbgroup (e.g., by starting up new workers) can trigger spurious connection failures for no good reason. (A similar problem exists when removing inpcbs from an lbgroup, but that is harder to fix and is not addressed by this patch; see the review for a bit more commentary.) Fix this by augmenting each lbgroup with a linked list of inpcbs that are pending a listen() call. When adding an inpcb to an lbgroup, keep the inpcb on this list if listen() hasn't been called, so it is not yet visible to the lookup path. Then, add a new in_pcblisten() routine which makes the inpcb visible within the lbgroup now that it's safe to let it handle new connections. Add a regression test which verifies that we don't get spurious connection errors while adding sockets to an LB group. Reviewed by: glebius MFC after: 1 month Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D48544
54 lines
1.2 KiB
Makefile
54 lines
1.2 KiB
Makefile
PACKAGE= tests
|
|
|
|
TESTSDIR= ${TESTSBASE}/sys/netinet
|
|
BINDIR= ${TESTSDIR}
|
|
|
|
TESTS_SUBDIRS+= libalias
|
|
|
|
ATF_TESTS_C= ip_reass_test \
|
|
ip6_v4mapped_test \
|
|
so_reuseport_lb_test \
|
|
socket_afinet \
|
|
tcp_connect_port_test \
|
|
tcp_implied_connect \
|
|
tcp_md5_getsockopt \
|
|
udp_io
|
|
|
|
ATF_TESTS_SH= arp \
|
|
carp \
|
|
divert \
|
|
fibs \
|
|
fibs_test \
|
|
forward \
|
|
lpm \
|
|
output \
|
|
redirect
|
|
|
|
ATF_TESTS_PYTEST+= carp.py
|
|
ATF_TESTS_PYTEST+= igmp.py
|
|
|
|
LIBADD.so_reuseport_lb_test= pthread
|
|
|
|
# Some of the arp tests look for log messages in the dmesg buffer, so run them
|
|
# serially to avoid problems with interleaved output.
|
|
TEST_METADATA.arp+= is_exclusive="true"
|
|
TEST_METADATA.divert+= required_programs="python" \
|
|
execenv="jail" \
|
|
execenv_jail_params="vnet allow.raw_sockets"
|
|
TEST_METADATA.fibs_test+= execenv="jail" \
|
|
execenv_jail_params="vnet allow.raw_sockets"
|
|
TEST_METADATA.forward+= required_programs="python" \
|
|
execenv="jail" \
|
|
execenv_jail_params="vnet allow.raw_sockets"
|
|
TEST_METADATA.output+= required_programs="python"
|
|
TEST_METADATA.redirect+= required_programs="python"
|
|
|
|
PROGS= udp_dontroute tcp_user_cookie
|
|
|
|
${PACKAGE}FILES+= redirect.py
|
|
|
|
${PACKAGE}FILESMODE_redirect.py=0555
|
|
|
|
MAN=
|
|
|
|
.include <bsd.test.mk>
|