FreeBSD/src 411c28bsys/kern subr_hash.c

hash(9): fix my stupid off-by-one

Fixes:  abf68d1cf02550c3c0341f5bb90be0d34f655a15
DeltaFile
+1-1sys/kern/subr_hash.c
+1-11 files

FreeBSD/src 6604989lib/libsys fork.2

fork.2: note that all methods to pre-resolve symbols have consequences

Reviewed by:    imp
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D56362
DeltaFile
+2-0lib/libsys/fork.2
+2-01 files

FreeBSD/src f286933include unistd.h

unistd.h: _Fork(2) is required by POSIX 2024

Reviewed by:    imp
Sponsored by:   The FreeBSD Foundation
MFC after:      1 week
Differential revision:  https://reviews.freebsd.org/D56362
DeltaFile
+4-1include/unistd.h
+4-11 files

FreeBSD/src 1ed6854usr.bin/lockf lockf.1

lockf.1: Organize and provide error numbers

Add error numbers to the exit codes so that readers can decode them
without having to use a separate utility. Organize exits by error code.
Mark up the error constants with the error constant macro, even though
this is really not very helpful because people will search for the error
code, the macro is explicitly for the constants and not the codes.

While where, align and alphabetize the options list as well, fix
misaligned padding in an example, and a one-sentance-per-line error.

MFC after:              3 days
Reported by:            Antranig Vartanian <antranigv at freebsd.am>
Differential Revision:  https://reviews.freebsd.org/D48470

(cherry picked from commit dd201e407e48ba59bdfa1f71d41acfdac1a9c562)
DeltaFile
+33-30usr.bin/lockf/lockf.1
+33-301 files

FreeBSD/src 46bd227usr.sbin/mfiutil mfiutil.8

mfiutil.8: Fix typo - missing macro for dev node

MFC after: 3 days

(cherry picked from commit 2bcdab574598e729273f7ddc7d898ffdb43b63b9)
DeltaFile
+2-1usr.sbin/mfiutil/mfiutil.8
+2-11 files

FreeBSD/src ece716csys/netinet raw_ip.c in_pcb.c

raw ip: move hash table manipulation to inpcb layer

The SOCK_RAW socket is a multiple receiver socket by its definition.  An
incoming packet may be copied to multiple sockets.  Thus, incoming packet
handling is expensive.  Systems with many thousands of raw sockets usually
have them connect(2)-ed to different destinations.  This allows for some
improvement of the input handling, which was introduced by 9ed324c9a588
back in 2008.  This optimization was made specifically for L2TP/PPTP VPN
concentrators based on ports/net/mpd5.

This change generalizes the idea of 9ed324c9a588, so that it potentially
can be used with IPv6 raw sockets.  This also eliminates last use of the
pcbinfo hash lock outside of in_pcb.c.

While here make a speculative design decision: put into the hash table
sockets that did only connect(2).  Previously, we were indexing only
sockets that were protocol bound, did bind(2) and did connect(2).  My
speculation is that only the remote IP provides some real entropy into the
hash and local address and proto are expected to be the same for majority

    [4 lines not shown]
DeltaFile
+23-95sys/netinet/raw_ip.c
+36-0sys/netinet/in_pcb.c
+10-0sys/netinet/in_pcb.h
+0-3sys/netinet/in_pcb_var.h
+69-984 files

FreeBSD/src edece33sys/netinet udp_usrreq.c in_pcb.c, sys/netinet6 udp6_usrreq.c in6_pcb.c

inpcb: move local address assignment out of in_pcbdisconnect()

The logic of clearing local address at the protocol level makes sense.  It
is feature of UDP, not of any protocol, that local address is cleared on
disconnect.  This code can be tracked down to pre-FreeBSD times.

For example, for TCP we want a disconnected socket to return previously
used local address with getsockname(2).  The TCP has successfully evaded
that by not calling in_pcbdisconnect() and calling in_pcbdetach() in the
very old code and in_pcbdrop() later.   After D55661 TCP again has this
potential bug masked.  Better make it right than rely on such
unintentional evasions.

The raw IP sockets don't use in_pcbdisconnect(), but they are going to in
the near future.  If in_pcbdisconnect() clears local address for them,
that would be a larger bug than just getsockname().  A raw socket may be
bound with bind(2) and then connect(2)ed, and then disconnected, e.g.
connect(INADDR_ANY).  And when we run raw IP socket through
in_pcbdisconnect() we don't want to lose local address.

    [6 lines not shown]
DeltaFile
+3-0sys/netinet6/udp6_usrreq.c
+3-0sys/netinet/udp_usrreq.c
+0-1sys/netinet6/in6_pcb.c
+0-1sys/netinet/in_pcb.c
+6-24 files

FreeBSD/src 1d0ea3dsys/netinet raw_ip.c

raw ip: remove extra argument to rip_dodisconnect()

No functional change.
DeltaFile
+7-7sys/netinet/raw_ip.c
+7-71 files

FreeBSD/src acb79b5sys/netinet in_pcb.c udp_usrreq.c

udp: make in_pcbbind_setup() acquire the hash lock internally

Reviewed by:            pouria, rrs, markj
Differential Revision:  https://reviews.freebsd.org/D55973
DeltaFile
+56-43sys/netinet/in_pcb.c
+0-4sys/netinet/udp_usrreq.c
+56-472 files

FreeBSD/src d7c4091sys/netinet6 in6_pcb.c udp6_usrreq.c

inpcb: make in6_pcbsetport() acquire the hash lock internally

Reviewed by:            pouria, rrs, markj
Differential Revision:  https://reviews.freebsd.org/D55972
DeltaFile
+18-7sys/netinet6/in6_pcb.c
+0-5sys/netinet6/udp6_usrreq.c
+18-122 files

FreeBSD/src 2c48736sys/netinet in_pcb.c tcp_syncache.c, sys/netinet6 in6_pcb.c udp6_usrreq.c

inpcb: make in_pcbconnect() acquire the hash lock internally

Reviewed by:            pouria, rrs, markj
Differential Revision:  https://reviews.freebsd.org/D55971
DeltaFile
+12-5sys/netinet/in_pcb.c
+11-4sys/netinet6/in6_pcb.c
+0-6sys/netinet6/udp6_usrreq.c
+0-4sys/netinet/tcp_syncache.c
+0-4sys/netinet/tcp_usrreq.c
+0-4sys/netinet/udp_usrreq.c
+23-276 files

FreeBSD/src 8b4d0besys/netinet tcp_usrreq.c in_pcb.c, sys/netinet6 in6_pcb.c udp6_usrreq.c

inpcb: make in_pcbbind() acquire the hash lock internally

Reviewed by:            markj
Differential Revision:  https://reviews.freebsd.org/D55970
DeltaFile
+11-4sys/netinet6/in6_pcb.c
+0-10sys/netinet/tcp_usrreq.c
+7-2sys/netinet/in_pcb.c
+0-6sys/netinet/udp_usrreq.c
+0-4sys/netinet6/udp6_usrreq.c
+18-265 files

FreeBSD/src 40dbb06sys/dev/cxgbe/iw_cxgbe qp.c, sys/dev/cxgbe/nvmf nvmf_che.c

inpcb: retire INP_DROPPED and in_pcbdrop()

The inpcb flag INP_DROPPED served two purposes.

It was used by TCP and subsystems running on top of TCP as a flag that
marks a connection that is now in TCPS_CLOSED, but was in some other state
before (not a new-born connection). Create a new TCP flag TF_DISCONNECTED
for this purpose.

The in_pcbdrop() was a TCP's version of in_pcbdisconnect() that also sets
INP_DROPPED.  Use in_pcbdisconnect() instead.

Second purpose of INP_DROPPED was a negative lookup mask in
inp_smr_lock(), as SMR-protected lookup may see inpcbs that had been
removed from the hash.  We already have had INP_INHASHLIST that marks
inpcb that is in hash.  Convert it into INP_UNCONNECTED with the opposite
meaning.  This allows to combine it with INP_FREED for the negative lookup
mask.


    [7 lines not shown]
DeltaFile
+74-124sys/netinet/tcp_usrreq.c
+26-48sys/netinet/in_pcb.c
+20-51sys/kern/uipc_ktls.c
+21-23sys/dev/cxgbe/tom/t4_cpl_io.c
+11-13sys/dev/cxgbe/iw_cxgbe/qp.c
+13-10sys/dev/cxgbe/nvmf/nvmf_che.c
+165-26923 files not shown
+258-36329 files

FreeBSD/src ce283e1sys/netinet6 ip6_output.c

netinet6: remove INP_DROPPED checks from setsockopt(2)

The INP_DROPPED is going to become an internal flag for inpcb.  As of now
it means a TCP pcb that is in TCPS_CLOSED.  There is nothing wrong with
calling setsockopt(2) on such socket, although has no practical use.

This deletes a piece of code from 56713d16a06c5 / D16201.  There is no
description of the panic fixed, but I will speculate that the panic was
about in6p->in6p_outputopts being NULL as the inpcb already went through
in_pcbfree_deferred().  This also can be related to compressed TIME-WAIT,
that is also gone now.

With current locking this shouldn't be possible.  An inpcb goes through
in_pcbfree() only with pr_detach method, which is called from sofree(),
and the latter is called on losing the very last socket reference.  So, at
the point when in_pcbfree() is called, the socket has lost its file
descriptor reference and there can not be any running setsockopt() on it.

Leave the call to ip6_pcbopt() still embraced with INP_WLOCK(), since we

    [9 lines not shown]
DeltaFile
+0-17sys/netinet6/ip6_output.c
+0-171 files

FreeBSD/src 0ba87desys/netinet udp_usrreq.c in_pcb.c, sys/netinet6 udp6_usrreq.c in6_pcb.c

inpcb: make in_pcbdisconnect() acquire the hash lock internally

Should be no functional change.

Reviewed by:            pouria, markj
Differential Revision:  https://reviews.freebsd.org/D55968
DeltaFile
+0-12sys/netinet6/udp6_usrreq.c
+0-12sys/netinet/udp_usrreq.c
+2-1sys/netinet6/in6_pcb.c
+2-1sys/netinet/in_pcb.c
+4-264 files

FreeBSD/src ac5b962sys/netinet in_pcb.c in_pcb.h, sys/netinet6 in6_pcb.c

inpcb: retire the inpcb global list

The iteration over all pcbs is possible without the global list. The
newborn inpcbs are put on a global list of unconnected inpcbs, then after
connect(2) or bind(2) they move to respective hash slot list.

This adds a bit of complexity to inp_next(), but the storage scheme is
actually simplified.

One potential problem before this change was that a couple of pcbs fall
into the same hash slot and are linked A->B there, but they also sit next
to each other in the global list, linked as B->A.  This can deadlock of
course.  The problem was never observed in the wild, but I was able to
instrument it with lots of effort: just few pcbs in the system, hash size
reduced down to 2 and a lot of repetitive calls into two kinds of
iterators.

However the main motivation is not the above problem, but make a step
towards splitting the big hash lock into per-slot locks.

    [2 lines not shown]
DeltaFile
+80-45sys/netinet/in_pcb.c
+32-17sys/netinet/in_pcb.h
+18-11sys/netinet/tcp_usrreq.c
+3-1sys/netinet6/in6_pcb.c
+1-1sys/netinet/in_pcb_var.h
+134-755 files

FreeBSD/src 2cfe626sys/netinet in_pcb.h in_pcb.c

inpcb: retire the inpcbinfo list lock

With the SMR locking of inpcbs the use of this lock reduced down to the
global list and generation number.  It was used only on an inpcb creation
and destruction.  Use the inpcbinfo hash lock for this purpose.

Reviewed by:            pouria, rrs, markj
Differential Revision:  https://reviews.freebsd.org/D55966
DeltaFile
+5-23sys/netinet/in_pcb.h
+5-7sys/netinet/in_pcb.c
+2-2sys/netinet/udp_usrreq.c
+1-1sys/netinet/raw_ip.c
+1-1sys/netinet/tcp_subr.c
+14-345 files

FreeBSD/src 2023709sys/netinet in_pcb.c, sys/netinet6 in6_pcb.c

inpcb: apply smr_advance(9)/smr_wait(9) trick only to reusable sockets

The protocols marked with PR_CONNREQUIRED can never go through pr_connect
after being disconnected.  This is a tiny improvement of fdb987bebddf0.

While here push clearing of the addresses under the same condition.
Although this clearing originates from pre-FreeBSD times, it actually
makes sense only for protocols that can reconnect.

Reviewed by:            pouria, markj
Differential Revision:  https://reviews.freebsd.org/D55661
DeltaFile
+8-7sys/netinet6/in6_pcb.c
+7-5sys/netinet/in_pcb.c
+15-122 files

FreeBSD/src 817e699sys/dev/usb/input wsp.c

wsp(4): Make evdev interface operational if sysmouse one is not opened

Before this change evdev interface sent only copy of data sent through
the sysmouse interface. It worked as /dev/wsp0 device node was
automatcaly opened by devd(8) with starting of moused(8).
Starting with 15.0 moused(8) does not open sysmouse interface by default
thus making wsp(4) device dysfunctional.
Fix it with adding extra checks of interfaces state.

MFC after:      1 week
DeltaFile
+10-1sys/dev/usb/input/wsp.c
+10-11 files

FreeBSD/src dc5a949sys/dev/usb/input wsp.c

wsp(4): Do not handle pressure on non-ForceTouch devices

They always report it value as zero breaking pressure-driven drivers
like moused(8) and xf86-input-synaptics.

MFC after:      1 week
DeltaFile
+4-2sys/dev/usb/input/wsp.c
+4-21 files

FreeBSD/src 9d0404csys/dev/hid bcm5974.c

bcm5974(4): Do not handle pressure on non-ForceTouch devices

They always report it value as zero breaking pressure-driven drivers
like moused(8) and xf86-input-synaptics.

MFC after:      1 week
DeltaFile
+5-3sys/dev/hid/bcm5974.c
+5-31 files

FreeBSD/src 2ba6ce5sys/dev/hid hid.h

hid: Change Usage Page names to match documentation

According to "HID Usage Tables FOR Universal Serial Bus (USB)"
Usage Page ID range 0x93-0xF1CF is "Reserved" and Usage Page ID range
0xFF00-0xFFFF is "Vendor-defined".

MFC after:      1 week
DeltaFile
+7-3sys/dev/hid/hid.h
+7-31 files

FreeBSD/src 8448878usr.sbin/bluetooth/iwmbtfw iwmbt_hw.c iwmbt_fw.c

iwmbtfw(8): Identify device type based on HCI quieries result

rather than on VID/PID. Later is not reliable for some types.
VID/PID identification can be restored by specifying of -p option.

Tested by:      arrowd, wulf
PR:             290639
MFC after:      1 week
DeltaFile
+47-103usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c
+105-0usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c
+75-5usr.sbin/bluetooth/iwmbtfw/main.c
+5-2usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
+3-0usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.h
+2-0usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.h
+237-1106 files

FreeBSD/src d6477cdsys/dev/hid bcm5974.c

bcm5974(4): Fix pre-2015 Apple touchpad support

These devices appeared to stop sending reports via mouse USB interface
after switching to RAW mode. Fix it with changing Usage of Top Level
Collection to one found in HID report descriptor of proper interface.

MFC after:      1 week
DeltaFile
+38-34sys/dev/hid/bcm5974.c
+38-341 files

FreeBSD/src 98118afsecure/lib/libcrypto Makefile

[OpenSSL] Add missing header file (openssl/ml_kem.h)

Add missing header file (openssl/ml_kem.h) of OpenSSL 3.5

Reviewed by:    fluffy, ngie
Approved by:    ngie (maintainer)
Differential Revision:  https://reviews.freebsd.org/D56291
DeltaFile
+1-1secure/lib/libcrypto/Makefile
+1-11 files

FreeBSD/src cd5ff4esys/net pfvar.h, sys/netpfil/pf pf.c

pf: use hashalloc(9) for key, id, src-node and udp-endpoint hashes

Reviewed by:            kp
Differential Revision:  https://reviews.freebsd.org/D56113
DeltaFile
+54-92sys/netpfil/pf/pf.c
+1-2sys/net/pfvar.h
+55-942 files

FreeBSD/src 87ef306sys/netinet tcp_lro.c

tcp lro: use hashalloc(9)

Reviewed by:            tuexen, rrs
Differential Revision:  https://reviews.freebsd.org/D56177
DeltaFile
+20-6sys/netinet/tcp_lro.c
+20-61 files

FreeBSD/src 9992eb4sys/net if_gif.c if_gif.h, sys/netinet in_gif.c

gif: use hashalloc(9)

Functional change is that on destruction INVARIANTS checks will run.  Also
the mask is no longer hardcoded, so makes it easier to make hash size a
tunable.

Reviewed by:            ae
Differential Revision:  https://reviews.freebsd.org/D56176
DeltaFile
+21-6sys/netinet6/in6_gif.c
+21-6sys/netinet/in_gif.c
+0-21sys/net/if_gif.c
+0-4sys/net/if_gif.h
+42-374 files

FreeBSD/src adba114sys/netinet ip_input.c

netinet: use hashalloc(9) for IP address hash

While here, slightly restyle ip_vnet_init() and use sparse initializer for
pfil_head_args.  There is no functional change wrt to pfil(9) hook
registration.

Differential Revision:  https://reviews.freebsd.org/D56175
DeltaFile
+26-15sys/netinet/ip_input.c
+26-151 files

FreeBSD/src 8e1513dsys/netinet in_pcb.c in_pcb.h, sys/netinet6 in6_pcb.c

inpcb: use hashalloc(9)

While here remove ipi_lbgrouphashmask, as it is always has the same value
as ipi_porthashmask.

Differential Revision:  https://reviews.freebsd.org/D56174
DeltaFile
+30-22sys/netinet/in_pcb.c
+1-2sys/netinet/in_pcb.h
+1-1sys/netinet6/in6_pcb.c
+32-253 files