Commit graph

10847 commits

Author SHA1 Message Date
Warner Losh
2b1460110e nvmecontrol: Add more keys for CA page (Additional smart data)
Micron and Samsung also use this standard, though Micron is known to use
a few different keys. Add the ones that public information say are the
same among those the drives that have them.

There's others, but either they aren't publicly documented in datasheets
or nvme-cli code, or they vary betwen models and our code needs a fair
amount of rework needed.

Also print hex value for unknown keys. This allows scripts to more
easily pick bytes out for those keys who have values that are encoded by
packing multiple values into the 48-bit field.

Sponsored by:		Netflix
2025-02-21 17:23:44 -07:00
Kristof Provost
8754ba5a5f pfctl: Rewrite to void using union sockaddr_union
ok mikeb

Obtained from:	OpenBSD, deraadt <deraadt@openbsd.org>, 8717211fe3
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-21 09:11:02 +01:00
Kristof Provost
c2346c3d3a pf: support source-hash and random with tables and dynifs, not just pools
This finally allows to use source-hash for dynamic loadbalancing, eg.
"rdr-to <hosts> source-hash", instead of just round-robin and least-states.

An older pre-siphash version of this diff was tested by many people.

OK tedu@ benno@

Obtained from:	OpenBSD, reyk <reyk@openbsd.org>, 252a05523f
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-20 09:25:51 +01:00
Kristof Provost
81dc007a00 pfctl: improve warnings for limits
If pfctl cannot set a limit in the kernel, print the name of the
limit and the requested value.
OK henning@

Obtained from:	OpenBSD, bluhm <bluhm@openbsd.org>, beb5ed50a7
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-19 11:41:10 +01:00
Kristof Provost
2514ac810d pfctl: Don't allow embedded nul characters in strings.
Fixes a pfctl crash with an anchor name containing
an embedded nul found with the afl fuzzer.

pfctl parse.y patch from and ok deraadt@

Obtained from:	OpenBSD, jsg <jsg@openbsd.org>, 41eef22fad
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-19 11:41:10 +01:00
Kristof Provost
5b7bfd0046 pfctl: consolidate some code by using reallocarray in all cases
ok deraadt millert

Obtained from:	OpenBSD, tedu <tedu@openbsd.org>, 97d14fe110
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-19 11:41:09 +01:00
Bjoern A. Zeeb
8f2e5b6ef3 net80211/ifconfig: swap IEEE80211_FVHT_USEVHT160 and 80P80
ieee80211_setupcurchan() compares the flags in a greater than manner.
In this case VHT160 should be > VHT80P80 as it is preferable.
Swap the two flags and add a comment to note this.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D48976
2025-02-15 15:49:02 +00:00
Kristof Provost
cba525e53b pfctl: relax the cfg file secrecy check slightly to allow group readability
default permissions and mtree NOT changed.
prodded by benno, ok phessler benno jmatthew theo pelikan florian

Obtained from:	OpenBSD, henning <henning@openbsd.org>, 7140c133f0
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-14 18:47:53 +01:00
Kristof Provost
a2614574f2 pfctl: if_item can be "any" now
Allows things like:
	block out on $someif received-on any

to prevent packets to get forwarded to $someif.

Obtained from:	OpenBSD, henning <henning@openbsd.org>, 5984d04852
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-14 18:47:52 +01:00
Kajetan Staszkiewicz
07e070ef08 pf: Add support for multiple source node types
For every state pf creates up to two source nodes: a limiting one
struct pf_kstate -> src_node and a NAT one struct pf_kstate -> nat_src_node.
The limiting source node is tracking information needed for limits using
max-src-states and max-src-nodes and the NAT source node is tracking NAT
rules only.

On closer inspection some issues emerge:
- For route-to rules the redirection decision is stored in the limiting source
  node. Thus sticky-address and source limiting can't be used separately.
- Global source tracking, as promised in the man page, is totally absent from
  the code. Pfctl is capable of setting flags PFRULE_SRCTRACK (enable source
  tracking) and PFRULE_RULESRCTRACK (make source tracking per rule). The kernel
  code checks PFRULE_SRCTRACK but ignores PFRULE_RULESRCTRACK. That makes
  source tracking work per-rule only.

This patch is based on OpenBSD approach where source nodes have a type and each
state has an array of source node pointers indexed by source node type
instead of just two pointers. The conditions for limiting are applied
only to source nodes of PF_SN_LIMIT type. For global limit tracking
source nodes are attached to the default rule.

Reviewed by:		kp
Approved by:		kp (mentor)
Sponsored by:		InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D39880
2025-02-13 15:59:12 +01:00
Kristof Provost
71594e3235 pf: support "!received-on <interface>"
ok dlg benno

Obtained from:	OpenBSD, henning <henning@openbsd.org>, 7d0482a910
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-13 13:38:44 +01:00
Kristof Provost
7cef9d196c pfctl: cache name/index mappings
Provide local implementations of if_nametoindex(3) and if_indextoname(3)
that make use of the cache of addresses populated by the ifa_load on
startup to save the trouble of calling expensive getaddrinfo(3) up to
four times per rule. Performance wise this change provides a speed up
factor of 20 with a 11k line ruleset on a machine with 150 VLANs and 250
IP addresses (20 seconds down to 1 in this case).

"wow!" henning, ok benno, florian

Obtained from:	OpenBSD, mikeb <mikeb@openbsd.org>, 918dda8655
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-13 13:38:43 +01:00
Kristof Provost
ddafb584b8 pfctl.8: explicitly mention that at least one option is required
zap one redundant line, replacing it with a note that although
SYNOPSIS suggests no options are neccessary, in fact a minimum of one
is required;

ok henning

Obtained from:	OpenBSD, jmc <jmc@openbsd.org>, 123a76b4bf
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-13 13:38:43 +01:00
Kristof Provost
21bc7eec2b pfctl: avoid truncating a time_t division into days
Obtained from:	OpenBSD, deraadt <deraadt@openbsd.org>, b14a9e0815
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-12 09:29:09 +01:00
Kristof Provost
0ce36b0698 pfctl.8: describe the counters that "pfctl -s info" displays
Tweaks jmc@, ok deraadt@

Obtained from:	OpenBSD, sthen <sthen@openbsd.org>, 83e508aa68
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-12 09:29:09 +01:00
Minsoo Choo
ca4eddea97 src: Use gnu17 as the default C standard for userland instead of gnu99
Tracking newer versions of C (and C++) permits assuming newer language
features in the base system.  Some C11 extensions are already used in
the base system but implemented on top of GNU C extensions such as
_Alignas and _Static_assert.  In some cases the fallback versions in
cdefs.h are more limited than the native C11 extensions.

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

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

Libraries and binaries for ZFS continue to use c99.

PR:		284039 (exp-run)
Reviewed by:	imp, arichardson, emaste
Differential Revision:	https://reviews.freebsd.org/D43237
2025-02-11 09:16:25 -05:00
Andrey V. Elsukov
706a03f61b ipfw: make 'ipfw show' output compatible with 'ipfw add' command
If rule was added in compact form and rule body is empty, print
'proto ip' opcode to be compatible with ipfw(8) syntax parser.

  Before:
  $ ipfw add allow proto ip
  000700 allow
  After:
  $ ipfw add allow proto ip
  000700 allow proto ip

MFC after:	1 week
2025-02-11 12:48:17 +03:00
Kristof Provost
0d2058abf3 pf: convert DIOCRDELTABLES to netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-10 12:09:47 +01:00
Kristof Provost
2c96c9b053 pfctl: simplify pfr_del_tables() to pfr_del_table()
We only ever delete a single table at a time, so remove the size argument.
This will make subsequent conversion to netlink easier.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-10 12:09:47 +01:00
Kristof Provost
84a80eae69 pf: convert DIOCRADDTABLES to netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-10 12:09:47 +01:00
Kristof Provost
b452e72bda pfctl: simplify pfr_add_tables() to pfr_add_table()
We only ever add a single table at a time, so remove the size argument.
This will make subsequent conversion to netlink easier.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-10 12:09:47 +01:00
Kristof Provost
97823244bd pfctl: Show which limit cannot be set.
idea mikeb
ok mikeb henning beck

Obtained from:	OpenBSD, camield <camield@openbsd.org>, d200c05e6c
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-06 15:00:05 +01:00
Kristof Provost
ebfcaba169 pfctl: load os passive fingerprints when testing the ruleset
ok henning

Obtained from:	OpenBSD, mikeb <mikeb@openbsd.org>, 4a9baa970f
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-06 15:00:05 +01:00
Kristof Provost
0ae2ba5e20 pfctl: remove unused variables
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-02-05 21:06:54 +01:00
Olivier Cochard
f16ca171ea man: Remove references to classful networks
Update wording in manual pages to replace references to classful networks with
CIDR notation.

Approved by:	glebius, dhw
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D48853
2025-02-04 22:27:21 +01:00
Jesper Schmitz Mouridsen
c14b016242 mt7601U: Importing if_mtw from OpenBSD
Added ht20 mode, based on if_run from FreeBSD, and if_mtw.c
from OpenBSD.

PR: 247545
Approved by:	adrian, wireless
Differential Revision: https://reviews.freebsd.org/D45179
2025-02-03 20:20:52 +01:00
John Baldwin
858280e60f nvmecontrol devlist: Annotate connected Fabrics hosts
If a Fabrics host is connected, use the discovery log entry from the
reconnect parameters to output the transport type and address.

Reviewed by:	chuck
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48731
2025-01-31 15:49:11 -05:00
John Baldwin
ad9dc97e4d nvmecontrol devlist: Handle disconnected Fabrics hosts
If a Fabrics host is disconnected, use the cached controller data
instead of reading the cdata via a pass-through command.  In addition,
annotate disconnected hosts including the amount of time since the
connection was lost.

Reviewed by:	chuck
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48220
2025-01-31 15:48:21 -05:00
Mark Johnston
afc38f1f23 sysctl: Add a regression test which runs sysctl -a
Run sysctl -a during the test suite so that KASAN/KMSAN have a chance to
catch something.

Inspired by https://jprx.io/cve-2024-54507/

Reviewed by:	jhb, emaste
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D48659
2025-01-31 15:22:24 +00:00
Kirk McKusick
1111a44301 Defer the January 19, 2038 date limit in UFS1 filesystems to February 7, 2106
UFS1 uses a signed 32-bit value for its times. Zero is
January 1, 1970 UTC. Negative values of 32-bit time predate
January 1, 1970 back to December 13, 1901. The maximum positive
value for 32-bit time is on January 19, 2038 (my 84th birthday).
On that date, time will go negative and start registering from
December 13, 1901. Note that this issue only affects UFS1 filesystems
since UFS2 has 64-bit times. This fix changes UFS1 times from
signed to unsigned 32-bit values. With this change it will no longer
be possible to represent time from before January 1, 1970, but it
will accurately track time until February 7, 2106. Hopefully there
will not be any FreeBSD systems using UFS1 still in existence by
that time (and by then I will have been dead long enough that no-one
will know at whom to yell :-).

It is possible that some existing UFS1 systems will have set times
predating January 1, 1970. With this commit they will appear as
later than the current time. This commit checks inode times when
they are read into memory and if they are greater than the current
time resets them to the current time. By default this reset happens
silently, but setting the sysctl vfs.ffs.prttimechgs=1 will cause
console messages to be printed whenever a future time is changed.

Reviewed-by: kib
Tested-by:   Peter Holm
MFC-after:   1 week
Differential Revision: https://reviews.freebsd.org/D48472
2025-01-30 17:31:08 -08:00
Zhenlei Huang
08aa7128de sysctl: Teach sysctl to attach and run itself in a jail
This allows the parent jail to retrieve or set kernel state when child
does not have sysctl(8) installed (e.g. light weighted OCI containers
or slim jails).

This is especially useful when manipulating jail prison or vnet sysctls.
For example, `sysctl -j foo -Ja` or `sysctl -j foo net.fibs=2`.

Reviewed by:	dfr (previous version), markj
MFC after:	1 week
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D48618
2025-01-31 02:20:41 +08:00
Zhenlei Huang
6193855fc7 sysctl: Refactor function parsefile()
Let the caller open the file and pass in the file handler. This can
benefit an upcoming change so that we will have cleaner logic.

No functional change intended.

Suggested by:	markj
MFC after:	1 week
2025-01-31 02:20:41 +08:00
John Baldwin
ec282601f7 nvmecontrol: Only do name resolution once for Fabrics connections
Reuse the addrinfo structure from the admin queue to establish
connections to I/O queues for the TCP transport.

Reviewed by:	dab, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48456
2025-01-30 10:50:58 -05:00
John Baldwin
10d188ae2c nvmecontrol: Consolidate error paths in connect_nvm_queues()
Zero the I/O queue array earlier so that disconnect_nvm_queues() can
be safely used for earlier failures.

Suggested by:	dab
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48654
2025-01-30 10:50:38 -05:00
Kirk McKusick
256389eaf1 Fix build from aa90fbed15 by eliminating an unused variable. 2025-01-28 00:48:42 -08:00
Kirk McKusick
aa90fbed15 Standardize the definition of a UFS dinode.
Each program that operates on UFS on-disk inodes defines its own
version of a dinode. They all (of necessity) define the same
layout but use different names. This change adds a definition of
a dinode (a union of a UFS1 on-disk inode and a UFS2 on-disk inode)
as well as a dinodep (a union of a pointer to a UFS1 on-disk inode
and a pointer to a UFS2 on-disk inode) in sys/ufs/ufs/dinode.h.
It then deletes the definitions of dinode and dinodep in all the
programs that operate on them and instead uses these standard
definitions.

No functional change intended.

MFC-after: 1 week
2025-01-27 17:39:45 -08:00
John Baldwin
8bba2c0f89 nvmf: Refactor reconnection support
Save more data associated with a new association including the network
address of the remote controller.  This permits reconnecting an
association without providing the address or other details.  To use
this new mode, provide only an existing device ID to nvmecontrol's
reconnect command.  An address can still be provided to request a
different address or other different settings for the new association.

The saved data includes an entire Discovery Log page entry to aim to
be compatible with other transports in the future.  When a remote
controller is connected to via a Discovery Log page entry (nvmecontrol
connect-all), the raw entry is used.  When a remote controller is
connected to via an explicit address, an entry is synthesized from the
parameters.

Note that this is a pseudo-ABI break for the ioctls used by nvmf(4) in
that the nvlists for handoff and reconnect now use a slightly
different set of elements.  Since this is only present in main I did
not bother implementing compatability shims.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48214
2025-01-24 09:43:19 -05:00
Mark Johnston
ff13773802 savecore tests: Update to match output from savecore(8) 2025-01-24 14:32:36 +00:00
Stéphane Rochoy
3dc18af577 savecore: add a test for LOG_PERROR
Signed-off-by: Stéphane Rochoy <stephane.rochoy@stormshield.eu>

Reviewed by:	markj, oshogbo
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1546
2025-01-24 14:21:36 +00:00
Stéphane Rochoy
c901e89d8e savecore: add missing call to cap_openlog when in capabilities mode
Signed-off-by: Stéphane Rochoy <stephane.rochoy@stormshield.eu>

Reviewed by:	markj, oshogbo
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1546
2025-01-24 14:20:51 +00:00
Kristof Provost
7a372bded8 pf: make reply-to work with nat64
Just like route-to reply-to is problematic when used in combination with nat64.

In the normal (i.e. without nat64) flow we return immediately from pf_route().
However, with nat64 we need to continue and do a route lookup. In that case
we should not make the extra pf_test(PF_OUT) call to remain similar to the
non-nat64 flow.

We also have to fix the interface binding. We can only bind to the interface
after we've done the route lookup, not before.

Add a funcional test case, and a test for pfctl's rule printing.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-01-24 11:20:31 +01:00
Kristof Provost
ca0e693453 pf: cope with route-to on af-to rules
af-to uses pf_route() and pf_route6(), which caused issues when af-to and
route-to were combined in a single rule.
Extend the relevant functions to cope with this and add test cases.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-01-24 11:20:30 +01:00
Kristof Provost
0972294ef0 pf: add a dedicated pf pool for route options
As suggested by henning.
Which unbreaks ie route-to after the recent pf changes.

With much help debugging and pointing out of missing bits from claudio@

ok claudio@ "looks good" henning@

Obtained from:	OpenBSD, jsg <jsg@openbsd.org>, 7fa5c09028
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-01-24 11:20:30 +01:00
Kristof Provost
899e79760d pfctl: allow an implicit address family for af-to rules
If the address family can be determined by the "from" or "to" parameter in the
matching part, it is no longer necessary to specify "inet" or "inet6" there.
OK henning@ mikeb@

Obtained from:	OpenBSD, bluhm <bluhm@openbsd.org>, ff33038bc1
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-01-24 11:20:30 +01:00
Kristof Provost
af33f86e6a carp: don't unintentionally revert to multicast mode
PR:		284140
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-01-24 11:20:30 +01:00
Kristof Provost
5cb08fddef pfctl: improve NAT pool handling
Ensure we always free the NAT pool (as well as the rdr pool) and actually handle
it in the optimiser.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-01-24 11:20:29 +01:00
Kristof Provost
096efeb658 pfctl: follow rpool -> rdr rename
In e11dacbf84 the redirect pool was renamed from
rpool to rdr. It included backwards compatibility support for libpfctl users,
but didn't fully implement the rename in our own code.

Do so now. No functional change.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-01-24 11:20:29 +01:00
John Baldwin
27bd6c32bb Remove references to gvinum(8) in various manpages
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D48540
2025-01-23 13:16:47 -05:00
John Baldwin
8432ddac21 ccdconfig.8: Bump Dd for gvinum removal 2025-01-23 11:20:43 -05:00
John Baldwin
63d7fcf2a0 bsdlabel.8: Don't document how to create vinum partitions
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D48539
2025-01-23 11:20:43 -05:00