History log of /src/tests/sys/netinet/socket_afinet.c (Results 1 – 25 of 40)
Revision Date Author Comments
# 9df110b1 30-Jan-2026 Gleb Smirnoff <glebius@FreeBSD.org>

tests/netinet: fix tests that depended on connect(in6addr_any)

Fixes: 627e126dbb07b167b028380ef61bb45f10493938


# 50789d0b 28-May-2025 Gleb Smirnoff <glebius@FreeBSD.org>

tests/netinet: fix several tests that depended on connect(INADDR_ANY)

Fixes: cd240957d7ba43d819e9d59c6f6517fe915102c7


# c9756953 23-Dec-2024 Mark Johnston <markj@FreeBSD.org>

inpcb: Further restrict binding to a port owned by a different UID

See commit 4f02a7d739b3 for more background.

I cannot see a good reason to continue ignoring mismatching UIDs when
binding to INAD

inpcb: Further restrict binding to a port owned by a different UID

See commit 4f02a7d739b3 for more background.

I cannot see a good reason to continue ignoring mismatching UIDs when
binding to INADDR_ANY. Looking at the sdr.V2.4a7n sources (mentioned in
bugzilla PR 7713), there is a CANT_MCAST_BIND hack wherein the
application binds to INADDR_ANY instead of a multicast address, but
CANT_MCAST_BIND isn't defined for FreeBSD builds.

It seems unlikely that we still have a use-case for allowing sockets
from different UIDs to bind to the same port when binding to the
unspecified address. And, as noted in D47832, applications like sdr
would have been broken by the inverted SO_REUSEPORT check removed in
that revision, apparently without any bug reports. Let's break
compatibility and simply disallow this case outright.

Also, add some comments, remove a hack in a regression test which tests
this funtionality, and add a new regression test to exercise the
remaining checks that were added in commit 4658dc8325e03.

MFC after: 1 month
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D47870

show more ...


# 4f02a7d7 12-Dec-2024 Mark Johnston <markj@FreeBSD.org>

inpcb: Remove bogus SO_REUSEPORT(_LB) checks in in_pcbbind()

This check for SO_REUSEPORT was added way back in commit 52b65dbe85faf.
Per the commit log, this commit restricted this port-stealing che

inpcb: Remove bogus SO_REUSEPORT(_LB) checks in in_pcbbind()

This check for SO_REUSEPORT was added way back in commit 52b65dbe85faf.
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 (1a43cff92a20d)
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

show more ...


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 150d8ca9 04-Jul-2023 Olivier Cochard <olivier@FreeBSD.org>

socket afinet tests: using dynamic ports instead of the same static port

Allows these tests to be run in parallel.

Approved by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.fr

socket afinet tests: using dynamic ports instead of the same static port

Allows these tests to be run in parallel.

Approved by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D40859

show more ...


# b1c66bc4 23-Jun-2023 Mark Johnston <markj@FreeBSD.org>

netinet tests: Add a test which connects a disconnected socket

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

show more ...


# 3aaaa2ef 28-Apr-2021 Thomas Munro <tmunro@FreeBSD.org>

poll(2): Add POLLRDHUP.

Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested. Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by: kib
MFC a

poll(2): Add POLLRDHUP.

Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested. Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29757

show more ...


# 69b7dbeb 20-Apr-2020 Li-Wen Hsu <lwhsu@FreeBSD.org>

Only skip sys.netinet.socket_afinet.socket_afinet_bind_zero in CI env

Sponsored by: The FreeBSD Foundation


# 7f49ce7a 27-Jun-2019 Alan Somers <asomers@FreeBSD.org>

MFHead @349476

Sponsored by: The FreeBSD Foundation


# 01e92e29 23-Jun-2019 Li-Wen Hsu <lwhsu@FreeBSD.org>

Skip sys.netinet.socket_afinet.socket_afinet_bind_zero temporarily because it
doesn't work when mac_portacl(4) loaded

PR: 238781
Sponsored by: The FreeBSD Foundation


# 0269ae4c 06-Jun-2019 Alan Somers <asomers@FreeBSD.org>

MFHead @348740

Sponsored by: The FreeBSD Foundation


# aa321596 21-May-2019 Bjoern A. Zeeb <bz@FreeBSD.org>

Add very basic afinet socket tests which I started to write in order
to then try to reproduce a kernel panic, which turned out to be a
race condition and hard to test from here.

Commit the changes a

Add very basic afinet socket tests which I started to write in order
to then try to reproduce a kernel panic, which turned out to be a
race condition and hard to test from here.

Commit the changes anywhere as the "bind zero" case was a surprise
to me and we should try to maintain this status.

Also it is easy examples someone can build upon.

With help from: markj
Event: Waterloo Hackathon 2019

show more ...


# 50789d0b 28-May-2025 Gleb Smirnoff <glebius@FreeBSD.org>

tests/netinet: fix several tests that depended on connect(INADDR_ANY)

Fixes: cd240957d7ba43d819e9d59c6f6517fe915102c7


# c9756953 23-Dec-2024 Mark Johnston <markj@FreeBSD.org>

inpcb: Further restrict binding to a port owned by a different UID

See commit 4f02a7d739b3 for more background.

I cannot see a good reason to continue ignoring mismatching UIDs when
binding to INAD

inpcb: Further restrict binding to a port owned by a different UID

See commit 4f02a7d739b3 for more background.

I cannot see a good reason to continue ignoring mismatching UIDs when
binding to INADDR_ANY. Looking at the sdr.V2.4a7n sources (mentioned in
bugzilla PR 7713), there is a CANT_MCAST_BIND hack wherein the
application binds to INADDR_ANY instead of a multicast address, but
CANT_MCAST_BIND isn't defined for FreeBSD builds.

It seems unlikely that we still have a use-case for allowing sockets
from different UIDs to bind to the same port when binding to the
unspecified address. And, as noted in D47832, applications like sdr
would have been broken by the inverted SO_REUSEPORT check removed in
that revision, apparently without any bug reports. Let's break
compatibility and simply disallow this case outright.

Also, add some comments, remove a hack in a regression test which tests
this funtionality, and add a new regression test to exercise the
remaining checks that were added in commit 4658dc8325e03.

MFC after: 1 month
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D47870

show more ...


# 4f02a7d7 12-Dec-2024 Mark Johnston <markj@FreeBSD.org>

inpcb: Remove bogus SO_REUSEPORT(_LB) checks in in_pcbbind()

This check for SO_REUSEPORT was added way back in commit 52b65dbe85faf.
Per the commit log, this commit restricted this port-stealing che

inpcb: Remove bogus SO_REUSEPORT(_LB) checks in in_pcbbind()

This check for SO_REUSEPORT was added way back in commit 52b65dbe85faf.
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 (1a43cff92a20d)
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

show more ...


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 150d8ca9 04-Jul-2023 Olivier Cochard <olivier@FreeBSD.org>

socket afinet tests: using dynamic ports instead of the same static port

Allows these tests to be run in parallel.

Approved by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.fr

socket afinet tests: using dynamic ports instead of the same static port

Allows these tests to be run in parallel.

Approved by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D40859

show more ...


# b1c66bc4 23-Jun-2023 Mark Johnston <markj@FreeBSD.org>

netinet tests: Add a test which connects a disconnected socket

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix

show more ...


# 3aaaa2ef 28-Apr-2021 Thomas Munro <tmunro@FreeBSD.org>

poll(2): Add POLLRDHUP.

Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested. Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by: kib
MFC a

poll(2): Add POLLRDHUP.

Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested. Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by: kib
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D29757

show more ...


# 69b7dbeb 20-Apr-2020 Li-Wen Hsu <lwhsu@FreeBSD.org>

Only skip sys.netinet.socket_afinet.socket_afinet_bind_zero in CI env

Sponsored by: The FreeBSD Foundation


# 7f49ce7a 27-Jun-2019 Alan Somers <asomers@FreeBSD.org>

MFHead @349476

Sponsored by: The FreeBSD Foundation


# 01e92e29 23-Jun-2019 Li-Wen Hsu <lwhsu@FreeBSD.org>

Skip sys.netinet.socket_afinet.socket_afinet_bind_zero temporarily because it
doesn't work when mac_portacl(4) loaded

PR: 238781
Sponsored by: The FreeBSD Foundation


12