]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
17 months agonetlink: Fix indentation in netlink_message_writer.c
Mark Johnston [Tue, 17 Jan 2023 14:37:33 +0000 (09:37 -0500)]
netlink: Fix indentation in netlink_message_writer.c

This file is indented with a mixture of tabs and spaces.  No functional
change intended.

Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38100

17 months agonetlink: Make the writers function table static and const
Mark Johnston [Tue, 17 Jan 2023 14:37:21 +0000 (09:37 -0500)]
netlink: Make the writers function table static and const

No functional change intended.

Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38099

17 months agonetlink: Zero-initialize mbuf messages
Mark Johnston [Tue, 17 Jan 2023 14:36:54 +0000 (09:36 -0500)]
netlink: Zero-initialize mbuf messages

Some users of nlmsg_reserve_object() and nlmsg_reserve_data() are not
careful to fully initialize pad and reserved fields, allowing
uninitialized bytes to leak to userspace.  For example, dump_nhgrp()
doesn't set nhm->resvd = 0.

Meanwhile, nlmsg_get_ns_buf() and nlmsg_get_ns_lbuf() zero-initialize
the buffer, so nlmsg_get_ns_mbuf() is inconsistent.  Let's just make
them all behave the same here.

Reported by: KMSAN
Reviewed by: melifaro
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38098

17 months agomixer(3): remove redundant argument in _mixer_readvol()
Christos Margiolis [Tue, 17 Jan 2023 13:08:59 +0000 (08:08 -0500)]
mixer(3): remove redundant argument in _mixer_readvol()

There's no reason to pass the mixer as an argument since we can fetch it
from mix_dev.  No functional change intended.

Reviewed by: markj, hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38076

17 months agoxhci(4): Add new USB IDs.
Dmitry Luhtionov [Tue, 17 Jan 2023 10:43:40 +0000 (11:43 +0100)]
xhci(4): Add new USB IDs.

MFC after: 1 week
Sponsored by: NVIDIA Networking

17 months agoehci(4): Add new USB IDs.
Dmitry Luhtionov [Tue, 17 Jan 2023 10:43:33 +0000 (11:43 +0100)]
ehci(4): Add new USB IDs.

MFC after: 1 week
Sponsored by: NVIDIA Networking

17 months agouhci(4): Add new USB IDs.
Dmitry Luhtionov [Tue, 17 Jan 2023 10:43:24 +0000 (11:43 +0100)]
uhci(4): Add new USB IDs.

MFC after: 1 week
Sponsored by: NVIDIA Networking

17 months agoif_tun: Add basic connectivity test with nc tun support
Tom Jones [Tue, 17 Jan 2023 10:05:00 +0000 (10:05 +0000)]
if_tun: Add basic connectivity test with nc tun support

Reviewed by:    kevans
Sponsored by:   Zenarmor
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D37435

17 months agonetcat: Allow nc to be an if_tun tunnel broker
Tom Jones [Tue, 17 Jan 2023 10:02:06 +0000 (10:02 +0000)]
netcat: Allow nc to be an if_tun tunnel broker

Reviewed by: kevans
Relnotes: yes
Sponsored by:   Zenarmor
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37435

17 months agoMinor changes to force commit these files so new freebsd*.cf files are
Gregory Neil Shapiro [Tue, 17 Jan 2023 06:49:49 +0000 (06:49 +0000)]
Minor changes to force commit these files so new freebsd*.cf files are
built to use the new sendmail-8.17.1/cf tree.

17 months agoSync with vendor sendmail 8.17.1 cf/cf/submit.mc
Gregory Neil Shapiro [Tue, 17 Jan 2023 06:49:07 +0000 (06:49 +0000)]
Sync with vendor sendmail 8.17.1 cf/cf/submit.mc

17 months agonetlink: add snl(3) manpage to the build
Alexander V. Chernikov [Mon, 16 Jan 2023 20:24:49 +0000 (20:24 +0000)]
netlink: add snl(3) manpage to the build

17 months agobsdconfig: correct name of the wpa_supplicant config file
Ceri Davies [Mon, 16 Jan 2023 18:56:45 +0000 (18:56 +0000)]
bsdconfig: correct name of the wpa_supplicant config file

Approved by: maintainer timeout (dteske)
Differential Revision: https://reviews.freebsd.org/D37750

17 months agolagg.4: update wireless example, document laggtype
Ceri Davies [Mon, 16 Jan 2023 18:53:30 +0000 (18:53 +0000)]
lagg.4: update wireless example, document laggtype

The wireless example in lagg(4)'s manpage no longer works, so update.

laggtype is not documented in the manpage other than in the example,
so add a paragraph about it.

While here, move section on rc.conf somewhere it sits more logically.

Reviewed by: pauamma
Differential Revision: https://reviews.freebsd.org/D31315

17 months agolinuxkpi: Define EBADSLT to 57
Jean-Sébastien Pédron [Mon, 2 Jan 2023 22:48:16 +0000 (23:48 +0100)]
linuxkpi: Define EBADSLT to 57

This is the same error code as Linux.

As emaste@ noted in the review, FreeBSD defines the following errno
values in `sys/errno.h`:
* 56 is `EISCONN`
* 57 is `ENOTCONN`

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

17 months agolinuxkpi: Add `memalloc_noreclaim_save()` and `memalloc_noreclaim_restore()`
Jean-Sébastien Pédron [Mon, 2 Jan 2023 20:59:17 +0000 (21:59 +0100)]
linuxkpi: Add `memalloc_noreclaim_save()` and `memalloc_noreclaim_restore()`

They are no-ops.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37933

17 months agolinuxkpi: Define `ioremap_cache()`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 10:36:24 +0000 (11:36 +0100)]
linuxkpi: Define `ioremap_cache()`

It uses the `VM_MEMATTR_WRITE_BACK` flag on FreeBSD.

It replaces `ioremap_wb()` which doesn't exist in Linux. Perhaps it
existed in the past and was removed.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37916

17 months agolinuxkpi: Add `gfp_mask` field to `struct shrink_control`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:56:46 +0000 (10:56 +0100)]
linuxkpi: Add `gfp_mask` field to `struct shrink_control`

bz@ asked if the KBI breakage is a concern here. My answer was that this
is the first time in the DRM drivers in Linux 5.13 (the version I'm
working on) that this structure is initialized (as a variable local to
the function in this case), so it shouldn't be a problem for the DRM
drivers.

However, I can't speak for other drivers maintained outside of the src
tree.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37913

17 months agolinuxkpi: Define `GFP_NOFS` in `linux/gfp.h`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:49:08 +0000 (10:49 +0100)]
linuxkpi: Define `GFP_NOFS` in `linux/gfp.h`

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37910

17 months agobsdconfig, bsdinstall: Refresh mirrors list
Danilo G. Baio [Tue, 10 Jan 2023 01:06:57 +0000 (22:06 -0300)]
bsdconfig, bsdinstall: Refresh mirrors list

The mirrors list is in sync with the Handbook / Mirrors section [1],
which was refreshed a few months ago. Mirrors removed were not
responding or had duplicated addresses (aliases) with another mirror.

1 - https://docs.freebsd.org/en/books/handbook/mirrors/

Reviewed by: philip (clusteradm)
Approved by: philip
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38014

17 months agovm_object: Fix a kernel memory disclosure via the vm_object list sysctl
Mark Johnston [Mon, 16 Jan 2023 15:53:59 +0000 (10:53 -0500)]
vm_object: Fix a kernel memory disclosure via the vm_object list sysctl

Reported by: Chris J-D <chris@accessvector.net>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

17 months agoipsec: Clear pad bytes in PF_KEY messages
Mark Johnston [Mon, 16 Jan 2023 15:46:20 +0000 (10:46 -0500)]
ipsec: Clear pad bytes in PF_KEY messages

Various handlers for SADB messages will allocate a new mbuf and populate
some structures in it.  Some of these structures, such as struct
sadb_supported, contain small reserved fields that are not initialized
and are thus leaked to userspace.

Fix the problem by adding a helper to allocate zeroed mbufs.  This
reduces code duplication and the overhead of zeroing these messages
isn't harmful.

Reviewed by: zlei, melifaro
Reported by: KMSAN
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D38068

17 months agoopenssh: remove mention of now-unused svn:keywords
Ed Maste [Mon, 16 Jan 2023 14:52:00 +0000 (09:52 -0500)]
openssh: remove mention of now-unused svn:keywords

Reported by: gshapiro

17 months agoatomic.9: Remove the stated dependency on types.h
Mark Johnston [Mon, 16 Jan 2023 13:04:01 +0000 (08:04 -0500)]
atomic.9: Remove the stated dependency on types.h

All machine/atomic.h necessarily include sys/atomic_common.h, which
brings in types.h.

Reviewed by: imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38040

17 months agoatomic: Remove cdefs.h includes from atomic_*.h
Mark Johnston [Mon, 16 Jan 2023 13:03:20 +0000 (08:03 -0500)]
atomic: Remove cdefs.h includes from atomic_*.h

Avoid including cdefs.h in system headers.  Both headers now include
types.h, and we can assume that that pulls in cdefs.h (required for
__typeof usage in some of the atomic macro expansions).

No functional change intended.

Reviewed by: imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38039

17 months agomixer: Fix default_unit switching with mixers that have no devices
Mark Johnston [Mon, 16 Jan 2023 13:02:54 +0000 (08:02 -0500)]
mixer: Fix default_unit switching with mixers that have no devices

Apparently it's possible for a mixer to have no devices:

$ mixer -f /dev/mixer2
pcm2:mixer: <USB audio> at ? kld snd_uaudio (rec)
$

If this is the default sound device, an attempt to change the default
unit using mixer -d fails with a segfault because mod_dunit is called
with a NULL device pointer, which is dereferenced to get the parent
mixer.

ctl_dunit seems to be a dummy, i.e., we don't actually need it and can
simply pass the mixer to mod_dunit() directly.  This patch removes that
structure and associated indirection to fix the crash.

Reviewed by: christos, hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38060

17 months agonetlink: fix compatibility with older netlink applications.
Alexander V. Chernikov [Mon, 16 Jan 2023 12:14:35 +0000 (12:14 +0000)]
netlink: fix compatibility with older netlink applications.

Some apps try to provide only the non-zero part of the required message
 header instead of the full one. It happens when fetching routes or
 interface addresses, where the first header byte is the family.
This behavior is "illegal" under the "strict" Netlink socket option,
 however there are many applications out there doing things in the
 "old" way.

Support this usecase by copying the provided bytes into the temporary
 zero-filled header and running the parser on this header instead.

Reported by: Goran Mekić <meka@tilda.center>

17 months agonetlink: fix typo in netlink(4)
Alexander V. Chernikov [Mon, 16 Jan 2023 10:56:10 +0000 (10:56 +0000)]
netlink: fix typo in netlink(4)

Reported by: Ihor Antonov <ihor@antonovs.family>

17 months agortsock: fix socket closure.
Alexander V. Chernikov [Sun, 15 Jan 2023 13:40:28 +0000 (13:40 +0000)]
rtsock: fix socket closure.

Currently `close(2)` erroneously return `EOPNOTSUPP` for `PF_ROUTE` sockets.
It happened after making rtsock socket implementation self-contained (
36b10ac2cd18 ). Rtsock code marks socket as connected in `rts_attach()`.
`soclose()` tries to disconnect such socket using `.pr_disconnect` callback.
Rtsock does not implement this callback, resulting in the default method being
substituted. This default method returns `ENOTSUPP`, failing `soclose()` logic.

This diff restores the previous behaviour by adding custom `pr_disconnect()`
returning `ENOTCONN`.

Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D38059

17 months agopf tests: properly destroy renamed interfaces
Kajetan Staszkiewicz [Mon, 16 Jan 2023 06:19:41 +0000 (07:19 +0100)]
pf tests: properly destroy renamed interfaces

The pfsync:pbr tests leaves  lot of interfaces when they finish, making
other tests slower due to long time of loading scapy from pft_ping.py
when more interfaces are present. When both sides of epair are assigned
to jails, they are both removed from created_interfaces.lst and thus
won't be removed during cleanup from this file. An interface assigned to
jail is stored in created_jails.lst but if it is renamed, it won't be
cleaned up either. Furthermore this test uses identical names for
multiple interfaces across multiple jails which after destroying those
jails adds to overall confusion.

To address this issue a new function is provided for renaming interfaces
in jails and storing their new names in created_jails.lst for deletion
during cleanup.

MFC after: 1 week
Sponsored by: InnoGames GmbH
Differential Revision: https://reviews.freebsd.org/D38024

17 months agoRequire INVARIANTS and WITNESS if DEBUG_VFS_LOCKS is set
Konstantin Belousov [Sun, 15 Jan 2023 21:33:10 +0000 (23:33 +0200)]
Require INVARIANTS and WITNESS if DEBUG_VFS_LOCKS is set

Reported by: pho
Reviewed by: markj, mjg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D38070

17 months agonfsserver: Fix handling of SP4_NONE
Rick Macklem [Sun, 15 Jan 2023 22:07:40 +0000 (14:07 -0800)]
nfsserver: Fix handling of SP4_NONE

For NFSv4.1/4.2, when the client specifies SP4_NONE for
state protection in the ExchangeID operation arguments,
the server MUST allow the state management operations for
any user credentials.  (I misread the RFC and thought that
SP4_NONE meant "at the server's discression" and not MUST
be allowed.)

This means that the "sec=XXX" field of the "V4:" exports(5)
line only applies to NFSv4.0.

This patch fixes the server to always allow state management
operations for SP4_NONE, which is the only state management
option currently supported. (I have patches that add support
for SP4_MACH_CRED to the server. These will be in a future commit.)

In practice, this bug does not seem to have caused
interoperability problems.

MFC after: 2 weeks

17 months agosendmail 8.17.1 included this fix, though in a different location so
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:25:39 +0000 (21:25 +0000)]
sendmail 8.17.1 included this fix, though in a different location so
removing the FreeBSD local code in favor of the vendor branch version

17 months agoAdd -DSTARTTLS CFLAG in order to enable DANE in sendmail builds
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:24:38 +0000 (21:24 +0000)]
Add -DSTARTTLS CFLAG in order to enable DANE in sendmail builds

17 months agoUpdate for new library files in sendmail 8.17.1
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:23:27 +0000 (21:23 +0000)]
Update for new library files in sendmail 8.17.1

17 months agoMerge commit '28fbd2825d216dafca4d991ad96d05b312f4f9a3'
Gregory Neil Shapiro [Sun, 15 Jan 2023 21:20:22 +0000 (21:20 +0000)]
Merge commit '28fbd2825d216dafca4d991ad96d05b312f4f9a3'

Merge vendor sendmail 8.17.1 into HEAD

17 months agoImport sendmail 8.17.1
Gregory Neil Shapiro [Sun, 15 Jan 2023 19:15:36 +0000 (19:15 +0000)]
Import sendmail 8.17.1

17 months agoDocument the mntopts(3) functions.
Kirk McKusick [Sun, 15 Jan 2023 18:20:48 +0000 (10:20 -0800)]
Document the mntopts(3) functions.

The mntopts(3) functions support operations associated with a mount
point. The main purpose of this commit is to document the mntopts(3)
functions that now appear in 18 utilities in the base system. See
mntopts(3) for the documentation details.

The getmntopts() function appeared in 4.4BSD. The build_iovec(),
build_iovec_argf(), free_iovec(), checkpath(), and rmslashes()
functions were added with nmount(8) in FreeBSD 5.0. The getmntpoint()
and chkdoreload() functions are being added in this commit.

These functions should be in a library but for historic reasons are
in a file in the sources for the mount(8) program. Thus, to access
them the following lines need to be added to the Makefile of the
program wanting to use them:

SRCS+= getmntopts.c
MOUNT= ${SRCTOP}/sbin/mount
CFLAGS+= -I${MOUNT}
.PATH: ${MOUNT}

Once these changes have been MFC'ed to 13 they may be made into
a library.

Reviewed by:  kib, gbe
MFC after:    2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37907

17 months agond6: fix panic in lltable_drop_entry_queue()
Alexander V. Chernikov [Sun, 15 Jan 2023 15:10:48 +0000 (15:10 +0000)]
nd6: fix panic in lltable_drop_entry_queue()

nd6_resolve_slow() can be called without mbuf. If the LLE entry
 is not reachable, nd6_resolve_slow() will add this NULL mbuf to
 the holdchain via lltable_append_entry_queue, which will "append"
 NULL to the end of the queue (effectively no-op) and bump la_numhold
 value. When this entry gets freed, the kernel will panic due to the
 inconsistency between the amount of mbufs in the queue and the value
 of la_numhold.

Fix the panic by checking of mbuf is not NULL prior to inserting it
 into the holdchain.

Reported by: kib
MFC after: 3 days

17 months agoman: add Netlink reference to socket(2)
Alexander V. Chernikov [Sat, 14 Jan 2023 17:35:43 +0000 (17:35 +0000)]
man: add Netlink reference to socket(2)

Reviewed by: lwhsu, pauamma, gbe
Differential Revision: https://reviews.freebsd.org/D38054

17 months agounbound: Fix config.h
Cy Schubert [Sun, 15 Jan 2023 06:55:05 +0000 (22:55 -0800)]
unbound: Fix config.h

FreeBSD src does not support HAVE_DECL_EVSIGNAL_ASSIGN. While reviewing
the new config.h after regenerating it, this definition was not removed.

Updating config.h is a manual process of configuring the port and
copying/merging the generated config.h into src. This definition was
missed and not removed (#undef'd).

Fixes: 1838dec31895fd4752fa8631322ab93be0705a66
MFC after: 1 month
X-MFC with: 1838dec31895fd4752fa8631322ab93be0705a66

17 months agounbound: Vendor import 1.17.1
Cy Schubert [Sun, 15 Jan 2023 05:39:31 +0000 (21:39 -0800)]
unbound: Vendor import 1.17.1

Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

MFC after:      1 month

Merge commit '7699e1386a16236002b26107ffd2dcbde375e197' into main

17 months agomixer(3): Add HEADNAME to TAILQ_HEAD declarations
Christos Margiolis [Sun, 15 Jan 2023 02:33:58 +0000 (21:33 -0500)]
mixer(3): Add HEADNAME to TAILQ_HEAD declarations

This allows us to use the TAILQ_PREV and TAILQ_FOREACH_REVERSE_* macros,
useful for an out-of-tree consumer.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D38055

17 months agostress2: Added a regression test
Peter Holm [Sat, 14 Jan 2023 19:19:05 +0000 (20:19 +0100)]
stress2: Added a regression test

17 months agoAllow a comma-separated list in login class capabilities,
Sean Eric Fagan [Sat, 14 Jan 2023 18:37:31 +0000 (10:37 -0800)]
Allow a comma-separated list in login class capabilities,
by adding a version of strcspn that allows quoting.

17 months agoffs_syncvnode(): avoid a LoR for SU
Konstantin Belousov [Sat, 7 Jan 2023 12:22:18 +0000 (14:22 +0200)]
ffs_syncvnode(): avoid a LoR for SU

There is another case where SU code does ffs_syncvnode(dvp) for the
parent directory dvp while the child vnode vp is locked.  Avoid the
issue by relocking and returning ERELOOKUP to indicate the need of
resync.

Reported by: jkim
Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37997

17 months agoStop cleaning MNT_LOCAL on unmount
Konstantin Belousov [Fri, 6 Jan 2023 16:38:44 +0000 (18:38 +0200)]
Stop cleaning MNT_LOCAL on unmount

There is no point in clearing just this flag.  Flags are reset on the
struct mount re-allocation for reuse anyway.

Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D37966

17 months agodepend-cleanup.sh: handle zic moving one level up.
Dag-Erling Smørgrav [Fri, 13 Jan 2023 18:09:51 +0000 (19:09 +0100)]
depend-cleanup.sh: handle zic moving one level up.

MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38044

17 months agotzcode: Silence warnings.
Dag-Erling Smørgrav [Fri, 13 Jan 2023 15:05:36 +0000 (16:05 +0100)]
tzcode: Silence warnings.

* Ignore failure to remove our temp file.
* Avoid a minor memory leak in the -D case.

Reported by: Coverity (CID 150253415025351502538)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38038

17 months agotzcode: Fully initialize structs before use.
Dag-Erling Smørgrav [Fri, 13 Jan 2023 14:59:05 +0000 (15:59 +0100)]
tzcode: Fully initialize structs before use.

Reported by: Coverity (CID 15025421502548)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38037

17 months agotzcode: Avoid memory leak if pthread_setspecific() fails.
Dag-Erling Smørgrav [Fri, 13 Jan 2023 14:57:19 +0000 (15:57 +0100)]
tzcode: Avoid memory leak if pthread_setspecific() fails.

Reported by: Coverity (CID 10184721018474)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38036

17 months agotzcode: Remove access() again, cf. 02ba1d993fa9.
Dag-Erling Smørgrav [Fri, 13 Jan 2023 14:54:21 +0000 (15:54 +0100)]
tzcode: Remove access() again, cf. 02ba1d993fa9.

Reported by: Coverity (CID 1250126)
MFC after: 1 week
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38035

17 months agoTypo, spotted by Matteo.
Poul-Henning Kamp [Sat, 14 Jan 2023 14:53:12 +0000 (14:53 +0000)]
Typo, spotted by Matteo.

17 months agoAdd a SVG version of vector-Beastie.
Poul-Henning Kamp [Sat, 14 Jan 2023 14:30:53 +0000 (14:30 +0000)]
Add a SVG version of vector-Beastie.

(If somebody with a proper vector-based drawingprogram replaced the
polylines with splines, the file would probably shrink by 80%.)

17 months agounbound: Vendor import 1.17.1
Cy Schubert [Fri, 13 Jan 2023 23:52:47 +0000 (15:52 -0800)]
unbound: Vendor import 1.17.1

Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

17 months agostand: dev can't be NULL in default_prasedev
Warner Losh [Fri, 13 Jan 2023 22:44:23 +0000 (15:44 -0700)]
stand: dev can't be NULL in default_prasedev

We pass in the address of a variable to store this value always in the
only place that calls this function, so there is no need to test for NULL.

Sponsored by: Netflix
Notied by: tsoome in D38041

17 months agocal: don't print terminal control characters unless stdout is a TTY
Alan Somers [Fri, 13 Jan 2023 20:19:03 +0000 (13:19 -0700)]
cal: don't print terminal control characters unless stdout is a TTY

A similar change was made in svn r223931, but it was incomplete, working
only when the utility was invoked as "ncal".  Fix the same issue when
invoking as "cal".

PR: 268936
Reported by: Ray Bellis <ray@bellis.me.uk>
MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D38045

17 months agokboot: Use standard set_currdev
Warner Losh [Fri, 13 Jan 2023 21:21:16 +0000 (14:21 -0700)]
kboot: Use standard set_currdev

Use the standard set_currdev instead of the (now very old) copy of
setting currdev and loaddev directly. We do this only when we don't go
find the ZFS pool to boot from.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38012

17 months agokboot: Add hostdisk override
Warner Losh [Fri, 13 Jan 2023 21:21:07 +0000 (14:21 -0700)]
kboot: Add hostdisk override

When hostdisk_override is set, all the /dev devices are hidden, and only
the files in that directory are used. This will allow filesystem testing
on FreeBSD without root, for example. Adjust the parse routine to not
require devices start with /dev (plus fix a leak for an error
condition). Add a match routine to allow the device name to be something
like "/home/user/testing/zfsfoo:" instead of strictly in /dev. Note:
since we need to look at all the devices in the system to probe for ZFS
zpools, you can't generally use a full path to get a 'virtual disk' at
this time.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38011

17 months agokboot: Fetch hostfs_root and bootdev from the environment
Warner Losh [Fri, 13 Jan 2023 21:20:56 +0000 (14:20 -0700)]
kboot: Fetch hostfs_root and bootdev from the environment

Fetch bootdev from the environment variable (so it should be set on the
command line). Default to 'zfs:' which will in the future look for the
first zpool that we can boot from. Prior versions of kboot would set
this from the second argument on the command line.

Fetch hostfs_root from the environment (defaulting to '/'). Prior
versions of kboot would set this from the first arg on the command line.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38010

17 months agokboot: Add ZFS support build glue
Warner Losh [Fri, 13 Jan 2023 21:20:48 +0000 (14:20 -0700)]
kboot: Add ZFS support build glue

Now that all the pieces are in place, allow kboot to be built with ZFS
support.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38009

17 months agokboot: Add support for ZFS volumes
Warner Losh [Fri, 13 Jan 2023 21:20:40 +0000 (14:20 -0700)]
kboot: Add support for ZFS volumes

Add the zfs device and filesystem to config and write the hook we need
to probe zfs since there's not a generic mechanism in place to do that
when ZFS is configured.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38008

17 months agokboot: Add ZFS support to hostdisk
Warner Losh [Fri, 13 Jan 2023 21:20:30 +0000 (14:20 -0700)]
kboot: Add ZFS support to hostdisk

Add helper function to walk through the disk drives we've found to look
for zpools. main.c will still need to call this because the loader
hasn't implemented a good way to 'taste' drives for zpools and/or GELI
partitions (mostly because there's no generic list of candidate
devices).

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38007

17 months agokboot: Rework hostdisk.c to allow easier ZFS support.
Warner Losh [Fri, 13 Jan 2023 21:20:09 +0000 (14:20 -0700)]
kboot: Rework hostdisk.c to allow easier ZFS support.

Keep a list of disks and partitions that we have. Keep track of the
sizes of the media and sector and use that to implement DIOCGMEDIASIZE
and DIOCGSECTORSIZE. Proivde a way to lookup disks by name.

Sponsored by: Netflix
Reviewed by: kevans (prior version)
Differential Revision: https://reviews.freebsd.org/D38013

17 months agostand/zfs: Fix memory leaking on error cases
Warner Losh [Fri, 13 Jan 2023 21:20:00 +0000 (14:20 -0700)]
stand/zfs: Fix memory leaking on error cases

Now that we return an allocated zfs_devdesc, we have to free it. These
frees were missing from the error cases. In addition, simplify the code
a bit for the out of memory case.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38006

17 months agostand/uboot: Explain why we test for NULL here
Warner Losh [Fri, 13 Jan 2023 21:19:47 +0000 (14:19 -0700)]
stand/uboot: Explain why we test for NULL here

Most parsedev routines assume that idev is non-null and can always be
set. Since we break from this pattern in uboot, explain why in a
comment. devparse was invented to put a lot of common code in one place
and to simplify the archsw.arch_getdev code and any dv_parsedev code
called. However, uboot couldn't use devparse at the time because its
device naming scheme slightly different parsing. So, we still use
uboot_parsedev directly from uboot_getdev where dev could be NULL. Add a
comment to this effect.

The match functionality added for ofw likely could be used to clean up
the multiple kludges that are here for uboot's device naming differences
with the normal boot loader. This work will wait for the future.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38042

17 months agostand/ofw: dev can't be NULL here
Warner Losh [Fri, 13 Jan 2023 21:19:39 +0000 (14:19 -0700)]
stand/ofw: dev can't be NULL here

dev can't be NULL here. ofw_common_parsedev is always called via
devparse (indirectly through dv_parsedev() calls there which call it
with the args unchanged). In the past, ofw_getdev could call us with
NULL pointer for the parse-only case, but that's now all handled inside
of devparse for simplicity.

Sponsored by: Netflix
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D38041

17 months agostand: Separate base and cli parts of nvstore
Warner Losh [Fri, 13 Jan 2023 21:19:30 +0000 (14:19 -0700)]
stand: Separate base and cli parts of nvstore

zfs lives in libsa. However, it depends on nvstore (and other things)
that are in common. Fix part of this layering violation by splitting
nvstore into a libsa piece (which is the base implementation) and
keeping a much smaller common piece (to implement the nvstore
command). This just leaves zfs' knowledge of device names that's
specific to common and its calling platform specific init code to
resolve. Add a nvstore.h file for these two parts to communicate private
things and move the public nvstore api from bootstrap.h to stand.h.

Sponsored by: Netflix
Reviewed by: tsoome, kevans
Differential Revision: https://reviews.freebsd.org/D38043

17 months agopf: fix panic on deferred packets
Kristof Provost [Fri, 13 Jan 2023 03:34:20 +0000 (04:34 +0100)]
pf: fix panic on deferred packets

The pfsync_defer_tmo() callout needs to set the correct vnet before it
can transmit packets. It used the rcvif in the mbuf to get this vnet,
but that doesn't work for locally originated traffic. In that case the
rcvif pointer is NULL, and the dereference leads to a panic.

Instead use the sc_sync_if, which is always set (if pfsync is enabled,
at least).

PR: 268246
MFC after: 2 weeks

17 months agoipfw: Add missing 'va' code point name
Jose Luis Duran [Fri, 13 Jan 2023 20:19:34 +0000 (20:19 +0000)]
ipfw: Add missing 'va' code point name

Per RFC 5865, add the 'va' (VOICE-ADMIT, 101100) symbolic name.

Reviewed By: melifaro, pauamma
Differential Revision: https://reviews.freebsd.org/D37508
MFC after: 2 weeks

17 months agoMechanically convert ena(4) to DrvAPI
Justin Hibbits [Fri, 13 Jan 2023 16:04:09 +0000 (17:04 +0100)]
Mechanically convert ena(4) to DrvAPI

Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D37837

17 months agoena: Update driver version to v2.6.2
Arthur Kiyanovski [Tue, 13 Dec 2022 16:58:25 +0000 (16:58 +0000)]
ena: Update driver version to v2.6.2

Bug Fixes:
* Remove timer service re-arm on ena_restore_device failure.
* Re-Enable per-packet missing tx completion print

Minor Changes:
* Switch driver owners from Semihalf to Amazon in man file.

MFC after: 2 weeks
Sponsored by: Amazon, Inc.
Pull Request: https://github.com/freebsd/freebsd-src/pull/637

17 months agoena: Switch driver owners from semihalf to amazon in man file
Arthur Kiyanovski [Tue, 13 Dec 2022 12:34:08 +0000 (12:34 +0000)]
ena: Switch driver owners from semihalf to amazon in man file

1. Update ena.4 manual file to include amazon owner emails.
2. State that the driver is developed by amazon but leave
that it was originally written by Semihalf, similarly to other
drivers in the /share/man/ directory of the FreeBSD source code.
3. Advance year in copyright notice to 2022.

MFC after: 2 weeks
Sponsored by: Amazon, Inc.

17 months agoena: Remove timer service re-arm on ena_restore_device failure
David Arinzon [Sun, 4 Dec 2022 10:37:32 +0000 (12:37 +0200)]
ena: Remove timer service re-arm on ena_restore_device failure

In case the reset sequence fails (ena_destroy_device() followed by
ena_restore_device() calls) during ena_restore_device(), the driver
resources are being freed. After the clean-up, the timer service is
re-armed in order to try and re-initialize the driver state.
But, such an attempt would fail given that the resources are freed.
Moreover, this would actually cause either the system to fail or a
panic.
When the driver fails in ena_restore_device() procedure, the only
recovery is either unloading and loading the driver or instance
reboot.

This change removes the timer service re-arm in case of failure
in ena_restore_device().

MFC after: 2 weeks
Sponsored by: Amazon, Inc.
Fixes: 78554d0c707c ("ena: start timer service on attach")
17 months agoena: Re-Enable per-packet missing tx completion print
Arthur Kiyanovski [Mon, 19 Dec 2022 13:56:44 +0000 (13:56 +0000)]
ena: Re-Enable per-packet missing tx completion print

Commit [1] first added the ena_tx_buffer.print_once member,
so that a message about a missing tx completion is printed only
once per packet (and not every second when the watchdog runs).
In this commit print_once is initialized to true, and is set back
to false after detecting a missing tx completion and printing
a warning about it to dmesg.

Commit [2] incorrectly reverses the values assigned to print_once.
The variable is initialized to be true but is checked to be false
when a missing tx completion is detected. This is never true, and
therefore the warning print for each missing tx completion is never
printed since this commit.

Commit [3] added time passed since last TX cleanup to the missing
tx completions per-packet print. However, due to the issue in commit
[2], this time is never printed.

This commit reverses back the values assigned to ena_tx_buffer.print_once
erroneously by commit [2], bringing back to life the missing tx
completion per-packet print.

Also add a space after "." in the missing tx completion print.

[1] - 9b8d05b8ac78 ("Add support for Amazon Elastic Network Adapter (ENA) NIC")
[2] - 74dba3ad7851 ("Split function checking for missing TX completion in ENA driver")
[3] - d8aba82b5ca7 ("ena: Store ticks of last Tx cleanup")

Fixes: 74dba3ad7851 ("Split function checking for missing TX completion in ENA driver")
Fixes: d8aba82b5ca7 ("ena: Store ticks of last Tx cleanup")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

17 months agokvmclock: Fix initialization when EARLY_AP_STARTUP is not defined
Mark Johnston [Fri, 13 Jan 2023 15:01:00 +0000 (10:01 -0500)]
kvmclock: Fix initialization when EARLY_AP_STARTUP is not defined

To attach to the hypervisor, kvmclock needs to write a per-CPU MSR.
When EARLY_AP_STARTUP is not defined, device attach happens too early:
APs are not yet spun up, so smp_rendezvous only runs the callback on the
local CPU.  As a result, the timecounter only gets initialized on the
BSP, and then timekeeping is broken on SMP systems.

Implement handling for !EARLY_AP_STARTUP kernels: keep track of the CPU
on which device attach ran, and then use a SI_SUB_SMP SYSINIT to
register the rest of the CPUs with the hypervisor.

Reported by: Shrikanth R Kamath <kshrikanth@juniper.net>
Reviewed by: kib, jhb (earlier versions)
Sponsored by: Klara, Inc.
Sponsored by: Juniper Networks, Inc.
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D37705

17 months agoif_lagg: Allow lagg interfaces to be used with netmap
Tom Jones [Fri, 13 Jan 2023 15:26:55 +0000 (15:26 +0000)]
if_lagg: Allow lagg interfaces to be used with netmap

Reviewed by: zlei
Sponsored by: Zenarmor
Sponsored by: OPNsense
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37436

17 months agojail: Avoid multipurpose return value of function prison_ip_restrict()
Zhenlei Huang [Sat, 31 Dec 2022 02:56:58 +0000 (10:56 +0800)]
jail: Avoid multipurpose return value of function prison_ip_restrict()

Currently function prison_ip_restrict() returns true if the replacement
buffer was used, or no buffer provided and allocation fails and should
redo. The logic is confusing and cause possibly infinite loop from
eb8dcdeac22d .

Reviewed by: jamie, glebius
Approved by: kp (mentor)
Differential Revision: https://reviews.freebsd.org/D37918

17 months agojail: Fix regression panic from eb8dcdeac22d
Zhenlei Huang [Fri, 13 Jan 2023 10:15:06 +0000 (18:15 +0800)]
jail: Fix regression panic from eb8dcdeac22d

And possibly infinite loop calling prison_ip_restrict() in
kern_jail_set() [2].

[1] It is possible that prisons do not have any IPv4 or IPv6 addresses.
[2] If prison_ip_restrict() is not provided with prison_ip, when it
    allocates prison_ip successfully, then it should return false to
    indicate not redo prison_ip_restrict() later.

Reviewed by: glebius
Approved by: kp (mentor)
Fixes: eb8dcdeac22d jail: network epoch protection for IP address lists
Differential Revision: https://reviews.freebsd.org/D37906

17 months agojail: Correctly access IPv[46] addresses of prison_ip
Zhenlei Huang [Fri, 13 Jan 2023 09:50:01 +0000 (17:50 +0800)]
jail: Correctly access IPv[46] addresses of prison_ip

* Fix wrong IPv[46] addresses inherited from parent jail
* Properly restrict the child jail's IPv[46] addresses

Reviewed by: melifaro, glebius
Approved by: kp (mentor)
Fixes: eb8dcdeac22d jail: network epoch protection for IP address lists
Differential Revision: https://reviews.freebsd.org/D37871
Differential Revision: https://reviews.freebsd.org/D37872

17 months agonetlink: add netlink to GENERIC@amd64
Alexander V. Chernikov [Fri, 13 Jan 2023 10:11:26 +0000 (10:11 +0000)]
netlink: add netlink to GENERIC@amd64

Netlink is a communication protocol defined in RFC 3549. It is async,
TLV-based protocol, providing 1-1 and 1-many communications between kernel
and userland. Netlink is currently used in Linux kernel to modify, read and
subscribe for nearly all networking states. Interface state, addresses, routes,
firewall, rules, fibs, etc, are controlled via Netlink.

Netlink support was added in D36002. It has got a number of improvements and
first customers since then:
* net/bird2 got netlink support, enabling route multipath in FreeBSD
* netlink-based devd notifications are being worked on ( D37574 ).
* linux(4) fully supports and depends on Netlink

Enabling Netlink in GENERIC targets two goals.
The first one is to provide stability for the third-party userland applications,
so they can rely on the fact that netlink always exists since 14.0 and potentially 13.2.
Loadable module makes life of the app delepers harder. For example, `net/bird2` can be
either build with netlink or rtsock support, but not both.

The second goal is to enable gradual conversion of the base userland tools
to use netlink(4) interfaces. Converting tools like netstat (D36529), route,
ifconfig one-by-one simplifies testing and addressing the feedback.
Othewise, switching all base to use netlink at once may be too big of a leap.

This change targets amd64, the other architectures will follow soon.

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

17 months agotcp_lro: Fix for undefined behaviour.
Hans Petter Selasky [Mon, 28 Nov 2022 22:56:16 +0000 (23:56 +0100)]
tcp_lro: Fix for undefined behaviour.

Make sure the size of the raw[] array in the lro_address union is
correctly set at compile time, so that static code analysis tools
do not report undefined behaviour.

MFC after: 1 week
Sponsored by: NVIDIA Networking

17 months agoxhci(4): Make sure allocated bandwidth is freed in hardware by unconfiguring endpoint.
Cheng, Huiming [Thu, 15 Dec 2022 22:30:11 +0000 (23:30 +0100)]
xhci(4): Make sure allocated bandwidth is freed in hardware by unconfiguring endpoint.

MFC after: 1 week
Sponsored by: NVIDIA Networking

17 months agousb(4): Call optional endpoint_uninit() when changing configuration or alternate...
Hans Petter Selasky [Thu, 15 Dec 2022 22:32:47 +0000 (23:32 +0100)]
usb(4): Call optional endpoint_uninit() when changing configuration or alternate setting.

MFC after: 1 week
Sponsored by: NVIDIA Networking

17 months agopf: default syncookies to adaptive mode
Kristof Provost [Sat, 31 Dec 2022 18:26:24 +0000 (19:26 +0100)]
pf: default syncookies to adaptive mode

The cost of enabling syncookies in adaptive mode is very low (basically
a single atomic add when we create a new half-open state), and the
payoff when under SYN flood is huge.

So, enable adaptive mode by default.

Suggested by:   Eirik Øverby

17 months agopf tests: test fast port re-use with syncookies
Kristof Provost [Sat, 31 Dec 2022 18:23:15 +0000 (19:23 +0100)]
pf tests: test fast port re-use with syncookies

When a src/dst ip/port tuple is re-used before the pf state fully
expires we clean up the state and create a new one, unless syncookies
are enabled.

Test this, by running two back-to-back nc sessions, with a fixed source
port. Move the interface and IP to a different (vnet) jail, to trick the
network stack into letting us do this.

MFC after:      2 weeks
Event:          Aberdeen hackathon 2022
Differential Revision:  https://reviews.freebsd.org/D36886

17 months agopf: fix syncookies in conjunction with tcp fast port reuse
Kristof Provost [Sat, 31 Dec 2022 14:59:10 +0000 (15:59 +0100)]
pf: fix syncookies in conjunction with tcp fast port reuse

Basic scenario: we have a closed connection (In TCPS_FIN_WAIT_2), and
get a new connection (i.e. SYN) re-using the tuple.

Without syncookies we look at the SYN, and completely unlink the old,
closed state on the SYN.
With syncookies we send a generated SYN|ACK back, and drop the SYN,
never looking at the state table.

So when the ACK (i.e. the third step in the three way handshake for
connection setup) turns up, we’ve not actually removed the old state, so
we find it, and don’t do the syncookie dance, or allow the new
connection to get set up.

Explicitly check for this in pf_test_state_tcp(). If we find a state in
TCPS_FIN_WAIT_2 and the syncookie is valid we delete the existing state
so we can set up the new state.
Note that when we verify the syncookie in pf_test_state_tcp() we don't
decrement the number of half-open connections to avoid an incorrect
double decrement.

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

17 months agoRevert "ifnet/API: Move the IfAPI from if_var.h to if.h"
Justin Hibbits [Fri, 13 Jan 2023 00:18:40 +0000 (19:18 -0500)]
Revert "ifnet/API: Move the IfAPI from if_var.h to if.h"

<net/if.h> should be a fully user-facing header, so these APIs don't
belong there.  Revert and will find another approach.

This reverts commit fe33e0ab83d1fbc3c5cd4a2591ba0036e47b1fec.

Fixes: fe33e0ab83d1
Sponsored by: Juniper Networks, Inc.

17 months agortw88: use #define for NL80211_BAND_2GHZ instead of hardcoded number
Bjoern A. Zeeb [Fri, 13 Jan 2023 01:05:01 +0000 (01:05 +0000)]
rtw88: use #define for NL80211_BAND_2GHZ instead of hardcoded number

Use NL80211_BAND_2GHZ instead of a hard coded 0 as array index for the
band.  While LinuxKPI provides a KPI compatibility some of these values
may not necessarily be KBI compatible (in this case they shoule be so
this is a NOP) and after all it is better style.

No functional change.

MFC after: 3 days

17 months agoiwlwifi: mark a declaration for a non-existent function
Bjoern A. Zeeb [Fri, 13 Jan 2023 01:00:00 +0000 (01:00 +0000)]
iwlwifi: mark a declaration for a non-existent function

iwl_trans_pcie_send_hcmd() does not seem to exist (anymore).  Mark it
as __linux__ so we can submit the cleanup with the next upstream run.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

17 months agonfsserver: Fix vrele() panic in nfsvno_open()
Rick Macklem [Fri, 13 Jan 2023 00:45:26 +0000 (16:45 -0800)]
nfsserver: Fix vrele() panic in nfsvno_open()

Commit 65127e982b94 removed a check for ni_startdir != NULL.
This allowed the vrele(ndp->ni_dvp) to be called with
a NULL argument.

This patch adds a new boolean argument to nfsvno_open()
that can be checked instead of ni_startdir, since mjg@ requested
that ni_startdir not be used. (Discussed in PR#268828.)

PR: 268828
Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D38032

17 months agoLinuxKPI: implement irq_get_msi_desc()
Bjoern A. Zeeb [Mon, 28 Nov 2022 18:27:03 +0000 (18:27 +0000)]
LinuxKPI: implement irq_get_msi_desc()

Add irq_get_msi_desc() as a wrapper around a PCI function which will
allocate a single cached value (see comment on struct) for the
msi_desc requested if it doesn't exist yet and handle freeing it
when the PCI device goes away.  We take the values from the ivars of
the native (FreeBSD) device.

While changing struct pci_dev also add the msi_cap field requested by
a wireless driver.

Bump __FreeBSD_version so these changes can be detected.

MFC after: 3 days
X-MFC: move fields to end of struct (alloc happens in linux_pci.c)
Reviewed by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37523

17 months agoLinuxKPI: pci: add [linuxkpi_]pci_get_device()
Bjoern A. Zeeb [Fri, 2 Dec 2022 22:14:09 +0000 (22:14 +0000)]
LinuxKPI: pci: add [linuxkpi_]pci_get_device()

Add a version of pci_get_device() as linuxkpi_pci_get_device()
not (yet) supporting the last argument.
Due to conflicts we cannot redefine it as we would normally do
in LinuxKPI so drivers have to be adjusted.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D37593

17 months agoLinuxKPI: fix pci_alloc_irq_vectors() for MSI
Bjoern A. Zeeb [Mon, 28 Nov 2022 18:05:48 +0000 (18:05 +0000)]
LinuxKPI: fix pci_alloc_irq_vectors() for MSI

pci_alloc_irq_vectors() is given a min and max vector value.
pci_enable_msi() will always succeed independent of these arguments as
it does not know about them.  Further it will only ever allocate
1 "vector" not supporting any other amount.
So upfront check that (a) the available pci_msi_count() can satisfy the
requested minv and (b) given the pci_enable_msi() hard coded limit check
that minv is not larger than 1.
If we cannot satisfy either requirement return an error.

This fixes problems with drivers which check that the returned value
of allocated "vectors" will match their requests and only otherwise try
to fall back to ask for 1 or deal otherwise.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37522

17 months agoLinuxKPI: add (skeleton) functions to make drivers compile
Bjoern A. Zeeb [Sat, 3 Dec 2022 23:00:04 +0000 (23:00 +0000)]
LinuxKPI: add (skeleton) functions to make drivers compile

Add more functions to netdevice.h (netif_napi_add_tx() being the only
one implemented) and add platform_device.h and netlink.h in order to
make driver code compile.
The skeleton functions are used only in very limited scope and not at
all in our usage so far but add (invasive) #ifdef if removed.
Add pr_debug() calls to each of them in order to log a TODO (if DEBUG
compiled in) and someone should hit them in the future.

MFC after: 3 days
Commented on by: hselasky (earlier version)
Differential Revision: https://reviews.freebsd.org/D37599

17 months agoLinuxKPI: add kstrtou32_from_user() and mac_pton()
Bjoern A. Zeeb [Sat, 22 Oct 2022 18:02:58 +0000 (18:02 +0000)]
LinuxKPI: add kstrtou32_from_user() and mac_pton()

While here:
- fix an argument of kstrtouint_from_user() to correct signedness.
- make kstrtou32() call kstrtouint() to avoid duplication (keep inline
  function)

Add kstrtou32_from_user() based on other examples in the file
making it a copy of the now fixed kstrtouint_from_user().

Also add a rudimentarily hacked up version of mac_pton() which is
leanient accepting non-well-formed input but so far only with ':'
separators.  It does not seem to obviously belong to any networking
header file so add it here.

Both new functions are needed for debugfs support for iwlwifi hence
coming together in one commit.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Commented on by: emaste
Differential Revision: https://reviews.freebsd.org/D37088

17 months agomakefs: don't needlessly require directories to exist
Brooks Davis [Thu, 12 Jan 2023 18:19:14 +0000 (18:19 +0000)]
makefs: don't needlessly require directories to exist

If a type=dir entry exists and all contents are directories, files
added with contents=, or symlinks with link= attributes then it doesn't
need to exist.  Just let openat fail in that case.  It's conceivable
this will make debugging some cases weird, but it's sufficent to handle
the way we add /root/.ssh in CheriBSD VM images.

This is a recommit of 794154149f95d0cbc11aade166f9da919747e397 with
bugfixes.

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

17 months agoRevert "makefs: don't needlessly require directories to exist"
Brooks Davis [Thu, 12 Jan 2023 18:21:27 +0000 (18:21 +0000)]
Revert "makefs: don't needlessly require directories to exist"

I pushed prematurely and this version is broken.

This reverts commit 794154149f95d0cbc11aade166f9da919747e397.

17 months agomakefs: don't needlessly require directories to exist
Brooks Davis [Thu, 12 Jan 2023 18:19:14 +0000 (18:19 +0000)]
makefs: don't needlessly require directories to exist

If a type=dir entry exists and all contents are directories, files
added with contents=, or symlinks with link= attributes then it doesn't
need to exist.  Just let openat fail in that case.  It's conceivable
this will make debugging some cases weird, but it's sufficent to handle
the way we add /root/.ssh in CheriBSD VM images.

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

17 months agomakefs: handle mtree link= for ZFS
Brooks Davis [Thu, 12 Jan 2023 18:18:45 +0000 (18:18 +0000)]
makefs: handle mtree link= for ZFS

When a link target is specified use it rather than attempting to read
a potentially non-existant file.

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