]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
18 months agobblog: improve timeout event handling
Michael Tuexen [Tue, 21 Feb 2023 21:38:18 +0000 (22:38 +0100)]
bblog: improve timeout event handling

Extend the BBLog RTO event to deal with all timers of the base
stack. Also provide information about starting, stopping, and
running off. The expiration of the retransmission timer is
reported as it was done before.

Reviewed by: rscheff@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D38710

18 months agovfs_export: Add mnt_exjail to control exports done in prisons
Rick Macklem [Tue, 21 Feb 2023 21:00:42 +0000 (13:00 -0800)]
vfs_export: Add mnt_exjail to control exports done in prisons

If there are multiple instances of mountd(8) (in different
prisons), there will be confusion if they manipulate the
exports of the same file system.  This patch adds mnt_exjail
to "struct mount" so that the credentials (and, therefore,
the prison) that did the exports for that file system can
be recorded.  If another prison has already exported the
file system, vfs_export() will fail with an error.
If mnt_exjail == NULL, the file system has not been exported.
mnt_exjail is checked by the NFS server, so that exports done
from within a different prison will not be used.

The patch also implements vfs_exjail_destroy(), which is
called from prison_cleanup() to release all the mnt_exjail
credential references, so that the prison can be removed.
Mainly to avoid doing a scan of the mountlist for the case
where there were no exports done from within the prison,
a count of how many file systems have been exported from
within the prison is kept in pr_exportcnt.

Reviewed by: markj
Discussed with: jamie
Differential Revision: https://reviews.freebsd.org/D38371
MFC after: 3 months

18 months agotcp: rearrange enum and remove unused variable
Michael Tuexen [Tue, 21 Feb 2023 17:26:49 +0000 (18:26 +0100)]
tcp: rearrange enum and remove unused variable

Rearrange the enum tt_which such that TT_REXMIT is 0. This allows
an extension of the BBLog event RTO in a backwards compatible way.
Remove tcptimers, which was only used in trpt, a utility removed
from the source tree recently.

Reviewed by: glebius@, guest-ccui@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D38547

18 months agoRevert "Port Linuxulator to IfAPI"
Justin Hibbits [Tue, 21 Feb 2023 17:18:36 +0000 (12:18 -0500)]
Revert "Port Linuxulator to IfAPI"

Revert pending netlink fixes, and further fixes to this.

This reverts commit 52d984831d82d97dc132d0d57fca6ee89572799b.

Requested by: dchagin

18 months agobblog: unbreak build
Michael Tuexen [Tue, 21 Feb 2023 17:13:23 +0000 (18:13 +0100)]
bblog: unbreak build

Ensure that tp is always declared and set.

Reported by: Michael Butler
Sponsored by: Netflix, Inc.

18 months agoRevert "unix/dgram: return EAGAIN instead of ENOBUFS when O_NONBLOCK set"
Gleb Smirnoff [Tue, 21 Feb 2023 16:50:07 +0000 (08:50 -0800)]
Revert "unix/dgram: return EAGAIN instead of ENOBUFS when O_NONBLOCK set"

This API change led to unexpected consequences with Go runtime. The
Go runtime emulates blocking sockets over non-blocking sockets and
for that uses available event dispatcher on the target OS, which is
kevent(2) if availabe, with OS independent layer on top.  It expects
that if whatever O_NONBLOCK socket returned ever EAGAIN, then it is
supposed to be reported as writable by the event dispatcher. kevent(2)
would never report a unix/dgram socket, since they never change their
state, they always are writeable.  The expectations of Go are not
literally specified by SUS, however they are in its spirit.  The SUS
specifies EAGAIN for send(2) as "The socket's file descriptor is marked
O_NONBLOCK and the requested operation would block" [1].  This doesn't
apply to FreeBSD unix/dgram socket, it never blocks on send(2).

Thus, changing API trying to mimic Linux was a mistake.  But what about
the problem we tried to fix? Discussed that with Max Dounin of nginx,
and we agreed that the log bomb described shall be fixed on nginx side,
and it actually isn't specific to FreeBSD, may happen with nginx on any
non-Linux system with a certain configuration.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html

This reverts commit 65572cade35a93add2168a7a012f808ac499218b.

18 months agovnet: Make vnet_sys[un]init() static
Zhenlei Huang [Tue, 21 Feb 2023 16:22:23 +0000 (00:22 +0800)]
vnet: Make vnet_sys[un]init() static

These two functions are intended to be used only when allocating or
destroying vnet instances.

No functional change intended.

Reviewed by: kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37955

18 months agojail: Fix redoing ip restricting
Zhenlei Huang [Tue, 21 Feb 2023 15:43:25 +0000 (23:43 +0800)]
jail: Fix redoing ip restricting

`prison_ip_restrict()` is called in loop FOREACH_PRISON_DESCENDANT_LOCKED.
While under low memory, it is still possible that in subsequent rounds
`prison_ip_restrict()` succeed and `redo_ip[46]` flip over from true to
false, thus leave some prisons's IPv[46] addresses unrestricted.

Reviewed by: jamie
Fixes: 8bce8d28abe6 jail: Avoid multipurpose return value of function prison_ip_restrict()
Differential Revision: https://reviews.freebsd.org/D38697

18 months agoi386: whack LINT-NO* kernels
Mateusz Guzik [Tue, 21 Feb 2023 08:35:19 +0000 (08:35 +0000)]
i386: whack LINT-NO* kernels

there is nothing i386-specific about them and equivalent configs already
build for amd64.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D38700

18 months agokern/sysv_ipc.c: use ANSI C function definition
Konstantin Belousov [Tue, 21 Feb 2023 14:00:22 +0000 (16:00 +0200)]
kern/sysv_ipc.c: use ANSI C function definition

Also remove pointless return's.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

18 months agosx: whack set-but-not-used warn in _sx_slock_hard
Mateusz Guzik [Tue, 21 Feb 2023 13:49:14 +0000 (13:49 +0000)]
sx: whack set-but-not-used warn in _sx_slock_hard

Sponsored by: Rubicon Communications, LLC ("Netgate")

18 months agovfs cache: whack set-but-not-used warn in cache_purgevfs
Mateusz Guzik [Tue, 21 Feb 2023 13:48:35 +0000 (13:48 +0000)]
vfs cache: whack set-but-not-used warn in cache_purgevfs

Reported by: kib
Sponsored by: Rubicon Communications, LLC ("Netgate")

18 months agosdt: add __sdt_used
Mateusz Guzik [Tue, 21 Feb 2023 13:43:00 +0000 (13:43 +0000)]
sdt: add __sdt_used

To pacify set-but-not-used warns when compiling without sdt probes.

Reviewed by:
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision:

18 months agonetlink: clear IPv6 embedded scope when dumping route gateways.
Alexander V. Chernikov [Tue, 21 Feb 2023 12:25:58 +0000 (12:25 +0000)]
netlink: clear IPv6 embedded scope when dumping route gateways.

Reported by: zarychtam@plan-b.pwste.edu.pl
MFC after: 3 days

18 months agobblog: add logging of protocol user requests
Michael Tuexen [Tue, 21 Feb 2023 11:07:35 +0000 (12:07 +0100)]
bblog: add logging of protocol user requests

This information was available in trpt and is useful. So provide
a way to get this information via TCP BBLog.

Reviewed by: rscheff@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D38701

18 months agotruss: Add preadv(2) and pwritev(2).
Thomas Munro [Tue, 21 Feb 2023 09:40:14 +0000 (22:40 +1300)]
truss: Add preadv(2) and pwritev(2).

We already knew how to decode readv(2)/writev(2).  Add the versions with
an offset.

Reviewed by:            asomers
Differential Revision:  https://reviews.freebsd.org/D27531
MFC after:              2 weeks

18 months agoMerge commit 'd84e570b54961e8874bbd8de25635eb96be0977e'
Simon J. Gerraty [Tue, 21 Feb 2023 06:13:27 +0000 (22:13 -0800)]
Merge commit 'd84e570b54961e8874bbd8de25635eb96be0977e'

18 months agoVendor import BearSSL hash 79c060e
Simon J. Gerraty [Tue, 21 Feb 2023 06:06:34 +0000 (22:06 -0800)]
Vendor import BearSSL hash 79c060e

18 months agokern: physmem: fix the format string again, i is a size_t
Kyle Evans [Tue, 21 Feb 2023 05:34:33 +0000 (23:34 -0600)]
kern: physmem: fix the format string again, i is a size_t

Fixes the riscv LINT build.

Fixes: 7b5cb32fca26 ("kern: physmem: properly cast %jx [...]")

18 months agonfscommon: Use IS_DEFAULT_VNET() in the vnet initialization
Rick Macklem [Tue, 21 Feb 2023 03:43:37 +0000 (19:43 -0800)]
nfscommon: Use IS_DEFAULT_VNET() in the vnet initialization

Another oopsie.  The vnet initialization function in
nfs_commonport.c for initializing prison0 by testing
curthread->td_ucred->cr_prison == &prison0. This is bogus
and always true.  Replace it with IS_DEFAULT_VNET(curvnet).

MFC after: 3 months

18 months agonfscl: Add NFSD_CURVNET macros to nfsclient syscall
Rick Macklem [Tue, 21 Feb 2023 00:40:07 +0000 (16:40 -0800)]
nfscl: Add NFSD_CURVNET macros to nfsclient syscall

Although the nfsclient syscall is used for client side,
it does set up server side krpc for callbacks.  As such,
it needs to have the vnet set.  This patch does this.
Without this patch, the system would crash when the
nfscbd(8) daemon was killed.

Reported by: freebsd@walstatt-de.de
MFC after: 3 months

18 months agobyacc: Update to 20230201.
Dag-Erling Smørgrav [Mon, 20 Feb 2023 22:35:32 +0000 (23:35 +0100)]
byacc: Update to 20230201.

Note that this enables the backtracking extension, which we had previously left disabled.

PR: 244149, 269425
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38421

18 months agobblog: sync tcp_log_events with Netflix tree
Michael Tuexen [Mon, 20 Feb 2023 20:42:57 +0000 (21:42 +0100)]
bblog: sync tcp_log_events with Netflix tree

This allows the addition of entries to tcp_log_events without
causing conflicts in the Netflix tree.
rrs@ will upstream the related functional changes eventually.

Reviewed by: guest-ccui@, rrs@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D38646

18 months agokern: physmem: properly cast %jx arguments to uintmax_t
Kyle Evans [Mon, 20 Feb 2023 22:11:44 +0000 (16:11 -0600)]
kern: physmem: properly cast %jx arguments to uintmax_t

While we're here, slap prfunc with a __printflike to get compiler
checking on args to catch silly mistakes like this.

Reported by: jrtc27

18 months agotarfs: Really prevent descending into a non-directory.
Dag-Erling Smørgrav [Mon, 20 Feb 2023 21:28:53 +0000 (21:28 +0000)]
tarfs: Really prevent descending into a non-directory.

The previous fix was incorrect: we need to verify that the current node, if it exists, is not a directory, but we were checking the parent node instead.  Address this, add more tests, and fix the test cleanup routines.

PR: 269519, 269561
Fixes: ae6cff89738b
Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38645

18 months agonfsd: Add VNET_SYSUNINIT() macros for vnet cleanup
Rick Macklem [Mon, 20 Feb 2023 21:11:22 +0000 (13:11 -0800)]
nfsd: Add VNET_SYSUNINIT() macros for vnet cleanup

Commit ed03776ca7f4 enabled the vnet front end macros.
As such, for kernels built with the VIMAGE option will malloc
data and initialize locks on a per-vnet basis, typically
via a VNET_SYSINIT().

This patch adds VNET_SYSUNINIT() macros to do the frees
of the per-vnet malloc'd data and destroys of per-vnet
locks.  It also removes the mtx_lock/mtx_unlock calls
from nfsrvd_cleancache(), since they are not needed.

Discussed with: bz, jamie
MFC after: 3 months

18 months agokern: physmem: don't truncate addresses in DEBUG output
Kyle Evans [Mon, 20 Feb 2023 18:54:00 +0000 (12:54 -0600)]
kern: physmem: don't truncate addresses in DEBUG output

Make it consistent with the above region printing, otherwise it appears
to be somewhat confusing.

18 months agonetlink: fix IPv6 route addition with link-local gateway
Alexander V. Chernikov [Mon, 20 Feb 2023 14:24:01 +0000 (14:24 +0000)]
netlink: fix IPv6 route addition with link-local gateway

Currently kernel assumes that IPv6 gateway address is in "embedded"
 form - that is, for the link-local IPv6 addresses, interface index
 is embedded in bytes 2 and 3 of the address.
Fix address embedding in netlink by wrapping nhop_set_gw() in the
 netlink-specific nl_set_nexthop_gw(), which does such embedding
 automatically.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

18 months agoman9: Add an smr(9) manual page
Mark Johnston [Mon, 20 Feb 2023 13:58:19 +0000 (08:58 -0500)]
man9: Add an smr(9) manual page

Also update the UMA manual page to mention its SMR-enabled
functionality, and update locking.9 to mention both epoch and SMR.
Details of its usage are provided in the SMR manual page.

Reviewed by: Olivier Certner, mhorne, kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38108

18 months agoWhen saving a context on arm call the vfp handler
Andrew Turner [Mon, 20 Feb 2023 12:22:11 +0000 (12:22 +0000)]
When saving a context on arm call the vfp handler

When adding kernel VFP support on arm a comparison instruction was
removed, however the branch to vfp_save_state was still conditional.
Remove the conditional check and always call into vfp_save_state as
it could cause unexpected results otherwise.

Sponsored by: Arm Ltd

18 months agoAdd myself to the github code owners file
Andrew Turner [Mon, 6 Feb 2023 09:30:34 +0000 (09:30 +0000)]
Add myself to the github code owners file

18 months agozless(1): handle uncompressed files
Fernando Apesteguía [Sun, 19 Feb 2023 16:31:11 +0000 (17:31 +0100)]
zless(1): handle uncompressed files

In the manual page for zmore(1) and zless(1) it is said that zless(1) is
equivalent to zmore(1) except that it uses less(1) as a pager. However
zmore(1) is able to handle uncompressed files transparently while zless(1)
is not.

Add another case to the switch in lesspipe.sh to handle non-compressed files.

PR: 196437
Reported by: marquis@roble.com
Approved by: mjg@
Differential Revision: https://reviews.freebsd.org/D38674

18 months agostress2: Added a fsck check to the scenario
Peter Holm [Mon, 20 Feb 2023 11:04:24 +0000 (12:04 +0100)]
stress2: Added a fsck check to the scenario

18 months agoping: Add ATF-Python tests
Jose Luis Duran [Mon, 20 Feb 2023 10:23:24 +0000 (10:23 +0000)]
ping: Add ATF-Python tests

ping(8) is an old utility, which has received many changes and updates through the years.
Some of these changes may have introduced small bugs, in part due to the lack of tests.
Attempt to remedy the current situation by introducing a way to easily add tests.

Differential Revision: https://reviews.freebsd.org/D38053

18 months agoRevert "ping: Add ATF-Python tests"
Alexander V. Chernikov [Mon, 20 Feb 2023 10:34:09 +0000 (10:34 +0000)]
Revert "ping: Add ATF-Python tests"

This reverts commit 0343e90f39e0eb2c0f9c3c9271db372cf9d9f454.

18 months agoping: Add ATF-Python tests
Alexander V. Chernikov [Mon, 20 Feb 2023 10:23:24 +0000 (10:23 +0000)]
ping: Add ATF-Python tests

ping(8) is an old utility, which has received many changes and updates through the years.
Some of these changes may have introduced small bugs, in part due to the lack of tests.
Attempt to remedy the current situation by introducing a way to easily add tests.

Differential Revision: https://reviews.freebsd.org/D38053

18 months agotests: add netlink large dump buffer check
Alexander V. Chernikov [Mon, 20 Feb 2023 10:20:23 +0000 (10:20 +0000)]
tests: add netlink large dump buffer check

Differential Revision: https://reviews.freebsd.org/D38665
MFC after: 2 weeks

18 months agobsd.sys.mk: Add NO_WSTRICT_PROTOTYPES like in kernel
Warner Losh [Sun, 19 Feb 2023 07:02:12 +0000 (00:02 -0700)]
bsd.sys.mk: Add NO_WSTRICT_PROTOTYPES like in kernel

Also add NO_WSTRICT_PROTOTYPES like we do for the kernel.

Sponsored by: Netflix

18 months agotail: Retry kevent if the system call was interrupted
Warner Losh [Sun, 19 Feb 2023 03:04:29 +0000 (20:04 -0700)]
tail: Retry kevent if the system call was interrupted

kevent returns EINTR when I suspend / resume. This causes tail -f
and tail -F to exit with interrupt system call. Ignore this error
and try kevent again.

Sponsored by: Netflix

18 months agostand: Better documentation for full-test.sh
Warner Losh [Sun, 19 Feb 2023 02:52:01 +0000 (19:52 -0700)]
stand: Better documentation for full-test.sh

Update now that things have been pushed into the tree.

Sponsored by: Netflix

18 months agonfsd: Enable the NFSD_VNET vnet front end macros
Rick Macklem [Sat, 18 Feb 2023 22:59:36 +0000 (14:59 -0800)]
nfsd: Enable the NFSD_VNET vnet front end macros

Several commits have added front end macros for the vnet
macros to the NFS server, krpc and kgssapi.  These macros
are now null, but this patch changes them to front end
the vnet macros.

With this commit, many global variables in the code become
vnet'd, so that nfsd(8), nfsuserd(8), rpc.tlsservd(8) and
gssd(8) can run in a vnet prison, once enabled.
To run the NFS server in a vnet prison still requires a
couple of patches (in D37741 and D38371) that allow mountd(8)
to export file systems from within a vnet prison.  Once
these are committed to main, a small patch to kern_jail.c
allowing "allow.nfsd" without VNET_NFSD defined will allow
the NFS server to run in a vnet prison.

One area that still needs to be settled is cleanup when a
prison is removed.  Without this, everything should work
except there will be a leak of malloc'd data and mutex locks
when a vnet prison is removed.

MFC after: 3 months

18 months agotests: fix netlink test_dump_ifaces_many test.
Alexander V. Chernikov [Sat, 18 Feb 2023 22:26:32 +0000 (22:26 +0000)]
tests: fix netlink test_dump_ifaces_many test.

Consider only loopback interfaces when counting.
Otherwise, if pf is loaded, 'pflog0' gets added to the vnet,
 breaking the test.

MFC after: 2 weeks

18 months agoSort a list of mentor/mentee relationships.
Joseph Koshy [Fri, 17 Feb 2023 20:51:27 +0000 (20:51 +0000)]
Sort a list of mentor/mentee relationships.

Approved by: gnn (mentor)
Differential Revision: https://reviews.freebsd.org/D38658

18 months agonetlink: do not crash when linux message translation fails.
Alexander V. Chernikov [Sat, 18 Feb 2023 17:41:48 +0000 (17:41 +0000)]
netlink: do not crash when linux message translation fails.

CID: 1498889
MFC after: 2 weeks

18 months agonetlink: fix OOB read in genetlink
Alexander V. Chernikov [Sat, 18 Feb 2023 17:24:59 +0000 (17:24 +0000)]
netlink: fix OOB read in genetlink

CID: 1498863
MFC after: 1 day

18 months agonetlink: initialise error in nl_autobind_port().
Alexander V. Chernikov [Sat, 18 Feb 2023 17:18:57 +0000 (17:18 +0000)]
netlink: initialise error in nl_autobind_port().

CID: 1498877
MFC after: 2 weeks

18 months agonetlink: check result of sooptcopyin().
Alexander V. Chernikov [Sat, 18 Feb 2023 17:15:25 +0000 (17:15 +0000)]
netlink: check result of sooptcopyin().

CID: 1498866
MFC after: 2 weeks

18 months agonetlink: remove redundant check.
Alexander V. Chernikov [Sat, 18 Feb 2023 17:10:39 +0000 (17:10 +0000)]
netlink: remove redundant check.

MFC after: 2 weeks
CID: 1498867

18 months agonetstat.1: Clarify -i and -I priorities
Fernando Apesteguía [Sat, 18 Feb 2023 17:00:29 +0000 (18:00 +0100)]
netstat.1: Clarify -i and -I priorities

netstat(1) allows to specify both -i (all interfaces) and -I <ifname>.
However, when both are specified, -I always overrides -i.
Add a comment where appropriate the same way we do in rm(1) for -f and -i.

PR: 202708
Reported by: demon@
Approved by: manpages (pauamma@)
Differential Revision: https://reviews.freebsd.org/D38654

18 months agonfsd: Add NFSD_VNET() macros to nfs_fha_new.c
Rick Macklem [Sat, 18 Feb 2023 15:45:38 +0000 (07:45 -0800)]
nfsd: Add NFSD_VNET() macros to nfs_fha_new.c

Although it is not 100% obvious if the affinity threads
lists need to be vnet'd when nfsd runs in a prison, I
think it is necessary for the unusual case where the
same file system is exported in multiple prisons.
For this case, the affinity code might try to assign
the RPC to a svc thread that runs in a different prison.
Also, it makes sense to vnet them, since there are
separate svc threads for each prison running nfsd(8).

This patch adds the macros for vnet'ng to nfs_fha_new.c.
The macros are still null, so the only semantics change
is malloc'ng the fha_param structure.

MFC after: 3 months

18 months agomutex(9): correct man page, mtx_trylock_spin returns int not void
Allan Jude [Sun, 22 May 2022 00:13:16 +0000 (00:13 +0000)]
mutex(9): correct man page, mtx_trylock_spin returns int not void

Reviewed by: kib, pauamma, debdrup
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D35283

18 months agonetlink: improve attribute decoding in python tests
Alexander V. Chernikov [Fri, 17 Feb 2023 18:04:53 +0000 (18:04 +0000)]
netlink: improve attribute decoding in python tests

MFC after: 2 weeks

18 months agonetlink: call genetlink notification handler upon successful family
Alexander V. Chernikov [Fri, 17 Feb 2023 17:58:53 +0000 (17:58 +0000)]
netlink: call genetlink notification handler upon successful family
search.

MFC after: 3 days

18 months agonetlink: simplify temporary address allocation in rtnl_handle_getlink().
Alexander V. Chernikov [Fri, 17 Feb 2023 17:57:44 +0000 (17:57 +0000)]
netlink: simplify temporary address allocation in rtnl_handle_getlink().

MFC after: 3 days

18 months agonetlink: fix if_allocdescr() malloc options argument.
Alexander V. Chernikov [Fri, 17 Feb 2023 17:35:28 +0000 (17:35 +0000)]
netlink: fix if_allocdescr() malloc options argument.

The current value was based on the initial revision of D37566 and
 was not updated afterwards.

MFC after: 1 day

18 months agonetlink: validate rtable value in RTM_<NEW|DEL|GET>ROUTE.
Alexander V. Chernikov [Fri, 17 Feb 2023 17:31:40 +0000 (17:31 +0000)]
netlink: validate rtable value in RTM_<NEW|DEL|GET>ROUTE.

Reported by: Stefan Grundmann <sg2342@googlemail.com>
MFC after: 1 day

18 months agorouting: always pass rtentry to add_route_flags().
Alexander V. Chernikov [Fri, 17 Feb 2023 17:20:38 +0000 (17:20 +0000)]
routing: always pass rtentry to add_route_flags().

add_route_flags() uses `rt` prefix data to lookup the the current
 rtentry from the routing table. Update rib_add_route_px() to
 always pass rtentry regardless of the op_flags.

Reported by: Stefan Grundmann <sg2342@googlemail.com>
MFC after: 1 day

18 months agotcp: Don't try to disconnect a socket multiple times.
John Baldwin [Fri, 17 Feb 2023 17:13:53 +0000 (09:13 -0800)]
tcp: Don't try to disconnect a socket multiple times.

When the checks for INP_TIMEWAIT were removed, tcp_usr_close() and
tcp_usr_disconnect() were no longer prevented from calling
tcp_disconnect() on a socket that was already disconnected.  This
triggered a panic in cxgbe(4) for TOE where the tcp_disconnect() on an
already-disconnected socket invoked tcp_output() on a socket that was
already in time-wait.

Reviewed by: rrs, np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D37112

18 months agocxgbe: Queue NIC TLS mbufs internally.
John Baldwin [Fri, 17 Feb 2023 17:07:17 +0000 (09:07 -0800)]
cxgbe: Queue NIC TLS mbufs internally.

Set internal mbuf properties and queue NIC TLS mbuf chains to the
connection's TX queue directly.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D38579

18 months agocxgbe: Move helper functions for mbuf metadata to adapter.h.
John Baldwin [Fri, 17 Feb 2023 17:06:12 +0000 (09:06 -0800)]
cxgbe: Move helper functions for mbuf metadata to adapter.h.

Previously private to t4_sge.c, this allows other parts of the driver
(such as NIC TLS) to use these helpers directly.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D38578

18 months agocxgbe: Allow parse_pkt to internally queue a packet.
John Baldwin [Fri, 17 Feb 2023 17:03:23 +0000 (09:03 -0800)]
cxgbe: Allow parse_pkt to internally queue a packet.

If parse_pkt returns EINPROGRESS, return from cxgbe_transmit
without queueing the packet in a txq.  Use this to move the call
to ethofld_transmit for packet pacing into parse_pkt.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D38577

18 months agonfsd: Get rid of useless "pool" field in nfs_fha_new.c
Rick Macklem [Fri, 17 Feb 2023 15:34:40 +0000 (07:34 -0800)]
nfsd: Get rid of useless "pool" field in nfs_fha_new.c

Since svcpool_create() is now called from an initialization function,
the pool field of fha_params is always non-NULL, so just get
rid of it and the useless check for it being NULL.

MFC after: 3 months

18 months agoBump __FreeBSD_version after linuxkpi changes
Emmanuel Vadot [Fri, 17 Feb 2023 13:57:24 +0000 (14:57 +0100)]
Bump __FreeBSD_version after linuxkpi changes

Needed to add a graphics/drm-515-kmod port.

Sponsored by: Beckhoff Automation GmbH & Co. KG

18 months agolinuxkpi: Add more suspend defines
Emmanuel Vadot [Fri, 17 Feb 2023 13:49:52 +0000 (14:49 +0100)]
linuxkpi: Add more suspend defines

Needed by drm 5.15-lts

Sponsored by: Beckhoff Automation GmbH & Co. KG

18 months agorc.conf.5: clarify source directories
Jamie Landeg-Jones [Thu, 16 Feb 2023 11:55:01 +0000 (12:55 +0100)]
rc.conf.5: clarify source directories

In 454adf0fa4d787bf6e6ff7be0aa6c27a91d2be8e some of the issues reported in the
PR where addressed. This commit adds a clarification about how the prefix of the
directories to be sourced actually behave.

PR: 197152
Reported by: jason.mann+freebsd@gmail.com
Approved by: manpages (bcr@)
Differential Revision: https://reviews.freebsd.org/D38627

18 months agoMFV: zlib 1.2.13.
Xin LI [Fri, 17 Feb 2023 07:57:24 +0000 (23:57 -0800)]
MFV: zlib 1.2.13.

Relnotes: yes
MFC after: 3 days

18 months agonfscommon: Revert use of nfsstatsv1_p in nfs_commonkrpc.c
Rick Macklem [Fri, 17 Feb 2023 01:44:19 +0000 (17:44 -0800)]
nfscommon: Revert use of nfsstatsv1_p in nfs_commonkrpc.c

Commit 9d329bbc9aea converted a lot of accesses to nfsstatsv1
to use nfsstatsv1_p instead.  However, the accesses in
nfs_commonkrpc.c are for client side and should not be
converted.  This patch puts them back in the correct
pre-commit 9d329bbc9aea form.

MFC after: 3 months

18 months agollvm: make sure to use ELFv2 ABI on powerpc64
Piotr Kubaj [Thu, 16 Feb 2023 23:49:43 +0000 (00:49 +0100)]
llvm: make sure to use ELFv2 ABI on powerpc64

Currently LLVM is more or less set up to use ELFv2, but it still defaults to
ELFv1 in some places. This causes lld to generate broken binaries when used
with LTO.

PR: 269455
Approved by: dim
MFC after: 3 days

18 months agokrpc: Replace !jailed() with IS_DEFAULT_VNET()
Rick Macklem [Thu, 16 Feb 2023 22:32:50 +0000 (14:32 -0800)]
krpc: Replace !jailed() with IS_DEFAULT_VNET()

Since svcpool_create() is now called from an initialization function,
!jailed() no longer works.  Replace it with IS_DEFAULT_VNET().

MFC after: 3 months

18 months agozfs: merge openzfs/zfs@57cfae4a2 (master)
Martin Matuska [Thu, 16 Feb 2023 21:38:51 +0000 (22:38 +0100)]
zfs: merge openzfs/zfs@57cfae4a2 (master)

Notable upstream pull request merges:
  #13816 Fix a race condition in dsl_dataset_sync() when
         activating features
  #14402 Prefetch on deadlists merge
  #14410 Improve resilver ETAs
  #14428 Resilver performance tuning
  #14439 Resolve WS-2021-0184 vulnerability in zstd
  #14440 EIO caused by encryption + recursive gang
  #14448 Fix console progress reporting for recursive send
  #14454 Improve arc_read() error reporting
  #14460 Restore FreeBSD to use .rodata
  #14474 Reduce need for contiguous memory for ioctls

Obtained from: OpenZFS
OpenZFS commit: 57cfae4a2f04aaff10c45b3f7975e0fe3ef3e8b8

18 months agopowerpc: remove nexus_get_cpus()
Mitchell Horne [Mon, 13 Feb 2023 17:38:41 +0000 (13:38 -0400)]
powerpc: remove nexus_get_cpus()

It is identical in functionality to root_get_cpus().

Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38494

18 months agokern/clock: remove interrupt reporting from watchdog_fire()
Elliott Mitchell [Thu, 16 Feb 2023 21:18:54 +0000 (17:18 -0400)]
kern/clock: remove interrupt reporting from watchdog_fire()

The interrupt counts may have been valuable in the past, but now DDB can
readily provide them via 'show intrcnt'. This is one of the only
consumers of these counter arrays outside of the interrupt code itself,
and this should be avoided.

Reviewed by: mhorne, fuz
Differential Revision: https://reviews.freebsd.org/D37870

18 months agoClean up additional obsolete MLINKS
Mitchell Horne [Mon, 13 Feb 2023 18:29:12 +0000 (14:29 -0400)]
Clean up additional obsolete MLINKS

Sponsored by: The FreeBSD Foundation
Fixes: d1c7405ef68a ("PCBGROUP.9: remove obsolete man page")
Fixes: 52f9a2823c64 ("rtalloc.9: remove obsolete man page")

18 months agoconfig: address a number of Coverity issues
Kyle Evans [Thu, 16 Feb 2023 20:36:17 +0000 (14:36 -0600)]
config: address a number of Coverity issues

Highlights:
- Various memory leaks
- FILE* leaks
- `tsize` in moveifchanged() is only needed if !changed, and `from_sb`
    is only valid if !changed.
- Simplify trivially true expression
- Sanity check elfdump size output (+ fix variable sizes) (des@)

CID: 1471167100639115053331505275150534915053061505232
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D38643

18 months agoconfig: error out on malformed env/hint lines
Kyle Evans [Thu, 16 Feb 2023 20:36:17 +0000 (14:36 -0600)]
config: error out on malformed env/hint lines

We need these to be assignments, error out if they're not.

While we're here, tag errout as __printflike so that the compiler will
sanity check the format string + args.

CID: 1505293
Reviewed by: emaste, imp
Differential Revision: https://reviews.freebsd.org/D38642

18 months agoconfig: push path() into moveifchanged()
Kyle Evans [Thu, 16 Feb 2023 20:36:16 +0000 (14:36 -0600)]
config: push path() into moveifchanged()

Every caller path()s its arguments anyways, just simplify these and push
path() into moveifchanged().  This fixes a number of memory leaks in the
process since path() allocates memory, which we will now free().

While we're here, make sure we close from_fd/to_fd appropriately.

CID: 14710401471714147204510069071006908
Reviewed by: emaste, imp
Differential Revision: https://reviews.freebsd.org/D38641

18 months agoconfig: fix some common issues with path() usage
Kyle Evans [Thu, 16 Feb 2023 20:36:16 +0000 (14:36 -0600)]
config: fix some common issues with path() usage

None of the callers check that the allocation in path() failed, so let's
check in path() and abort instead of failing.

Along those lines, none of the callers seem to acknowledge that the
returned string needs to be free()d -- let's do that as well.  There are
a couple not addressed in this commit that will be addressed in a future
commit by pushing the path() call down into moveifchanged() instead and
freeing it properly there.

CID: 150527115052501505279
Reviewed by: emaste, imp

18 months agoRevert "cpuset: add --count"
Mateusz Guzik [Thu, 16 Feb 2023 18:12:46 +0000 (18:12 +0000)]
Revert "cpuset: add --count"

The patch introduced a behavior change coming from getopt_long, namely
the entire argument array would be parsed looking for opts, which
affected uses spawning new processes without passing '--' to delimit
where cpuset arguments end. [1]

Apart from that turns out the change had a bug: using CPU_LEVEL_ROOT
instead of CPU_LEVEL_WHICH, returning a different cpuset than intended.
[2]

The intended functionality is provided with nproc(1), which landed after
this change.

As such, revert for the time being.

This reverts commit d9d5f2c042a51a9f0dd69eb1fc349efd81ffa483.

Reported by: Mark Millard [1]
Reported by: jbeich [2]

18 months agoefivar: Really look for labels for the provider with right efimedia
Warner Losh [Thu, 16 Feb 2023 15:53:53 +0000 (08:53 -0700)]
efivar: Really look for labels for the provider with right efimedia

The prior code mistakently thought that the g_consumer that hung off the
provider we found were the right thing to use to find all the glabel
aliases for this node. However, the only way to find that is to iterate
through all the geoms that belong to the glabel geom class, looking for
those geoms with the same name as the provider with the right efimedia.
Do this in a way that caches glabel class, and allows for it to be
absent. Tighten the filter for mounted filesystems to only look
for the ones that are mounted on /dev/.. since the rest of the code
assumes that.

MFC After: 3 days
Sponsored by: Netflix
Reviewed by: corvink, asomers
Differential Revision: https://reviews.freebsd.org/D38619

18 months agoefibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file
Warner Losh [Thu, 16 Feb 2023 15:53:45 +0000 (08:53 -0700)]
efibootmgr: Add --efidev (-u) to discover UEFI's device path to a dev or file

"efibootmgr --efidev unix-path" will return the UEFI device-path to the
file or device specified by unix-path. It's useful for debugging, but
may also be useful for scripting.

Sponsored by: Netflix
Reviewed by: corvink, manu
Differential Revision: https://reviews.freebsd.org/D38617

18 months agoefivar: support device paths as well as mounted paths in path_to_dp
Warner Losh [Thu, 16 Feb 2023 15:53:35 +0000 (08:53 -0700)]
efivar: support device paths as well as mounted paths in path_to_dp

In path_to_dp, allow passing in either the actual device path "eg
/dev/foo/bar" or the path where the device is mounted (say
/mnt/baz/bing). In the former case we'll assume the path within the
device is nothing (the relpath). In the latter, we'll take from the
mount point on down as the relpath.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38616

18 months agoefivar: Allow NULL paths in build_dp
Warner Losh [Thu, 16 Feb 2023 15:53:26 +0000 (08:53 -0700)]
efivar: Allow NULL paths in build_dp

Allow there to be NULL paths in buildp. This lets us return the device
path to the partition, as well as to files on the partition.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38615

18 months agoefivar: Try harder to find label's efimedia
Warner Losh [Thu, 16 Feb 2023 15:53:15 +0000 (08:53 -0700)]
efivar: Try harder to find label's efimedia

If there's no efimedia attribute on the provider, and the provider's a
glabel, then find the 'parent' geom. In this case, the provider's name
is label-type/name, but the geom's label will that of the underlying
device (eg ada0p1). If it is, recurisvely call find_geom_efimedia with
the geom's name, which shuold have the efimedia attribute.

Sponsored by: Netflix
Reviewed by: corvink, manu, asomers
Differential Revision: https://reviews.freebsd.org/D38614

18 months agolibpcap: Make pcap/bpf.h a wrapper around system net/bpf.h
Joseph Mingrone [Mon, 13 Feb 2023 22:06:51 +0000 (18:06 -0400)]
libpcap: Make pcap/bpf.h a wrapper around system net/bpf.h

In the past, we modified pcap/pcap.h to include the system net/bpf.h
rather than libpcap's own pcap/bpf.h.  However, starting around 1.10.2,
libpcap requires a few extern functions defined in pcap/bpf.h to build.
Simply reverting that local change and pulling in pcap/bpf.h is not a
solution, because some ports with '#include <pcap.h>' such as mail/spamd
and net/xprobe require the system net/bpf.h to be pulled in.  To
accommodate both requirements, make pcap/bpf.h a wrapper around the
system net/bpf.h, but retain the extern function definitions.  This is
in preparation for libpcap 1.10.3.

Approved by: cy, philip, emaste, delphij (earlier revision)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38575

18 months agonetlink: fix interface dump.
Alexander V. Chernikov [Thu, 16 Feb 2023 13:17:58 +0000 (13:17 +0000)]
netlink: fix interface dump.

The current code missed interface addition when reallocating
 temporary buffer.
Tweak the code to perform the reallocation first and add
 interface afterwards unconditionally.

Reported by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after: 3 days

18 months agoVendor import of zlib 1.2.13.
Xin LI [Thu, 16 Feb 2023 09:12:35 +0000 (01:12 -0800)]
Vendor import of zlib 1.2.13.

18 months agopfsync: ensure 'error' is always initialised
Kristof Provost [Thu, 16 Feb 2023 08:16:35 +0000 (09:16 +0100)]
pfsync: ensure 'error' is always initialised

Reported by: Herbert J. Skuhra <herbert@gojira.at>
MFC after: 2 weeks

18 months agopfsync: support deferring IPv6 packets
Kristof Provost [Tue, 14 Feb 2023 06:11:38 +0000 (07:11 +0100)]
pfsync: support deferring IPv6 packets

When we send out a deferred packet we must make sure to call
ip6_output() for IPv6 packets. If not we might end up attempting to
ip_fragment() an IPv6 packet, which could lead to us reading outside of
the mbuf.

PR: 268246
Reviewed by: melifaro, zlei
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38586

18 months agoipsec: only update lastused when it changes
Mateusz Guzik [Wed, 8 Feb 2023 09:53:05 +0000 (09:53 +0000)]
ipsec: only update lastused when it changes

to limit cache-line bouncing.

Note that as there is no atomic_store we are hoping the compiler wont
speculatively do the store. It is not employed because the size depends
on target arch.

Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D38433

18 months agoExclude MMCCAM kernels from make universe
Mateusz Guzik [Wed, 8 Feb 2023 22:02:16 +0000 (22:02 +0000)]
Exclude MMCCAM kernels from make universe

They don't provide any value and are quite arbitrary.

Note arm64 GENERIC-MMCCAM was already excluded, just not the NODEBUG
variant.

The option is already build-tested with arm64 LINT kernel.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D38458

18 months agohyperv: Fix Coverity issues in the Hyper-V driver
Robert Herndon [Sun, 12 Feb 2023 05:09:20 +0000 (23:09 -0600)]
hyperv: Fix Coverity issues in the Hyper-V driver

Summary:
Coverity reports the use of two uninitialized variables in the hyperv
driver. Examination shows the variables can be accessed while
uninitialized in error cases. Fix both.

CID: 1365235
CID: 1365236
Sponsored by: Dell Technologies
MFC after: 1w

Test Plan: Changes in use at $WORK

Reviewers: robert.herndon_dell.com, vangyzen, bret_ketchum_dell.com

Subscribers: imp, badger

Differential Revision: https://reviews.freebsd.org/D38551

18 months agonfsd: Wrap nfsstatsv1_p in the NFSD_VNET() macro
Rick Macklem [Thu, 16 Feb 2023 01:39:07 +0000 (17:39 -0800)]
nfsd: Wrap nfsstatsv1_p in the NFSD_VNET() macro

Commit 7344856e3a6d added a lot of macros that will front end
vnet macros so that nfsd(8) can run in vnet prison.
The nfsstatsv1_p variable got missed.  This patch wraps all
uses of nfsstatsv1_p with the NFSD_VNET() macro.
The NFSD_VNET() macro is still a null macro.

MFC after: 3 months

18 months agowc: Make the read buffer static.
Dag-Erling Smørgrav [Thu, 16 Feb 2023 00:40:30 +0000 (00:40 +0000)]
wc: Make the read buffer static.

The read buffer in cnt() is 64 kB, which is a bit excessive for a stack variable.  MAXBSIZE has grown since this code was originally written, and it might grow again in the future.  Since the program is single-threaded and cnt() does not recurse, we can safely make the buffer static.

While there, constify p since it is only used to read.

Sponsored by: Klara, Inc.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38608

18 months agowc: Improve test coverage.
Dag-Erling Smørgrav [Thu, 16 Feb 2023 00:40:22 +0000 (00:40 +0000)]
wc: Improve test coverage.

* Add a test that causes mbrtowc() to return 0.

* Add a test that causes mbrtowc() to return -2.

Sponsored by: Klara, Inc.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38605

18 months agotarfs: Use a separate debug bit for bounce buffer usage.
Dag-Erling Smørgrav [Thu, 16 Feb 2023 00:40:18 +0000 (00:40 +0000)]
tarfs: Use a separate debug bit for bounce buffer usage.

Sponsored by: Juniper Networks, Inc.
Sponsored by: Klara, Inc.
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D38588

18 months agokgssapi: Add macros so that gssd(8) can run in vnet prison
Rick Macklem [Wed, 15 Feb 2023 23:18:46 +0000 (15:18 -0800)]
kgssapi: Add macros so that gssd(8) can run in vnet prison

Commit 7344856e3a6d added a lot of macros that will front end
vnet macros so that nfsd(8) can run in vnet prison.
This patch adds similar macros named KGSS_VNETxxx so that
the gssd(8) daemon can run in a vnet prison, once the
macros front end the vnet ones.  For now, they are null macros.

This is the last commit that adds macros.  The next step is
to change the macros to front end the vnet ones.

MFC after: 3 months

18 months agoefidp: Remove write only variable
Warner Losh [Wed, 15 Feb 2023 23:03:02 +0000 (16:03 -0700)]
efidp: Remove write only variable

Sponsored by: Netflix

18 months agolibefivar: Add note about extra compiler flags
Warner Losh [Wed, 15 Feb 2023 23:02:56 +0000 (16:02 -0700)]
libefivar: Add note about extra compiler flags

Add a note about why we need these extra compiler flags to suppress
warnings. EDK2 upstream code is being used verbatim and as of the last
update these issuse persist, but are benign.

Sponsored by: Netflix
Reviewed by: asomers
Differential Revision: https://reviews.freebsd.org/D38613

18 months agoixgbe(4): Filter out spurious link up indication
Krzysztof Galazka [Wed, 15 Feb 2023 22:35:40 +0000 (14:35 -0800)]
ixgbe(4): Filter out spurious link up indication

Extend SFP+ cage crosstalk fix by re-checking link state after 5ms delay
to filter out spurious link up indication by transceiver with no fiber
cable connected.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: Gowtham Kumar Ks <gowtham.kumar.ks@intel.com>
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D38395

18 months agoixl(4): Fix MAC/VLAN filters accounting
Krzysztof Galazka [Wed, 15 Feb 2023 22:28:01 +0000 (14:28 -0800)]
ixl(4): Fix MAC/VLAN filters accounting

- Account for a filter required to enable reception of untagged frames
while registering and unregistering VLANs to avoid trying to add more
filters than HW supports

- While adding MAC/VLAN filters, pre-set matching method field in the
Admin Queue Command response buffer to expected error value to work
around an issue with some FW versions, which do not update that field if
operation fails, and be able correctly track which filters were
configured in HW.

- Remove unused IXL_MAX_FILTERS macro definition

- Update number of available MAC/VLAN filters as in newer FW versions it
was decreased by one.

- Simplify i40e_dma_mem structure

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Signed-off-by: Eric Joyner <erj@FreeBSD.org>
Reviewed by: erj@
Tested by: Gowtham Kumar Ks <gowtham.kumar.ks@intel.com>
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D37457