History log of /src/sys/netinet/udp_usrreq.c (Results 1 – 25 of 1767)
Revision Date Author Comments
# 7b71f57f 03-Dec-2025 Warner Losh <imp@FreeBSD.org>

netinet: Remove left-over sys/cdefs.h

These were for $FreeBSD$ that was removed a while ago, but these
includes didn't get swept up in that. Remove them all now.

Sponsored by: Netflix
MFC After:

netinet: Remove left-over sys/cdefs.h

These were for $FreeBSD$ that was removed a while ago, but these
includes didn't get swept up in that. Remove them all now.

Sponsored by: Netflix
MFC After: 2 weeks

show more ...


# d3a3854f 26-Oct-2025 Michael Tuexen <tuexen@FreeBSD.org>

udp: honor IPV6_TCLASS cmsg for UDP/IPv4 packets

Honor the IPPROTO_IPV6-level cmsg of type IPV6_TCLASS when sending
an UDP/IPv4 packet on an AF_INET6 socket.

Reviewed by: bz
MFC after: 3 days
Spo

udp: honor IPV6_TCLASS cmsg for UDP/IPv4 packets

Honor the IPPROTO_IPV6-level cmsg of type IPV6_TCLASS when sending
an UDP/IPv4 packet on an AF_INET6 socket.

Reviewed by: bz
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D53347

show more ...


# 3535546a 26-Oct-2025 Michael Tuexen <tuexen@FreeBSD.org>

udp: honor IPV6_TCLASS socket option for UDP/IPv4 packets

Honor the IPPROTO_IPV6-level socket option IPV6_TCLASS when sending
an UDP/IPv4 packet on an AF_INET6 socket.

Reviewed by: bz, glebius
MFC

udp: honor IPV6_TCLASS socket option for UDP/IPv4 packets

Honor the IPPROTO_IPV6-level socket option IPV6_TCLASS when sending
an UDP/IPv4 packet on an AF_INET6 socket.

Reviewed by: bz, glebius
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D53346

show more ...


# be93b274 23-Oct-2025 Michael Tuexen <tuexen@FreeBSD.org>

UDP-Lite: export pcblist via sysctl interface

Export the list of pcbs for UDP-Lite to be consumed by sockstat and
netstat.

Reviewed by: Peter Lei, Nick Banks
MFC after: 3 days
Differential Revisi

UDP-Lite: export pcblist via sysctl interface

Export the list of pcbs for UDP-Lite to be consumed by sockstat and
netstat.

Reviewed by: Peter Lei, Nick Banks
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53229

show more ...


# be3c59ff 20-Oct-2025 Michael Tuexen <tuexen@FreeBSD.org>

UDP: let udp_pcblist() support UDP and UDP-Lite

Provide the IPPROTO_UDP in the arg2 parameter of udp_pcblist() and use
this to determine the inpcbinfo. This allows the same function to be
used in an

UDP: let udp_pcblist() support UDP and UDP-Lite

Provide the IPPROTO_UDP in the arg2 parameter of udp_pcblist() and use
this to determine the inpcbinfo. This allows the same function to be
used in an upcoming commit to provide the list of pcbs for UDP-Lite
just by providing IPPROTO_UDPLITE in the arg2 parameter.

Reviewed by: rrs
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D53218

show more ...


# 7294d260 20-Oct-2025 Michael Tuexen <tuexen@FreeBSD.org>

Revert "UDP: let udp_pcblist() support UDP and UDP-Lite"

This reverts commit 5f6f2c3fa25b3f37936b564b433251c33b27a8b3.
Missing link to review.


# 5f6f2c3f 20-Oct-2025 Michael Tuexen <tuexen@FreeBSD.org>

UDP: let udp_pcblist() support UDP and UDP-Lite

Provide the IPPROTO_UDP in the arg2 parameter of udp_pcblist() and use
this to determine the inpcbinfo. This allows the same function to be
used in an

UDP: let udp_pcblist() support UDP and UDP-Lite

Provide the IPPROTO_UDP in the arg2 parameter of udp_pcblist() and use
this to determine the inpcbinfo. This allows the same function to be
used in an upcoming commit to provide the list of pcbs for UDP-Lite
just by providing IPPROTO_UDPLITE in the arg2 parameter.

Reviewed by: rrs
MFC after: 3 days
Pull Request: https://reviews.freebsd.org/D53218

show more ...


# d0f4c558 01-Sep-2025 Gleb Smirnoff <glebius@FreeBSD.org>

udp: slightly refactor udp_append()

Make it bool. Reword the comment, add note that mbuf is always consumed.
In case tunnel consumed the mbuf, don't INP_RUNLOCK(), behave just like
all the other no

udp: slightly refactor udp_append()

Make it bool. Reword the comment, add note that mbuf is always consumed.
In case tunnel consumed the mbuf, don't INP_RUNLOCK(), behave just like
all the other normal exits from the function.

Reviewed by: tuexen, kp, markj
Differential Revision: https://reviews.freebsd.org/D52171

show more ...


# c8a5df48 01-Sep-2025 Gleb Smirnoff <glebius@FreeBSD.org>

udp: don't leak mbuf if tunnel didn't consume and inpcb is gone

Fixes: e1751ef896119d7372035b1b60f18a6342bd0e3b

Reviewed by: tuexen, kp, markj
Differential Revision: https://reviews.freebsd.org/D5

udp: don't leak mbuf if tunnel didn't consume and inpcb is gone

Fixes: e1751ef896119d7372035b1b60f18a6342bd0e3b

Reviewed by: tuexen, kp, markj
Differential Revision: https://reviews.freebsd.org/D52170

show more ...


# a3a78bd7 17-Aug-2025 Gordon Bergling <gbe@FreeBSD.org>

udp: Fix a typo in a source code comment

- s/datgram/datagram/

MFC after: 3 days


# 0312f803 12-Aug-2025 Michael Tuexen <tuexen@FreeBSD.org>

udp: use appropriate error counters

Since there are multicast and broadcast specific error counters,
use them.

Reviewed by: rrs
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revisio

udp: use appropriate error counters

Since there are multicast and broadcast specific error counters,
use them.

Reviewed by: rrs
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D51869

show more ...


# bcb298fa 01-Aug-2025 Timo Völker <timo.voelker@fh-muenster.de>

sctp, tcp, udp: improve deferred computation of checksums

When the SCTP, TCP, or UDP implementation send a packet, it does not
compute the corresponding checksum but defers that. The network layer
w

sctp, tcp, udp: improve deferred computation of checksums

When the SCTP, TCP, or UDP implementation send a packet, it does not
compute the corresponding checksum but defers that. The network layer
will determine whether the network interface selected for the packet
has the requested capability and computes the checksum in software,
if the selected network interface doesn't have the requested
capability.
Do this not only for packets being sent by the local SCTP, TCP,
and UDP stack, but also when forwarding packets. Furthermore, when
such packets are delivered to a local SCTP, TCP, or UDP stack, do not
compute or validate the checksum, since such packets never have been on
the wire.
This allows to support checksum offloading also in the case of local
virtual machines or jails.
Support for epair, vtnet, and tap interfaces will be added in
separate commits.

Reviewed by: kp, rgrimes, tuexen, manpages
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D51475

show more ...


# e1751ef8 25-Jul-2025 Mark Johnston <markj@FreeBSD.org>

udp: Fix a inpcb refcount leak in the tunnel receive path

When the socket has a tunneling function attached, udp_append() drops
the inpcb lock before calling it. To keep the inpcb alive, we bump th

udp: Fix a inpcb refcount leak in the tunnel receive path

When the socket has a tunneling function attached, udp_append() drops
the inpcb lock before calling it. To keep the inpcb alive, we bump the
refcount. After commit 742e7210d00b we only dropped the reference if
the tunnel consumed the packet, but it needs to be dropped in either
case. if_ovpn is the only driver that can trigger this bug.

Fixes: 742e7210d00b ("udp: allow udp_tun_func_t() to indicate it did not eat the packet")
Reviewed by: kp
MFC after: 2 weeks
Sponsored by: Stormshield
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D51505

show more ...


# 3ff865c6 20-Mar-2025 Mark Johnston <markj@FreeBSD.org>

netinet: Fix getcred sysctl handlers to do nothing if no input is given

These routines were all assuming that the sysctl handler has some new
value, but this is not the case. SYSCTL_IN() returns 0

netinet: Fix getcred sysctl handlers to do nothing if no input is given

These routines were all assuming that the sysctl handler has some new
value, but this is not the case. SYSCTL_IN() returns 0 in this
scenario, so they were all operating on an uninitialized address. This
is mostly harmless, but trips KMSAN checks, so let's fix them.

Reviewed by: zlei, rrs, glebius
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D49348

show more ...


# 2472f4db 05-Mar-2025 Zhenlei Huang <zlei@FreeBSD.org>

udp: Do not recursively enter net epoch

The only caller udp_send() has already entered net epoch before invoking
udp_v4mapped_pktinfo().

No functional change intended.

This partially reverts commi

udp: Do not recursively enter net epoch

The only caller udp_send() has already entered net epoch before invoking
udp_v4mapped_pktinfo().

No functional change intended.

This partially reverts commit d74b7baeb0d4 (ifnet_byindex() actually
requires network epoch).

Reviewed by: ae, glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D49227

show more ...


# 97309cec 27-Feb-2025 Zhenlei Huang <zlei@FreeBSD.org>

netinet: Make in_ifhasaddr() return bool

No functional change intended.

MFC after: 1 week


# 69c05f42 22-Feb-2025 Gleb Smirnoff <glebius@FreeBSD.org>

udp: make sendto(2) on unconnected UDP socket use public inpcb KPIs

UDP allows to sendto(2) on unconnected socket. The original BSD devise
was that such action would create a temporary (for the dur

udp: make sendto(2) on unconnected UDP socket use public inpcb KPIs

UDP allows to sendto(2) on unconnected socket. The original BSD devise
was that such action would create a temporary (for the duration of the
syscall) connection between our inpcb and remote addr:port specified in
sockaddr 'to' of the syscall. This devise was broken in 2002 in
90162a4e87f0. For more motivation on the removal of the temporary
connection see email [1].

Since the removal of the true temporary connection the sendto(2) on
unconnected socket has the following side effects:

1) After first sendto(2) the "unconnected" socket will receive datagrams
destined to the selected port.
2) All subsequent sendto(2) calls will use the same source port.

Effectively, such sendto(2) acts like a bind(2) to INADDR_ANY:0. Indeed,
if you do this:

s1 = socket(PF_INET, SOCK_DGRAM, 0);
s2 = socket(PF_INET, SOCK_DGRAM, 0);
sendto(s1, ..., &somedestination, ...);
bind(s2, &{ .sin_addr = INADDR_ANY, sin_port = 0 });

And then look into kgdb at resulting inpcbs, you would find them equal in
all means modulo bound to different anonymous ports.

What is even more interesting is that Linux kernel had picked up same
behavior, including that "unconnected" socket will receive datagrams. So
it seems that such behavior is now an undocumented standard, thus I
covered it in recently added tests/sys/netinet/udp_bindings.

Now, with the above knowledge at hand, why are we using
in_pcbconnect_setup() and in_pcbinshash(), which are supposed to be
private to in_pcb.c, to achieve the binding? Let's use public KPI
in_pcbbind() on the first sendto(2) and use in_pcbladdr() on all
sendto(2)s. Apart from finally hiding these two should be private
functions, we no longer acquire global INP_HASH_WLOCK() for every
sendto(2) on unconnected socket as well as remove a couple workarounds.

[1] https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210141935.aa83883

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D49043

show more ...


# 197fc4ca 22-Feb-2025 Gleb Smirnoff <glebius@FreeBSD.org>

netinet: rename in_broadcast() to in_ifnet_broadcast()

This aligns with existing in_ifaddr_broadcast() and aligns with other
simple functions or macros with bare "in_" prefix that operator just on
s

netinet: rename in_broadcast() to in_ifnet_broadcast()

This aligns with existing in_ifaddr_broadcast() and aligns with other
simple functions or macros with bare "in_" prefix that operator just on
struct in_addr and nothing else, e.g. in_nullhost(). No functional
change.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D49041

show more ...


# 08e638c0 06-Feb-2025 Mark Johnston <markj@FreeBSD.org>

udp: Add a sysctl to modify listening socket FIB inheritance

Introduce the net.inet.udp.bind_all_fibs tunable, set to 1 by default
for compatibility with current behaviour. When set to 0, all recei

udp: Add a sysctl to modify listening socket FIB inheritance

Introduce the net.inet.udp.bind_all_fibs tunable, set to 1 by default
for compatibility with current behaviour. When set to 0, all received
datagrams will be dropped unless an inpcb bound to the same FIB exists.

No functional change intended, as the new behaviour is not enabled by
default.

Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D48664

show more ...


# bbd0084b 06-Feb-2025 Mark Johnston <markj@FreeBSD.org>

inpcb: Add a flags parameter to in_pcbbind()

Add a flag, INPBIND_FIB, which means that the inpcb is local to its FIB
number. When this flag is specified, duplicate bindings are permitted,
so long a

inpcb: Add a flags parameter to in_pcbbind()

Add a flag, INPBIND_FIB, which means that the inpcb is local to its FIB
number. When this flag is specified, duplicate bindings are permitted,
so long as each FIB contains at most one inpcb bound to the same
address/port. If an inpcb is bound with this flag, it'll have the
INP_BOUNDFIB flag set.

No functional change intended.

Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D48661

show more ...


# 949190c5 28-Nov-2024 Zhenlei Huang <zlei@FreeBSD.org>

udp: Prefer memcpy() over bcopy()

The variable b[] is on the stack, thus cannot overlap with ipov, which
points to the heap area, so prefer memcpy() over memmove(), aka bcopy().

No functional chang

udp: Prefer memcpy() over bcopy()

The variable b[] is on the stack, thus cannot overlap with ipov, which
points to the heap area, so prefer memcpy() over memmove(), aka bcopy().

No functional change intended.

Reviewed by: cc, rrs, cy, #transport, #network
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47713

show more ...


# 0b4539ee 14-Nov-2024 Gleb Smirnoff <glebius@FreeBSD.org>

inpcb: gc unused argument of in_pcbconnect()


# 4d32367a 30-Jul-2024 Michael Tuexen <tuexen@FreeBSD.org>

Revert "udp: improve handling of cached route"

This reverts commit 71867653008ce17a66a9c935e9dc29c1320bf48b.
Two tests of the test suite are failing. Reverting the change
until it is improved.


# 71867653 28-Jul-2024 Michael Tuexen <tuexen@FreeBSD.org>

udp: improve handling of cached route

The inp_route pointer should only be provided to the network
layer, when no destination address is provided. This is only
one of the conditions, where a write l

udp: improve handling of cached route

The inp_route pointer should only be provided to the network
layer, when no destination address is provided. This is only
one of the conditions, where a write lock is needed.
If, for example, the route is also cached, when the socket is
unbound, problems show up, when the sendto is called, then
connect and finally send, when the route for the addresses
provided in the sendto and connect call use different outgoing
interfaces.
While there, clearly document why the write lock is taken.

Reported by: syzbot+59122d2e848087d3355a@syzkaller.appspotmail.com
Reviewed by: Peter Lei, glebius
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D46056

show more ...


# ce69e373 03-Feb-2024 Gleb Smirnoff <glebius@FreeBSD.org>

Revert "sockets: retire sorflush()"

Provide a comment in sorflush() why the socket I/O sx(9) lock is actually
important.

This reverts commit 507f87a799cf0811ce30f0ae7f10ba19b2fd3db3.


12345678910>>...71