Bjoern A. Zeeb [Sat, 20 May 2023 00:51:01 +0000 (00:51 +0000)]
LinuxKPI: netdevice: add dev_set_threaded()
Add dev_set_threaded() to the dummy functions of netdevice.h in order
to keep an upcoming wireless driver compiling.
While here also update the name of a function argument for consistency.
Randall Stewart [Fri, 19 May 2023 15:16:28 +0000 (11:16 -0400)]
There are congestion control algorithms will that pull in srtt, and this can cause issues with rack.
When using rack, cubic and htcp will grab the srtt, but they think it is in ticks. For rack
it is in micro-seconds (which we should probably move all stacks to actually). This causes
issues so instead lets make a new interface so that any CC module can pull the srtt in
whatever granularity they want.
Kristof Provost [Thu, 18 May 2023 18:04:45 +0000 (20:04 +0200)]
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.
Kristof Provost [Thu, 18 May 2023 20:06:37 +0000 (22:06 +0200)]
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.
Kristof Provost [Thu, 18 May 2023 19:37:48 +0000 (21:37 +0200)]
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
Bjoern A. Zeeb [Wed, 17 May 2023 20:40:47 +0000 (20:40 +0000)]
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
Colin Percival [Thu, 18 May 2023 03:17:24 +0000 (20:17 -0700)]
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.
Dmitry Chagin [Thu, 18 May 2023 07:55:39 +0000 (10:55 +0300)]
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.
Corvin Köhne [Fri, 12 May 2023 05:37:32 +0000 (07:37 +0200)]
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: ca14781c8170f3517ae79e198c0c880dbc3142dd ("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
Kristof Provost [Thu, 11 May 2023 16:10:33 +0000 (18:10 +0200)]
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.
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.
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.
Bjoern A. Zeeb [Tue, 16 May 2023 16:03:17 +0000 (16:03 +0000)]
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
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
pbuff [Tue, 16 May 2023 03:05:30 +0000 (11:05 +0800)]
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.
Jessica Clarke [Tue, 16 May 2023 01:06:34 +0000 (02:06 +0100)]
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: 28f66935d400 ("tests: Disable sys/compat32 and sys/compat32/aarch64 tests")
Jessica Clarke [Mon, 15 May 2023 22:16:40 +0000 (23:16 +0100)]
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.
Simon J. Gerraty [Mon, 15 May 2023 20:25:10 +0000 (13:25 -0700)]
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.
Kirk McKusick [Mon, 15 May 2023 19:56:27 +0000 (12:56 -0700)]
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
Kyle Evans [Mon, 15 May 2023 15:54:15 +0000 (10:54 -0500)]
arm64: simplify expression
!a != !b -> a != b; this part was lifted from NetBSD, and I clearly did
not reconsider that these are bools (I'm guessing they were ints in an
earlier iteration of the NetBSD implementation).
while we're here, it should be easy to see that we've covered all of the
cases but let's add in an __assert_unreachable() to make it easier on
the eyes.
Kyle Evans [Mon, 15 May 2023 15:42:16 +0000 (10:42 -0500)]
arm64: add tests for swp/swpb emulation
One test is suitable to be hooked up to the build, so I've done this
here. The other test lives in tools/regression because failure is a
bit more subjective -- generally, one runs it for some unbounded amount
of time and observe if it eventually exits because two threads acquired
the same mutex.
Kyle Evans [Mon, 15 May 2023 15:42:10 +0000 (10:42 -0500)]
arm64: emulate swp/swpb instructions
Add another undefined instruction handler for compat32 and watch out for
SWP/SWPB instructions.
SWP/SWPB were deprecated in ARMv6 and declared obsolete in ARMv7, but
this implementation is motivated by some proprietary software that still
uses SWP/SWPB. Because it's deprecated, emulation is pushed back behind
a sysctl that defaults to OFF in GENERIC so that it doesn't potentially
adversely affect package builds; it's unknown whether software may test
for a functional swp/swpb instruction with the desire of using it later,
so we err on the side of caution to ensure we don't end up with swp/swpb
use in freebsd/arm packages (which are built on aarch64).
The EMUL_SWP config option may be used to enable emulation by default in
environments where emulation is desired and won't really be turned off.
netlink: add an optional post-process hook to the message parsers.
It is primarily used for adding scopeid to the IPv6 link-local
sockaddrs. Having proper sockaddrs after parsing minimises the
possibility of human mistake when using the parsing.
Michael Osipov [Thu, 4 May 2023 12:35:59 +0000 (14:35 +0200)]
periodic: Use locale-agnostic (ISO 8601) timestamp format
Instead of reyling on locale-sensitive output which can be mangled when e-mailed
use consistently ISO 8601 format which contains the same information as '-T'.
Dmitry Chagin [Sun, 14 May 2023 21:27:31 +0000 (00:27 +0300)]
linux(4): Rework signal trampoline on Aarch64
To avoid clobbering of any registers by the trampoline code use Linux
way to call signal handlers. I.e., we are out from the kernel right into
the signal handler, put return address from the signal handler into the
link register.
The mysterious NOP is required for some unwinders (e.g. libc++) that
unconditionally subtract one from the result of _Unwind_GetIP() in order
to identify the calling function.
Dmitry Chagin [Sun, 14 May 2023 21:25:57 +0000 (00:25 +0300)]
linux(4): Fix stack unwinding on arm64 [2/2]
To allow unwinders to go througth a previous to sigreturn frame we should
properly emulate the trampoline frame record which should points to the
previous frame and set the trampoline frame pointer to the emulated frame
before calling signal handler.
Dmitry Chagin [Sun, 14 May 2023 21:24:57 +0000 (00:24 +0300)]
linux(4): Fix stack unwinding on arm64 [1/2]
An Aarch64 sigreturn trampoline frame can't currently be described in
a DWARF .eh_frame section, because Aarch64 does not define a register
number for PC and provide no direct way to encode PC of the previous
frame. Instead, unwinders (libgcc, gdb, libunwind) detect the sigreturn
frame by looking for the sigreturn instruction. If a sigreturn frame is
detected, unwinders restores all the gprs, SP and PC by assuming that
sp points to an rt_sigframe Linux kernel struct
When entering the kernel, the link register (lr) contains the return
address of the previous frame, the exception link register (elr) contains
the address of the next instruction after the one which generated the
exception, i.e., PC.
Simon J. Gerraty [Sun, 14 May 2023 16:50:03 +0000 (09:50 -0700)]
sys.dirdeps.mk we do want to override OBJTOP
Add more comments to explain what and why.
Ensure OBJROOT ends in / or - (/ preferred).
Export OBJTOP if level > 0
this avoids the issue with bmake/unit-tests.
Check if we have to override MAKEOBJDIR
and if so, put it into env correctly.
Ed Maste [Sun, 14 May 2023 14:17:59 +0000 (10:17 -0400)]
src.conf.5: regen
Fixes: df9974197e46 ("Add description of WITH_META_ERROR_TARGET") Fixes: 2b519b170709 ("Update description of WITH_DIRDEPS_BUILD") Fixes: 722cfce5f494 ("Fix typo and use .Fx in WITH_DIRDEPS_BUILD")
Sponsored by: The FreeBSD Foundation
o parse.c: don't print null filename in stack traces
o for.c: skip syntactically wrong .for loops
o var.c: allow for :gmtime=${mtime}
add :mtime[=timestamp] where timestamp is used if stat(2)
fails, if :mtime=error stat(2) failure causes error.
o make.1: fix documentation of .PREFIX to match reality and POSIX
o unit-tests: improved var-scope-local
Enji Cooper [Thu, 11 May 2023 05:47:09 +0000 (22:47 -0700)]
rc.subr(8): delete debug cpuset helper
Summary:
The intention of the original author (I assume) was to add this logic
for testing. This removes the debug statement so it no longer shows up
in calls to `status`.
Ed Maste [Tue, 9 May 2023 13:19:42 +0000 (09:19 -0400)]
loader: restore userboot help file
Commit e32fecd0c2c3 intended to skip installing all but one copy of
each loader variant's help file, but accidentally skipped all copies for
the userboot help file. (Other loaders install help files via the _simp
variant, but there is is no userboot_simp.)
PR: 271178
Fixes: e32fecd0c2c3 ("loader: install help files only once")
Sponsored by: The FreeBSD Foundation