Commit Graph

283994 Commits

Author SHA1 Message Date
Kristof Provost
f3546eacf0 if_bridge: fix potential panic
When a new bridge_rtnode is added it is added with a NULL brt_dst. The
brt_dst is set after the entry is added. This means there's a small
window where another core could also attempt to add this node, leading
to the code attempting to log that the MAC addresses moved to a new
interface.
Aside from that being a spurious log entry it also panics, because
obif is NULL (and we attempt to dereference it).

Avoid this by settings brt_dst before we insert the bridge_rtnode.
Assert that obif is non-NULL, as an extra precaution.

Reported by:	olivier@
Reviewed by:	zlei@
Differential Revision:	https://reviews.freebsd.org/D40147
2023-05-19 15:26:52 +02:00
Alexander V. Chernikov
1377eb268a netlink: add IPv4/IPv6 attribute writers using in[6]_addr instead of
sockaddrs.

MFC after:	2 weeks
2023-05-19 09:45:49 +00:00
Kristof Provost
6408d025cf carp test: improve jail names for unicast_ll_v6 test
Rename the jails used in the unicast_ll_v6 test, to ensure the jail
names are unique to this test.
That is one of the requirements for running these tests in parallel.
2023-05-18 22:12:08 +02:00
Kristof Provost
0d574d8ba8 pfsync tests: check for the correct IP address
When checking if the state synced over we should look for
198.51.100.254, not 198.51.100.2. The test worked because the incorrect
address is a substring of the correct one, but we should fix it anyway.

Reported by:	Naman Sood <naman@freebsdfoundation.org>
MFC after:	1 week
2023-05-18 22:12:07 +02:00
Mateusz Guzik
9a19595cad proc: s/short/int lock-related counters
short is small enough that it can overflow in practice for certain cases
and then trigger wrong asserts.

One known example is vfs namecache resize which grabs all locks at once.

Reported by:	gallatin
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 19:57:38 +00:00
Mateusz Guzik
6ba1be38f6 proc: s/short/u_char for td_stopsched
bool is not used because of massive header mess

While here move it into a gap.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 19:44:29 +00:00
George Amanakis
482eeef804 Teach zpool scrub to scrub only blocks in error log
Added a flag '-e' in zpool scrub to scrub only blocks in error log. A
user can pause, resume and cancel the error scrub by passing additional
command line arguments -p -s just like a regular scrub. This involves
adding a new flag, creating new libzfs interfaces, a new ioctl, and the
actual iteration and read-issuing logic. Error scrubbing is executed in
multiple txg to make sure pool performance is not affected.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Co-authored-by: TulsiJain tulsi.jain@delphix.com
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #8995
Closes #12355
2023-05-18 11:59:42 -07:00
Brian Behlendorf
e34e15ed6d
Add the ability to uninitialize
zpool initialize functions well for touching every free byte...once.
But if we want to do it again, we're currently out of luck.

So let's add zpool initialize -u to clear it.

Co-authored-by: Rich Ercolani <rincebrain@gmail.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
Closes #12451 
Closes #14873
2023-05-18 10:02:20 -07:00
Cheng Cui
e5738ee04b
Under RSS, assign a TCP flow's inp_flowid anyway.
Summary:
This brings some benefit of a tcp flow identification for some kernel
modules, such as siftr.

Reviewers: rrs, rscheff, tuexen, #transport!
Approved by: tuexen (mentor), rrs
Subscribers: imp, melifaro, glebius
Differential Revision: https://reviews.freebsd.org/D40061
2023-05-18 11:11:53 -04:00
Peter Wemm
e829181c65
libc: Update copyright text to match current templates. 2023-05-18 11:30:10 -07:00
Jesse Rosenstock
6de1a005d4 traceroute.8: Document TOS as DiffServ and ECN
Reviewed by: imp,karels
Pull Request: https://github.com/freebsd/freebsd-src/pull/744
2023-05-18 11:17:24 -06:00
Dmitry Chagin
1d76741520 linux(4): Implement ptrace_pokeusr for x86_64
Differential Revision:	https://reviews.freebsd.org/D40097
MFC after:		1 week
2023-05-18 20:02:35 +03:00
Dmitry Chagin
3d0addcd35 linux(4): Make ptrace_pokeusr machine dependent
Differential Revision:	https://reviews.freebsd.org/D40096
MFC after:		1 week
2023-05-18 20:01:12 +03:00
Dmitry Chagin
dd2a6cd701 linux(4): Make ptrace_peekusr machine dependend
And partially implement it for x86_64.

Differential Revision:	https://reviews.freebsd.org/D40095
MFC after:		1 week
2023-05-18 20:00:12 +03:00
Dmitry Chagin
38a137f416 linux(4): Move linux_debug decalration to linux_util.h
To avoid inclusion of linux_mib.h with linux_util.h in cases where
we need rate limiting macro.

MFC after:		1 week
2023-05-18 19:58:23 +03:00
Kristof Provost
33ff01cebc carp tests: test unicast carp via link-local addresses
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 17:47:04 +02:00
Kristof Provost
c2c28c0fa2 carp: fix unicast link-local
If the peer6 address is a link-local address we have to embed the
scopeid, much like we have to for IPv6 multicast as well.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 17:47:03 +02: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
Colin Percival
dc5361ea16 rc.d/netif: Don't DAD if lo0 is the only IPv6 IF
The code in rc.d/netif waiting for IPv6 Duplicate Address Detection if
any network interfaces support IPv6.  Unfortunately, since lo0 *always*
has IPv6 enabled, this means unconditionally sleeping, even on systems
which have no external IPv6 interfaces.

Since we presume that there is little risk of a duplicate address being
assigned on lo0, amend the test to wait only if there is an interface
*other than lo0* which supports IPv6.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D40141
2023-05-18 08:20:15 -07:00
Dmitry Chagin
0f62290e7f linux(4): Check fd passed to unlockpt()
In our implementation, grantpt() and unlockpt() don't actually have
any use, because PTY's are created on the fly and already have proper
permissions upon creation.
Atleast check that a proper fd passed to unlockpt(). For grantpt()
Glibc calls TIOCGPTN ioctl which would fail if fd is not a master.

Differential Revision:	https://reviews.freebsd.org/D40100
MFC after:		1 week
2023-05-18 10:55:39 +03:00
Gleb Smirnoff
743516d51f ktls: don't try to unlock pcb if tcp_drop() already did
Reviewed by:	rrs, gallatin
2023-05-17 10:25:28 -07:00
Kajetan Staszkiewicz
8c23afdb57 pf: Standardize rtableid
Prepare for rtableid being included in struct pfsync_state where it will
be int32_t. Make variables which will be set to and from it the same
width.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40013
2023-05-17 15:57:42 +02:00
Corvin Köhne
26d9f973d8
bhyve: error out if fwcfg user file isn't read completely
At the moment, fwcfg reads the file once at startup and passes these
data to the guest. Therefore, we should always read the whole file.
Otherwise we should error out.

Additionally, GCC12 complains that the comparison whether
fwcfg_file->size is lower than 0 is always false due to the limited
range of data type.

Reviewed by:		markj
Fixes:			ca14781c81 ("bhyve: add cmdline option for user defined fw_cfg items")
MFC after:		1 week
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D40076
2023-05-17 15:39:37 +02:00
Kristof Provost
bdd4717752 pf: release rules lock before passing the packet to dummynet
In the Ethernet rules we held the PF_RULES lock while we called
ip_dn_io_ptr() (i.e. dummynet). That meant that we could end up back in
pf while still holding the PF_RULES lock.
That's not immediately fatal, because that lock is recursive, but still
not ideal.

There also appear to be scenarios where this can actually trigger
deadlocks.

We don't need to hold the PF_RULES lock, as long as we make a local copy
of the data we need from the rule (in this case, the action and
bridge_to target). It's safe to keep the struct ifnet pointer around,
because we remain in NET_EPOCH.

See also:	https://redmine.pfsense.org/issues/14373
MFC after:	1 week
Reviewed by:	mjg
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40067
2023-05-17 15:20:18 +02:00
Andrew Turner
37c1ef5ac0 Move the arm64 sigcode to .rodata
The kernel doesn't execute this code, it's only ever copied to
userspace. Move it to .rodata as we don't need to modify it.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D39399
2023-05-17 12:28:45 +01:00
Bjoern A. Zeeb
71fde8e507 LinuxKPI: add ns_to_timespec64()
Add ns_to_timespec64() which does not seem to require anything from
us given timespec64 is aliases to timespec.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D40123
2023-05-17 10:22:07 +00:00
Piotr Kubaj
2e57f7bf20 ix(4): correct max MTU
The max MTU for the ix(4) is 9710.

Differential revision:	https://reviews.freebsd.org/D40003
Approved by:	erj, bcr
2023-05-17 12:16:22 +02:00
Piotr Kubaj
d0cdec7a20 em: sync platform detection with Linux
Switch 16 and 23 adapters from tgp to adp.

PR:	270929
Differential revision:	https://reviews.freebsd.org/D39977
Approved by:	erj, kbowling
2023-05-17 12:14:02 +02:00
Alexander V. Chernikov
b50e1465e8 routing: plug mbuf leak for the packets hitting IPv6 blackhole route
Reported by:	Dmitriy Smirnov <fox@sage.su>
Tested by:	Dmitriy Smirnov <fox@sage.su>
MFC after:	1 day
2023-05-17 09:06:04 +00:00
Alexander V. Chernikov
4c63ecf5c7 routing: fix panic triggered by the 'gr_idx != 0' assert in nhg code
Nexthop groups can be referenced by the external code. The reference
 can be released after the VNET destruction. Furthermore, nexthop
 groups use a single per-rib lock, which is destroyed during the
 VNET desctruction. To eliminate use-after-free problem, each nhg
 is marked as "unlinked" during the VNET destruction stage, leaving
 nhg_idx intact. Normally there should not be such nexthops, but if
 there are any, the kernel will panic on 'gr_idx != 0' when the
 last nhg reference is released.

Address this by using the assert checks only when the nexthop group
 is destroyed during "valid" VNET lifetime.

MFC after:	3 days
2023-05-17 08:40:29 +00:00
Konstantin Belousov
848d5bb1ab net/if_var.h: consistently use if_t over struct ifnet *
Reviewed by:	jhibbits
Sponsored by:	NVidia networking
Differential revision:	https://reviews.freebsd.org/D40125
2023-05-17 06:31:07 +03:00
Konstantin Belousov
616a6c9f66 net/if.h: fix style of if_t definition
Reviewed by:	jhibbits
Sponsored by:	NVidia networking
Differential revision:	https://reviews.freebsd.org/D40125
2023-05-17 06:30:59 +03:00
Kajetan Staszkiewicz
cdc231bd49 pfsync: Remove deletion of states using the full pfsync_state struct
State deletions are sent over pfsync using struct pfsync_del_c.

Remove the code for receiving state deletions using struct pfsync_state
as such deletions are never sent. Rename functions and constants so that
only the "compressed" versions remain.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D40004
2023-05-17 02:39:58 +02:00
Bjoern A. Zeeb
262c5e8193 LinuxKPI: skbuff.h: add skb_hwtstamps(), implement *mac_header()
Add a dummy skb_hwtstamps() function for now, and implement
skb_mac_header(), skb_reset_mac_header(), and skb_set_mac_header().

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-16 21:26:50 +00:00
Bjoern A. Zeeb
972bf40b62 LinuxKPI: add ptp_clock_kernel.h
Add the new ptp_clock_kernel.h with structs and dummy functions for
kernel ptp support.  This is needed for the next iwlwifi update.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-16 21:26:40 +00:00
Dmitry Chagin
0282f87530 ktrace: Simplify ae6ac587, drop the sa var declaration
Suggested by:		kib
MFC after:		5 days
2023-05-16 22:46:26 +03: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 V. Chernikov
10b94e4064 netlink: add support for adding/deleting interface addresses
Differential Revision: https://reviews.freebsd.org/D40103
MFC after:	2 weeks
2023-05-16 19:39:13 +00:00
Bjoern A. Zeeb
7232e6dcc8 net80211: Radiotap: update for newer standards (add EHT, U-SIG)
iwlwifi already uses suggested EHT and U-SIG bits as well as some
more TLV bits.  Update radiotap to know of those even if they might
get updated again in the future in order to get newer versions of
the driver to compile.

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
2023-05-16 16:05:55 +00:00
Alexander V. Chernikov
584ad4126c testing: improve vnet support in pytest
* Allow vnet object to be directly referenced
 (self.vnet1 vs self.vnet_map["vnet1"])
* Allow iface object to be directly reference
 (vnet.bridge vs vnet.iface_alias_map["bridge"])
* Allow arbitrary interface alias names insted of ifX
* Add wait_objects_any() method for waiting object from
 multiple vnets
* Add wait() method for indefinite sleep on vnet handlers

MFC after:	2 weeks
2023-05-16 15:00:45 +00:00
Jose Luis Duran
6e068d6bea passwd.5: Update man page after e0155c6989
MFC After:	3 days
2023-05-16 13:57:49 +02:00
Jose Luis Duran
d047a4e486 passwd.5: Remove .Tn (Trade Name) macros
To appease mandoc -T lint, remove .Tn macros.

MFC After:	3 days
2023-05-16 13:57:32 +02:00
pbuff
e0155c6989 pw: The pw_checkname function has added ';' checking.
The pw_checkname function forgot to include a ';'
when checking usernames, causing shell commands
to be executed when a username with a ';' is deleted.

PR:		271427
MFC After:	3 days
2023-05-16 08:48:08 +02:00
Jessica Clarke
816129210a tests: Don't recurse into sys/compat32
Stubbing out the whole file means it has no targets, so recursive makes
fail with "don't know how to make X". We could fix that, but because the
level above is adding it to TESTS_SUBDIRS it'll generate an include line
for the subdirectory in its Kyuafile, which won't work (the problem that
was previously seen on non-aarch64 in CI). Thus we really need to not
even add it to TESTS_SUBDIRS in the first place.

Reported by:	Dan Mack <mack@macktronics.com>
Fixes:		28f66935d4 ("tests: Disable sys/compat32 and sys/compat32/aarch64 tests")
2023-05-16 02:06:34 +01:00
Antonio Russo
e0d5007bcf
test-runner: pass kmemleak and kmsg to Cmd.run
test-runner.py orchestrates all of the ZTS executions. The `Cmd` object
manages these process, and its `run` method specifically invokes these
possibly long-running processes, possibly retrying in the event of a
timeout. Since its inception, memory leak detection using the kmemleak
infrastructure [1], and kernel logging [2] have been added to this run
mechanism.

However, the callback to cull a process beyond its timeout threshold,
`kill_cmd`, has evaded modernization by both of these changes. As a
result, this function fails to properly invoke `run`, leading to an
untrapped exception and unreported test failure.

This patch extends `kill_cmd` to receive these kernel devices through
the `options` parameter, and regularizes all the `.run` calls from
`Cmd`, and its subclasses, to accept that parameter.

[1] Commit a69765ea5b
[2] Commit fc2c0256c5

Reviewed-by: John Wren Kennedy <john.kennedy@delphix.com>
Signed-off-by: Antonio Russo <aerusso@aerusso.net>
Closes #14849
2023-05-15 16:11:33 -07:00
Jessica Clarke
28f66935d4 tests: Disable sys/compat32 and sys/compat32/aarch64 tests
The former has build system issues, with missing Kyuafiles, presumably
due to not using TESTS_SUBDIRS and bsd.test.mk (and possibly some issues
on top of that around TESTSDIR and related variables). The latter has
issues with GCC and cut-down LLVM builds.

Requested by:	kevans
Fixes:		ccb59683b9 ("arm64: add tests for swp/swpb emulation")
2023-05-15 23:16:40 +01: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
Simon J. Gerraty
92a4e8b348 dirdeps.mk allow for TARGET_SPEC_VARS.host
While *most* projects need only DEP_MACHINE for host, there is always
an exception.  So we allow for TARGET_SPEC_VARS.host to be a subset of
TARGET_SPEC_VARS.  The default will *just work* for most projects.

We set DEP_TARGET_SPEC_VARS and hence DEP_TARGET_SPEC based on
DEP_MACHINE.  Allow for M_dep_qual_fixes.host to be different too and
take care to apply the right set.
2023-05-15 13:25:10 -07: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