Commit graph

10648 commits

Author SHA1 Message Date
Ed Maste 75be7e3027 sysctl: emit a newline after NULL node descriptions
Previously when printing the sysctl description (via the -d flag) we
omitted the newline if the node provided no description (i.e., NULL).
This could be observed via e.g. `sysctl -d dev`.

PR:		44034
Reviewed by:	zlei
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42112
2023-10-09 22:48:53 -04:00
Benedict Reuschling 3ddd961db1 mount_nfs(8): Indicate that the -t option is deprecated
In mount_nfs.c the -t option is deprecated and advises to use
timeout=<N> instead. However, since that refers to NFS over UDP, which
is not used nowadays, mark this option as deprecated in the man page.

PR:		260611
Suggested by:	rmacklem
2023-10-08 13:57:47 +00:00
Kristof Provost 7ce98cf2f8 pfctl: fix incorrect mask on dynamic address
A PF rule using an IPv4 address followed by an IPv6 address and then a
dynamic address, e.g. "pass from {192.0.2.1 2001:db8::1} to (pppoe0)",
will have an incorrect /32 mask applied to the dynamic address.

MFC after:	3 weeks
Obtained from:	OpenBSD
See also:	https://ftp.openbsd.org/pub/OpenBSD/patches/5.6/common/007_pfctl.patch.sig
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Event:		Oslo Hackathon at Modirum
2023-10-06 18:11:28 +02:00
Mina Galić 70a0fb43f9 growfs: make exit codes more consistent
We have overused err(1), so it's hard to distinguish when an error is
very, very serious, and when it's just a user-error, or even harmless.

This patch changes the current behaviour to distinguish between the
following three:

1 for usage errors
2 for recoverable errors
3 or higher for unrecoverable errors

Reviewed by:	jilles, pauamma_gundo.com, des
Differential Revision:	https://reviews.freebsd.org/D27161
2023-10-06 15:02:40 +02:00
Kyle Evans 9b03a5de73 bectl: fix some mandoc -Tlint complaints
The EXAMPLES mis-comments caused an obnoxious amount of blank space
above SEE ALSO when rendered by mandoc to a terminal.  The missing
termination of .Xo meant the description of -h ran together with the
subcommand synopsis. The other changes were generally ignored tags due
to context that simply don't need to be there.

Provoked by:	grahamperrin
2023-10-04 21:26:55 -05:00
Jose Luis Duran 4b38c532ef mount.8: Mention tarfs(5)
Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/856
2023-10-04 11:52:40 -04:00
Olivier Certner 8d7a48d367 sysctl(8): Mention more security.bsd knobs; Refer to security(7)
Reviewed by:            mhorne, pauamma_gundo.com, emaste
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D41113
2023-09-28 12:05:47 -03:00
Zhenlei Huang 12349f3889 ipfw.8: Adjust section for loader tunables
Move the descriptions of loader tunables from section 'SYSCTL VARIABLES'
to section 'LOADER TUNABLES'.

See also 49197c391b (ipfw: Add sysctl flag CTLFLAG_TUN to loader tunables).

MFC after:	2 days
Differential Revision:	https://reviews.freebsd.org/D41981
2023-09-28 12:58:44 +08:00
John Baldwin eba230afba Purge more stray embedded $FreeBSD$ strings
These do not use __FBSDID but instead use bare char arrays.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D41957
2023-09-25 07:54:56 -07:00
John Baldwin 701468baa4 ifconfig/ifvlan.c: Whitespace fix 2023-09-23 15:03:25 -07:00
R. Christian McDonald 2a78083fc2 route(8): fix route not found exit code and warn with netlink
Fix route(8) incorrectly returning a zero exit code even when unable to
find the specified route with route -n get <route>.

Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D41882
2023-09-19 19:34:02 +02:00
Dag-Erling Smørgrav a2d1360142 ping: The -C option is also supported for IPv6.
MFC after:	3 days
Sponsored by:	Klara, Inc.
Sponsored by:	NetApp, Inc.
Reviewed by:	rscheff, allanjude
Differential Revision:	https://reviews.freebsd.org/D41881
2023-09-19 10:47:11 +02:00
Dag-Erling Smørgrav 4cd9d804ae libipf: fix parser error message.
MFC after:	1 week
Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D41652
2023-08-31 22:15:54 +02:00
Gleb Smirnoff 6f3947be2a ifconfig: fix 'ifconfig -l link'
The rtnetlink(4) RTM_GETADDR does not list link level addresses, thus
the correct match for interfaces that have a link level address should
be based on what was returned by RTM_GETLINK.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D41586
2023-08-25 10:31:55 -07:00
Gleb Smirnoff 31016aa0be ifconfig: fix 'ifconfig -l ether'
When matching interfaces for being Ethernet, use same trick that
the link module does - pass if_type through convert_iftype().
That restores historicaly behaviour of listing lagg(4) ports.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D41585
2023-08-25 10:31:26 -07:00
Gleb Smirnoff 24a81a968d ifconfig: fix logical error in interface matching for '-l ether'
This affects only ifconfig(8) compiled WITHOUT_NETLINK_SUPPORT, which
is not the default.

Reviewed by:		melifaro
Differential Revision:	https://reviews.freebsd.org/D41584
Fixes:			d1cd0344f7
2023-08-25 10:30:25 -07:00
Simon J. Gerraty 1554ba03b6 Add mac_grantbylabel
This module allows controlled privilege escallation via mac labels
securely associated with a process via mac_veriexec.

There are over 700 PRIV_* but we can compress many of them into
a single GBL_* thus constraining the size of gbl labels.

The goal is to allow a daemon to run as an unprivileged process while
still being able a set of privileged operations needed.

We add APIs to libveriexec so that userland processes can check labels
and an exec_script API that allows a suitably labeled process to run
something like a python interpreter directly if necessary;
overcomming the 'indirect' flag applied to the interpreter.

Add -l option to sbin/veriexec to report labels.

Reviewed by:	stevek
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D41431
2023-08-24 17:42:11 -07:00
Robert Wing 760987ecd3 bectl: make mount subcommand less verbose
The mount subcommand currently produces output such as:
    # bectl mount <bootenv>
    Successfully mounted <bootenv> at <mountpoint>

This commit changes it to only print the mountpoint:
    # bectl mount <bootenv>
    <mountpoint>

This makes it easier to script the mount subcommand. If an error occurs
while mounting, an error message is printed to stderr and bectl will
exit with a non-zero value.

PR:             273180
Reviewed by:    kevans, asomers
Differential Revision:	https://reviews.freebsd.org/D41562
2023-08-23 10:45:01 -08:00
Ed Maste 4722ceb7d5 Use 115200 bps by default for serial communication
9600 was a standard baud rate decades ago, but 115200 is now more common
so choose defaults that are useful to the largest number of users.

Note that boot0sio does not support rates above 9600 so it remains
unchanged.

Reviewed by:	bz, imp, manu
Relnotes:	Yes
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36295
2023-08-17 13:31:38 -04:00
Warner Losh 05248206f7 Remove $FreeBSD$: one-line bare tag
Remove /^\s*\$FreeBSD\$$\n/
2023-08-16 11:55:20 -06:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh c857356409 Remove $FreeBSD$: alt one-line .c pattern
Remove /^\s*__RCSID\("\$FreeBSD\$"\);\n/
2023-08-16 11:54:53 -06:00
Warner Losh da5432eda8 Remove $FreeBSD$: alt two-line .c pattern
Remove /^\s*__RCSID\("\$FreeBSD\$"\);\n\n/
2023-08-16 11:54:48 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Warner Losh 2a63c3be15 Remove $FreeBSD$: one-line .c comment pattern
Remove /^/[*/]\s*\$FreeBSD\$.*\n/
2023-08-16 11:54:29 -06:00
Warner Losh 42b388439b Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:23 -06:00
Warner Losh b3e7694832 Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:16 -06:00
Bjoern A. Zeeb a1df36f1b9 devmatch: introduce quiet command line option
In setups without hints whatsoever one can get a long list of
"Can't read linker hints file" error messages during boot.
Add a -q/--quiet option which would suppress the noise and leave
space for more essential information.

While here switch to a pre-defined exit code from sysexits.

MFC after:	4 weeks
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D41443
2023-08-15 22:54:48 +00:00
R. Christian McDonald 9f2cddd261 ping: use the in6_addr buffer when parsing src address as AF_INET6
Reviewed by:	kp
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-08-08 23:21:49 +02:00
Kristof Provost f8b4f9aab5 pfctl: optionally clarify which anchors are layer 3 and which are Ethernet
When listing anchors pfctl lists both 'regular' layer 3 anchors and
Ethernet anchors. It's possible to have the same anchor name in both,
which can be confusing.

Mitigate this a little by explicitly marking where the Ethernet anchors
start. Avoid breaking scripts by only doing this at the second level
of verbosity.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-08-07 19:59:50 +02:00
Mariusz Zaborski 2ea65afbd1 md5: extend capabilites
In 4849767cb1, we did a large refactor of the md5(1) source code.
One of them is that instead of reading data using read(2) syscall, we
are using binary stream input (fread(3)).

fread(3) requires additional Capsicum capabilities:
sha256 CAP operation requires CAP_FSTAT, descriptor holds CAP_READ
sha256 RET fstat -1 errno 93 Capabilities insufficient

Reviewed by:	des
Differential Revision:	https://reviews.freebsd.org/D41348
2023-08-07 14:19:26 +02:00
Kirk McKusick 4ce2a2db41 Update newfs(8) and tunefs(8) manual pages.
Delete note that UFS/FFS filesystems running with journaled soft updates
cannot run background fsck as 344b5bf made it possible to do so.

MFC-with:     344b5bf
Sponsored-by: The FreeBSD Foundation
2023-08-05 23:40:26 -07:00
Kirk McKusick 02b7bf07c5 Improve dumpfs(8) error messages when a cylinder group read fails.
Previously dumpfs(8) exited when a cylinder group read failed (such
as a cylinder-group check-hash failure). Now an error message
indicating the cylinder group number and the type of failure is
printed and the output continues for the remaining cylinder groups.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-08-05 23:10:15 -07:00
Andrius V abe10d21b4 nvmecontrol: fix typos
PR:		261911
Reviewed by:	kp
2023-08-03 12:14:19 +02:00
Kirk McKusick 344b5bf825 Support background fsck_ffs(8) on filesystems using journaled soft updates
An earlier addition of code to fsck_ffs(8) allowed it to support
snapshots when running with journalled soft updates. Further
functionality has now been added to fsck_ffs(8) to allow it to use
snapshots to run in background on live filesystems running with
journaled soft updates. This commit enables the use of this functionality.

Tested-by:    Peter Holm
Sponsored-by: The FreeBSD Foundation
MFC-after:    2 weeks
2023-08-01 13:17:02 -07:00
Mark Johnston a94158d255 dhclient tests: Serialize pcp tests 2023-07-31 11:01:43 -04:00
Kirk McKusick 6f0ca273a3 Add diagnostics to fsck_ffs(8) for journaled soft-updates debugging.
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-26 14:50:02 -07:00
Kirk McKusick d059e44b80 Add quitclean command to fsdb(8) to request a filesystem not be marked dirty.
A new command, quitclean, is added to fsdb(8) to request that the
filesystem not be marked as needing a full fsck(8). This is useful
when creating deliberately bad filesystem images to be used to check
that fsck is properly able to clean them up.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-25 19:42:41 -07:00
Kirk McKusick d51bdf327d Have fsdb(8) only mark a filesystem dirty when it is modified.
Until this update, the fsdb(8) command always marked a filesystem
as needing a full fsck unless it was run with the -n flag which
allowed no changes to be made.

This change tracks modifications to the filesystem. Two types of
changes are tracked. The first type of changes are those that are
not critical to the integrity of the filesystem such as changes to
owner, group, time stamps, access mode, and generation number. The
second type of changes are those that do affect the integrity of
the filesystem including zeroing inodes, changing block pointers,
directory entries, link counts, file lengths, file types, and file
flags.

When quitting having made no changes or only changes to data that
is not critical to filesystem integrity, the clean state of the
filesystem is left unchanged. But if filesystem critical data are
changed then fsdb will set the unclean flag which will require a
full fsck to be run before the filesystem can be mounted.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-25 19:29:05 -07:00
Kirk McKusick 4d512b0735 Debugging output additions. No functional changes intended.
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-25 14:03:43 -07:00
Warner Losh efff068cbf camcontrol: Migrate to modern uintXX_t from u_intXX_t
As per https://lists.freebsd.org/archives/freebsd-scsi/2023-July/000257.html
move to the modern uintXX_t.

MFC After:	3 days
Sponsored by:	Netflix
2023-07-24 21:32:57 -06:00
Kristof Provost 010ee43f56 pf: initial SCTP support
Basic state tracking for SCTP. This means we scan through the packet to
identify the different chunks (so we can identify state changes).

MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40862
2023-07-21 12:32:18 +02:00
Kristof Provost 0bd4a6837c pfctl: SCTP can have port numbers
MFC after:	3 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D40861
2023-07-21 12:32:18 +02:00
Navdeep Parhar a29916a6f8 ifconfig_netlink.c: whitespace cleanup.
No functional change.
2023-07-20 10:54:56 -07:00
Navdeep Parhar 88284368fa ifconfig: Shift unsigned value to avoid UB.
Reported by:	kib@
2023-07-20 10:54:56 -07:00
Navdeep Parhar 47b1fef6fb ifconfig: Fix the display of capabilities in the netlink based code.
The capabilities in if_capabilities2/if_capenable2 are reported in the
second 32b and were not being displayed correctly.  v does not need to
be advanced because v[i / 32] is the correct 32b value already.

Sponsored by:	Chelsio Communications

Reviewed by:	kib@
Differential Revision:	https://reviews.freebsd.org/D41107
2023-07-20 10:26:18 -07:00
Kirk McKusick 239597e030 Text format cleanups. No functional changes intended.
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-07-17 17:29:09 -07:00
R. Christian McDonald 4b426cf3a4 libbe: recursively promote deep BE datasets
beadm will recursively promote deep BE datasets. In order to match the
beadm behavior, we need to recursively iterate over child filesystems
and promote them along the way.

This patch further refines the work from D40903, completing the fix for
promotion.

Reviewed by:	kevans, rew
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40972
2023-07-17 14:08:32 -05:00
John Baldwin 39248950a0 nvmecontrol.8: Fix a few formatting nits. 2023-07-13 17:10:36 -07:00
Luiz Amaral 6fc7fc2dbb pfsync: transport over IPv6
Implement pfsync over IPv6.

Submitted by:	Luiz Amaral <email@luiz.eng.br>
Submitted by:	Naman Sood <naman@freebsdfoundation.org>
Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40102
2023-07-13 08:09:42 +02:00
Kyle Evans 5d0826017f libbe: promote activated BEs all the way
This matches the beadm behavior; generally, we need to keep promoting
until the BE is no longer a clone from a snapshot.  This fixes scenarios
where the dataset associated with a BE's origin is itself a clone,
activating the BE previously would promote it to a clone of the origin's
origin.

We could keep using be_get_dataset_props here, except for two
annoyances:

1.) I couldn't find a clean way to just clear an nvlist rather than
    having to re-alloc it, and I didn't want to just remove the one prop
    we're inspecting out of it.

2.) That's a lot of overhead when all we want to do is fetch the origin
    anyways.

Note that this is not a complete fix, but it does fix the majority of
cases; deep BE subordinates are still notably broken, pending a patch
from Christian.

Reported by:	R. Christian McDonald <rcm@rcm.sh>
Reviewed by:	rew
Differential Revision:	https://reviews.freebsd.org/D40903
2023-07-11 00:44:13 -05:00
Eric van Gyzen eb8d2e123d dhclient: fix build on i386
Only i386 still uses a 32-bit time_t.  I knew this, and I still failed
to compile-test on i386.  My bad.

Reported by:	cy
Fixes:		c210cac00f ("dhclient: fix time parsing for leases...")
Sponsored by:	Dell EMC Isilon
2023-07-10 15:03:39 -05:00
Alex Bahm c210cac00f dhclient: fix time parsing for leases expiring after 2038
Convert lease parsing to timegm to calculate timestamp. For reference, when
writing the lease, we use gmtime to convert the timestamp to struct tm.

Reviewed By:	markj, vangyzen
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D40760
2023-07-10 11:00:34 -05:00
Jessica Clarke 1e635e87e3 ldconfig: Use __PATH_ELF_HINTS("32") over _PATH_ELF32_HINTS
This will allow the latter to be removed, reducing the boilerplate
needed for a new libcompat.

Reviewed by:	kib, brooks, jhb
Differential Revision:	https://reviews.freebsd.org/D40933
2023-07-09 18:50:15 +01:00
Alfonso Gregory 65f3be9110 Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:17 -06:00
Mateusz Guzik e01f9fe10c ipf: low-effort fix to make it compilable without inet6 2023-07-05 10:02:32 +00:00
Mateusz Guzik cea9f49f82 ping: low-effort fix to make it compilable without inet 2023-07-05 10:02:32 +00:00
Mateusz Guzik 55e0aefae6 ping: low-effort fix to make it compilable without inet6 2023-07-05 10:02:32 +00:00
Alfonso Gregory 27cebb4eac newfs: nextnum should be a u_int32_t, not an int
The function that uses nextnum expects to return a u_int32_t, not a mere
int, so let's make nextnum a u_int32_t instead.

Note: retained current u_int32_t style, since the rest of the file uses
it.

Reviewed by: imp, mckusick
Pull Request: https://github.com/freebsd/freebsd-src/pull/734
2023-06-28 16:26:06 -06:00
Alfonso Gregory 430168942f newfs: prefer unsigned index over signed
We can just use a for loop starting at 0 instead of a while loop
starting at -1.

Reviewed by: imp, mckusick
Pull Request: https://github.com/freebsd/freebsd-src/pull/733
2023-06-28 16:18:47 -06:00
Graham Perrin 6927176113 bectl(8): clarifications, expansion
Reviewed-by:  imp
Pull-request: https://github.com/freebsd/freebsd-src/pull/728
2023-06-28 03:05:26 +01:00
Alfonso Gregory 21c32cebf8 ifconfig: skip calling fnmatch once the result no longer matters
Because fnmatch has no side effects, we can safely avoid calling fnmatch
if the end result does not matter anyway (the compiler cannot see this,
so it calls fnmatch in the event it has side-effects).

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/747
2023-06-27 16:28:44 -06:00
John Baldwin 90f2fee0e0 ipf: Remove set but unused variables.
Reported by:	clang
Differential Revision:	https://reviews.freebsd.org/D40667
2023-06-27 10:19:32 -07:00
John Baldwin f5e7330633 ipfw: Remove set but unused variables.
Reported by:	GCC
Differential Revision:	https://reviews.freebsd.org/D40654
2023-06-27 10:19:32 -07:00
John Baldwin a7f25f141a libipf: Remove set but unused variable from printfraginfo().
Reported by:	GCC
Differential Revision:	https://reviews.freebsd.org/D40652
2023-06-27 10:19:31 -07:00
Ed Maste c079bcbc60 ifconfig: consistently sort set/clear commands
Sponsored by:	The FreeBSD Foundation
2023-06-25 16:09:26 -04:00
Koichiro Iwao 9aca30d878 ifconfig.8: Document limitation of groupname
Approved by:		kp
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D40645
2023-06-20 23:08:04 +09:00
Warner Losh 6bd922e154 camcontrol: Include stdbool.h rather than relying on namespace pollution
I have several environments, and at least one of them fails to build
because bool is undefined. Since we use bool, always include stdbool.h
rather than relying on any indirect definitions to pull it in.

Sponsored by:		Netflix
2023-06-19 14:54:32 -06:00
Warner Losh 90f05f6840 camcontrol: Zone fix two warnings
Remove a set but never used variable, and use the protocol variable for
its intended purpose.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40528
2023-06-19 14:51:07 -06:00
Warner Losh e8cdabb4e1 camcontrol: In defects make -S actually imply 12-byte command
camcontrol(8) says that -S to start at a different offset implies that
we're using the 12 byte command. But really, we're using the 10-byte
command. Fix this by setting use_12byte for -S.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40526
2023-06-19 14:45:43 -06:00
Warner Losh 2e105b61e9 camcontrol: simplify summary logic for defects
We don't need to count the number of lists requested. Instead, use the
more general form of checking to see if any of the non-defect format
bits are set. Also, check summary boolean to control summary reporting
behavior.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40524
2023-06-19 14:45:43 -06:00
Warner Losh f20d86e171 camcontrol: No need to set CAM_ARG_[PG]LIST in defects
We can or in the the list_format bits directly if we or in the
list_format when we look it up the first time. Free up CAM_ARG_[PG]LIST
from the CAM_ARG_xxx enum.

Sponsored by:		Netflix
Reviewed by:		mav (I made his suggested change)
Differential Revision:	https://reviews.freebsd.org/D40523
2023-06-19 14:45:43 -06:00
Warner Losh 97e24c3868 camcontrol: Simplfiy 12-byte retry logic in defects command
We always start out using the 10-byte version of READ DEFECT DATA, and
then switch to 12-byte when necessary due to errors or data length
requirements. We always need to get the length again when we do this,
and we're always going to be using 12-byte commands from that point
forward. Simplify the logic a bit based on this observation.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40522
2023-06-19 14:45:43 -06:00
Warner Losh fc78fd9dae camcontrol: Convert int used as booleans to bools
Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40521
2023-06-19 14:45:43 -06:00
Warner Losh 8259fc46ac camcontrol: Label the unused command args
Remove CAM_ARG_FORMAT_{BLOCK,BLI,PHYS} since they are not used.  Label
all the unused CAM_ARG_ bits as unused in comments to make them stand
out.

Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D40520
2023-06-19 14:45:43 -06:00
John Baldwin f19ae3633b ifconfig: Pacify a sign comparison warning in regdomain_sort.
Both ic_flags values are unsigned (uint32_t), so cast them to a signed
int to generate a signed result.  Both ic_req values are also
unsigned, but since they are uint16_t, they are implicitly promited to
int before the subtraction.

Reported by:	GCC -Wsign-compare
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40610
2023-06-19 10:38:18 -07:00
John Baldwin a3b1138778 ifconfig: Consistently use uint32_t for wireless channel flags.
Reported by:	GCC -Wsign-compare
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40609
2023-06-19 10:38:07 -07:00
John Baldwin 08992b2078 ifconfig: Avoid issues with trying to negate unsigned values.
The if_flags and if_cap fields hold a bitmask of flags.  If a flag is
the MSB of the field, then the logic in setifflags and setifcap which
uses a < 0 check does the wrong thing (it tries to clear the flag
rather than setting it).  Also, trying to use -<FOO> doesn't actually
work as the result is a nop.  To fix, stop overloading setifcap and
setifflags and instead add new dedicated action functions clearifcap
and clearifflags for clearing a flag.  The value passed in the
argument to the command is now always the raw flag.

This was reported by a GCC warning after raising WARNS:

sbin/ifconfig/ifconfig.c:2061:33: error: integer overflow in expression '-2147483648' of type 'int' results in '-2147483648' [-Werror=overflow]
 2061 |         DEF_CMD("-txtlsrtlmt",  -IFCAP_TXTLS_RTLMT,     setifcap),
      |                                 ^

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40608
2023-06-19 10:37:52 -07:00
Ed Maste e77b2ea427 ifconfig: set boolean to true rather than incrementing
GCC warns about "increment of a boolean expression."

Reported by:	amd64-gcc12 Cirrus-CI run
Sponsored by:	The FreeBSD Foundation
2023-06-19 11:02:38 -04:00
Rick Macklem 7e53f16baa mount_nfs.8: Note a case where the "nconnect" option does not work
The "nconnect" NFS mount option will not work
correctly for servers where the TCP connections
might connect to different NFS clusters that do not
share NFSv4.1/4.2 state information, such as file locks.

This patch adds a sentence to the "nconnect" section
of mount_nfs.8 noting this case.

This is a content change.

Reviewed by:	karels, pauamma_gundo.com (manpages)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D40547
2023-06-18 13:02:20 -07:00
Johannes Totz ec0bd8b07f rc.suspend: update man pages for new keyword
rc.suspend has gained an rcorder keyword recently. Document it alongside
the existing resume keyword.

Reviewed By:	mhorne, Pau Amma <pauamma@gundo.com>
Differential Revision:	https://reviews.freebsd.org/D40484
2023-06-16 13:51:10 -03:00
Alexander V. Chernikov c344eff910 netlink: dump interface capabilities with other interface data.
This change exports interface capabilities using the standard
Netlink attribute type, bitset, and switches `ifconfig(8)` to use
it when displaying interface data.
Bitset comes in two representations. The first one is "compact",
where the bits are exported via two arrays - "mask" listing the
"valid" bits and "values, providing the values for those bits.
The second one is more verbose, listing each bit as a separate item,
with its name, id and value. The latter option is handy when submitting
update requests.

The support for setting capabilities will be added in the upcoming diffs.

Differential Revision: https://reviews.freebsd.org/D40331
2023-06-16 15:33:49 +00:00
Alexander V. Chernikov 0fcc603a07 ifconfig: fix armv6 build 2023-06-16 08:23:50 +00:00
Alexander V. Chernikov 7e1ec25c8b ipfw: add state/comment tests 2023-06-16 07:24:19 +00:00
Alexander V. Chernikov a3930cd46c ifconfig: use default (more rigid) WARNS level.
It helps catch more errors at compile time.

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D40536
MFC after:	2 weeks
2023-06-16 07:19:22 +00:00
Alexander V. Chernikov f414f37e38 ifconfig: remove global 'ifr' usage from ifmedia.c & remove 'ifr'.
Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D40535
MFC after:	2 weeks
2023-06-16 07:19:21 +00:00
Alexander V. Chernikov 7fa282e616 ifconfig: remove (most of) the usages of global 'struct ifreq ifr'.
It is hard to reason about the contents of 'ifr' at any given time
as nearly every function sets random fields or pointers in this
structure.
Use local on-stack clean 'struct ifreq' for each function instead.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D40534
MFC after:	2 weeks
2023-06-16 07:19:21 +00:00
Alexander V. Chernikov 2b5dd8b890 ipfw: use function return value to fetch insn argument.
This is a prerequsite for splitting compile_rule() into smaller
chunks.

MFC after:	2 weeks
2023-06-15 06:46:42 +00:00
Alexander V. Chernikov 84b41342da ipfw: add eaction tests
MFC after:	2 weeks
2023-06-15 06:36:16 +00:00
Marko Zec 32b28e3ae2 route.8: mention DXR in FIB_ALGO section
While here, add a sentence describing DPDK DIR24-8 principle of
operation.

MFC after:	2 weeks.
2023-06-15 07:21:51 +02:00
Alexander V. Chernikov 52ff888318 ifconfig: fix ifconfig crash when compiled w/WITHOUT_NETLINK.
Properly update the recently-introduced `ctx->ifname` when iterating
over interfaces.

Reported by:	Gary Jennejohn <garyj@gmx.de>
MFC after:	2 weeks
2023-06-14 10:37:07 +00:00
Alexander V. Chernikov 3927d0fb37 ifconfig: fix -Wunused warnings
MFC after:	2 weeks
2023-06-14 09:16:09 +00:00
Alexander V. Chernikov a6094f844a ifconfig: remove 'newaddr' global variable
Differential Revision: https://reviews.freebsd.org/D40441
MFC after:	2 weeks
2023-06-14 09:16:09 +00:00
Alexander V. Chernikov bbad5525fa ifconfig: start ifconfig context from main()
Differential Revision: https://reviews.freebsd.org/D40440
MFC after:	2 weeks
2023-06-14 09:15:58 +00:00
Alexander V. Chernikov d61064229f ifconfig: fix comparison in printmimo().
Differential Revision: https://reviews.freebsd.org/D40301
MFC after:	2 weeks
2023-06-14 07:39:06 +00:00
Alexander V. Chernikov 6a9cfebaf1 ipfw: simplify action case parser
Remove "goto charg" from the action parser.
This is a prerequisite for the further split of the gigantic
compile_rule().

Differential Revision: https://reviews.freebsd.org/D40490
MFC after: 2 weeks
2023-06-13 11:55:37 +00:00
Alexander V. Chernikov 9f44a47fd0 ipfw(8): add ioctl/instruction generation tests
Differential Revision: https://reviews.freebsd.org/D40488
MFC after:	2 weeks
2023-06-13 11:55:37 +00:00
Trond Endrestol d77ca41f77 ifconfig(8): add the dotted format for MAC addresses.
MFC after:	2 weeks
PR:	261572
2023-06-13 06:40:15 +00:00
Alexander V. Chernikov ea73ff9752 ifconfig: remove global_args variable.
This variable was temporarily introduced in the beginning of the
code cleanup. Use on-stack instance in main() instead.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40439
MFC after:	2 weeks
2023-06-13 06:25:16 +00:00
Alexander V. Chernikov 85e0016a97 ifconfig: remove global 'name' variable.
Consistenly use newly-added 'ctx->ifname' as the name of the current
target interface.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40438
MFC after:	2 weeks
2023-06-13 06:22:41 +00:00
Alexander V. Chernikov c6f0602f23 ifconfig: pass if_ctx instead of socket to the tunnel handlers.
This is a pre-requisite for the global 'name' variable removal.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40432
MFC after:	2 weeks
2023-06-13 06:20:00 +00:00
Alexander V. Chernikov 4106282ec4 ifconfig: remove global 'printifname' variable.
This variable was used to print the created interface name in the
atexit(3) handler. The interface name was calculated in the
ifclonecreate() by matching old & new names.

This change alter the implementation the following way:
1) the function responsible for the interface creation (ifcreate_ioctl)
 updates all necessary state internally. This removes the need for the
 name manipulation hack in wlan_create().
2) As atexit(3) handler does not accept any parameters, explicitly store
 the name to print in the ifname_to_print variable read by the atexit(3)
 handler.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40431
MFC after:	2 weeks
2023-06-13 06:18:10 +00:00
Alexander V. Chernikov c6885dbda7 ifconfig: eliminate global 'verbose' and 'printkey' variables
Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40427
MFC after:	2 weeks
2023-06-13 06:16:14 +00:00
Alexander V. Chernikov 74b4261161 ifconfig: add if_ctx argument to the generic and ifclone callbacks.
This is the continuation of the ifconfig cleanup work. This change is
a pre-requsite for the next changes removing some of the global variables.
It will also help in implementing functionality via Netlink instead of ioctl.
No functional changes intended.
* vxlan_cb() was removed as it contained no code
* ioctl_ifcreate() was renamed to ifcreate_ioctl() to follow the other
netlink/ioctl function naming. Netlink and ioctl provide _different_
interfaces and it's not possible to have a unified interface object
that can be filled by either netlink or ioctl implementations. With that
in mind, I'm leaning more to the function_<nl|ioctl> postfix pattern,
than doing ioctl_ or netlink_ prefix.

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D40426
MFC after:	2 weeks
2023-06-13 06:10:56 +00:00
Yan Ka, Chiu ab4d1b73cb route(8): teach route to attach to jails
Add -j <jail> flag to route(8) to allow route to perform actions in
a Jail.

Differential Revision: https://reviews.freebsd.org/D40377
MFC after:	2 weeks
2023-06-13 06:06:27 +00:00
Tom Hukins c9a1abe79b mount_nullfs(8): refer to nullfs(5)
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/772
2023-06-12 08:35:36 -06:00
John Baldwin 553022aba5 ipf: Remove no-longer-needed NO_WARRAY_BOUNDS. 2023-06-09 15:35:32 -07:00
Pierre Pronchery e730066a64 decryptcore: Request the OpenSSL 1.1 API
OPENSSL_API_COMPAT can be used to specify the OpenSSL API version in
use for the purpose of hiding deprecated interfaces and enabling
the appropriate deprecation notices.

This change is a NFC while we're still using OpenSSL 1.1.1 but will
avoid deprecation warnings upon the switch to OpenSSL 3.0.

A future update may migrate to use the OpenSSL 3.0 APIs.

PR:		271615
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2023-06-05 13:48:05 -04:00
Pierre Pronchery caf98b9d13 dumpon: Request the OpenSSL 1.1 API
OPENSSL_API_COMPAT can be used to specify the OpenSSL API version in
use for the purpose of hiding deprecated interfaces and enabling
the appropriate deprecation notices.

This change is a NFC while we're still using OpenSSL 1.1.1 but will
avoid deprecation warnings upon the switch to OpenSSL 3.0.

A future update may migrate to use the OpenSSL 3.0 APIs.

PR:		271615
Pull request:	https://github.com/freebsd/freebsd-src/pull/757
Sponsored by:	The FreeBSD Foundation
2023-06-02 10:00:48 -04:00
Tom Hukins 409594ef34 gpart(8): Improve manual page syntax
Fix various warnings from `mandoc -Tlint lib/geom/part/gpart.8`.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/702
2023-06-01 20:43:04 -06:00
Tom Hukins 2bcbf4d831 camcontrol(8): Use simpler language
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/702
2023-06-01 20:41:33 -06:00
Tom Hukins 2675b8bd3d camcontrol(8): Add manual page cross references
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/702
2023-06-01 20:41:32 -06:00
Elyes Haouas e5263025de fsck_ffs: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:41 -06:00
Elyes Haouas e4861dc857 ipfw/ipfw2: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:40 -06:00
Elyes Haouas 843fe4892e ipf: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:40 -06:00
Elyes Haouas b66b2c4d9b ifconfig: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:40 -06:00
Elyes Haouas d15f57a29d camcontrol: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:40 -06:00
Elyes Haouas 589fe499b7 nvmecontrol: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:39 -06:00
Elyes Haouas e095cbab2f ipf/ipfstat: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:39 -06:00
Elyes Haouas 136a9bb4e3 hastd: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:39 -06:00
Elyes Haouas 0939cf32c0 ipf/libipf: Fix typos
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/653
2023-06-01 20:33:38 -06:00
Ed Maste 79d4d7133f dumpon: update OpenSSL initialization call
ERR_load_crypto_strings() was deprecated in OpenSSL 1.1.0, and explicit
initialization is generally not reqiured.  In the case of dumpon however
we initialize prior to entering capability mode, so replace with an
OPENSSL_init_crypto call.

Reviewed by:	def, Pierre Pronchery
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40353
2023-06-01 21:21:23 -04:00
Alexander V. Chernikov 0c2beef72d ifconfig: fix warnings #2
Fix all -Wparameter-unused and cast alignment

Differential Revision: https://reviews.freebsd.org/D40303
MFC after:	2 weeks
2023-06-01 11:54:25 +00:00
Ed Maste eb2b00da56 decryptcore: add OPENSSL_INIT_LOAD_CONFIG to init call
Reported by:	def
Reviewed by:	Pierre Pronchery
Sponsored by:	The FreeBSD Foundation
2023-05-31 13:00:57 -04:00
Ed Maste 8e7a31b65f decryptcore: update for OpenSSL 1.1 API
ERR_load_crypto_strings is deprecated in OpenSSL 1.1, and OpenSSL 1.1
generally does not require explicit initialization.  However, we do need
to ensure that initialization is done before entering capability mode so
call OPENSSL_init_crypto instead.  Also include header needed for
ERR_error_string.

Reviewed by:	vangyzen
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40343
2023-05-31 12:20:34 -04:00
Kajetan Staszkiewicz c45d6b0ec0 pfctl: Add missing state parameters in DIOCGETSTATESV2
Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Different Revision:	https://reviews.freebsd.org/D40259
2023-05-30 14:28:57 +02:00
Kajetan Staszkiewicz 4bf98559d9 pf: make contents of struct pfsync_state configurable
Make struct pfsync_state contents configurable by sending out new
versions of the structure in separate subheader actions. Both old and
new version of struct pfsync_state can be understood, so replication of
states from a system running an older kernel is possible. The version
being sent out is configured using ifconfig pfsync0 … version XXXX. The
version is an user-friendly string - 1301 stands for FreeBSD 13.1 (I
have checked synchronization against a host running 13.1), 1400 stands
for 14.0.

A host running an older kernel will just ignore the messages and count
them as "packets discarded for bad action".

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D39392
2023-05-30 14:28:56 +02:00
Chuck Silvers d464a7698d ffs: restore backward compatibility of newfs and makefs with older binaries
The previous change to CGSIZE had the unintended side-effect of allowing
newfs and makefs to create file systems that would fail validation when
examined by older commands and kernels, by allowing newfs/makefs to pack
slightly more blocks into a CG than those older binaries think is valid.
Fix this by having newfs/makefs artificially restrict the number of blocks
in a CG to the slightly smaller value that those older binaries will accept.
The validation code will continue to accept the slightly larger value
that the current newfs/makefs (before this change) could create.

Fixes:		0a6e34e950
Reviewed by:	mckusick
MFC after:	3 days
Sponsored by:	Netflix
2023-05-29 19:26:28 -07:00
Konstantin Belousov cf85818e05 setkey(8): document NAT-T and NAT-T MTU extensions syntax
Reviewed by:	ae
Discussed with:	bz
Sponsored by:	NVidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40300
2023-05-30 01:10:02 +03:00
Konstantin Belousov 2fa1b8617f setkey(8): NAT-T manual configuration support
This is needed for testing of offload capabilities.

Reviewed by:	ae
Discussed with:	bz
Sponsored by:	NVidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40300
2023-05-30 01:10:02 +03:00
Konstantin Belousov 2c1296a3c5 setkey(8): extract prefixlen calculation info helper
While there, hide AF_INET case under #ifdef INET.

Reviewed by:	ae
Discussed with:	bz
Sponsored by:	NVidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40300
2023-05-30 01:10:02 +03:00
Kirk McKusick 6a71277c30 Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.
When loading the root directory ensure that it is a directory
and has a size greater than the minimum directory size. If an
invalid root directory is found, fall back to full fsck.

Reported-by:  Robert Morris
PR:           271414
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-05-29 14:58:20 -07:00
Kirk McKusick 5267120645 Cleanups to fsck_ffs(8).
When checking an inode ensure that it does not have a negative size.
Stop scaning a directory when an unallocated block is found.
Fully clear an inode when it is first allocated.
Ensure that an inode is marked dirty whenever it is updated and that
it has a correct check hash when it is released.

MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-05-29 14:55:54 -07:00
Kirk McKusick b796bfce48 Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.
Check for valid block numbers while loading journal entries that
contain block numbers. If an invalid block number is found, fall
back to full fsck.

Reported-by:  Robert Morris
PR:           271383
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-05-28 15:23:37 -07:00
Kirk McKusick 101a9ac071 Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.
Check for valid file size before processing journal entries for it.
Done by extracting the file size check from pass1.c into chkfilesize()
then using it in the journal code in suj.c

Reported-by:  Robert Morris
PR:           271378
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-05-27 17:12:30 -07:00
Kirk McKusick 11ce203e05 Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.
The last valid inode in the filesystem is maxino - 1, not maxino.
Thus validity checks should ino < maxino, not ino <= maxino.

Reported-by:  Robert Morris
PR:           271312
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-05-27 16:07:09 -07:00
Alexander V. Chernikov 656a39c1a0 netlink: use newly-added snl(3) array parsing for handling multipath
routes.

MFC after:	2 weeks
2023-05-27 11:13:14 +00:00
Kirk McKusick 49943856eb Do not try to adjust a directory depth when its reconnection is declined.
MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2023-05-26 22:55:11 -07:00
Kirk McKusick 03a8680202 Correct two bugs in fsck_ffs(8) triggered by corrupted filesystems.
Always create a directory inode structure when a directory inode is
found in Pass 1 as it is not known whether it will be saved or removed
in later passes. If it is to be saved the directory inode structure
is needed to track its status and fsck_ffs(8) will segment fault if
it does not exist.

Reported-by:  Robert Morris
PR:           271310
PR:           271354
MFC-after:    1 week
Sponsored-by: The FreeBSD Foundation
2023-05-26 22:43:21 -07:00
Enji Cooper 52b63df9b6 dumpon: provide diag info when PEM_read_RSA_PUBKEY fails
This change modifies dumpon to print out the last error from OpenSSL
when `PEM_read_RSA_PUBKEY` fails. This allows end-users to diagnose why
reading in RSA pubkey files fails so they can adjust the usage to meet
the needs of the command.

MFC after:	1 week
2023-05-26 18:05:04 -07:00
Kirk McKusick e4a905d1e0 Add the ability to adjust directory depths to background fsck_ffs(8).
Commit fe5e6e2 improved FFS directory placement when creating new
directories. It is done by keeping track of the depth of directories
in the filesystem and placing those lower in the tree closer together
while spreading out those higher in the tree.

Fsck_ffs(8) checks these depths and if incorrect adjusts them to
their correct value. When running in background fsck_ffs(8) needs
to be able to make an adjustment to the depth. This commit adds
the sysctl to make such an adjustment and adds the code to fsck_ffs(8)
to use the new sysctl.

MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2023-05-25 19:27:04 -07:00
Kirk McKusick 4b08a62ed4 When running fsck_ffs(8) in background ensure that a superblock has been read.
Reported by:  Mikhail T.
PR:	      271352
MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2023-05-25 18:59:16 -07:00
Alexander V. Chernikov 6d204407ec ifconfig: fix ifconfig IFX inet[6] ADDR -alias
Internally, inet and inet6 family handlers store state for
 address addition and deletion separately, as, for example,
 "ifconfig lo0 inet 127.0.0.2/32" triggers a) deletion of the
 first interface address and b) addition of a new one.
The current logic behind handling "-alias" being the last argument
 is to copy the address from "addition" state to the "deletion"
 state. It is done by the generic ifconfig code, which explicitly
 typecasts opaque handler state pointers to "struct ifreq", which
 doesn't work in the Netlink case.

Fix this by introducing family-specific "af_copyaddr" handler,
 which removes the peeking & typecasting logic from the generic code.

Reported by:	otis
Tested by:	otis
2023-05-25 15:03:35 +00:00
Alexander V. Chernikov 4bf44dd73b ifconfig: switch IPv4/IPv6 address manipulations to Netlink.
Differential Revision: https://reviews.freebsd.org/D40182
2023-05-25 12:22:18 +00:00
Mike Karels 8955236a10 bectl.8: update /home
The default location for home directories is moving from /usr/home
to /home, including the default zfs datasets.  Update accordingly.
Add zroot/usr/src as replacement example of nested datasets.

While here, mark zroot/var as "canmount off" as per current setup.

Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D40206
2023-05-24 22:08:39 -05:00
Alexander V. Chernikov 12cfa3c1bd ifconfig: fix interface address ordering with Netlink. 2023-05-24 15:34:21 +00:00
Mike Karels aa1a1e7dc4 mksnap_ffs.8: update /home examples
The default location for home directories is moving from /usr/home
to /home.  Update the examples accordingly.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D40205
2023-05-24 10:31:50 -05:00
Alexander V. Chernikov 6e3a9d7f2c ifconfig: introduce ifconfig_context to store current global state.
The structure consists of all current context - arguments,
open sockets, current family and so on.

Pass this structure as a first argument to most of the af_ menthods.
This allows to propagate and update shared data without using
 global variables.

The diff is pretty large, but de-facto mechanical. All changes
 except the structure setup in ifconfig[_netlink].c are one-line
 mechanical changes.

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D40239
MFC after:	2 weeks
2023-05-24 10:40:34 +00:00
Alexander V. Chernikov 44cd85d42e ifconfig: cleanup warnings #1
Cleanup compiler warnings in preparation to set Wextra and remove WARNS?=2

Differential Revision: https://reviews.freebsd.org/D40238
MFC after:	2 weeks
2023-05-24 10:40:34 +00:00
Yan Ka Chiu 7e49aa86a2
ifconfig(8): Teach ifconfig to attach and run itself in a jail
Add -j <jail> flag to ifconfig to allow ifconfig to attach and run inside a
jail. This allow parent to configure network interfaces of its children
even if ifconfig is not available in child's tree (e.g. Linux Jails)

Reviewed by:	emaste, khng, melifaro
Event:		Kitchener-Waterloo Hackathon 202305
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D40213
2023-05-23 16:39:22 -04:00
Alexander V. Chernikov 26056fa8d3 Revert "ifconfig: switch IPv4/IPv6 address manipulations to Netlink"
Revert the change as 2 non-expected issues have been reported.

This reverts commit 54418f79fd.
2023-05-22 15:17:57 +00:00
Alexander V. Chernikov 454d72ec40 Revert "ifconfig: Fix the build"
This reverts commit 5b8ce85e1a.
2023-05-22 15:17:45 +00:00
Mark Johnston 5b8ce85e1a ifconfig: Fix the build
Fix indentation in warn_nomask() while here.

Fixes:	54418f79fd ("ifconfig: switch IPv4/IPv6 address manipulations to Netlink")
2023-05-22 10:53:38 -04:00
Alexander V. Chernikov 54418f79fd ifconfig: switch IPv4/IPv6 address manipulations to Netlink
Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D40182
2023-05-22 13:45:33 +00:00
Alexander V. Chernikov 63ad5ce733 ifconfig: simplify ifconfig() by factoring out ifa add/del logic
Reviewed by:	kp
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40180
2023-05-21 09:42:11 +00:00
Alexander V. Chernikov 197bff385e ifconfig: split argument parsing
Simplify main() by factoring out argument parsing code.

Reviewed by:	kp
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40179
2023-05-21 09:42:11 +00:00
Alexander V. Chernikov a72b78905a ifconfig: simplify carp vhid setup.
Currently carp implementation peeks into the opaque 'afp->af_addreq'
 buffer, assumes it knows the af-specific layout and assigns vhid
 directly.
Simplify the code and remove abstraction leak by introducing per-afp
 callback for setting vhid.
This change is a pre-requisite to set addresses via Netlink,
 as Netlink implementiation uses different structure layout.

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D40160
MFC after:	2 weeks
2023-05-20 09:49:15 +00:00
Kristof Provost 2d9d97e66e ifconfig: improve error checking for carp peer6
getaddrinfo() returns 0 if it succeeded, but it's not guaranteed to
return 1 on error. Check for success rather than for one specific error.

Without this fix commands such as `ifconfig bnxt1 inet6 add vhid 1 peer6
2001:db8::1/64` would segfault ifconfig.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 17:47:03 +02:00
Bjoern A. Zeeb 2e6756b752 ifconfig: improve trimming off interface number at end
When trying to auto-load a module, we trim the interface number off
the end.  Currently we stop at the first digit.  For interfaces which
have numbers in the driver name this does not work well.
In the current example ifconfig ath10k0 would load ath(4) instead of
ath10k(4).  For module/interface names like rtw88[0] we never guess
correctly.
To improve for the case we can, start trimming off digits from the
end rather than the front.

Sponsored by:	The FreeBSD Foundation
Reported by:	thierry
MFC after:	20 days
Reviewed by:	melifaro, thierry
Differential Revision: https://reviews.freebsd.org/D40137
2023-05-18 15:22:53 +00:00
Alexander V. Chernikov 4c91a5dfe4 ifconfig: make interface and address listing use Netlink as transport
Differential Revision: https://reviews.freebsd.org/D40044
2023-05-16 19:39:13 +00:00
Alexander Motin f409f11bc5 nvmecontrol: Fix power subcommand output.
The returned value consists of two fields.  Report them separately.

MFC after:	2 weeks
2023-05-15 16:48:50 -04:00
Kirk McKusick 0a6e34e950 Fix size differences between architectures of the UFS/FFS CGSIZE macro value.
The cylinder group header structure ended with `u_int8_t cg_space[1]'
representing the beginning of the inode bitmap array. Some architectures
like the i386 rounded this up to a 4-byte boundry while other
architectures like the amd64 rounded it up to an 8-byte boundry.
Thus sizeof(struct cg) was four bytes bigger on an amd64 machine
than on an i386 machine. If a filesystem created on an i386 machine
was moved to an amd64 machine, the size of the cylinder group
calculated by the CGSIZE macro would appear to grow by four bytes.
Filesystems whose cylinder groups were exactly equal to the block
size on an i386 machine would appear to have a cylinder group that
was four bytes too big when moved to an amd64 machine. Note that
although the structure appears to be too big, it in fact is fine.
It is just the calaculation of its size that is in error.

The fix is to remove the cg_space element from the cylinder-group
structure so that the calculated size of the structure is the same
size on all architectures.

Reported by:  Tijl Coosemans
Tested by:    Tijl Coosemans and Peter Holm
MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2023-05-15 12:57:15 -07:00
Alexander V. Chernikov d1cd0344f7 ifconfig: split printing functions into smaller per-type chunks.
This change is a prerequisite for netlink conversion.
No functional changes intended.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D40033
MFC after: 2 weeks
2023-05-15 13:37:27 +00:00
Warner Losh eb8f887758 spdx: The BSD-3-Clause-FreeBSD identifier never was, drop -FreeBSD
There never was a BSD-3-Clause-FreeBSD SPDX identifier. Replace it
with BSD-3-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh b61a573019 spdx: The BSD-2-Clause-NetBSD identifier is obsolete, drop -NetBSD
The SPDX folks have obsoleted the BSD-2-Clause-NetBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:04 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Dag-Erling Smørgrav 27e74c8fff md5: Add missing <errno.h>.
Sponsored by:	Klara, Inc.
Reviewed by:	yuripv
Differential Revision:	https://reviews.freebsd.org/D40051
2023-05-11 06:24:02 +00:00
Dag-Erling Smørgrav 00de65aaed md5: Add missing references to sha384.
Fixes:		4849767cb1
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D40032
2023-05-10 15:45:11 +02:00
Alexander V. Chernikov 444b9aa78c ifconfig: fix family selection after 982cd5ae8e 2023-05-10 12:40:51 +00:00
Alexander V. Chernikov a3cb80bc63 ifconfig: fix interface selection after 982cd5ae8e. 2023-05-10 12:22:39 +00:00
Alexander V. Chernikov 982cd5ae8e ifconfig: split argument parsing and actual execution logic
Reduce the amount of global variables by creating the dedicated
 ifconfig_args structure and use it as a context-passing variable.
Simplify the code by moving all argument preparation code a
 separate function.

Reviewed by: kp (previous version)
Differential Revision: https://reviews.freebsd.org/D39932
MFC after:	2 weeks
2023-05-10 10:39:12 +00:00
Dag-Erling Smørgrav facc213643 md5: Don't increment a bool.
Fixes:		4849767cb1
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D40020
2023-05-10 09:25:21 +00:00
Dag-Erling Smørgrav 90eaf4b2f9 md5: Include <osreldate.h> for __FreeBSD_version.
It is usually provided by <sys/param.h>, but not when bootstrapping.

Fixes:		4849767cb1
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	yuripv, kevans
Differential Revision:	https://reviews.freebsd.org/D40018
2023-05-10 09:25:21 +00:00
Dag-Erling Smørgrav f1ceb05a46 md5: Fix input error check.
Fixes:		4849767cb1
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	tsoome, kevans, lwhsu
Differential Revision:	https://reviews.freebsd.org/D40017
2023-05-10 09:25:21 +00:00
Kirk McKusick b3fe5d9322 Fix off-by-one error in fsck_ffs(8) chkrange() block-number check.
On an amd64-CURRENT machine with an i-node that refers to a block
number that is one too large will cause a core dump, due to writing
beyond the end of blockmap[] and corrupting the next heap block,
which happens to contain a struct inoinfo in inphash[]. Note that
valgrind catches the blockmap[] access.

Reported by:  Robert Morris
PR:           271289
MFC after:    1 week
Sponsored by: The FreeBSD Foundation
2023-05-09 13:08:10 -07:00
Mateusz Piotrowski 794f5122bb geom.8: Fix typos and wordsmith
MFC after:	3 days
2023-05-09 16:20:13 +02:00
Dag-Erling Smørgrav 4849767cb1 md5: Improve compatibility.
* Overhaul the GNU compatibility mode to more closely emulate what the GNU tools do.

* Add a Perl compatibility mode which emulates the shasum tool that ships with Perl.  This is currently not installed.

* Overhaul the tests.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D39446
2023-05-08 06:56:22 +00:00
Simon J. Gerraty b75d7e2cbe md5 Makefile.depend.host 2023-05-04 12:03:34 -07:00
Chuck Silvers 4064755812 fsck_ffs: fix the previous change that skipped pass 5 in some cases
The previous change involved calling check_cgmagic() twice in a row
for the same CG in order to differentiate when the CG was already ok vs.
when the CG was rebuilt, but that doesn't work because the second call
(which was supposed to rebuild the CG) returns 0 (indicating that
the CG was not rebuilt) due to the prevfailcg check causing an early
failure return.  Fix this by moving the rebuild part of check_cgmagic()
out into a separate function which is called by pass1() when it wants to
rebuild a CG.

Fixes: da86e7a20d
Reported by:	pho
Discussed with:	mckusick
Sponsored by:	Netflix
2023-05-03 13:31:32 -07:00
Mateusz Guzik a50ef47c0a newfs: fix up 32-bit compile
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-04-30 18:00:20 +00:00
Kirk McKusick 2e7797cd9b Yet another try to fix printf format conflict.
I find it very annoying that there is no FreeBSD infrastructure to
determine failures across architectures other than to check in
changes and then have Jenkins find them.

Suggested by: Jessica Clarke
MFC after:    1 week
2023-04-30 00:00:23 -07:00
Kirk McKusick 6995e6b323 Fix printf format conflict
MFC after:   1 week
2023-04-29 17:55:15 -07:00
Kirk McKusick 62dc21b107 Additional validity checking in newfs(8).
A check in the superblock validity code verifies that the computed
size of the filesystem cylinder groups (CGSIZE macro) does not
exceed the filesystem block size (fs_bsize).

A report was received that a filesystem had been flagged as failing
this check. We were unable to determine how the reported filesystem
could have been created. This commit adds a check at the end of the
newfs(8) command to verify that the the cylinder group size is valid.
If an oversize cylinder group is found newfs(8) prints a diagnostic
output and rebuilds the filesystem to make it compiliant.

MFC after:   1 week
2023-04-29 17:01:18 -07:00
Kirk McKusick 04997e19e2 Additional output from dumpfs(8).
Provide an additional line of output for the superblock giving the
computed size of the cylinder group (CGSIZE macro) along with the
details needed to calculate it.

MFC after:   1 week
2023-04-29 17:01:18 -07:00
Alexander V. Chernikov 30d7e724db route: show originator PID in netlink monitor
Replacing rtsock with netlink also means providing similar tracing facilities,
rtsock provides `route -n monitor` interface, where each message can be traced
to the originating PID.
This diff closes the feature gap between rtsock and netlink in that regard.

Netlink works slightly differently from rtsock, as it is a generic message
"broker". It calls some kernel KPIs and returns the result to the caller.
Other Netlink consumers gets notified on the changed kernel state using the
relevant subsystem callbacks. Typically, it is close to impossible to pass
some data through these KPIs to enhance the notification.

This diff approaches the problem by using osd(9) to assign the relevant
socket pointer (`'nlp`) to the per-socket taskqueue execution thread.
This change allows to recover the pointer in the aforementioned notification
callbacks and extract some additional data.
Using `osd(9)` (and adding additional metadata) to the notification receiver
comes with some additional cost attached, so this interface needs to be
enabled explicitly by using a newly-created `NETLINK_MSG_INFO` `SOL_NETLINK`
socket option.

The actual medatadata (which includes the originator PID) is provided via
control messages. To enable extensibility, the control message data is
encoded in the standard netlink(TLV-based) fashion. The list of the
currently-provided properties can be found in `nlmsginfo_attrs`.
snl(3) is extended to enable decoding of netlink messages with metadata
(`snl_read_message_dbg()` stores the parsed structure in the provided buffer).

Differential Revision: https://reviews.freebsd.org/D39391
2023-04-28 13:54:54 +00:00
Kristof Provost 9ec48bc31e pfctl: match expand_label_addr() prototype to definition
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-04-26 17:09:46 +02:00
Christian McDonald ef661d4a5b pf: introduce ridentifier and labels to ether rules
Make Ethernet rules more similar to the usual layer 3 rules by also
allowing ridentifier and labels to be set on them.

Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-04-26 11:14:41 +02:00
Kyle Evans 3a5855dd22 gbde: stop rebuilding sha512 bits
In the early days of gbde, it linked against libmd.  Shortly after
conception, phk replaced ARC4 with SHA-512, but libmd did not have SHA2
at the time thus he built a copy of sha2.c for gbde.

Fast forward 3 years, cperciva adds SHA2 to libmd -- this makes gbde's
build of sha2.c redundant, but it's (understandably) overlooked.  Let's
simplify the gbde build now and just assume that libmd includes the most
optimal implementation.

Reported by:	koobs (weird lto errors?)
Differential Revision:	https://reviews.freebsd.org/D34668
2023-04-26 00:36:33 -05:00
Kyle Evans 4163bae030 bectl: document the -r flag to bectl
Independent of all of the commands, bectl itself takes an `-r` flag that
specifies the BE root to use.  This was originally added to facilitate
testing, but it was later discovered to be incredibly useful in other
scenarios; e.g., trying to recover some boot environments in rescue
media.

The "BE root" described here is the parent dataset that holds boot
environments, but I've no idea if that's an accepted definition for that
dataset.

Reviewed by:	gallatin, imp, Pau Amma
MFC after:	1 week
Differential Review:	https://reviews.freebsd.org/D39710
2023-04-26 00:33:25 -05:00
Boris Lytochkin fc727ad63d ipfw: add [fw]mark implementation for ipfw
Packet Mark is an analogue to ipfw tags with O(1) lookup from mbuf while
regular tags require a single-linked list traversal.
Mark is a 32-bit number that can be looked up in a table
[with 'number' table-type], matched or compared with a number with optional
mask applied before comparison.
Having generic nature, Mark can be used in a variety of needs.
For example, it could be used as a security group: mark will hold a security
group id and represent a group of packet flows that shares same access
control policy.

Reviewed By: pauamma_gundo.com
Differential Revision: https://reviews.freebsd.org/D39555
MFC after:	1 month
2023-04-25 12:40:23 +00:00
Eugene Grosbein 9f5dc374d0 ipfw.8: improve description for interface matching
The manual describes "if*" form only while kernel uses fnmatch(3)
and allows use for more versatile shell-like patterns.
Note that explicitly and provide an example.

MFC after:	3 days
2023-04-25 18:16:22 +07:00
John Baldwin 0a04bb7a4f fdisk: Use valid prototypes for function declarations with no arguments.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39726
2023-04-24 08:53:49 -07:00
Bjoern A. Zeeb e17944a821 ath10k: ath11k: ammend devd.conf regex
In order to match these drivers, and in expectiation of ath12k
happening add ath[0-9]+k to the regex pattern for wlan devices.

MFC after:	2 months
2023-04-23 21:31:07 +00:00
Bjoern A. Zeeb 88e71cc06d mt76: devd: add support for mt79* wireless drivers to devd.conf
Add the "mt79" to the regex for wireless drivers in devd.conf so
that they get handled as expected.

MFC after:	2 months
2023-04-23 21:31:07 +00:00
Kristof Provost dbce131b8f pfctl: match geticmpcodeby*()/print_fromto() prototypes to definitions
The definitions use sa_family_t, not u_int8_t.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-04-22 19:43:56 +02:00
Kristof Provost 5e3bb05147 pfctl: remove unneeded includes
We don't use nvlists (directly) or sysctls, so there's no need to
include the headers.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-04-22 19:43:55 +02:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Kirk McKusick da86e7a20d Skip Pass 5 in fsck_ffs(8) when corrupt cylinder groups remain unfixed.
Pass 1 of fsck_ffs checks the integrity of all the cylinder groups.
If any are found to have been corrupted it offers to rebuild them.
Pass 5 then makes a second pass over the cylinder groups to validate
their block and inode maps. Pass 5 assumes that the cylinder groups
are not corrupted and can segment fault if they are corrupted. Rather
than rerunning the corruption checks a second time in pass 5, this
fix keeps track whether any corrupt cylinder groups were found but not
fixed in pass 1 either due to running with the -n flag or by explicitly
answering `no' when asked whether to fix a corrupted cylinder group.
If any corrupted cylinder groups remain after pass 1, fsck_ffs will
decline to run pass 5. Instead it marks the filesystem as unclean
so that fsck_ffs will need to be run again before the filesystem can
be mounted.

This patch cleans up and documents the return value from check_cgmagic().
It also renames the variable / parameter "rebuildcg" to "rebuiltcg".
This parameter describes whether the cylinder group has been rebuilt
rather than whether it should be rebuilt.

Reported by: Chuck Silvers
Reviewed by: Chuck Silvers
MFC after:   1 week
2023-04-18 16:13:26 -07:00
Kirk McKusick 18746531a8 Bug fixes for fsck_ffs(8).
Increment a reference count when returning a zero'ed out buffer
after a failed read.

Zero out a structure before using it.

Only dirty a buffer that has been modified.

Submitted by: Chuck Silvers
Sponsored by: Netflix
MFC after:    1 week
2023-04-18 16:13:26 -07:00
Kirk McKusick 7636973c68 Add `chdb' command to fsdb(8) to set direct block numbers.
Add the ability to set direct blocks numbers in inodes so that manual
corrections can be made. No checking of the values is attempted so
accidental or deliberate bad values can be set.

Submitted by: Chuck Silvers
MFC after:    1 week
2023-04-18 16:13:26 -07:00
John Baldwin 2ac057dd33 ipf: Use C89 function definitions.
Reviewed by:	zlei
Differential Revision:	https://reviews.freebsd.org/D39523
2023-04-18 11:22:28 -07:00
Gordon Bergling c2a9d23736 mount_nfs.8: Fix a mandoc warning
- sections out of conventional order: Sh IMPLEMENTATION NOTES

MFC after:	3 days
2023-04-18 09:14:20 +02:00
Stephen J. Kiernan 88a3358ea4 veriexec: Add SPDX-License-Identifier 2023-04-16 21:23:00 -04:00
Stephen J. Kiernan 1c7ac0c23b veriexec: fix use of getopt
getopt(3) returns int type not char. Using char triggers the
-Wtautological-constant-out-of-range-compare warning with clang.
Change the type of the variable used for holding the return value
of getopt(3) to int to match the prototype and eliminate the warning.

MFC after:	1 week
2023-04-16 21:02:04 -04:00
Stephen J. Kiernan 2e6a433811 veriexec: allow sha512 fingerprint in manifest parser
MAC/veriexec already supports SHA512 fingerprints, therefore the
veriexec program should also.

Reviewed by:	sjg
2023-04-16 19:25:27 -04:00
Kajetan Staszkiewicz 39282ef356 pf: backport OpenBSD syntax of "scrub" option for "match" and "pass" rules
Introduce the OpenBSD syntax of "scrub" option for "match" and "pass"
rules and the "set reassemble" flag. The patch is backward-compatible,
pf.conf can be still written in FreeBSD-style.

Obtained from:	OpenBSD
MFC after:	never
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38025
2023-04-14 09:04:06 +02:00
Reid Linnemann f0311046a0 ifconfig: change carp commands mcast and mcast6 to DEF_CMD as they take no args
Reviewed by:	kp
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39548
2023-04-13 09:18:18 +02:00
Rick Macklem 61330e494f mount_nfs.8: Update man page for the "syskrb5" option
Commit 896516e54a added a new NFS mount option
used for Kerberized NFSv4.1/4.2 mounts. It specifies that
AUTH_SYS be used for state maintenance (also called system)
operations. This allows the mount to be done without the
"gssname" option or a valid Kerberos TGT being held by the
user doing the mount (so it can be specified in fstab(5) for
example).

Reviewed by:	gbe (manpages), karels
MFC after:	3 months
Differential Revision:	https://reviews.freebsd.org/D39469
2023-04-11 12:17:09 -07:00
Rob Norris 461ccb55d5 dhclient: add ability to ignore options in offers
A machine might exist on multiple networks, all of which offer, say, default
routes or name servers. There's no easy way to indicate in the config
that those options are only valid for a single interface.

Now, we can write:

    interface "lan0" {
      request routers;
      require routers;
    }
    interface "lan1" {
      ignore routers;
    }

And only take action on default routes offered on lan0.

Tested by:	Jose Luis Duran <jlduran at gmail dot com>
MFC after:	2 months
Reviewed by:	allanjude, imp
Sponsored by:	Zenith Electronics LLC
Sponsored by:	Klara, Inc.
Pull Request:	#693
2023-04-10 23:13:18 +00:00
Alexander V. Chernikov 351e4592f6 route: remove always-true expression 2023-04-09 10:04:56 +00:00
Alexander V. Chernikov 091fec1188 route: switch transport protocol to Netlink.
All known bugs have been fixed, try to enable Netlink once again.
2023-04-08 18:02:57 +00:00
Alexander V. Chernikov ee8f5c2a31 route: fix netlink route operations with link-local gw / dst.
Extract ifindex from either gw or dst sockaddr and add it as a
 dedicated RTA_OIF attribute.
2023-04-08 11:38:05 +00:00
Zhenlei Huang 09e5e3d598 ifconfig: Fix configuring if_bridge with additional operating parameters
For clone create and rename operations, the interface name get back can be
different from the one passed to ioctl(). Use the interface name we get back
so that ifconfig will not return unexpected ENXIO.

PR:		270618
Reviewed by:	kp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39396
2023-04-07 22:25:41 +08:00
Alexander V. Chernikov f262b06a57 route: fix route get netlink translation.
route.c uses newroute() to handle the "route get" command. The logic
 inside newroute() adds RTF_GATEWAY flag if "-interface" flag is not
 specified. That results in the inconsistent RTM_GET message with
 RTF_GATEWAY set but no RTAX_GATEWAY provided. Address this in the
 translation code by checking if the gateway is actually provided.
2023-04-04 08:42:33 +00:00
Konstantin Belousov bef81bc0ae setkey(8): ansify parser
Sponsored by:	NVidia networking
MFC after:	1 week
2023-04-03 22:48:49 +03:00
Konstantin Belousov 462c3d3cf4 setkey(8): remove redundand returns
Sponsored by:	NVidia networking
MFC after:	1 week
2023-04-03 22:48:49 +03:00
Konstantin Belousov 3cb808226c setkey(8): add -e option to take script from the command line
Reviewed by:	ae
Sponsored by:	Nvidia networking
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D39393
2023-04-03 22:48:48 +03:00
Martin Matuska 2a58b312b6 zfs: merge openzfs/zfs@431083f75
Notable upstream pull request merges:
  #12194 Fix short-lived txg caused by autotrim
  #13368 ZFS_IOC_COUNT_FILLED does unnecessary txg_wait_synced()
  #13392 Implementation of block cloning for ZFS
  #13741 SHA2 reworking and API for iterating over multiple implementations
  #14282 Sync thread should avoid holding the spa config write lock
         when possible
  #14283 txg_sync should handle write errors in ZIL
  #14359 More adaptive ARC eviction
  #14469 Fix NULL pointer dereference in zio_ready()
  #14479 zfs redact fails when dnodesize=auto
  #14496 improve error message of zfs redact
  #14500 Skip memory allocation when compressing holes
  #14501 FreeBSD: don't verify recycled vnode for zfs control directory
  #14502 partially revert PR 14304 (eee9362a7)
  #14509 Fix per-jail zfs.mount_snapshot setting
  #14514 Fix data race between zil_commit() and zil_suspend()
  #14516 System-wide speculative prefetch limit
  #14517 Use rw_tryupgrade() in dmu_bonus_hold_by_dnode()
  #14519 Do not hold spa_config in ZIL while blocked on IO
  #14523 Move dmu_buf_rele() after dsl_dataset_sync_done()
  #14524 Ignore too large stack in case of dsl_deadlist_merge
  #14526 Use .section .rodata instead of .rodata on FreeBSD
  #14528 ICP: AES-GCM: Refactor gcm_clear_ctx()
  #14529 ICP: AES-GCM: Unify gcm_init_ctx() and gmac_init_ctx()
  #14532 Handle unexpected errors in zil_lwb_commit() without ASSERT()
  #14544 icp: Prevent compilers from optimizing away memset()
         in gcm_clear_ctx()
  #14546 Revert zfeature_active() to static
  #14556 Remove bad kmem_free() oversight from previous zfsdev_state_list
         patch
  #14563 Optimize the is_l2cacheable functions
  #14565 FreeBSD: zfs_znode_alloc: lock the vnode earlier
  #14566 FreeBSD: fix false assert in cache_vop_rmdir when replaying ZIL
  #14567 spl: Add cmn_err_once() to log a message only on the first call
  #14568 Fix incremental receive silently failing for recursive sends
  #14569 Restore ASMABI and other Unify work
  #14576 Fix detection of IBM Power8 machines (ISA 2.07)
  #14577 Better handling for future crypto parameters
  #14600 zcommon: Refactor FPU state handling in fletcher4
  #14603 Fix prefetching of indirect blocks while destroying
  #14633 Fixes in persistent error log
  #14639 FreeBSD: Remove extra arc_reduce_target_size() call
  #14641 Additional limits on hole reporting
  #14649 Drop lying to the compiler in the fletcher4 code
  #14652 panic loop when removing slog device
  #14653 Update vdev state for spare vdev
  #14655 Fix cloning into already dirty dbufs
  #14678 Revert "Do not hold spa_config in ZIL while blocked on IO"

Obtained from:	OpenZFS
OpenZFS commit:	431083f75b
2023-04-03 16:49:30 +02:00
Zhenlei Huang 28b498e65a ifconfig: Improve VLAN identifier parsing
VLAN identifier 0xFFF is reserved. It must not be configured or
transmitted.

Also validate during parsing to prevent potential integer overflow.

Reviewed by:	#network, melifaro
Fixes:		c7cffd65c5 Add support for stacked VLANs (IEEE 802.1ad, AKA Q-in-Q)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39282
2023-04-03 01:54:31 +08:00
Alexander V. Chernikov 25b86f8559 ping: fix failing test_pinger[_3_1_verbose_false] test. 2023-04-02 14:10:16 +00:00
Alexander V. Chernikov 68f9e13563 route: add support for exact-prefix-match via netlink. 2023-04-02 13:50:05 +00:00
Andrew Gallatin 588f03ec9b bectl: Improve error message when ZFS root is not found.
When recovering a system that is unbootable due to some
problem with the active BE, it is likely you'll be booted
from a rescue image running UFS.  In this case, bectl
needs help finding the zpool root that you want to operate
on.  In this case, improve the error message to suggest
specifying a root, rather than just emitting a generic
error message that might imply, to the naive user, that
there is a ZFS compatibility issue between the rescue
image and the on-disk ZFS pool.

Reviewed by: imp, kevans
Sponsored by: Netflix
Differential Revision:	https://reviews.freebsd.org/D39346
2023-03-31 10:27:38 -04:00
Alexander V. Chernikov 140ddeba08 route: try to autoload netlink(4) module if not present in the kernel.
Differential Revision: https://reviews.freebsd.org/D39324
2023-03-30 09:53:06 +00:00
Kirk McKusick fe5e6e2cc5 Improvement in UFS/FFS directory placement when doing mkdir(2).
The algorithm for laying out new directories was devised in the 1980s
and markedly improved the performance of the filesystem. In those days
large disks had at most 100 cylinder groups and often as few as 10-20.
Modern multi-terrabyte disks have thousands of cylinder groups. The
original algorithm does not handle these large sizes well. This change
attempts to expand the scope of the original algorithm to work well
with these much larger disks while still retaining the properties
of the original algorithm for small disks.

The filesystem implementation is divided into policy routines and
implementation routines. The policy routines can be changed in any
way desired without risk of corrupting the filesystem. The policy
requests are handled by the implementation layer. If the policy
asks for an available resource, it is granted. But if it asks for
an already in-use resource, then the implementation will provide
an available one nearby the request. Thus it is impossible for a
policy to double allocate. This change is limited to the policy
implementation.

This change updates the ffs_dirpref() routine which is responsible
for selecting the cylinder group into which a new directory should
be placed. If we are near the root of the filesystem we aim to
spread them out as much as possible. As we descend deeper from the
root we cluster them closer together around their parent as we
expect them to be more closely interactive. Higher-level directories
like usr/src/sys and usr/src/bin should be separated while the
directories in these areas are more likely to be accessed together
so should be closer. And directories within commands or kernel
subsystems should be closer still.

We pick a range of cylinder groups around the cylinder group of the
directory in which we are being created. The size of the range for
our search is based on our depth from the root of our filesystem.
We then probe that range based on how many directories are already
present. The first new directory is at 1/2 (middle) of the range;
the second is in the first 1/4 of the range, then at 3/4, 1/8, 3/8,
5/8, 7/8, 1/16, 3/16, 5/16, etc.

It is desirable to store the depth of a directory in its on-disk
inode so that it is available when we need it. We add a new field
di_dirdepth to track the depth of each directory. Because there are
few spare fields left in the inode, we choose to share an existing
field in the inode rather than having one of our own. Specifically
we create a union with the di_freelink field. The di_freelink field
is used to track inodes that have been unlinked but remain referenced.
It is not needed until a rmdir(2) operation has been done on a
directory. At that point, the directory has no contents and even
if it is kept active as a current directory is no longer able to
have any new directories or files created in it. Thus the use of
di_dirdepth and di_freelink will never coincide.

Reported by:  Timo Voelker
Reviewed by:  kib
Tested by:    Peter Holm
MFC after:    2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39246
2023-03-29 21:13:27 -07:00
Eric van Gyzen 3bbd1a1a00 camcontrol powermode: fix use-after-free
Free the ccb after processing the response therein.

Reported by:	Coverity
Fixes:		3bed0179ee
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2023-03-29 14:17:16 -05:00
Alexander V. Chernikov bd9d75e49f route: revert transport to rtsock
Temporary switch route(8) back to using rtsock to address
 the discovered issues.
2023-03-28 08:56:18 +00:00
Yuri Pankov 21af4e09f4 nvmecontrol(8): fix resv register -i synopsis
-i is "ignore existing key" and does not take argument

Reviewed by:	pauamma (manpages)
Differential Revision:	https://reviews.freebsd.org/D37709
2023-03-27 15:00:33 +02:00
Yuri Pankov 6aa5b10d0c nvme: fix resv commands with nda device
- passing I/O commands through nda requires nsid field to be set (it was
  unused when going through nvme_ns_ioctl())
- ccb's status can be OR'ed with the flags, use CAM_STATUS_MASK

Reviewed by:	imp (cam)
Differential Revision:	https://reviews.freebsd.org/D37696
2023-03-27 14:53:24 +02:00
Jose Luis Duran 9fc2d858b4 ping tests: Add a regression test
Test regression fixed in 4630a3252a. Add two tests that do not
use the verbose flag, so the code path in question can be reached:

1. Respond with a proper ICMP destination host unreachable packet.
2. Respond with a doctored ICMP destination host unreachable packet,
   that has the ICMP Identifier field modified (+1 bit).

Reviewed by:	cy
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39244
2023-03-26 19:54:29 -07:00
Alexander V. Chernikov 3a151e31ac route: fix RTF_HOST & non-empty mask handling in netlink translation. 2023-03-26 18:07:23 +00:00
Alexander V. Chernikov c597432e22 route(8): convert to netlink
This change converts all kernel rtsock interactions in route(8)
 to Netlink.

Based on the WITHOUT_NETLINK_SUPPORT src.conf(5) variable, route(8)
 now fully operates either via Netlink or via rtsock/sysctl.
The default (compile-time) is Netlink.

The output for route delete/add/get/flush is targeted to be exactly
 the same (apart from some error handling cases).
The output for the route monitor has been changed to improve
 readability and support netlink models.

Other behaviour changes:
* exact prefix lookup (route -n get a.b.c.d/e) is not yet supported.
* route monitor does not show the change originator yet.

Differential Revision:	https://reviews.freebsd.org/D39007
2023-03-26 11:06:56 +00:00
Gordon Bergling 328ebd4680 devd.conf.5: Fix a typo in the manual page
- s/deteted/detected/

MFC after:	5 days
2023-03-26 09:43:58 +02:00
Kristof Provost 0ab2c92234 ifconfig: free memory allocated by getaddrinfo()
Reported by:	emaste, Coverity
Sponsored by:	Rubicon Communications, LLC (Netgate)
2023-03-24 08:08:19 +01:00
Jose Luis Duran 4630a3252a ping: Fix an uninitialized variable
The variable oicmp, which holds the original ("quoted packet") ICMP
packet in a structured way, did not have a copy of the original ICMP
packet obtained from the raw data.

The code was accidentally removed in 20b4130314. Bring it back.

Reported by:	Coverity Scan, cy
Reviewed by:	cy
CID:		1506960 (UNINIT)
Fixes:		20b4130314
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39233
2023-03-23 21:58:28 -07:00
Bjoern A. Zeeb e091be417a ifconfig: ifieee80211: print bssid name
In certain setups (e.g., autonomous APs) it is extremly helpful to have
a way to map the BSSIDs to names for both normal status output as well
as the scan list.  This often allows a quicker overview than remembering
(or manually looking up) BSSIDs.
Call ether_ntohost() on the bssid and consult /etc/ethers
and print "(name)" after the bssid for the status output and "(name)"
at the end of the line after the IE list.

MFC after:	10 days
Reviewed by:	adrian, cy
Differential Revision: https://reviews.freebsd.org/D39192
2023-03-23 00:15:15 +00:00
Kirk McKusick e5d0d1c5fb Rewrite function definitions with identifier lists.
A few functions snuck in with K&R style definitions.

Also add some missing memory frees.

MFC after:    1 week
2023-03-22 15:58:18 -07:00
Kristof Provost b1a4ccdd83 carp: document peer/peer6 and mcast/mcast6 in the relevant man pages
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D38943
2023-03-20 14:37:10 +01:00
Kristof Provost 137818006d carp: support unicast
Allow users to configure the address to send carp messages to. This
allows carp to be used in unicast mode, which is useful in certain
virtual configurations (e.g. AWS, VMWare ESXi, ...)

Reviewed by:	melifaro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D38940
2023-03-20 14:37:09 +01:00
Kristof Provost 40e0435964 carp: add netlink interface
Allow carp configuration information to be supplied and retrieved via
netlink.

Reviewed by:	melifaro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39048
2023-03-20 10:52:27 +01:00
Jose Luis Duran ea6d169266 ping: Avoid reporting negative time statistics
Display a warning when the time goes back.

PR:		192417
Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38480
2023-03-19 12:24:06 -04:00
Jose Luis Duran 076b718d9e ping tests: Add tests for IP header options
The function pr_pack() prints out a packet, if the IP packet contains
options, these are printed as well.

Test the functionality fixed in
70960bb86a.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38470
2023-03-19 12:23:44 -04:00
Jose Luis Duran 1dc1f6bd31 ping: Remove pr_retip()
Ping used to provide some sort of packet sniffing capabilities, this was
in an era where hubs were used and tcpdump wasn't invented.

pr_iph() is a function that prints the IP header of the packet.

pr_retip() is essentially a wrapper function to pr_iph(), that also
displays the source and destination ports of a TCP or UDP packet.

After ef9e6dc7ee some of this
functionality was almost removed, to only display packets sent by us
(26+ years ago).

At this point, reaching this code path was only possible by doctoring
the original packet.

After 46d7b45a26 this code path can never
be reached.

Remove the code.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38475
2023-03-19 12:23:22 -04:00
Jose Luis Duran 20b4130314 ping: Print the IP options of the original packet
When an ICMP packet contains an IP packet in its payload, and that
original IP packet contains options, these options were not displayed
accordingly in pr_iph().

pr_iph() is a function that prints the original "quoted packet" IP
header, with only an IP struct as an argument.  The IP struct does not
contain IP options, and it is not guaranteed that the options will be
contiguous in memory to the IP struct after
d9cacf605e.

Pass the raw ICMP data along with the IP struct, in order to print the
options, if any.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38469
2023-03-19 12:23:06 -04:00
Jose Luis Duran 491263d7a6 ping: Avoid magic numbers
The sizeof(struct ip) is 20.
The sizeof(struct in_addr) is 4.

No functional change intended.

Reviewed by:	asomers, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D39125
2023-03-17 09:24:44 -04:00
Jose Luis Duran 6d33121337 ping: Remove ifndef icmp_data guards
Early versions of <netinet/ip_icmp.h> [1] did not have icmp_data
defined, but FreeBSD has always had.  Remove these guards.

NetBSD [2] and OpenBSD [3] have already removed them.

[1]: https://www.tuhs.org/cgi-bin/utree.pl?file=4.2BSD/usr/src/sys/netinet/ip_icmp.h
[2]: 203dfd3486
[3]: d83449c83c

Reviewed by:	markj
MFC after:	1 week
2023-03-14 11:58:03 -04:00
Jose Luis Duran 9185854d19 ping: Fix the display of Flags/Fragment Offset
In the IP header, Flags + Fragment Offset is a 16-bit field.

Use ntohs() instead of ntohl(), otherwise the Flags/Fragment Offset
values may not display correctly.

Before (DF set)

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  5  00 0054 0001   0 0000  40  01 b6a4 192.0.2.1  192.0.2.2

After (DF set)

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  5  00 0054 0001   2 0000  40  01 b6a4 192.0.2.1  192.0.2.2

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38479
2023-03-14 11:58:02 -04:00
Jose Luis Duran f32d6f745d ping6: Use errx to avoid appending a specious error message
Reviewed by:	asomers, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D38418
2023-03-14 11:58:02 -04:00
Gordon Bergling 21f2681828 route.8: Don't reference an external command in EXAMPLES
It is better to mention the externel command for showing
the routing table as using an explicit command.

PR:	231579
Suggested by:	karels
Reviewed by:	karles, gbe
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D39075
2023-03-14 14:55:28 +01:00
Alexander Motin 20dc2c4d11 nvmecontrol: Fix default ns create parameters.
Instead of passing 0xff's for all unset parameters, prefer reasonable
defaults.  It is much easier to use it this was without specs in hand.

MFC after:	1 week
2023-03-09 10:19:00 -05:00
Kirk McKusick 129ea078cd FFS/UFS snapshots: improve documentation for removal (deletion) and unlinking.
Clarification of the size of the snapshot file.

Suggested by: Matteo Riondato
PR:           266358
MFC after:    2 weeks
Differential Revision: https://reviews.freebsd.org/D38817
2023-03-07 22:03:00 -08:00
Kirk McKusick 52f9710412 Correct several bugs in fsck_ffs(8) triggered by corrupted filesystems.
If a directory entry has an illegal inode number (less than zero
or greater than the last inode in the filesystem) the entry is removed.
If a directory '.' or '..' entry had an illegal inode number they
were being removed. Since fsck_ffs knows what the correct value is
for these two entries fix them rather deleting them.

Add much more extensive cylinder group checks and use them to be
more careful about rebuilding a cylinder group.

Check for out-of-range block numbers before trying to free them.

When a directory is deleted also remove its cache entry created
in pass1 so that later passes do not try to operate on a deleted
directory.

Check for ctime(3) returning NULL before trying to use its return.

When freeing a  directory inode, do not try to interpret it as a
directory.

Reserve space in the inostatlist to have room to allocate a
lost+found directory.

If an invalid block number is found past the end of an inode simply
remove it rather than clearing and removing the inode.

Modernize the inoinfo structure to use queue(3) LIST rather than a
handrolled linked list implementation.

Reported by:  Bob Prohaska, John-Mark Gurney, and Mark Millard
Tested by:    Peter Holm
Reviewed by:  Peter Holm
MFC after:    2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38668
2023-03-07 15:14:47 -08:00
Kirk McKusick 7741a5c4dc FFS/UFS snapshots: improve documentation for removal (deletion) and unlinking.
Minor clarification.
2023-03-06 21:45:41 -08:00
Kristof Provost 1be25bdb73 pfctl: remove set but unused variable
In pfctl_show_ifaces() `i` is set, but never used. Remove it.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-06 19:22:35 +01:00
Kajetan Staszkiewicz 9f1beeaed4 pfctl: fix superblock printf format mismatch
It is impossible to compile pfctl with OPT_DEBUG due to integer width mismatch:

	/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:1479:9: error: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Werror,-Wformat]
					    i - pf_rule_desc[closest].prf_off--- pfctl_optimize.o ---
	^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	/usr/home/kajetan.staszkiewicz/freebsd.git/sbin/pfctl/pfctl_optimize.c:52:44: note: expanded from macro 'DEBUG'
		printf("%s: " str "\n", __FUNCTION__ , ## v)
			      ~~~                         ^
	1 error generated.

Reviewed by:	kp
Obtained from:	OpenBSD (pfctl_optimize.c 1.15)
Differential Revision:	https://reviews.freebsd.org/D38918
2023-03-06 19:22:35 +01:00
Alexander V. Chernikov e2dc8d789f dhclient: do not add 0.0.0.0 interface alias.
Subscribers: imp

Differential Revision: https://reviews.freebsd.org/D38908
2023-03-06 15:08:09 +00:00
Kirk McKusick 528d8e55c8 FFS/UFS snapshots: improve documentation.
This update provides a more detailed description of FFS/UFS snapshots
and adds links to useful man pages.

Requested by: Graham Perrin
Submitted by: darius-dons.net.au
Reviewed by:  Ravi Pokala
PR:           266358
MFC after:    2 weeks
Differential Revision: https://reviews.freebsd.org/D38817
2023-03-05 21:38:57 -08:00
Kristof Provost f5b204adf4 ifconfig: remove unused variable
In printgroup() 'cnt' is set, but never read. Remove it.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-04 11:19:12 +01:00
Kyle Evans 0c42886449 sysctl: tests: fix a couple issues
The function that sets test case metadata is actually named ${tc}_head
rather than ${tc}, so add the suffix.

While we're here, hook the tests up to the infrastructure so that they
do get run.

Sponsored by:	Klara, Inc.
2023-03-01 14:38:46 -06:00
Poul-Henning Kamp 996606792f Add deprecation notice to the gbde(8) program, scheduled to be removed in FreeBSD 15.0. 2023-02-28 21:39:06 +00:00
Gordon Bergling 6dbfbe6e11 route.8: Fix mandoc warnings
- skipping end of block that is not open: Oc
- no blank before trailing delimiter
- remove useless TN macros
- remove commented out reference for esis(4)

MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D38783
2023-02-26 14:33:58 +01:00
Gordon Bergling b06338167d route.8: Add information about ROUTE_MPATH and FIB_ALGO
Since the kernel options ROUTE_MPATH and FIB_ALGO are enabled
per default for a while, it's good to have some user facing
documetation about the general functionality of multipath
routing and fib lookup algorithms.

Reviewed by:	pauamma, Jose Luis Duran <jlduran at gmail dot com>
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D38783
2023-02-26 14:15:34 +01:00
Cy Schubert 70960bb86a ping: Fix unsigned integer underflow resuling in a ping -R segfault
ping -R (F_RROUTE) will loop at ping.c:1381 until it segfaults or
the unsigned int hlen happens to be less than the size of an IP header:

slippy$ ping -R 192.168.0.101
PING 192.168.0.101 (192.168.0.101): 56 data bytes
64 bytes from 192.168.0.101: icmp_seq=0 ttl=63 time=1.081 ms
RR: 	192.168.0.1
	192.168.0.101
	192.168.0.101
	10.1.1.254
	10.1.1.91
unknown option bb
unknown option 32
unknown option 6
...
unknown option 96
unknown option 2d
Segmentation fault

The reason for this is while looping through loose source routing (LSRR)
and strict source routing (SSRR), hlen will become smaller than the IP
header. It may even become negative. This should terminate the loop.
However, when hlen is unsigned, an integer underflow occurs becoming a
large number causing the loop to continue virtually forever until hlen
is either by chance smaller than the lenghth of an IP header or it
segfaults.

Reviewed by:	asomers
Fixes:		46d7b45a26
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D38744
2023-02-24 06:50:53 -08:00
Mina Galić 7e2af4f90b veriexec(4): Fix a compiler error
When building WITH_BEARSSL=1 veriexec(4) failes to compile.
So update the function prototype so that veriexec(4)
compiles again.

Reported by:	gbe
Reviewed by:	mjg, gbe
Approved by:	mjg
Pull Request:	https://github.com/freebsd/freebsd-src/pull/657
2023-02-23 12:14:41 +01:00
Jose Luis Duran 5b8af90fe3 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
2023-02-20 10:34:33 +00:00
Alexander V. Chernikov 3d360ca49c Revert "ping: Add ATF-Python tests"
This reverts commit 0343e90f39.
2023-02-20 10:34:09 +00:00
Alexander V. Chernikov 0343e90f39 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
2023-02-20 10:31:38 +00:00
Konstantin Belousov 5942b4b6fd sys/param.h: Add _WANT_P_OSREL
Use it instead of defining IN_RTLD by base sources that want P_OSREL_
defines in userspace, but are not rtld.
This allows to remove abuse of IN_RTLD from userspace.

Reviewed by:	dchagin, markj, imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38585
2023-02-15 02:43:18 +02:00
Kyle Evans 8d78a0d331 md5: fix *sum -c with missing files
If we fail to open one of the files in the file listing, we still need
to advance `rec` along with `argv` so that the checksum we're checking
against lines up with the file we're hashing.

Tests added both for the -c flag, as well as the -b and -t modes of
the *sum programs.

PR:		267722
Reviewed by:	emaste (earlier version)
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D37374
2023-02-13 00:32:38 -06:00
Emmanuel Vadot cab549c76c pkgbase: Create a FreeBSD-console-tools package
And put in it:
 - kbdcontrol
 - vidcontrol
 - moused
 - kbdmap

Those aren't useful in a jail or for a modern desktop.
While here, split the devd.conf part into some new files.

Reviewed by:	bapt
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38321
2023-02-08 08:52:40 +01:00
Emmanuel Vadot 2878e21ff1 devd: Move power_profile part in devd/power_profile.conf
And make it part of the FreeBSD-acpi package.
This avoid calling service power_profile on an installation without it
installed.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38324
2023-02-08 08:52:17 +01:00
Emmanuel Vadot 9150a0455e devd: Move bluetooth part in devd/bluetooth.conf
And make it part of the FreeBSD-bluetooth package.
This avoid calling service bluetooth on an installation without it
installed.

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38323
2023-02-08 08:51:34 +01:00
Emmanuel Vadot f4d9116de1 devd: Move dhclient part in devd/dhclient.conf
And make it part of the FreeBSD-dhclient package.
This avoid calling dhclient on an installation without dhclient
installed.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D38322
2023-02-08 08:51:20 +01:00
Dmitry Chagin de59f46a82 bsdlabel: Fix whitespace.
MFC after:		1 week
2023-02-07 10:43:40 +03:00
Dmitry Chagin 901b050b36 bsdlabel: Remove a write-only variable.
Since r149061 (2005) the total_size variable is write-only.

Differential Revision:	https://reviews.freebsd.org/D38368
MFC after:		2 weeks
2023-02-07 10:43:18 +03:00
Stefan Eßer d804497068 md5/tests: extend md5 test
The testloop function is called with various parameters, but those
were ignored in the coreutils-c-test script. This was an oversight
and is fixed by passing the option to all invocations of the hash
functions in this test script.

Reported by:	des
MFC after:	3 days
2023-02-06 21:25:44 +01:00
Dag-Erling Smørgrav 2768d70567 libmd / md5: Add SHA-512/224.
While there, remove .Tn from man pages.

Also remove an obsolete comment about the 80386.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D38373
2023-02-06 18:03:04 +01:00
Xin LI fdbfaefefa hastctl: use zlib's crc32 implementation.
X-MFC-with:	6998572a74
MFC after:      2 weeks
2023-02-03 00:30:08 -08:00
Xin LI 6998572a74 hastd: use zlib's crc32 implementation.
Reviewed by:	pjd
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D35767
2023-02-02 23:14:21 -08:00
Mateusz Piotrowski 197947e0a3 ifconfig.8: Improve readability of vlanproto's description
Sponsored by:	Klara Inc.
MFC after:	1 week
2023-02-01 16:06:45 +01:00
Xin LI 195ec47b47 sbin/ping6: Remove remains of ping6.
MFC after:	2 weeks
2023-01-29 15:21:25 -08:00
Kirk McKusick ad055467be Fix for getmntpoint(3) when checking for NFS mount points.
Only attempt to add /dev/ to f_mntfromname names that result in a
valid character device.

MFC after:    1 week
Reported by:  Bjoern A. Zeeb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37907
2023-01-29 15:14:43 -08:00
Ed Maste ac4c695ad6 Retire WITHOUT_CXX option
Several important base system components are written in C++, and the
WITHOUT_CXX option produced a system that was not fully functional.
Just accept this, and remove the option to build without C++ support.

This reverts commit adc3c128c6.

Reviewed by:	brooks, kevans, jhb (earlier)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33108
2023-01-26 21:13:16 -05:00
Kirk McKusick 0bd4c448ec Rewrite to avoid Coverity false positive.
MFC after:    1 week
Reported by:  Coverity (CID 1502669)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37907
2023-01-25 16:57:26 -08:00
Ceri Davies da52fc464a ipfw.8: there never was a "skip-action" action
It was renamed during review of D1776 but this entry slipped through.

PR:		243284
Reported by:	pprocacci@gmail.com
Obtained from:	Chad Jacob Milios <milios@ccsys.com>
2023-01-25 18:15:18 +00:00
Kristof Provost cd80c52cad pfctl: rule.label is a two-dimensional array
Fix checking for a non-empty first string.

PR:		269075
MFC after:	1 week
Reported by:	nreilly@blackberry.com
2023-01-24 07:46:46 +01:00
Alan Somers 5205908816 Revert "ifconfig: abort if loading a module fails other than for ENOENT"
This reverts commit 2c24ad3377.

This change causes some commands to fail, for example when working with
renamed interfaces or when trying to list a nonexistent interface by
name.

PR:		269042
Reported by:	dbaio, Michael Paepcke <bugs.fbsd@paepcke.de>
MFC with:	2c24ad3377
2023-01-20 10:17:21 -07:00
Kirk McKusick 906c312bbf 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
2023-01-15 10:21:31 -08:00
Jose Luis Duran bdd60b224f 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
2023-01-13 20:21:27 +00:00
Alan Somers 2c24ad3377 ifconfig: abort if loading a module fails other than for ENOENT
If "ifconfig create" tries to load a kernel module, and the module
exists but can't be loaded, fail the command with a useful error
message.  This is helpful, for example, when trying to create a cloned
interface in a vnet jail.  But ignore ENOENT, because sometimes ifconfig
can't correctly guess the name of the required kernel module.

MFC after:	2 weeks
Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D37873
2023-01-09 19:56:18 -07:00
Jose Luis Duran 8eb4df9487 ping(8): man page cleanup
* Appease mandoc -T lint and igor

* Use example.com for documentation

* Update the IPv4 TTL section.
  Update the IPv4 TTL section specifically for FreeBSD.
  FreeBSD changed the default TTL to 64 in
  5639e86bdd.  NetBSD and OpenBSD still
  use 255.  Remove some references of extinct operating systems.

Reviewed by:	gbe (manpages), asomers
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/630
2023-01-02 00:48:25 +00:00
Alan Somers e35cfc606a Add test cases for ping with IP options in the response
MFC after:	1 week
Reviewed by:	markj
Differential Revision: https://reviews.freebsd.org/D37210
2022-12-25 22:59:58 -07:00
Kirk McKusick f126d34981 Add -F option to sysctl(8) to display sysctl format.
Also add a test to ensure that it is working correctly.

Submitted by: ota_j.email.ne.jp
Reviewed by:  mckusick
Differential Revision: https://reviews.freebsd.org/D34012
2022-12-24 22:59:00 -08:00
Ceri Davies 8183df7f00 mount_nullfs.8: Bump .Dd for file mounts update. 2022-12-19 18:58:39 +00:00
Doug Rabson a3f714c4ff Add support for mounting single files in nullfs
My main use-case for this is to support mounting config files and secrets
into OCI containers. My current workaround copies the files into the
container which is messy and risks secrets leaking into container images
if the cleanup fails.

Reviewed by:	mjg, kib
Tested by:	pho
Differential Revision: https://reviews.freebsd.org/D37478
2022-12-19 16:44:54 +00:00
Ed Maste fa4d25f5b4 retire sconfig(8) ce(4)/cp(4) configuration tool
The ce(4) and cp(4) drivers have been retired.

Differential Revision:	https://reviews.freebsd.org/D33469
2022-12-13 15:25:13 -05:00
Ed Maste 20dfe27b2d Add deprecation notices to ce,cp sync serial drivers
And the related sconfig utility.  Sync serial (e.g. E1/T1) interfaces
are obsolete, and nobody responded to several inquires on the mailing
lists about use of these drivers.

Relnotes:	Yes
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D23928
2022-12-13 14:59:08 -05:00
Jose Luis Duran 47972d6dc4 Fix rcorder example to match the keyword in the description
Differential Revision: https://reviews.freebsd.org/D37686
2022-12-13 19:56:28 +00:00
Ceri Davies cd9cdd0eaa sysctl.8: grammar nit 2022-12-13 19:52:10 +00:00