opnsense-src/tests/sys/netinet
Mark Johnston 4f02a7d739 inpcb: Remove bogus SO_REUSEPORT(_LB) checks in in_pcbbind()
This check for SO_REUSEPORT was added way back in commit 52b65dbe85.
Per the commit log, this commit restricted this port-stealing check to
unicast addresses, and then only if the existing socket does not have
SO_REUSEPORT set.  In other words, if there exists a socket bound to
INADDR_ANY, and we bind a socket to INADDR_ANY with the same port, then
the two sockets need not be owned by the same user if the existing
socket has SO_REUSEPORT set.

This is a surprising semantic; bugzilla PR 7713 gives some additional
context.  That PR makes a case for the behaviour described above when
binding to a multicast address.  But, the SO_REUSEPORT check is only
applied when binding to a non-multicast address, so it doesn't really
make sense.  In the PR the committer notes that "unicast applications
don't set SO_REUSEPORT", which makes some sense, but also refers to
"multicast applications that bind to INADDR_ANY", which sounds a bit
suspicious.

OpenBSD performs the multicast check, but not the SO_REUSEPORT check.
DragonflyBSD removed the SO_REUSEPORT (and INADDR_ANY) checks back in
2014 (commit 0323d5fde12a4).  NetBSD explicitly copied our logic and
still has it.

The plot thickens: 20 years later, SO_REUSEPORT_LB was ported from
DragonflyBSD: this option provides similar semantics to SO_REUSEPORT,
but for unicast addresses it causes incoming connections/datagrams to be
distributed among all sockets in the group.  This commit (1a43cff92a)
inverted the check for SO_REUSEPORT while adding one for
SO_REUSEPORT_LB; this appears to have been inadvertent.  However:
- apparently no one has noticed that the semantics were changed;
- sockets belonging to different users can now be bound to the same port
  so long as they belong to a single lbgroup bound to INADDR_ANY, which
  is not correct.

Simply remove the SO_REUSEPORT(_LB) checks, as their original
justification was dubious and their current implementation is wrong; add
some tests.

Reviewed by:	glebius
MFC after:	1 month
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D47832
2024-12-12 14:25:15 +00:00
..
libalias libalias: Add support for EIM NAT 2024-12-05 16:19:13 +00:00
arp.sh tests/arp: test arp -s/-S work 2024-02-20 10:32:03 -08:00
carp.py netinet tests: basic VRRP tests 2024-05-08 13:19:04 +02:00
carp.sh vnet tests: check for if_bridge.ko 2024-06-04 22:16:56 +02:00
divert.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
fibs.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
fibs_test.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
forward.sh netinet: handle blackhole routes 2024-11-20 16:52:41 +01:00
igmp.py netinet tests: test that we send IGMP join/leave packets as expected 2023-12-19 17:47:41 +01:00
ip6_v4mapped_test.c tests: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:01 -07:00
ip_reass_test.c tests: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:01 -07:00
lpm.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
Makefile fibs_test: Run in a jail 2024-11-21 18:54:59 +00:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
output.sh netinet tests: Make test jail names unique 2024-01-27 13:51:37 -05:00
redirect.py Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
redirect.sh Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
so_reuseport_lb_test.c tests: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:01 -07:00
socket_afinet.c inpcb: Remove bogus SO_REUSEPORT(_LB) checks in in_pcbbind() 2024-12-12 14:25:15 +00:00
tcp_connect_port_test.c tests: Automated cleanup of cdefs and other formatting 2023-11-26 22:24:01 -07:00
tcp_implied_connect.c tests/netinet: push variable 'sin' into function scope 2024-02-02 21:09:02 -08:00
tcp_md5_getsockopt.c Add tests for TCP_MD5 getsockopt 2022-06-23 15:57:56 +01:00
tcp_user_cookie.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
udp_dontroute.c Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:16 -06:00
udp_io.c tests/netinet: fix UDP I/O test build 2024-03-23 09:21:13 -07:00