Commit graph

10646 commits

Author SHA1 Message Date
Warner Losh 64db9a0f82 Add kenv .Xr in kldload(8) and loader.conf(5)
Sponsored by:		Netflix
2023-12-20 21:17:38 -07:00
Richard Scheffenegger 31cf66d755 dummynet: add simple gilbert-elliott channel model
Have a simple Gilbert-Elliott channel model in
dummynet to mimick correlated loss behavior of
realistic environments. This allows simpler testing
of burst-loss environments.

Reviewed By:           tuexen, kp, pauamma_gundo.com, #manpages
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D42980
2023-12-17 13:20:45 +01:00
Warner Losh 69ae43a1e6 camcontrol: One file per line in Makefile
We have enough files now that moving to one file per line makes sense.

Sponsored by:		Netflix
2023-12-07 13:21:57 -07:00
R. Christian McDonald ca7edd0d2c
route: introduce add interface route test cases
As a followup to D41330 and D41436, this patch introduces two new tests
for sbin/route: interface_route_v[46].

These tests fail without D41330.

Reviewed by:	kp
Approved by:	kp (mentor)
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-28 16:16:25 -05:00
Mike Karels cd201c0908 ifconfig: add -D option to print driver name for interface
Add -D option to add the drivername and unit number to ifconfig output
for normal display, including -a.  Use ifconfig_get_orig_name() from
libifconfig to fetch the name.  Note that this is the original name
for many drivers, but not for some exceptions like epair (which appends
'a' or 'b' to the unit number).  epair interface pairs both display
as "epair0", etc.  Make -v imply -D; might as well be fully verbose.

MFC after:	1 week
Reviewed by:	zlei, kp
Differential Revision:	https://reviews.freebsd.org/D42721
2023-11-28 13:47:37 -06:00
Luiz Amaral 0187875a6c pfctl: Fix recursive printing of anchor labels
We recently noticed that the recursive printing of labels wasn't working
like the recursive printing of rules.

When running pfctl -sr -a* we get a listing of all rules, including the
ones inside anchors. On the other hand, when running pfctl -sl -a*, it
would only print the labels in the root level, just like without the
-a* argument.

As in our use-case we are interested on labels only and our labels are
unique even between anchors, we didn't add indentation or hierarchy to
the printing.

Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D42728
2023-11-27 21:37:33 +01:00
Kristof Provost 47a0b59379 pfctl: use libpfctl instead of DIOCGETRULES directly
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-11-27 21:36:48 +01:00
Warner Losh 32e86a82f5 sbin: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:23:59 -07:00
Warner Losh 0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh 5b31cc94b1 sccs: Manual changes
For the uncommon items: Go through the tree and remove sccs tags that
didn't fit any nice pattern. If in the neighborhood, other SCM tags were
removed when they were detritis of long-ago CVS somehow in the early
mists of the project. Some adjacent copyrights stringswere removed (they
duplicated the copyright notices in the file). This also removed
non-standard formations of omission of SCCS tags (usually by adding an
extra #if 0 somewhere.

After this commit, a number of strings tagged with the 'what' @(#)
prefix remain, but they are primarily copyright notices.

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh 51e16cb8fc sbin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:29 -07:00
Emmanuel Vadot b3c116d50e devd: autofs: Move autofs related events to a separate file
If a user don't have FreeBSD-autofs installed there is no need to try calling
automount on every GEOM event.
It's also easier to add/delete autofs related event in a separate file.

Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D42495
Reviewed by:	imp
2023-11-24 10:45:03 +01:00
Kirk McKusick 772430dd67 Ensure I/O buffers in libufs(3) are 128-byte aligned.
Various disk controllers require their buffers to be aligned to a
cache-line size (128 bytes). For buffers allocated in structures,
ensure that they are 128-byte aligned. Use aligned_malloc to allocate
memory to ensure that the returned memory is 128-byte aligned.

While we are here, we replace the dynamically allocated inode buffer
with a buffer allocated in the uufsd structure just as the superblock
and cylinder group buffers do.

This can be removed if/when the kernel is fixed. Because this problem
has existed on one I/O subsystem or another since the 1990's, we
are probably stuck with dealing with it forever.

The problem most recent showed up in Azure, see:
    https://reviews.freebsd.org/D41728
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=267654
Before these fixes were applied, it was confirmed that the changes
in this commit also fixed the issue in Azure.

Reviewed-by: Warner Losh, kib
Tested-by:   Souradeep Chakrabarti of Microsoft (earlier version)
PR:          267654
Differential Revision: https://reviews.freebsd.org/D41724
2023-11-17 14:11:24 -08:00
Gordon Bergling 115459be31 SEE ALSO section improvements for tuning(7), tunefs(8) and fsck_ffs(8)
cross-reference ffs(7) in fsck_ffs(8)
cross-reference ffs(7) and tuning(7) in tunefs(8)
cross-reference ffs(7) in tuning(7)

PR:	263433
Reviewed by:	bcr
MFC after:	5 days
Differential Revision:	https://reviews.freebsd.org/D42631
2023-11-17 19:24:22 +01:00
Konstantin Belousov a294b02fbc reboot(8): print syscall error on sysctl failure
Noted by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D42561
2023-11-13 03:46:51 +02:00
Konstantin Belousov 194cc45a81 reboot(8): adapt for vmmeter v_swappgsin expansion to 64bit
Otherwise reboot(8) requires COMPAT_FREEBSD11 kernel config option.

PR:	275048
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D42561
2023-11-13 03:46:36 +02:00
Luiz Amaral 81d4c78620 pfsync: Document the transport over IPv6 feature
On D40102 we implemented support for transport over IPv6 but the
documentation was not updated to reflect the new feature.

Clarify what is available and how it can be used.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D42505
2023-11-10 16:40:02 +01:00
Antranig Vartanian d6e457328d
ping6(8): Add ping6(8) as MLINK to ping(8)
Reviewed by:	chuck
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42203
2023-11-08 05:17:37 +08:00
Kristof Provost a6173e9463 pf: expose more syncookie state information to userspace
Allow userspace to retrieve low and high water marks, as well as the
current number of half open states.

MFC after:	1 week
Sponsored by:	Modirum MDPay
2023-11-06 22:22:24 +01:00
Kristof Provost ca9dbde881 pf: support SCTP-specific timeouts
Allow SCTP state timeouts to be configured independently from TCP state
timeouts.

Reviewed by:	tuexen
MFC after:	1 week
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D42393
2023-10-31 16:03:22 +01:00
Konstantin Belousov 224fc33f60 setkey(8): make the policy specification more readable
by applying markup and highlighting the semantical blocks.

Sponsored by:	NVidia networking
MFC after:	1 week
2023-10-31 06:07:10 +02:00
Stephen J. Kiernan 5e3190f700 dirdeps: Update Makefile.depend* files with empty contents
Some Makefile.depend* files were committed with no contents or empty
DIRDEPS list, but they should have DIRDEPS with some contents.
2023-10-29 17:01:04 -04:00
Warner Losh aa7c028adb devd: Improve devmatch support
We know that calling devmatch will be futile if there's no plug and play
information for it to match on. Avoid this generically when we see
	"? at +on"
which happens only when the location and pnpinfo aren't provided. Don't
call "service devmatch quietstart" here.

We also ignore ACPI devices with a _HID of none. These also will never
load a new driver, so avoid calling "service devmatch quietstart" here too.

Use the more compatct "$*" instead of "'?'$_" when calling "service
devmatch quietstart" since it will evaluate to the same thing.

On my laptop, this eliminates 45% of the calls to devmatch. While it
would be even better to integrate devmatch into devd (so we only parse
linker.hints once), that will have to wait for another day as it's a bit
more complex to arrange that avoiding easy to avoid calls.

Sponsored by:		Netflix
Reviewed by:		emaste
Differential Revision:	https://reviews.freebsd.org/D42326
2023-10-27 15:24:19 -06:00
Warner Losh dbf203548b devd: Remove obsolete / wrong nomatch examples
These examples are wrong, and with devmatch, nobody would ever see them
(since it's a higher priority).

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D42325
2023-10-27 15:24:19 -06:00
Warner Losh 5e50df6dc0 devd: Restore WARNS=6
We compile correctly on all platforms with clang and WARNS=6. We build
on amd64 with gcc12 and WARNS.6. Restore WARNS=6. This reverts
3741a56c31, since that's no longer relevant.

Sponsored by:		Netflix
2023-10-26 10:11:59 -06:00
Kirk McKusick d3a36e4b74 Delete snapshot after opening it when running fsck_ffs(9) in background.
When fsck_ffs(8) runs in background, it creates a snapshot named
fsck_snapshot in the filesystem's .snap directory. The fsck_snapshot
file was removed when the background fsck finished. If the system
crashed or the fsck exited unexpectedly, the fsck_snapshot file
would remain. The snapshot would consume ever more space as the
filesystem changed over time until it was removed by a system
administrator or a future run of background fsck removed it to
create a new snapshot file.

This commit unlinks the .snap/fsck_snapshot file immediately after
opening it so that it will be reclaimed when fsck closes it at the
conclusion of its run. After a system crash, it will be removed as
part of the filesystem cleanup because of its zero reference count.
As only a few milliseconds pass between its creation and unlinking,
there is far less opportunity for it to be accidentally left behind.

PR:           106107
MFC-after:    1 week
2023-10-25 15:38:11 -07:00
Jose Luis Duran 0514f032c8 devfs(8): Remove references to /usr/share/examples/etc/devfs.conf
This file does not exist, remove it from the list of files to avoid
confusion.  The example file is just /etc/devfs.conf.

Reviewed by:	mhorne
Pull Request:	https://github.com/freebsd/freebsd-src/pull/871
2023-10-23 15:14:23 -03:00
Kristof Provost 4f33755051 pf: allow states to be killed by their pre-NAT address
If a connection is NAT-ed we could previously only terminate it by its
ID or the post-NAT IP address. Allow users to specify they want look for
the state by its pre-NAT address. Usage: `pfctl -k nat -k <address>`.

See also:	https://redmine.pfsense.org/issues/11556
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42312
2023-10-23 16:37:05 +02:00
Kristof Provost 044eef6ab9 pf: support basic filters for state listing
Allow users(pace) to specify a protocol, interface, address family and/
or address and mask, allowing the state listing to be pre-filtered in
the kernel.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42280
2023-10-23 16:24:52 +02:00
Kirk McKusick 1e39a0886e Fix a bug in fsck_ffs(8) triggered by corrupted filesystems.
Add missing check for failed block read when checking information about
a snapshot file.

Reported-by:  Andreas Bock
PR:           274404
MFC-after:    1 week
2023-10-20 15:15:40 -07:00
Jose Luis Duran 24fe0cb84d ping tests: Fix test on i386 platforms
Actually use INT_MAX (0x7fffffff), not UINT_MAX (0xffffffff) to avoid
overflowing time_t and missing the test.

Reported by:	Jenkins
Reviewed by:	markj
Fixes:		5b8af90fe3 ("ping: Add ATF-Python tests")
Pull Request:	https://github.com/freebsd/freebsd-src/pull/874
Differential Revision: https://reviews.freebsd.org/D42268
2023-10-19 09:35:39 -04:00
Kristof Provost 4f8f43b06e netlink: cope with growing requests
If a request ends up growing beyong the initially allocated space the
netlink functions (such as snl_add_msg_attr_u32()) will allocate a
new buffer. This invalidates the header pointer we can have received
from snl_create_msg_request(). Always use the hdr returned by
snl_finalize_msg().

Reviewed by:	melifaro
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42223
2023-10-17 08:47:52 +02:00
Kajetan Staszkiewicz 18be782c4e pfsync: Provide documentation regarding message version
Reviewed by:	kp
MFC after:	3 days
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D42235
2023-10-17 06:38:47 +02:00
Kristof Provost 6ace92326f ifconfig: add static bridge addresses for vlan 0, not 1
Since fd7edfcdc3 ("bridge: fix lookup for untagged packets in
bridge_transmit()") and b0e38a1373 ("bridge: distinguish no vlan and
vlan 1") we do a better job of distinguishing between untagged and VLAN
1 traffic.

However, ifconfig still defaulted to adding addresses for VLAN 1, rather
than for untagged traffic. Change this to be the most common (i.e.
untagged) option.

Reviewed by:	zlei, philip
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D42188
2023-10-15 16:21:53 +02:00
Kristof Provost 81647eb60e pf: implement start/stop calls via netlink
Implement equivalents to DIOCSTART and DIOCSTOP in netlink. Provide a
libpfctl implementation and add a basic test case, mostly to verify that
we still return the same errors as before the conversion

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42145
2023-10-13 09:53:22 +02:00
Dag-Erling Smørgrav fc7143b483 ping: Add missing ATF boilerplate.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42161
2023-10-11 21:45:06 +02:00
Dag-Erling Smørgrav c4ffb80ef1 ping: Consistently use EX_NOHOST for DNS failures.
Traditionally, ping returned exit code EX_NOHOST if a DNS lookup failed.
That is still the case for the legacy code in the new merged ping, but
not for IPv6 targets, nor when a DNS lookup is performed in order to
determine which version of the tool to invoke.

While here, also make sure that the error message is consistent.

Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D42159
2023-10-11 21:44:30 +02:00
Jose Luis Duran 4efaf43c6f ping: Require root user for pytests
atf_python may use vnet jails for creating an isolated test environment.
Mark these tests that require root user privileges.

Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
2023-10-11 13:48:28 -04:00
Jose Luis Duran b86e4812cc ping: pr_iph() improvements
Very early on, the Src/Dst IP addresses were printed in hex notation
(%08x), which will always be 8-characters wide.  It was later changed to
use a dot-decimal notation.  Depending on the IP address length, the Src
and Dst headers may require a different padding.  Use the source and
destination IP lengths as padding for the headers.

Also, print an Opts (options) header, if there are options present.  It
has been abbreviated to Opts to match the length of the previous Data
header, removed in ef9e6dc7ee.

Print the header info such that no trailing spaces are produced.  As
some git workflows may automatically trim them, and make the tests fail
(see 25b86f8559).

Before

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1  192.0.2.2␣

After

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1 192.0.2.2

And with options:

Before

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks      Src      Dst
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1  192.0.2.2 01...

After

    Vr HL TOS  Len   ID Flg  off TTL Pro  cks       Src       Dst Opts
     4  f  00 007c 0001   0 0000  40  01 d868 192.0.2.1 192.0.2.2 01...

Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D39561
2023-10-11 13:48:28 -04:00
Jose Luis Duran 8db2c5802a ping: Fix the spacing between the time stamp and cp/dp
When an echo reply packet is received, the data is compared with the
sent data.  When a wrong byte is detected the command displays a report
with the differences.

The first row (the first 8-bytes of data after the ICMP header) should
include the time stamp (if data is at least 8-bytes), this value is not
taken into consideration for the comparison.  The remaining rows
represent the data (padded pattern) received/sent, with each byte being
compared for differences.

Print the space before (not after), to add an extra space after cp:/dp:
for better readability when the first time stamp octet is not
zero-padded, and to remove trailing spaces in the output.

Before:
    cp:99  0  0  c  1  5  c  0␣
    	ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd␣
    	...

After:
    cp: 99  0  0  c  1  5  c  0
    	 ab cd ab cd ab cd ab cd ab cd ab cd ab cd ab cd
    	 ...

Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D39492
2023-10-11 13:48:28 -04:00
Jose Luis Duran 03d4d1c778 ping: Unify ping/ping6 statistics section
This is a first step towards a unification/simplification of ping/ping6
(internally).  The end goal is to produce a standardized user-facing
output.

Before (ping6):

    PING6(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
    16 bytes from ::1, icmp_seq=0 hlim=64 time=0.168 ms
    16 bytes from ::1, icmp_seq=1 hlim=64 time=0.068 ms

    --- 2001:db8::2 ping6 statistics ---
    round-trip min/avg/max/std-dev = 0.068/0.118/0.168/0.050 ms

After (ping6):

    PING(56=40+8+8 bytes) 2001:db8::1 --> 2001:db8::2
    16 bytes from ::1, icmp_seq=0 hlim=64 time=0.168 ms
    16 bytes from ::1, icmp_seq=1 hlim=64 time=0.068 ms

    --- 2001:db8::2 ping statistics ---
    round-trip min/avg/max/stddev = 0.068/0.118/0.168/0.050 ms

This has the nice side-effect of adding units to SIGINFO's statistics,
as printing numbers without units may not be of much help.  Also
mentions the fact that these times are round-trip.

Before (ping/ping6 SIGINFO):

    2/2 packets received (100.0%) 0.068 min / 0.118 avg / 0.168 max

After (ping/ping6 SIGINFO):

    --- <ipv4/ipv6 address> ping statistics ---
    2 packets transmitted, 2 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 0.068/0.118/0.168/0.050 ms

In the case of a SIGINFO, the output will be printed to stderr, for both
ping and ping6.

Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D39126
2023-10-11 13:48:28 -04:00
Jose Luis Duran 72d3e6677f ping: Specify the sigaction(2) name
After a2a0088805, specify the signal name.

Obtained from:	Darwin
MFC after:	1 week
Reviewed by:	asomers
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D38484
2023-10-11 13:48:28 -04:00
Jose Luis Duran d2c9a14054 ping: Remove an extra new line character
This matches the behavior when an RR truncated route is printed.

Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D39485
2023-10-11 13:48:27 -04:00
Jose Luis Duran 20012a3a1a ping tests: Test IHL/quoted data/inner packet paths
Commit 46d7b45a26 introduced these code
paths.  Test and document them.

- Add inner packet too short test
- Add inner IHL too short test
- Add quoted data too short test
- Add IHL too short test
- Add max inner packet IHL without payload test

Reviewed by:	markj
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D38528
2023-10-11 13:48:27 -04:00
Jose Luis Duran 4d348e83b7 ping: Avoid reporting NaNs
Avoid calculating the square root of negative zero, which can easily
happen on certain architectures when calculating the population standard
deviation with a sample size of one, e.g., 0.01 - (0.1 * 0.1) =
-0.000000.

Avoid returning a NaN by capping the minimum possible variance value to
zero (positive).

In the future, maybe skip reporting statistics at all for a single
sample.

Reported by:	Jenkins
Reviewed by:	asomers
MFC after:	1 week
Pull Request:	https://github.com/freebsd/freebsd-src/pull/863
Differential Revision:	https://reviews.freebsd.org/D42114
2023-10-11 13:48:27 -04:00
Dag-Erling Smørgrav 7fd2c91a29 ping: Simplify protocol selection.
* Interrupt the option loop as soon as we have an indication of which
  protocol is intended.
* If we end up having to perform a DNS lookup, loop over the entire
  result looking for either IPv4 or IPv6 addresses.

Sponsored by:	NetApp, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	rscheff, kevans, allanjude
Differential Revision:	https://reviews.freebsd.org/D42137
2023-10-11 00:47:59 +02:00
Kristof Provost a7191e5d7b pf: add a way to list creator ids
Allow userspace to retrieve a list of distinct creator ids for the
current states.

This is used by pfSense, and used to require dumping all states to
userspace. It's rather inefficient to export a (potentially extremely
large) state table to obtain a handful (typically 2) of 32-bit integers.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42092
2023-10-10 11:48:21 +02:00
Kristof Provost f218b851da libpfctl: introduce state iterator
Allow consumers to start processing states as the kernel supplies them,
rather than having to build a full list and only then start processing.
Especially for very large state tables this can significantly reduce
memory use.

Without this change when retrieving 1M states time -l reports:

    real 3.55
    user 1.95
    sys 1.05
        318832  maximum resident set size
           194  average shared memory size
            15  average unshared data size
           127  average unshared stack size
         79041  page reclaims
             0  page faults
             0  swaps
             0  block input operations
             0  block output operations
         15096  messages sent
        250001  messages received
             0  signals received
            22  voluntary context switches
            34  involuntary context switches

With it it reported:

    real 3.32
    user 1.88
    sys 0.86
          3220  maximum resident set size
           195  average shared memory size
            11  average unshared data size
           128  average unshared stack size
           260  page reclaims
             0  page faults
             0  swaps
             0  block input operations
             0  block output operations
         15096  messages sent
        250001  messages received
             0  signals received
            21  voluntary context switches
            31  involuntary context switches

Reviewed by:	mjg
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42091
2023-10-10 11:48:21 +02:00
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