rge: correct SPDX tags to reflect ISC licence
The licence from openbsd and the licence body of each of the file
is the ISC licence, but I had put BSD-2-Clause in the headers.
* Correct the SPDX headers to reflect the ISC licence.
* Remove the '-' at the top of each header file where it's present.
Thanks for kevlo@ for reminding me.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D62422
pfsync: account for second tickover in bulk updates
When one peer requests a bulk update it keeps track of when it sent this
request. The exporting peer includes 'endtime', indicating how long it
took to send the entire update along with its final message.
That allows the receiving peer to verify that the entire update was done
in response to its most recent request. However, due to different second
tickovers this calculation might be off by one.
Use milliseconds internally. This does not change the wire protocol,
'endtime' is still expressed in seconds. When the exporting peer
computes this value it will implicitly round down.
PR: 300824
Sponsored by: Rubicon Communications, LLC ("Netgate")
(cherry picked from commit f3cb62f798070570db00b51138873474c31bbc6a)
dummynet: Ignore DN_QHT_HASH when checking for an unchanged flowset
fsk_attach() sets DN_QHT_HASH in fs->fs.flags when the flowset or its
scheduler has a mask. Userland never sends that flag, so the bcmp() in
config_fs() never matches for such a flowset and re-applying the same
"queue N config ... mask ..." line takes the changed path, which
destroys all queues of the flowset and the packets in them. Firewall
front ends that re-run their dummynet config on every reload hit this.
Take the flag from the existing flowset before the comparison. If the
flowset did change, fsk_attach() computes the flag again.
PR: 298731
Reviewed by: kp
Signed-off-by: Abdul Wasey <w453y.me at gmail.com>
Differential Revision: https://reviews.freebsd.org/D61257
dummynet: Allow AQM reconfiguration of flowsets with traffic
config_aqm() refused to configure CoDel/PIE on a flowset whose
scheduler had a hash table or an instance ("flowset busy"). The check
was there because queues that already exist were left without AQM
state after aqm_cleanup_deconfig_fs(). It had two bad effects:
- a scheduler with a mask always has siht allocated, so CoDel/PIE could
never be configured on "pipe N config ... mask ... codel" or on a
queue of a masked scheduler, even with no traffic at all;
- on the changed-parameters path of config_fs(), fsk_detach() has
already removed the old AQM, so a refusal left the flowset with
DN_IS_AQM set and aqmfp NULL. Changing the weight of a queue while
its pipe carried traffic silently turned it into droptail.
The error never reached userland, only the kernel log.
Instead of refusing, init the AQM status of the queues that exist
after the new AQM is configured, which is what si_new() and q_new()
[12 lines not shown]
dummynet tests: Add CoDel/PIE masked and reconfiguration cases
aqm_masked configures CoDel and PIE on pipes with a mask and CoDel on
a queue of a masked WF2Q+ scheduler. aqm_reconfig changes the
parameters and the AQM of a pipe and of two queues (one masked) while
ping keeps an instance alive, and checks that the AQM is still there
and that traffic still passes afterwards.
PR: 298731
Reviewed by: kp
Signed-off-by: Abdul Wasey <w453y.me at gmail.com>
Differential Revision: https://reviews.freebsd.org/D61258
libpfctl: remove unused pfctl_get_clear_rule()
All in-tree users already use the pfctl_get_clear_rule_h() variant.
This lets us remove a lot of nvlist-based code.
Sponsored by: Rubicon Communications, LLC ("Netgate")
iflib: Cancel stale reset requests when a driver quiesces
A TX watchdog closes admission before the admin task runs. A driver
can then quiesce the datapath from its admin callback and rebuild its
resources. Acting on the earlier watchdog verdict after the callback
can restart a down interface or duplicate the driver's own restart.
Capture reset requests under the context lock before calling the
driver. A successful quiesce cancels both queued requests and those
captured for this pass. A fresh request after quiesce stays queued for
the next pass, which checks IFF_UP before a conditional restart.
Keep the watchdog event for reporting. Request a conditional restart
only while the timed-out datapath still has admission closed.
Check for detach while collecting reset requests. Only the device
selected for the detach failpoint needs the earlier check. Release the
context lock before freeing the taskqueue on failed attach so a late
admin task can acquire the lock, observe detach, and exit.
[5 lines not shown]
sockets: refuse MSG_OOB on a datagram socket
The MSG_OOB is supported by TCP only and I wish we dropped this support.
The sosend_dgram() is now used by UDP only. It could be used for a
different datagram protocol, but no way this protocol could want MSG_OOB.
Differential Revision: https://reviews.freebsd.org/D62305
bootp: provide mbuf to sosend() instead of uio
This is what kernel users of sockets are supposed to do. The kernel BOOTP
client was the last one that didn't.
Differential Revision: https://reviews.freebsd.org/D62413
inpcb: in in_pcbladdr() make an exclusion for kernel BOOTP client
Allow use of unspecified source address in in_pcbladdr() for the kernel
BOOTP client. It needs to send BOOTP/DHCP request with INADDR_ANY source.
We considered other options, but they all look too complex and intrusive.
This tiny hack hidden by #ifdef BOOTP, that is not included in the GENERIC
kernel, would be good enough to keep support for the legacy BOOTP boot.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D62412
Fixes: 713264f6b8bc5f927dd52cf8ffcccfa397034fec
PR: 278043
bootpd(8): add minimal RFC1542 support and improve multihoming
Support the broadcast flag from RFC1542. With this flag a BOOTP client
requests the server to send initial reply as a broadcast, all-ones both on
the IP and on Ethernet layers.
The EDK2 Firmware for bhyve from the sysutils/edk2-bhyve sets the
broadcast flag and is not able to boot if server doesn't support it. This
change makes edk2-bhyve with stock bootpd(8) bootable.
Improve multihoming. With multiple interfaces in the system bootpd does a
bad job sending replies. Set IP_RECVIF on the socket and upon receive
find the interface we received the packet and then its primary IP address
& broadcast. Use the broadcast address later with IP_ONESBCAST socket
option if client requested broadcast reply. Use the primary IP address as
server address in case if sa= is missing in the bootptab(5).
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D62411
ng_btsocket_l2cap: stop using stale hdr pointer after m_pullup
The connectionless-channel pullup may reallocate. hdr was from the
previous pullup. Use m_pkthdr.len instead.
Differential Revision: https://reviews.freebsd.org/D62430
top: implement pid highlighting
Implement PID highlighting. This can be activated by pressing
'L' and entering a PID to highlight. Highlighting can be cleared
by entering '+' as a PID to highlight. This feature is inspired by
the OpenBSD top, which uses 'P' key for that. We have to use 'L'
because 'P' is already used for toggling per-CPU statistics.
Reviewed by: kib
Obtained from: OpenBSD (partially)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61090
(cherry picked from commit 3dcd4a2fd6b84fe962897f3c07e684ce166798a4)
top: allow filtering by command name
top(1) already supports interactive command filtering using
the '/' key. Support it also with a command line
argument '-g' / '--grep'.
Reviewed by: kib
Obtained from: OpenBSD
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61160
(cherry picked from commit d668d96259d568877fa863095fc28bd6c323dd01)
ng_netflow: re-derive pointers after M_CHECK
M_CHECK calls m_pullup, which may reallocate. Three pointers were stale:
evh in the VLAN path and ip in the IP-options path.
Reviewed by: markj, glebius
Differential Revision: https://reviews.freebsd.org/D62429
top: implement pid highlighting
Implement PID highlighting. This can be activated by pressing
'L' and entering a PID to highlight. Highlighting can be cleared
by entering '+' as a PID to highlight. This feature is inspired by
the OpenBSD top, which uses 'P' key for that. We have to use 'L'
because 'P' is already used for toggling per-CPU statistics.
Reviewed by: kib
Obtained from: OpenBSD (partially)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61090
(cherry picked from commit 3dcd4a2fd6b84fe962897f3c07e684ce166798a4)
top: allow filtering by command name
top(1) already supports interactive command filtering using
the '/' key. Support it also with a command line
argument '-g' / '--grep'.
Reviewed by: kib
Obtained from: OpenBSD
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61160
(cherry picked from commit d668d96259d568877fa863095fc28bd6c323dd01)
pkg: Add support for mldsa (ML-DSA-87) signatures
pkg(8) gained an "mldsa" signer backed by OpenSSL's ML-DSA-87
implementation. Teach the bootstrap to verify it so that a repository
signed with it can be bootstrapped.
As in pkg(8), the signed message is the hex-encoded SHA-512 digest of
pkg.pkg, for both PUBKEY and FINGERPRINTS verification, and only
ML-DSA-87 keys are accepted. The signer is only built when OpenSSL is
3.5 or later.
While here, report the actual signer type rather than "rsa" when the
signer for a fingerprint signature cannot be found, and document
SIGNATURE_TYPE=PUBKEY and PUBKEY in pkg(7).
Reviewed by: kevans
MFC after: 1 week
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D62408
pkg: Accept SHA-512 certificate fingerprints
Accept SHA-512 certificate fingerprints ("function: sha512") in the
trusted and revoked fingerprint directories, as pkg(8) does. Trusted
and revoked fingerprints are each compared against the certificate
digest of their own type, so a revocation of either type applies.
Reviewed by: kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62408
pkg: Fix signature length after the $PKGSIGN$ marker
parse_sigtype() only subtracted the length of "<type>$" from the
signature size, not the full "$PKGSIGN:<type>$" marker, so
read_pubkey() copied 9 bytes past the end of the signature buffer
into the signature. The ECC signer happened to tolerate this because
its DER parser ignores trailing bytes, but a signer that checks the
signature length exactly will reject every typed pubkey signature.
Also search for the closing '$' with memchr() bounded by the buffer
length rather than relying on the buffer being NUL-terminated.
While here, drop an unneeded __DECONST: BIO_new_mem_buf() takes a
const pointer.
Reviewed by: kevans
Fixes: 3d0a0dda3a7d ("pkg: finish adding the ECC signer...")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D62407
linux(4): accept EPOLLOUT on inotify, timerfd and epoll descriptors
On Linux, epoll_ctl() accepts any event mask on a pollable file; a
descriptor that can never become writable simply never reports
EPOLLOUT. We turn EPOLLOUT into an EVFILT_WRITE knote, but inotify,
timerfd and kqueue descriptors only support EVFILT_READ, so the call
fails with EINVAL.
Go's runtime registers every non-blocking descriptor with
EPOLLIN|EPOLLOUT|EPOLLRDHUP|EPOLLET. When that fails for an inotify
descriptor, fsnotify ends up reading it in a loop that only ever gets
EAGAIN. With a Go CLI tool under the Linuxulator this kept about eight
cores busy per idle process and wrote megabytes of error logs per
second. Because the read knote is added before the write knote fails,
the descriptor was also left half registered, and a later
EPOLL_CTL_ADD returned EEXIST.
Drop the write bits for these three descriptor types before building
the kevents, so the registration succeeds and only read readiness is
[7 lines not shown]
bhyve: make UART TCP backend not disconnect on EAGAIN
Currently, uart_rxfifo_putchar() disconnects a TCP client when
ttywrite() returns -1. However, EAGAIN does not mean the client
has disconnected.
Thus, ignore EAGAIN and do not disconnect a client unnecessarily.
In this case the character is dropped, as the stdio and tty backends
already do.
Reviewed by: aokblast
Reported by: llm-postcr
Fixes: 1f903953fbf8 ("bhyve: Add raw tcp to uart backend")
MFC after: 3 days
MFC to: stable/15
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D62404
vmm: Use an rms lock to synchronize ioctls
Certain vmm ioctls, such as VM_RAISE_MSI, do not synchronize with
VM_REINIT. This can lead to use-after-frees, as VM_REINIT will free and
reallocate various bits of VM state, such as per-vCPU vlapic structures.
Handle this with a per-VM read-mostly lock which synchronizes ioctl
handlers and VM_REINIT calls. Handlers which freeze a vCPU do not need
additional synchronization and don't acquire the lock at all.
An alternate approach would be to change VM_REINIT to avoid freeing and
allocating new structures when possible. This would fix the obvious
memory safety bugs, but the implementation is more complicated, and it
seems better to explicitly synchronize.
Reported by: Myeonghun Pak
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D61044
LinuxKPI: pci: implement pci_clear_and_set_config_dword()
Implement pci_clear_and_set_config_dword() as a combination of
read and write config_dword. Note while the read function returns
an error value its current implementation can never fail so we do
not have to deal with the error case.
This is needed by an rtw89 update.
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D60687
LinuxKPI: add field_get() and FIELD_GET_SIGNED()
An updated rtw89 driver uses both so add them with the added
__FIELD_GET() not doing any extra checks. We assume the Linux
counterpart will do that and drivers will fail them there, so
no need to add assertions here.
MFC after: 3 days
Reviwed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D60716
LinuxKPI: firmware: ensure name stays valid
The name argument passed into request_firmware_nowait() may only be
valid locally in the calling function and could be out of scope by the
time the task runs; make a copy to ensure it stays valid over the
callback.
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D60630
LinuxKPI: add spinlock_bh guard support
We will likely have to add more DEFINE_LOCK_GUARD_1 cleanup.h
defintions for various lock types. Add the one for spinlock_bh
as a wireless driver update needs it.
MFC after: 3 days
Reviewed by: dumbbell
Differential Revision: https://reviews.freebsd.org/D60631