Commit graph

21125 commits

Author SHA1 Message Date
John Baldwin
5b51147399 ctld: Permit simpler syntax for target LUNs in UCL
Allow the LUN number to be specified as the key for a LUN instead
of requiring it as a "number" field.  If a key is used, permit
a simple string value to be used for non-anymous LUNs.  This permits
replacing:

	lun = [
		{ number = 0, name = zvol_lun },
		{
			number = 1
			backend = ramdisk
			size = 1GB
		}
	]

with:

	lun = {
		0 = zvol_lun
		1 {
			backend = ramdisk
			size = 1GB
		}
	}

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48939
2025-02-26 10:14:53 -05:00
John Baldwin
e49db000c4 ctld: Permit targets to use a string for portal-groups in UCL
In the case that a separate auth-group is not required, this permits
replacing:

	portal-group = { name = pg0 }

with:

	portal-group = pg0

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48938
2025-02-26 10:13:56 -05:00
John Baldwin
b797cc839a ctld: Support anonymous LUN entries in UCL
If a target LUN entry doesn't have a name property, assume it is an
anonymous LUN and parse other properties from the entry to define the
LUN.

This removes the odd support for target LUNs only named by an integer.
My guess is this was meant to implement support for anonymous LUNs
based on how the syntax for this works in the non-UCL case, but the
prior implementation was useless (it just created unconfigured LUNs).

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48937
2025-02-26 10:13:48 -05:00
John Baldwin
67940b204f ctld: Add missing properties to the UCL parser
- Support for "foreign", "offload", and "tag" properties in portal
  group contexts.

- Support for "ctl-lun" and "device-type" properties in LUN contexts.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48936
2025-02-26 10:12:25 -05:00
John Baldwin
e28b758b35 ctld: Be more consistent for auth parameters in the UCL config
The auth-group context required an array of entries for "chap",
"chap-mutual", "initiator-name", and "initiator-portal" whereas the
target context required exactly one entry (and only permitted a single
entry).

Allow either a single entry or an array of entries for these keywords
in both the auth-group and target contexts.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48935
2025-02-26 10:11:30 -05:00
John Baldwin
f3a43b3db8 ctld: Fail UCL configurations with a nested error
Errors from auth groups, portal groups, global luns, and targets were
not propagated out of the main loop.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D49071
2025-02-26 10:11:07 -05:00
John Baldwin
d42a73fb6a ctld: Add a dedicated API between parse.y and the rest of the program
The primary purpose of this is to permit the rest of ctld to use C++.
However, this also has the nice side effect of reducing code
duplication with the UCL parser.

As a general rule, setting of options including error handling for
invalid values, etc. is moved out of parse.y and into conf.c.  The
globals for the current configuration, auth group, portal group, lun,
and target are also moved into conf.c hiding the types from parse.y.
The intention is that all of the functions declared in conf.h will be
extern "C" for use by parse.y and that the backing data structures can
be reimplemented as C++ classes instead of C structures if desired.

A few other small changes are included with this refactoring:

- Warn and fail a configuration that specifies the same LUN multiple
  times for a target.

- Use T_* constants for SCSI device types instead of magic numbers.

- Warn and fail for a few UCL properties that aren't the required type
  including "discovery-auth-group" in a portal group context,
  "auth-type" and "port" in a target context.

- Fix a bug where chap-mutual in a target in UCL would not auto-create
  a new auth-group.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48934
2025-02-26 10:10:33 -05:00
Konstantin Belousov
8c108dccd7 acpidump: do not use pointer arithmetic to check for overflow
Pointer arithmetic overflow is UB.  Convert to unsigned uintptr_t and do
the check there.

PR:	204945
Reported by:	David Binderman <dcb314@hotmail.com>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2025-02-26 07:27:32 +02:00
Bjoern A. Zeeb
c66308d7bc usbconfig: add -l option to dump_device_desc for single line output
Like pciconf -l add a -l to dump_device_desc for usbconfig which will
fold most fields into a single line.  We do filter out some we think
will not be interesting in this case.

While mangling with string output in ways not always anticipated when
the program was initially written this should help to parse the
available devices for programs like fwget(8).  While I had this in
mind for other bits for a while I got prompted by D48678 to finally
do it.

Sponsored by:	The FreebSD Foundation
MFC after:	3 days
Reviewed by:	bapt (LGTM), ziaee (man)
Differential Revision: https://reviews.freebsd.org/D48974
2025-02-24 00:59:06 +00:00
Kristof Provost
08d0120417 snmp_pf: fix rules->label use
We now support multiple lables on a rule, so 'rule' is an array of strings, not
just one string. Adjust the check for 'is there a label?'.

CID:		1471808
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-21 09:49:06 +01:00
Kristof Provost
207f938bc5 snmp_pf: address Coverity remarks about time_t
On most platforms time_t is 64 bits wide, but we assign it to 32 bits
variables. Unfortunately these are SNMP fields that are defined to be 32 bits
wide, so we cannot change this. We are similarly unable to prevent the passage
of time, meaning that time_t must remain 64 bits wide as well.

Explicitly cast to tell Coverity that we're aware of these limitations and do
not wish to be reminded of them.

CID:		1553869
CID:		1557025
CID:		1592232
CID:		1592234
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-21 09:25:57 +01:00
Bjoern A. Zeeb
045a4c108f wlanstats: add -Wno-cast-align back for now
After fixing the obvious build and cast error when moving this from tools
to usr.sbin and removing -Wno-cast-align, re-add it back as at least
powerpc* does not compile without it (amd64, arm64, and i386 were ok).

In general wlanstats may now get a bit more love after 22 years of
being in the tree and being moved at least twice.
But first unbreak things again.

Reported by:	mmel, cperciva (weekly snapshots)
Sponsored by:	The FreeBSD Foundation
Fixes:		61ce422531
MFC after:	3 days
2025-02-20 21:53:09 +00:00
John Baldwin
8206fcc5ef ctladm: portlist -i lists target and initiator names rather than addresses
Sponsored by:	Chelsio Communications
2025-02-20 10:39:50 -05:00
John Baldwin
b277346d24 ctladm: Handle connected hosts for NVMeoF ports
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48776
2025-02-20 10:31:21 -05:00
Bjoern A. Zeeb
61ce422531 wlanstats: move from tools to usr.sbin
wlanstats is an incredible tool to get a quick overview of state
of affairs of wireless by looking at the counters.
And it makes it simple.

Having landed the LinuxKPI HW_CRYPTO bits I was asked by users
what to check and I realised the answer is in wlanstats.

It is annoying even as a developer to manually build it for each
installation but given it's also useful to users and support
make it available with the general installation.
Probably very long overdue.

Adjust the Makefile and make build again on main.
Hook it up to the build conditional on MK_WIRELESS.

Discussed with:	adrian
Sponsored by:	The FreeBSD Foundation
TODO:		man page
MFC after:	3 days
2025-02-19 02:56:59 +00:00
Mark Johnston
649a910e34 bhyve: Avoid holding /dev/pci open unnecessarily
Some device models, LPC in particular, will call pci_host_read_config()
when probing for devices.  Currently this results in pcifd_init()
opening /dev/pci, and thus bhyve holds the fd open even when it's not
needed.

Modify pci_host_{read,write}_config() to open /dev/pci independent of
the global pcifd.  This means that these routines can only be used
during VM initialization, as capsicum will prevent further opens
afterward.  Introduce internal wrappers which use the global pcifd,
intended for the passthru code.

Reviewed by:	jhb
MFC after:	3 weeks
Fixes:		563fd2240e ("bhyve: export funcs for read/write pci config")
Differential Revision:	https://reviews.freebsd.org/D48908
2025-02-14 15:25:08 +00:00
Jamie Gritton
3d11af1e59 jls: fix the -q option to put quotes around all whitespace
PR:		283414
2025-02-13 07:48:18 -08:00
Jamie Gritton
b144e883ca jls: admit that jail parameters with newlines print multiple lines
PR:		283414
Reported by:	dch
2025-02-13 07:47:12 -08:00
John Baldwin
5e6a462277 ctld: Fix parsing of text values for DSCP in UCL parser
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48933
2025-02-12 14:27:53 -05:00
John Baldwin
79a4240b13 ctld: Use preferred style for evaluating result of strcmp
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48932
2025-02-12 14:27:30 -05:00
John Baldwin
f42f7bedab ctld: Fail for missing or invalid CHAP secrets in UCL config
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48931
2025-02-12 14:27:06 -05:00
John Baldwin
64905b38b1 ctld: Fix the isns-period and isns-timeout keywords in the UCL parser
These keywords were setting the wrong configuration value (connection
timeout).

Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48930
2025-02-12 14:26:43 -05:00
John Baldwin
6de7a0d6c4 ctld: Consistently free temporary strings during yacc parsing
The lexer always allocates a duplicate string via strdup for STR
tokens.  The parse handlers did not always free these duplicated
strings after consuming them.

Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48929
2025-02-12 14:26:16 -05:00
John Baldwin
450a84c292 ctld: Some bool-related cleanups
- Convert a few variables from int to bool

- Return bool instead of inverted 0/1 from configuration parsing
  functions and the auth check functions

- Invert the existing dont_daemonize bool into a daemonize boolx

Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48928
2025-02-12 14:25:52 -05:00
John Baldwin
ca8a23d6cb ctld: Drop some #if 0'd debugging traces
Suggested by:	asomers
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48927
2025-02-12 14:25:22 -05:00
Jose Luis Duran
8d9c25c4e1
syslogd: Fix tests when if_epair is not loaded
Take a cue from vnet.subr and abstract module loading, jail creation and
cleanup.

Note that the way jails are created differs slightly from vnet.subr, to
maintain the current style of the tests.

Reported by:	Jenkins
Reviewed by:	markj
Approved by:	emaste (mentor)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D48949
2025-02-12 14:42:09 +00:00
Minsoo Choo
ca4eddea97 src: Use gnu17 as the default C standard for userland instead of gnu99
Tracking newer versions of C (and C++) permits assuming newer language
features in the base system.  Some C11 extensions are already used in
the base system but implemented on top of GNU C extensions such as
_Alignas and _Static_assert.  In some cases the fallback versions in
cdefs.h are more limited than the native C11 extensions.

Even though C11 is the next major version of C, C17 is chosen instead
since C17 does not add new features to C but merely fixes defects in
C11.  It is also well supported by a wide range of clang (7.0.0+) and
GCC (8.1+) versions.

Along with changing the default, this change also removes explicit
requests for c11 via the CSTD variable in various Makefiles.

Libraries and binaries for ZFS continue to use c99.

PR:		284039 (exp-run)
Reviewed by:	imp, arichardson, emaste
Differential Revision:	https://reviews.freebsd.org/D43237
2025-02-11 09:16:25 -05:00
Bryan Drewery
2f17efa0d7 config(5): Fix display of includeoptions 2025-02-10 21:05:26 -08:00
John Baldwin
4dfc2553c3 ctladm: Use nvlist instead of home-rolled name-value lists
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48774
2025-02-05 14:55:16 -05:00
John Baldwin
9e425a8a7e ctld: Move kernel_limits into login.c where it is used
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48771
2025-02-05 14:55:16 -05:00
John Baldwin
0a3e74f55a ctld: Don't specify the TCP port for default iSCSI portal group sockets
portal_group_add_listen already uses the default TCP port if no port
is specified so this was redundant.

Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48770
2025-02-05 14:55:16 -05:00
John Baldwin
aa06023270 ctld: Factor out functions to parse dscp and pcp properties
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48769
2025-02-05 14:55:16 -05:00
John Baldwin
7bad3c3e5f ctld: Write the pidfile once after forking
Don't rewrite the pidfile each time main_loop is called.

PR:		284282
Reported by:	asomers
Reviewed by:	asomers
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48768
2025-02-05 14:55:16 -05:00
Ruslan Bukin
48f91cacc3 bhyve/riscv: clean up SBI handlers.
Similar to kernel SBI clean up patch, do clean up in userspace SBI part:

- use standard SBI error codes;
- remove unused function.

Differential Revision:	https://reviews.freebsd.org/D48829
2025-02-05 09:32:25 +00:00
Ruslan Bukin
6492ef7b83 bhyve: Sleep for a short period after VM_EXITCODE_DEBUG exits
Apply 2e2b8afa52 for RISC-V:

As on amd64 and aarch64 APs will repeatedly exit until they are
brought online, so this hack helps avoid burning CPU time during
guest bootup.

Reviewed by:	corvink, markj
Differential Revision:	https://reviews.freebsd.org/D48811
2025-02-05 09:30:58 +00:00
Ruslan Bukin
d69ab49ce0 bhyve/riscv: fix HSM extension handling.
Pass private data from supervisor as the second argument on secondary
CPU startup.

This is used by Linux guest.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D48807
2025-02-05 09:24:35 +00:00
Enji Cooper
d90e14fc18 mptutil: Capture CAM errors from bus rescan
This will force reporting of CAM errors from rescanning the bus.

PR: 174072
Reviewed by: imp
2025-02-04 20:54:26 -07:00
Olivier Cochard
f16ca171ea man: Remove references to classful networks
Update wording in manual pages to replace references to classful networks with
CIDR notation.

Approved by:	glebius, dhw
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D48853
2025-02-04 22:27:21 +01:00
Jessica Clarke
97350075fe bsdinstall: Switched back to amended single-button finalconfig
Commit ac78e3e9c5 ("bsdinstall: Add "Finish" button to finalconfig")
removed the Exit entry from the menu, renamed OK to Select and added a
Finish in place of the old Exit entry. On the surface this seemed like a
good idea, as at a glance OK wasn't clear that it was selecting an entry
rather than just closing the box, Exit isn't the most obvious term
to use for proceeding through the installer without doing anything, and
it separated out the different cases of "do something extra" and
"continue". However, because bsddialog (and dialog) keep a menu entry
highlighted even when the Cancel (in this case, Finish) button is
selected, this now looks even more confusing, with users easily
believing that they are about to select the Add User option (being
either surprised when it doesn't actually do that, or being confused
about how to not select it).

Instead, go back to the old scheme that fits more with bsddialog's
supported functionality but tweak it to try and improve on the confusing
UI/UX from the past. Specifically, the UI changes compared with the
original version are as follows:

1. The OK button is renamed to Select, as in the current UI
2. The Exit entry is renamed to Finish, mirroring the label of the
   button in the current UI that it replaces

This partially reverts commit ac78e3e9c5.

Reviewed by:	khorben_defora.org
Differential Revision:	https://reviews.freebsd.org/D47229
2025-02-04 17:27:00 +00:00
Ed Maste
ecccb638d4 mountd: Promote missing netmask log to LOG_ERR
Historical network classes are deprecated, but currently still supported
in mountd with a LOG_WARNING-priority message added by Mike Karels in
2021.  Upgrade the log to LOG_ERR well in advance of this becoming a
fatal error.

Reviewed by:	rmacklem
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48795
2025-02-04 11:58:41 -05:00
Alexander Ziaee
8b35839346
gstat: Sync usage/synopsis + tag SPDX
Sort options using the slightly unusual convention used here as well.

MFC after:		3 days
Approved by:		carlavilla (mentor), imp (src)
Differential Revision:	https://reviews.freebsd.org/D48800
2025-02-03 10:06:59 -05:00
Ruslan Bukin
7ac65902d8 bhyve/riscv: fix interrupts-extended property.
Construct interrupts-extended (property of APLIC) properly.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D48713
2025-02-03 11:44:18 +00:00
Ruslan Bukin
6b599b34df bhyve/riscv: remove clock-frequency from CPU node.
Remove CPU clock-frequency property as incorrectly constructed
and not needed.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D48712
2025-02-03 11:42:50 +00:00
Ruslan Bukin
95b8b67f3c bhyve/riscv: add clock-frequency property to DTS.
Add clock-frequency property to the UART adapter node in DTS.

Differential Revision:	https://reviews.freebsd.org/D48699
2025-02-03 11:39:21 +00:00
Gleb Smirnoff
765ad4f039 rpcsec_tls: cleanup the rpctls_syscall()
With all the recent changes we don't need extra argument that specifies
what exactly the syscalls does, neither we need a copyout-able pointer,
just a pointer sized integer.

Reviewed by:		rmacklem
Differential Revision:	https://reviews.freebsd.org/D48649
2025-02-01 01:00:28 -08:00
Gleb Smirnoff
8e5f80da89 rpc.tlsservd: provide parallelism with help of pthread(3)
At normal NFS server runtime there is not much RPC traffic from kernel to
rpc.tlsservd.  But as Rick rmacklem@ explained, the notion of multiple
workers exists to handle a situation when a server reboots and it has
several hundred or thousands of TLS/TCP connections from clients.  Once it
comes back up, all the clients make TCP connections and do TLS handshakes.

So cleanup the remnants of the workers, that left after the conversion of
RPC over netlink(4) transport and restore desired parallelism with help of
pthread(3).

We are processing the TLS handshakes in separate threads, one per
handshake.  Number of concurrent threads is capped by hw.ncpu / 2, but this
can be overriden with -N.

Differential Revision:	https://reviews.freebsd.org/D48570
2025-02-01 01:00:28 -08:00
Gleb Smirnoff
550e8e306a rpc.tlsservd/rpc.tlsclntd: rename 'refno' field to 'cookie'
Since in the kernel and in the API this is now called socket cookie.
No functional change.

Reviewed by:		rmacklem
Differential Revision:	https://reviews.freebsd.org/D48777
2025-02-01 01:00:27 -08:00
Gleb Smirnoff
4df8df92d4 rpc.tlsservd: followup of API refactoring in the previous commit
Userland counterpart of the previous commit.

Reviewed by:		rmacklem
Differential Revision:	https://reviews.freebsd.org/D48567
2025-02-01 01:00:27 -08:00
Gleb Smirnoff
e1b723d5fe rpc.tlsclntd: followup of API refactoring in the previous commit
Userland counterpart of the previous commit.

Reviewed by:		rmacklem
Differential Revision:	https://reviews.freebsd.org/D48565
2025-02-01 01:00:27 -08:00
Gleb Smirnoff
d3d6c9b615 rpc.tlsservd: run netlink(4) service and use new API to get sockets
Userland counterpart of the previous commit.

Note: this change intentionally ignores aspect of multiple workers of
rpc.tlsservd(8).  This also will be addressed in a future commit.

Reviewed by:		rmacklem
Differential Revision:	https://reviews.freebsd.org/D48562
2025-02-01 01:00:27 -08:00