FreeBSD/src 0fac350sys/kern uipc_syscalls.c, sys/netgraph/bluetooth/socket ng_btsocket_l2cap.c ng_btsocket_sco.c

sockets: don't malloc/free sockaddr memory on getpeername/getsockname

Just like it was done for accept(2) in cfb1e92912b4, use same approach
for two simplier syscalls that return socket addresses.  Although,
these two syscalls aren't performance critical, this change generalizes
some code between 3 syscalls trimming code size.

Following example of accept(2), provide VNET-aware and INVARIANT-checking
wrappers sopeeraddr() and sosockaddr() around protosw methods.

Reviewed by:            tuexen
Differential Revision:
+145-29737 files not shown
+420-69843 files

FreeBSD/src cfb1e92sys/kern uipc_syscalls.c, sys/netgraph/bluetooth/socket ng_btsocket_l2cap.c ng_btsocket_rfcomm.c

sockets: don't malloc/free sockaddr memory on accept(2)

Let the accept functions provide stack memory for protocols to fill it in.
Generic code should provide sockaddr_storage, specialized code may provide
smaller structure.

While rewriting accept(2) make 'addrlen' a true in/out parameter, reporting
required length in case if provided length was insufficient.  Our manual
page accept(2) and POSIX don't explicitly require that, but one can read
the text as they do.  Linux also does that. Update tests accordingly.

Reviewed by:            rscheff, tuexen, zlei, dchagin
Differential Revision:
+190-19922 files not shown
+261-30928 files

FreeBSD/src 7aaf39fsys/kern vfs_mount.c, sys/sys mount.h

nfsd: Fix NFS access to .zfs/snapshot snapshots

When a process attempts to access a snapshot under
/<dataset>/.zfs/snapshot, the snapshot is automounted.
However, without this patch, the automount does not
set mnt_exjail, which results in the snapshot not being
accessible over NFS.

This patch defines a new function called vfs_exjail_clone()
which sets mnt_exjail from another mount point and
then uses that function to set mnt_exjail in the snapshot
automount.  A separate patch that is currently a pull request
for OpenZFS, calls this function to fix the problem.

PR:     275200

(cherry picked from commit f5f277728adec4c5b3e840a1fb16bd16f8cc956d)
+39-02 files

FreeBSD/src 8daee41sys/vm vm_kern.c

vm: Use vmem_xalloc in kva_alloc

The kernel_arena used in kva_alloc has the qcache disabled. vmem_alloc
will first try to use the qcache before falling back to vmem_xalloc.

Rather than trying to use the qcache in vmem_alloc just call
vmem_xalloc directly.

Reviewed by:    alc, kib, markj
Sponsored by:   Arm Ltd
Differential Revision:
+3-21 files

FreeBSD/src 839999esys/vm vm_kern.c vm_extern.h

vm: Add kva_alloc_aligned

Add a function like kva_alloc that allows us to specify the alignment
of the virtual address space returned.

Reviewed by:    alc, kib, markj
Sponsored by:   Arm Ltd
Differential Revision:
+22-02 files

FreeBSD/src 8959056sys/cddl/contrib/opensolaris/uts/common/fs/zfs dmu.c

dnode_is_dirty: check dnode and its data for dirtiness

Over its history this the dirty dnode test has been changed between
checking for a dnodes being on `os_dirty_dnodes` (`dn_dirty_link`) and

It turns out both are actually required.

In the case of appending data to a newly created file, the dnode proper
is dirtied (at least to change the blocksize) and dirty records are
added.  Thus, a single logical operation is represented by separate
dirty indicators, and must not be separated.

The incorrect dirty check becomes a problem when the first block of a
file is being appended to while another process is calling lseek to skip
holes. There is a small window where the dnode part is undirtied while
there are still dirty records. In this case, `lseek(fd, 0, SEEK_DATA)`
would not know that the file is dirty, and would go to
`dnode_next_offset()`. Since the object has no data blocks yet, it

    [10 lines not shown]
+2-11 files

FreeBSD/src 34c45bcshare/man/man4 tcp.4, sys/netinet tcp_input.c

tcp: enable LRD by default

Lost Retransmission Detection was added as a
feature in May 2021, but disabled by default.

Enabling the feature by default to reduce the
flow completion time by avoiding RTOs when
retransmissions get lost too.

Reviewed By:           tuexen, #transport, zlei
MFC after:             10 weeks
Sponsored by:          NetApp, Inc.
Differential Revision:
+3-32 files

FreeBSD/src 6031499include/rpc rpc_com.h, lib/libc/rpc clnt_vc.c clnt_dg.c

libc/libc/rpc: refactor some global variables

* Combine dg_fd_locks and dg_cv into one array.
* Similarly for vc_fd_locks and vc_cv
* Turn some macros into inline functions

This is a mostly cosmetic change to make refactoring these strutures in
a future commit easier.

Sponsored by:   Axcient
Reviewed by:    kib
Differential Revision:

(cherry picked from commit a5c2f4e939430f0048136c39fb9fa6093d401905)

lib/libc/rpc: switch the per-fd structs in clnt_{dg,vc}.c to RB Trees

This saves oodles of memory, especially when "ulimit -n" is large.  It
also prevents a buffer overflow if getrlimit should fail.

    [9 lines not shown]
+168-2076 files

FreeBSD/src 51e7276usr.sbin/jail jail.c

Unbreak build from ed31b3f4a146 (misapplied diff).

Differential Revision:  <
+0-11 files

FreeBSD/src a8c36fd., share/man/man9 ieee80211_node.9 Makefile

net80211: remove ieee80211_unref_node()

ieee80211_unref_node() was only used in two error cases in
ieee80211_send_nulldata().  There we do not need to guard against
ni pointer reuse after decrementing the refcount of the ni as we
only update the stats and return.

Update the man page and remove the link for the now gone function.

Note: the last uses of the function were removed in 493d6255434ce.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    adrian, emaste
Differential Revision:

(cherry picked from commit 1137943b1c5b225e30b82350ff7fb12c258ea90f)
+10-225 files

FreeBSD/src 981462dsys/net80211 ieee80211_vht.c ieee80211_ht.c

net80211: combine iv_vhtcaps and iv_vht_mcsinfo

The iv_vhtcaps and iv_vht_mcsinfo fields together form
struct ieee80211_vht_cap so combine them into one field in the VAP
and keep the information together.

While the structure layout changes no other functional changes intended.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    adrian, cc
Differential Revision:

(cherry picked from commit fbba0d6b636492505dc5878b9ed2c1bbdcd88b91)
+30-315 files

FreeBSD/src 5f760adsys/net80211 ieee80211_ht.c ieee80211_vht.c

net80211: rename iv_flags_vht to iv_vht_flags

While the flag field is internal start naming it as well as "iv_vht*"
so we keep all "VHT" fields together.  This breaks with what was done
done for HT but with HE, EHT, .. coming one day seems the more logic

No functional changes intended.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    adrian, cc
Differential Revision:

(cherry picked from commit ef48d4fa122d863db11e41608ceea641eec54704)
+24-243 files not shown
+28-289 files

FreeBSD/src 7019af0sys/compat/linuxkpi/common/src linux_80211.c, sys/net80211 ieee80211_vht.c ieee80211.c

net80211: migrate ic_vhtcaps, ic_vht_mcsinfo, ic_flags_vht

Like for the VAP rename ic_flags_vht to ic_vht_flags for consistency to
keep "VHT" fields together and merge ic_vhtcaps and ic_vht_mcsinfo
into struct ieee80211_vht_cap ic_vht_cap.

While the structure layout changes no other functional changes intended.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    adrian, cc
Differential Revision:

(cherry picked from commit 562adbe1d354377a260e66eedb6072b720a606dc)
+18-192 files not shown
+20-218 files

FreeBSD/src bf0d632sys/compat/linuxkpi/common/src linux_80211.h

LinuxKPI: 802.11: zero-pad debug flags

Write the debug flags as full 32bit hex numbers to have a better
view on them.

No functional changes.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    cc, emaste
Differential Revision:

(cherry picked from commit 8895b47638ea4d7a13fba97afe8cd9faacfdda83)
+12-121 files

FreeBSD/src bd10aa1sys/net80211 ieee80211_vht.c ieee80211_vht.h

net80211: add ieee80211_add_vhtcap_ch()

Add an implementation of ieee80211_add_vhtcap() which works based on
information derived from the vap (and possibly channel/band but we do
not support that yet in net80211).  This is needed for scans request
information in LinuxKPI at times before we have a BSS.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    adrian, cc
Differential Revision:

(cherry picked from commit 6c3ae01cc75afdd575f54289b2879a7c98d55bf6)
+29-02 files

FreeBSD/src d425c3csys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: fix ieee80211_add_channel_cbw() argument

Fix the last argument passed to ieee80211_add_channel_cbw() in
lkpi_ic_getradiocaps() for both 2Ghz and 5Ghz bands.
We passed in the unmodified version rather than the adjusted version
based on the per-band channel information possibly leaving
ieee80211_channel_flags enabled which should not be.

So far this should not have made a difference given we did not enable
HT or VHT.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    cc
Differential Revision:

(cherry picked from commit 5856761fd5f675c3871a82effdbf714a1d1bcc5e)
+2-21 files

FreeBSD/src 1d2f963sys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: error on state transition failure

The state transition failures we were seeing in the early days are
solved.  If we now experience one stop processing before passing
over to net80211 (sta_newstate()) and before updating iv_state on
the vap.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    cc
Differential Revision:

(cherry picked from commit 45c27ad5241f5491234afd0b47d13b8005fdb4de)
+1-21 files

FreeBSD/src c0398e3sys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: add unconditional error reporting

Multiple reports have shown missed state transitions in net80211 without
major cause obvious (or with a txq warning in iwlwifi).
In order to better track down potential problems add unconditional
ic_printf calls to any case in the lkpi state machine compat code which
would let us return with an error in the hope that it helps us to catch
the actual problems.
Also remove the debug conditions from ieee80211_{beacon,connection}_loss
which can also cause state transitions to have the ic_printf all the time
there too.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 018d93ece16bd33077021383940d0da5121f0691)
+64-201 files

FreeBSD/src 861bf06sys/compat/linuxkpi/common/src linux_80211.c

LinuxKPI: 802.11: deal with scan_ie_len

We only need to reserve the extra space for DSSS if
NL80211_FEATURE_DS_PARAM_SET_IE_IN_PROBES is set, so add the conditional.
Also add checks in case scan_ie_len will grow beyond the maximum.
Given this is currently unlikely, leave the cleanup for later as
some other restructuring should be done first.

Sponsored by:   The FreeBSD Foundation
Reviewed by:    cc
Differential Revision:

(cherry picked from commit 78ca45df310563ca46448a124674e0542aab2e31)
+16-61 files

FreeBSD/src d27f3b8sys/contrib/dev/iwlwifi/mvm tx.c

iwlwifi: re-enable "Invalid TXQ id" logging

Various reports recently hit the "Invalid TXQ id" in iwlwifi again.
Unconditionally enable logging and add a note to report to a specific
PR in the log message for now.
Along with 018d93ece16b this will hopefully help us to understand what
is going on.

Sponsored by:   The FreeBSD Foundation
PR:     274382

(cherry picked from commit ad134f8ab768e3b1d2db203f1cc963bdf0eea857)
+4-31 files

FreeBSD/src 02c014asys/net80211 ieee80211_node.c

net80211: pass __func__, __LINE__ also to ieee80211_alloc_node()

Pass caller information to ieee80211_alloc_node() so that in case
IEEE80211_DEBUG_REFCNT is compiled in we can (better) track references,
in this case the initial ieee80211_node_initref().

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 3a11944bca0f07079a61f10468b704589c52a76f)
+22-71 files

FreeBSD/src 24df98csys/net80211 ieee80211_node.c ieee80211_node.h

net80211: de-inline ieee80211_ref_node()

Make ieee80211_ref_node() a macro so we can pass __func__, __LINE__
in for IEEE80211_DEBUG_REFCNT as we do for other refcount related
functions.  Add the appropriate IEEE80211_DPRINTF() call to the
_ieee80211_ref_node() implementation to support wlandebug(8) +node
printf style tracing.
As a plus we can now also use Dtrace fbt on the
_ieee80211_{ref,free}_node() implementations with futher logic,
gathering backtraces, etc. more flexibly.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 2188852196151e5f04533eaa928a7ad0896e4bd6)
+18-72 files

FreeBSD/src b50d8a1sys/net80211 ieee80211_node.c ieee80211_node.h

net80211: make ieee80211_alloc_node() private

Looking through the allocation/free and reference cycle of nodes we have
a few (publicly) (almost) unused macros and functions.
Start making them private and reducing the amount of entry paths to the
same/similar functionality.
First is to make ieee80211_alloc_node() static as it is nowhere used
in the tree outside this file.

Sponsored by:   The FreeBSD Foundation

(cherry picked from commit db195a523f9bbeb111b621d2c2c7a46d8b921631)
+4-42 files

FreeBSD/src c321612sys/dev/mii miidevs

mii: resort VSC8641 entry in miidevs

VSC8641 is a ciphy not a vscphy.
Sort it with the other entries of ciphy to avoid confusion.

(cherry picked from commit 43324ec770f6b598f0ce25487f69a64b3c9822bd)
+1-11 files

FreeBSD/src 91987a9sys/dev/dpaa2 dpaa2_ni.c

dpaa2: defer link_state updates until we are up

dpaa2_ni_media_change() was called in early setup stages, before we
were fully setup.  That lead to internal driver state being all synched
and fine but hardware state was lost/never setup corrently.

Introduce dpaa2_ni_media_change_locked() so we can avoid reccursive
locking and call "dpaa2_ni_media_change()" instead of mii_mediachg()
as the latter does not setup our state there either.

In order for this all to work, call if_setdrvflagbits() just before
rather than after the above.

Also remove an unecessary direct call to dpaa2_ni_miibus_statchg()
which mii_mediachg() will trigger anyway.

This all fixes a problem [1] that one had to lose the link (either
unplugging/replugging the cable or using ifconfig media none;
ifconfig media auto) to re-trigger the all updates and get the

    [7 lines not shown]
+36-101 files

FreeBSD/src 4500044sys/dev/mii miidevs vscphy.c

mii: add Vitesse/Microsemi VSC8514

The VSC8514 Quad-Port 10/100/1000BASE-T PHY seems to match the handling
for the VSC8504 (for the little we support of what we could) and while
it works with our generic ukphy add it as vscphy for porper display of
names in the system message buffer and the like (or in case we decide
to implement some extra features).

Tested on:      Ten64

(cherry picked from commit 1965dd85c3b33ed99cb8ef164dd7c5b20425a85e)
+2-02 files

FreeBSD/src e0910cfsys/dev/dpaa2 dpaa2_ni.c

dpaa2: make software VLANs usable on dpni

dpni announces IFCAP_VLAN_MTU but internally does not increase the
maximum frame length.  Createing a vlan interface on top of a dpni
interface will result in full-sized frames not passing.
Extend the maximum frame length by ETHER_VLAN_ENCAP_LEN to allow at
least for one layer of (software) vlans for now

Reviewed by:    dsl
Differential Revision:

(cherry picked from commit 0480dccd3f347da0dbccf5917633435d5ce6cb86)
+1-11 files

FreeBSD/src 9197f22sys/dev/dpaa2 dpaa2_mc_fdt.c

dpaa2: fdt improve detection for dpmac/phys

'pcs-handles' are not mandatory in the device tree here so do not
enforce them.  This allows us to find dpmac entries needed for phys
on the WHLE-LS1 as well.

Reviewed by:    jceel, dsl
Differential Revision:

(cherry picked from commit 6c46ebb05dccdcee18f64dc122e6685c05180217)
+0-21 files

FreeBSD/src ed31b3flib/libc/sys jail.2, sys/kern kern_jail.c

jail: Don't allow jail_set(2) to resurrect dying jails.

Currently, a prison in "dying" state (removed but still holding
resources) can be brought back to alive state via "jail -d", or
the JAIL_DYING flag to jail_set(2).  This seemed like a good idea
at the time.

Its main use was to improve support for specifying the jid when
creating a jail, which also seemed like a good idea at the time.
But resurrecting a jail that was partway through thr process of
shutting down is trouble waiting to happen.

This patch deprecates that flag, leaving it as a no-op for creating
jails (but still useful for looking at dying jails).  It sill allows
creating a new jail with the same jid as a dying one, but will renumber
the old one in that case.  That's imperfect, but allows for current

Reviewed by:    bz
Differential Revision:
+186-1915 files

FreeBSD/src c18c577tests/sys/fs/fusefs

fusefs: add more readdir tests for misbehaving servers

Inspired by PR 274268

Sponsored by:   Axcient

(cherry picked from commit 6a773a0582ba936cc19734b21ee5a7bed49cfdec)
+87-01 files