Aaron LI [Mon, 11 Dec 2023 06:03:34 +0000 (14:03 +0800)]
netstat(1): Update route.c to get rid of some file-global variables
No functional changes.
Aaron LI [Mon, 11 Dec 2023 05:54:51 +0000 (13:54 +0800)]
netstat(1): Whitespace cleanups
Aaron LI [Fri, 24 Nov 2023 06:05:06 +0000 (14:05 +0800)]
net/radix: Various minor improvements and cleanups
- Change 'rn_bit' and 'rm_bit' from type 'short' to 'int', for
consistency with the other types. This doesn't change the structure
size because of the implicit padding. However, the userland netstat(1)
utility must be recompiled with the updated header.
- Rename variable 'b' to 'bit' for clarity.
- Adjust the parameter orders of rn_search_m() for consistency.
- Various style cleanups.
Aaron LI [Tue, 31 Oct 2023 00:49:36 +0000 (08:49 +0800)]
getsockopt.2: Improve manpage markups a bit
Obtained-from: FreeBSD
Matthew Dillon [Wed, 20 Dec 2023 03:14:23 +0000 (19:14 -0800)]
kernel - Fix umount -f related panic
* Adjust umount -f (forced unmount) logic to kill processes which
still hold references to the mount in question, due to being chrooted
or jailed in the mount, their current directory being on the mount,
or having any open file via the mount.
To be frank, it is hard to find a nice way to rip a mount out from under
processes as their behavior upon suddenly having file descriptors go bad
is completely non-deterministic. A forced unmount is not supposed to be
kind to the system. The best solution is to kill the processes.
* Fixes panics related to regular use of umount -f if the operation
happens to race active operations by processes on the mount.
Reported-by: marino
Roy Marples [Mon, 18 Dec 2023 16:10:46 +0000 (16:10 +0000)]
Merge branch 'vendor/DHCPCD'
Roy Marples [Mon, 18 Dec 2023 16:08:41 +0000 (16:08 +0000)]
Import dhcpcd-10.0.6 with the following changes:
* privsep: Stop proxying stderr to console and fix some detachment issues
* non-privsep: Fix launcher hangup
* DHCP6: Allow the invalid interface name - to mean don't assign an address from a delegated prefix
* DHCP6: Load the configuration for the interface being activated from prefix delegation
Tomohiro Kusumi [Tue, 12 Dec 2023 10:12:23 +0000 (02:12 -0800)]
sbin/hammer2/hammer2.8: Correct default vfs.hammer2.cluster_write value
The default is 0 since
f66cf3712cde69127a27daf2d8a805b7c7da52ce in 2018.
Matthew Dillon [Mon, 11 Dec 2023 18:46:36 +0000 (10:46 -0800)]
dhclient - Only clear arp table on specified interface
* When clearing the arp table after dhclient updates an interface,
only clear the arp entries on the interface and not all arp entries.
Tomohiro Kusumi [Mon, 11 Dec 2023 08:10:08 +0000 (00:10 -0800)]
sys/vfs/hammer2: Remove unused chain LRU related
Remove stuff leftover from
34fb48c236fd17fbe558c7b2cf21b4e50f38153e.
Michael Neumann [Thu, 7 Dec 2023 13:56:25 +0000 (14:56 +0100)]
Fix typos
Michael Neumann [Sat, 9 Dec 2023 01:46:00 +0000 (02:46 +0100)]
busdma - Remove filter functionality
- Remove filtfunc and filtarg arguments from bus_dma_tag_create() and
fix all callers. All callers use NULL today for both filterfunc and
filterarg with one exception: if_jme.
- Remove filter functionality internally and parent tag tracking.
Without filter functions, we do not need to keep track of tag
ancestry. All inheritance of the parent tag's parameters occurs when
creating the new child tag.
- rename run_filter() to addr_needs_bounce().
- FreeBSD keeps the filtfunc and filtarg arguments but requires them to
be NULL.
- Drop filterfunc usage from if_jme.
In case of "JMC260 chip full mask revision 2", which has a hardware bug
when it comes to DMA transfers crossing the 4 GB bounday, the parent
buffer tag already limits DMA memory to 32bit address space. As such it
should be safe to drop the filterfunc. The filterfunc was checking if
the lower 32bits of the physical address used for DMA are all 0. In case
of a 32bit address space, the only address where all lower 32-bits are
all zero is 0 itself and I am here assuming that the physical address 0
is not used for DMA transfers!
Mainly obtained from: FreeBSD (commits
7cb028de,
900907f4,
1228b93b,
3933ff56)
Matthew Dillon [Wed, 6 Dec 2023 07:03:01 +0000 (23:03 -0800)]
pf - Fix bug causing permissive TCP reset code
* Fix a bug that permissively allows TCP resets even if the sequence
number does not match due to an incorrect IP fragmentation check.
Reported-by: mjg
Taken-from: FreeBSD
6284d5f76d6bd2
Tomohiro Kusumi [Fri, 1 Dec 2023 08:01:23 +0000 (00:01 -0800)]
usr.sbin/makefs/hammer2: Properly support block device for image creation
Unlike regular file image, block device image creation fails
if estimated image size exceeds the device size.
Sparse file option is ignored. The block device blocks aren't
zero cleared.
Tomohiro Kusumi [Thu, 30 Nov 2023 08:12:13 +0000 (00:12 -0800)]
sys/vfs/hammer2: Remove unused local variable *pmp
No longer used since
34fb48c236fd17fbe558c7b2cf21b4e50f38153e.
makefs code warned on Linux.
Tomohiro Kusumi [Wed, 29 Nov 2023 08:34:04 +0000 (00:34 -0800)]
usr.sbin/makefs: Sync with sys/vfs/hammer2
Sync with following sys/vfs/hammer2 commits.
Also remove unused makefs specific function hammer2_pfs_inode_count().
$ git log --pretty="%h %s"
961db90e96d4d039edbd15dd78ecc822445405ec.. -- sys/vfs/hammer2/
bb70b93b8e sys/vfs/hammer2: Rename HAMMER2_INODE_ONRBTREE -> HAMMER2_INODE_ONHASH
ad82725233 sys/vfs/hammer2: Remove REGFILE/SOFTLINK test in hammer2_inode_create_pfs()
258074ba74 sys/vfs/hammer2: Minor cleanup
0130729cda sys/vfs/hammer2: Fix comments on comp|check macros
9046282cb0 hammer2: Use HAMMER2_CHECK_DEFAULT when creating inode
a071436b39 hammer2: Rename HAMMER2_COMP_NEWFS_DEFAULT -> HAMMER2_COMP_DEFAULT
da9dedd0a7 sys/vfs/hammer2: Remove unused lbase local variables for hammer2_calc_logical()
caf661fcf8 hammer2 - Try to reduce no-activity stalls during complex flushes
34fb48c236 hammer2 - Multitude of SMP contention fixes, work on flush
34a86030d9 sys/vfs/hammer2: Remove obsolete comments on common parent
74fa7b92b4 sys/vfs/hammer2: Remove obsolete comments on hidden inode
3a3a7c0e9c sys/vfs/hammer2: vnops need to return unix errno
2b3f93ea6d kernel - Add per-process capability-based restrictions
eeb5b5dd2c sys/vfs/hammer2: Use hammer2_off_t in hammer2_io_alloc()
68e37e5676 sys/vfs/hammer2: Fix double count of hammer2_iod_file_{read,write}
7cf689a5ea sys/vfs/hammer2: Don't fail to lockinit diolk for fchain / vchain
73da171931 sys/vfs/hammer2: Use HAMMER2_VOLUME_BYTES for volume header size
41fa929b83 sys/vfs/hammer2: Fix XOP structure used in hammer2_inode_chain_flush()
4fe5868fa3 usr.sbin/makefs/hammer2: Fix -Wunused-but-set-variable warnings on Linux
Tomohiro Kusumi [Wed, 29 Nov 2023 08:34:12 +0000 (00:34 -0800)]
sys/vfs/hammer2: Rename HAMMER2_INODE_ONRBTREE -> HAMMER2_INODE_ONHASH
inode is indexed by hash (hammer2_io_hash), not rbtree (hammer2_io_tree)
since
34fb48c236fd17fbe558c7b2cf21b4e50f38153e.
Aaron LI [Sun, 26 Nov 2023 03:49:16 +0000 (11:49 +0800)]
urtwn(4): Add support for TP-Link TL-WN722N v2
Patch submitted and tested by @UnixAwesome on GitHub.
GitHub PR: https://github.com/DragonFlyBSD/DragonFlyBSD/pull/17
Tomohiro Kusumi [Fri, 24 Nov 2023 09:15:20 +0000 (01:15 -0800)]
sys/vfs/hammer2: Remove REGFILE/SOFTLINK test in hammer2_inode_create_pfs()
This code appeared in
5afbe9d887367290d89391c2d29697655f9fc1da in 2018,
when inode creation function got split into normal and PFS.
However, PFS inode is always a directory (HAMMER2_OBJTYPE_DIRECTORY),
so xop->meta.type is never a REGFILE or SOFTLINK.
See right above this removed code.
Tomohiro Kusumi [Sat, 18 Nov 2023 07:12:15 +0000 (23:12 -0800)]
sys/vfs/hammer2: Minor cleanup
- blockref size was 64 bytes back in 2012, but 128 bytes now.
- Doesn't make much sense to assert vap in here, as it's already
dereferenced earlier in this same function.
- "hammer2_tid_t lhcbase" should be "hammer2_key_t lhcbase",
though both are uint64_t.
Aaron LI [Sat, 18 Nov 2023 01:57:53 +0000 (09:57 +0800)]
opencrypto: Update aes_ctr_setkey() to validate key bits to avoid panic
AES rijndaelKeySetupEnc() only accepts key of length 128/192/256 bits
and it uses a KASSERT() to assert this. However, aes_ctr_setkey() can
be given an improper key via ioctl() and thus panic the system. Fix
this panic by validating the key in aes_ctr_setkey() before calling
rijndaelKeySetupEnc().
This partially resolves bug #3311.
Bug: https://bugs.dragonflybsd.org/issues/3311
Aaron LI [Sat, 18 Nov 2023 01:47:23 +0000 (09:47 +0800)]
opencrypto: Update auth_hash.Setkey() to return an error code
The Setkey() method can fail, so better to change it return an error
code for the caller to properly handle it. This also makes it like
enc_xform.setkey(), which also returns an error code.
Update AES_GMAC_Setkey() accordingly.
Aaron LI [Sat, 18 Nov 2023 01:28:15 +0000 (09:28 +0800)]
opencrypto: Manage context memory within cryptosoft
Each algorithm declares its context size and let cryptosoft allocate and
free the context memory. This greatly simplifies the setkey() routine
of each algorithm and removes the unnecessary zerokey() routine.
Derived from OpenBSD:
https://github.com/openbsd/src/commit/
2dbd8e13008692ff92b9560da7b770daf2889930
Aaron LI [Thu, 9 Nov 2023 00:37:43 +0000 (08:37 +0800)]
opencrypto: Minor style cleanups / tweaks
Aaron LI [Thu, 16 Nov 2023 00:47:19 +0000 (08:47 +0800)]
net/radix: Add and update various function/structure comments
While there, adjust several parameter names to match the prototypes.
Aaron LI [Wed, 15 Nov 2023 09:19:40 +0000 (17:19 +0800)]
Remove no longer needed casts for radix routines
Aaron LI [Wed, 15 Nov 2023 08:20:21 +0000 (16:20 +0800)]
net/radix: Update parameter types to save callers from boring casts
Change the function parameters of key/address/mask from type
'const char *' to 'const void *', so the callers don't need to do boring
casts in passing them without causing any compilation warnings.
In addition, change rn_key/rn_mask/rmu_mask to 'const u_char *' type as
that makes more sense.
Referred to FreeBSD.
Aaron LI [Wed, 15 Nov 2023 05:05:56 +0000 (13:05 +0800)]
net/radix: Update rn_inithead() parameter type to avoid boring casts
Change to use the proper 'struct radix_node_head **' instead of an
opaque 'void **'.
Aaron LI [Wed, 15 Nov 2023 05:03:41 +0000 (13:03 +0800)]
kernel: Use rn_flush()/rn_freehead() to flush/delete radix trees
Aaron LI [Tue, 14 Nov 2023 08:58:09 +0000 (16:58 +0800)]
net/radix: Implement rn_flush() and rn_freehead()
rn_flush() flushes all nodes in the given radix tree and thus makes the
tree empty; rn_freehead() can then free the emptied tree.
The separation of flushing and freeing is required to support the use
case in ipfw2, which needs to flush a table without destroying it.
A mask tree is somewhat special, because its nodes are allocated inside
this radix code, so the rn_freemask() callback function is provided to
be used in rn_flush() to flush a mask tree and reclaim its memory.
These APIs can help the radix users to easily flush and free the radix
trees without rolling their own versions.
Aaron LI [Tue, 14 Nov 2023 02:28:14 +0000 (10:28 +0800)]
net/radix: Move 'rn_bmask' to 'rn_u.rn_node' as it's node-only
Add the 'rn_bmask' macro define to access it.
In addition, rename rn_L/rn_R to rn_Left/rn_Right for clarity, similar
to rn_Offset.
Aaron LI [Wed, 13 Sep 2023 00:33:50 +0000 (08:33 +0800)]
net/radix: Clean up rn_newpair() for readability
- Add a brief description.
- Rename variables to read and understand better.
Aaron LI [Wed, 15 Nov 2023 05:05:25 +0000 (13:05 +0800)]
pf: Remove unneeded critical section around radix routines
This is a follow-up commit to
dd1ea33ae219094c4039c133d321809be68f396a.
Aaron LI [Wed, 15 Nov 2023 08:45:07 +0000 (16:45 +0800)]
Use sizeof(uint32_t) for bpfattach(DLT_NULL) for clarity
The DLT_NULL link-layer header is a 4-byte field in host byte order. So
use 'sizeof(uint32_t)' instead of 'sizeof(u_int)' to make it clear.
Aaron LI [Wed, 15 Nov 2023 08:35:47 +0000 (16:35 +0800)]
if_tun: Remove redundant assignment of 'ifp->if_type'
It's already set by if_alloc(IFT_PPP).
Bill Yuan [Tue, 14 Nov 2023 13:12:37 +0000 (21:12 +0800)]
ipfw3 table: `add` as an alias of `append`
Bill Yuan [Tue, 14 Nov 2023 13:11:55 +0000 (21:11 +0800)]
ipfw3 table: remove the `static`
Bill Yuan [Tue, 14 Nov 2023 12:24:15 +0000 (20:24 +0800)]
ipfw3_table: invoke the init in ipfw3_basic module
ipfw3 table 1 type ip
ipfw3 table 1 append ip <ip>
ipfw3 table list
ipfw3 table 1 show
Aaron LI [Tue, 14 Nov 2023 00:48:43 +0000 (08:48 +0800)]
Minor cleanups to 'sruct domain' definitions
Aaron LI [Tue, 14 Nov 2023 00:43:28 +0000 (08:43 +0800)]
Update rn_inithead() users to switch to byte offset
Aaron LI [Mon, 13 Nov 2023 05:05:42 +0000 (13:05 +0800)]
net/radix: Document rn_inithead() and change to use byte offset
The radix code only supports offset bit being multiple of bytes but not
any byte fraction, so it's clearer and better to just use byte offset
instead of bit offset. In addition, the caller can be easier to
determine this argument using offsetof().
On the other hand, ignore this off_bytes parameter and auto set it to
zero when to create a mask tree.
Also add a detailed description for rn_inithead().
Aaron LI [Mon, 13 Nov 2023 03:49:26 +0000 (11:49 +0800)]
routed(8): Cleanup code w.r.t. _HAVE_SA_LEN and _HAVE_SIN_LEN
Aaron LI [Tue, 14 Nov 2023 00:36:32 +0000 (08:36 +0800)]
ipfw3: Fix offset mistake in creating the MAC-type table
The rn_inithead() requires the offset be the bit count of the address
portion from the key beginning, so it should be
offsetof(struct sockaddr, sa_data) * NBBY = 2 * 8 = 16 (instead of 48)
for the MAC-type table.
Also change to use offsetof() to replace the hardcode 32 in creating the
IP-type table. In addition, improve the assignments of sin_len/sa_len
members of the keys.
While there, fix the indentation style.
Aaron LI [Sun, 12 Nov 2023 06:32:16 +0000 (14:32 +0800)]
Revert "<net/route.h>: Abuse RNF_NORMAL to fix 'sbin/routed' build"
This reverts commit
fba4e0b47c9a290df148ef3492ae46bad6c021ae.
routed(8) has been updated to use the same radix code as kernel, so this
hack is no longer needed.
Aaron LI [Sun, 12 Nov 2023 06:20:43 +0000 (14:20 +0800)]
routed(8): Update to use the same radix code as the kernel
Since the radix code at sys/net/radix.[ch] is already make usable in
userland, so update to use it and remove the bundled old radix code.
As a result, we can remove the hack of abusing 'RNF_NORMAL' in
<net/route.h> later.
Aaron LI [Sun, 12 Nov 2023 04:36:43 +0000 (12:36 +0800)]
net/radix: Make this code also usable in userland
sbin/routed bundles its own radix implementation that is basically an
old copy of the kernel sys/net/radix code. Make this kernel version
also usable in userland so that we can get rid of the duplicate version
in sbin/routed.
Aaron LI [Sun, 12 Nov 2023 01:32:05 +0000 (09:32 +0800)]
net/radix: Add 'const' qualifier to rn_zeros/rn_ones globals
These two globals are no longer modified during the rn_init(), so just
add 'const' qualifier to them.
Aaron LI [Sat, 11 Nov 2023 12:56:55 +0000 (20:56 +0800)]
net/radix: Fix a 'sign-compare' compilation warning in rn_insert()
This compilation warning shows up in userland build, although not in
kernel build. Fix it for the forthcoming work to use this code in
userland 'sbin/routed'.
Aaron LI [Fri, 10 Nov 2023 01:10:33 +0000 (09:10 +0800)]
crypto: Remove unused/useless chacha20/chacha-sw.c
It's used in FreeBSD to hook the software-implementation (without
hardware acceleration) of Chacha20 to the crypto(9) framework. Given
our crypto(9) is significantly different from FreeBSD's, this source is
useless to us. The hook code must be rewritten in our side.
Aaron LI [Fri, 10 Nov 2023 01:05:47 +0000 (09:05 +0800)]
crypto: Include chacha20 into this module
Aaron LI [Fri, 10 Nov 2023 01:01:35 +0000 (09:01 +0800)]
crypto: Cleanup Makefile by grouping and sorting the sources
Aaron LI [Wed, 8 Nov 2023 06:13:03 +0000 (14:13 +0800)]
crypto: Remove obsolete chacha (superseded by chacha20)
Aaron LI [Wed, 8 Nov 2023 06:08:52 +0000 (14:08 +0800)]
csprng: Update to use crypto/chacha20 (a better version)
The CSPRNG code was already using Chacha20 (from crypto/chacha) to
generate the random stream. However, the 'crypto/chacha20' version
has been tweaked for and better suited to random stream generation.
The enhancements include:
- Provide the KEYSTREAM_ONLY mode to help ease the invocation and
improve performance.
- Allow to use a 128-bit counter to avoid worrying about overflow
(i.e., nonce reuse). This also remove the burden on the caller
to check for counter overflow and rotate nonce.
- Can be embedded for better compiler optimization.
The 'crypto/chacha20' was imported on 2023-02-25 from FreeBSD to
implement the libc arc4random(3) API. After the CSPRNG migration,
the old 'crypto/chacha' version become unused and will be removed
in a later commit.
Referred to FreeBSD and OpenBSD.
Aaron LI [Wed, 8 Nov 2023 02:08:02 +0000 (10:08 +0800)]
crypto/chacha20: Multiple minor tweaks and cleanups
- Use 'uint32_t' instead of 'u_int'.
- Use 'ifdef' instead of 'ifndef' for CHACHA_NONCE0_CTR128 to improve
readability.
- Add 'chacha_ctrsave()' prototype to the header.
- Remove unnecessary header inclusions.
- Remove unnecessary CHACHA_UNUSED define.
- Remove useless '$FreeBSD$' tag.
- Minor whitespace cleanups to look better.
No functional change.
Aaron LI [Wed, 8 Nov 2023 01:26:12 +0000 (09:26 +0800)]
csprng: Make use of the CSPRNG_UNLIMITED flag
Update csprng_get_random() to make use of its 'flags' parameter with the
existing CSPRNG_UNLIMITED (was unused), and thus remove the redundant
'unlimited' parameter.
Update the function comments accordingly.
Kyle Butt [Fri, 10 Nov 2023 13:17:28 +0000 (06:17 -0700)]
pf: Fix 4 uses of PF_ANEQ
The uses were depending on the old broken behavior of always checking
against IPv6 unless the family was specifically AF_INET. In 2 cases, the
AF argument was 0 seeking for a full comparison. Pass AF_INET6 instead
for these two cases to restore the intended behavior of a full
comparison. The other two cases appear to just be uncaught typos. They
are inside of an AF_INET6 case, and there is no obvious reason why you
would want an AF_INET comparison in this case.
Aaron LI [Fri, 10 Nov 2023 14:46:31 +0000 (22:46 +0800)]
netstat(1): Fix build against with <net/radix.h> gaining 'const'
Aaron LI [Fri, 10 Nov 2023 14:36:24 +0000 (22:36 +0800)]
<net/route.h>: Abuse RNF_NORMAL to fix 'sbin/routed' build
This actually reverts my previous commit
349590df029cb3452440bcc4c7fd01a56c378a97.
Nevertheless, add explaination about the reason; also add a TODO of
getting rid of this hack.
Aaron LI [Fri, 10 Nov 2023 12:38:47 +0000 (20:38 +0800)]
<net/radix.h>: Include <stdbool.h> for userland
Fix build failures in 'lib/libc/net', and maybe others.
Aaron LI [Fri, 10 Nov 2023 12:30:08 +0000 (20:30 +0800)]
<net/radix.h>: Add 'ifdef' guard for MALLOC_DECLARE()
While there, adjust order to use 'ifdef' instead of 'ifndef' to read
more clearly.
Aaron LI [Fri, 10 Nov 2023 06:18:44 +0000 (14:18 +0800)]
<net/route.h>: Just always include <net/radix.h>
Don't bother with checking RNF_NORMAL.
Aaron LI [Sun, 10 Sep 2023 04:47:27 +0000 (12:47 +0800)]
net/radix: Rename field 'rn_Off' to 'rn_Offset' for clarity
Aaron LI [Sat, 9 Sep 2023 08:39:42 +0000 (16:39 +0800)]
net/radix: Fix a subtle type cast error in rn_lexobetter()
The char byte comparison should be cast to 'unsigned'; otherwise, the
result is wrong in some special cases, e.g.,
rn_lexobetter(<255.255.0.0>, <255.255.128.0>) was giving 'true' while
'false' is expected.
While there, add a brief function description and clean up a bit for
readability.
Aaron LI [Sat, 9 Sep 2023 02:46:29 +0000 (10:46 +0800)]
net/radix: Clean up rn_refines() for readability
Aaron LI [Sat, 9 Sep 2023 02:07:53 +0000 (10:07 +0800)]
net/radix: Various minor style tweaks
Aaron LI [Tue, 27 Jun 2023 13:29:05 +0000 (21:29 +0800)]
net/radix: Add 'const' qualifier to input key/netmask
They're only referenced in the radix tree and wouldn't be modified, so
add 'const' qualifier to make it clear.
Adjust callers for this change accordingly.
Referred to FreeBSD.
Aaron LI [Tue, 27 Jun 2023 13:19:21 +0000 (21:19 +0800)]
net/radix: Improve prototypes of public functions
- Add variable name to all function parameters.
- Don't share the return type between functions.
Aaron LI [Tue, 27 Jun 2023 13:15:14 +0000 (21:15 +0800)]
net/radix: Remove unnecessary prototype of local functions
Personally I think it looks cleaner without these prototypes. Meanwhile,
move the RN_DEBUG related static variables to the top part.
Aaron LI [Tue, 27 Jun 2023 13:10:57 +0000 (21:10 +0800)]
net/radix: Improve clen() macro by casting result to int
Obtained-from: FreeBSD
Aaron LI [Fri, 10 Nov 2023 06:13:34 +0000 (14:13 +0800)]
pf: No need to enclose rn_lookup() with critical section
After the rn_addmask() update in the last commit, rn_lookup() no longer
mess up with globals. So no need to add a critical section for
rn_lookup() here any more.
Aaron LI [Sun, 18 Jun 2023 13:26:18 +0000 (21:26 +0800)]
net/radix: Simplify mask manipulation in rn_addmask()
Since the max key length is known, so use an on-stack variable instead
of memory allocation for the 'addmask_key' variable. Therefore also get
rid of the 'rnh_last_zeroed' member from 'radix_node_head' struct.
Rename 'rnh_last_zeroed' to its origin 'rnh_addrsize' instead of
removing it.
Referred-to: FreeBSD
Aaron LI [Sun, 18 Jun 2023 07:26:03 +0000 (15:26 +0800)]
net/radix: Rename Free() to R_Free() to better align with R_Malloc()
Also reduces the chances of conflicting with other macros.
Aaron LI [Sat, 17 Jun 2023 02:16:22 +0000 (10:16 +0800)]
net/radix: Use the standard type 'bool' and true/false values
Aaron LI [Sat, 17 Jun 2023 02:14:31 +0000 (10:14 +0800)]
net/radix: Add 'const' qualifier for rn_refines()
Aaron LI [Fri, 10 Nov 2023 01:44:32 +0000 (09:44 +0800)]
kernel: No need to handle mbuf allocation failures if use M_WAITOK
Aaron LI [Mon, 6 Nov 2023 05:45:06 +0000 (13:45 +0800)]
mbuf(9): Remove obsolete and unused 'kern.ipc.mbuf_wait' sysctl
This sysctl MIB has been obsolete and unused since the re-implementation
of mbuf allocation using objcache(9) in commit 7b6f875 (year 2005).
Remove this sysctl MIB.
Update the mbuf.9 manpage about the 'how' argument to avoid ambiguity,
i.e., MGET()/m_get() etc. would not fail if how=M_WAITOK.
Aaron LI [Fri, 20 Oct 2023 01:08:50 +0000 (09:08 +0800)]
sys/net: Refactor ifq_dispatch() a bit to improve readability
No functional change.
Tomohiro Kusumi [Sun, 5 Nov 2023 09:45:12 +0000 (01:45 -0800)]
sys/vfs/hammer2: Fix comments on comp|check macros
The comments and defines don't match.
Tomohiro Kusumi [Sun, 5 Nov 2023 07:30:29 +0000 (00:30 -0700)]
hammer2: Use HAMMER2_CHECK_DEFAULT when creating inode
There are a few cases where inode check type is explicitly
specified (usually derived from parent directory inode).
These cases should use HAMMER2_CHECK_DEFAULT rather than
HAMMER2_CHECK_XXHASH64, in the same way HAMMER2_COMP_DEFAULT
is being used.
Tomohiro Kusumi [Sun, 5 Nov 2023 07:14:34 +0000 (00:14 -0700)]
hammer2: Rename HAMMER2_COMP_NEWFS_DEFAULT -> HAMMER2_COMP_DEFAULT
This was originally only used within newfs_hammer2(8) when first
appeared in
f481450ffccdbf50f8c9604067c25eb642a0c562 in 2013,
but it's now always used when creating a new inode (e.g. ioctl).
The check version of this is HAMMER2_CHECK_DEFAULT without "NEWFS_".
Tomohiro Kusumi [Sat, 4 Nov 2023 08:30:15 +0000 (01:30 -0700)]
sbin/hammer2/show: Use comp|checkmode string for blockref methods
in addition to ondisk inode ones (for file data) applied in
2a98b0e0d4aa48b8c50a866f4c054f37b556dca2.
Aaron LI [Sun, 5 Nov 2023 02:33:26 +0000 (10:33 +0800)]
libkern: Remove karc4rand() in favor of karc4random_buf()
The latter karc4random_buf()/arc4random_buf() sees more adoptions in
other BSDs as well as the userland. So only reserve the latter and
remove the former.
Update the kernel code accordingly to use karc4random_buf() only.
Aaron LI [Thu, 19 Oct 2023 08:40:09 +0000 (16:40 +0800)]
libkern: Add karc4random_uniform()
Obtained-from: FreeBSD
Aaron LI [Thu, 19 Oct 2023 08:38:29 +0000 (16:38 +0800)]
libkern: Add alias karc4random_buf() to karc4rand()
Align better with FreeBSD and OpenBSD that provide arc4random_buf()
in libkern.
Also for consistency with the userland arc4random_buf(3) API.
Aaron LI [Sun, 15 Oct 2023 00:26:21 +0000 (08:26 +0800)]
sys/conf: Sort libkern files
Aaron LI [Sun, 15 Oct 2023 00:25:54 +0000 (08:25 +0800)]
libkern: Import explicit_bzero() from FreeBSD
Obtained-from: FreeBSD
Aaron LI [Thu, 2 Nov 2023 01:13:36 +0000 (09:13 +0800)]
jail.8: Order the sysctl MIBs a bit to look more logical
Aaron LI [Wed, 1 Nov 2023 05:06:22 +0000 (13:06 +0800)]
taskqueue(9): Change timeout_task_init() to use callout_init_mp()
Currently only 'vfs/autofs' and 'netproto/802_11' use this API and
there task functions are MP-safe, so update this API to use
callout_init_mp().
Aaron LI [Wed, 1 Nov 2023 04:57:28 +0000 (12:57 +0800)]
taskqueue(9): Add enqueue func assertion for taskqueue_start_threads()
It's already described in the taskqueue(9) man page for
taskqueue_start_threads():
The taskqueue specified by tqp must be created previously by calling
taskqueue_create() with the argument enqueue set to
'taskqueue_thread_enqueue'.
Therefore, add such an assertion to taskqueue_start_threads() to catch
potential caller mistakes.
Aaron LI [Wed, 1 Nov 2023 04:54:00 +0000 (12:54 +0800)]
nfs: Fix a memory leak in the unused nfsrv_rcv()
Although nfsrv_rcv() is unused (disabled in nfsrv_rcv_upcall()), it was
failing to free the obtained socket name 'nam'. Since 'nam' is actually
unused in that code path, so fix the memory leak by passing it as NULL.
Aaron LI [Wed, 1 Nov 2023 04:45:14 +0000 (12:45 +0800)]
socket: Fix a bug in soreceive() for the MSG_OOB case
For the MSG_OOB case, soreceive() was failing to traverse the mbuf chain
when supplying the sio to return the data. Fix the bug by adding the
missing 'm = m_free(m)'.
While there, update the description about function parameters.
Reviewed-by: dillon
Tomohiro Kusumi [Fri, 3 Nov 2023 07:08:21 +0000 (00:08 -0700)]
sbin/hammer2: Make comp|checkmodestr() available in subs.c
These functions have been static in sbin/hammer2/cmd_stat.c,
but useful in other directives as well, e.g. show.
Tomohiro Kusumi [Thu, 2 Nov 2023 08:20:07 +0000 (01:20 -0700)]
usr.sbin/makefs: Add -o c|C option to specify comp|check type
mainly for debugging purpose to use "none" by default.
These options aren't available in newfs_hammer2(8) atm.
Note that level specification for "-o c" is currently unsupported,
and "sha192" for "-o C" is currently unsupported at runtime.
Tomohiro Kusumi [Mon, 30 Oct 2023 07:12:09 +0000 (00:12 -0700)]
sys/vfs/hammer2: Remove unused lbase local variables for hammer2_calc_logical()
These variables are never used after assigned values.
If the third argument is NULL, the second argument is unused either,
in which case 0 is usually passed. If the fourth argument is NULL,
the first argument is unused either, in which case NULL can be passed.
(So if at least the last 2 arguments are NULL, caller is just looking
for an fs block size, which is always 64KB...)
Peeter Must [Sat, 28 Oct 2023 06:15:59 +0000 (09:15 +0300)]
kernel/evdev: change USB scancode 0x54 from KEY_SLASH to KEY_KPSLASH
* This follows FreeBSD's commit
3e10195c86ce900b08ceba7509b39e61e979807e
Submitted-by: Uwe Münzberg
Matthew Dillon [Sun, 22 Oct 2023 17:26:31 +0000 (10:26 -0700)]
wifi - Add ID for Mercusys MW150US
* Rebadged, just requires an ID
Submitted-by: phcoder
Matthew Dillon [Fri, 20 Oct 2023 06:00:44 +0000 (23:00 -0700)]
hammer2 - Try to reduce no-activity stalls during complex flushes
* Hammer2 keeps track of directory dependencies to maintain
meta-data consistency at flush boundaries. This can cause
issues when heavy simultaneous front-end activity blows out
dirty buffer limits and stalls in 'h2memw'.
These front-end stalls are not supposed to be holding vnodes,
but there do appear to be cases where the backend flusher is
not able to immediately acquire some vnode locks during the flush.
This causes the backend flush to skip that vnode but also
introduce some static delays (rather than becoming cpu-bound).
The backend flush ultimately restarts the flush and tries again.
Situations can develop where the backend also stalls in a
sequence of 'h2syndel' tsleep delays, resulting in zero
cpu activity (frontend is stalled in 'h2memw'), and zero
disk activity (backend is also stalled) for a short period of
time.
* This problem does not lead to permanent deadlocks, however.
H2 is always able to recover.
* Rearrange a 'h2syndel' tsleep() call in the backend flusher.
Instead of tsleep on a per-failed-to-lock-vnode basis, we
now finish flushing the remaining vnodes, then try to wakeup
processes blocked in 'h2memw' on the frontend, and THEN sleep
for a few ticks before restarting.
This is an attempt to close the gap causing these periods of
no-activity.
Matthew Dillon [Fri, 20 Oct 2023 01:54:00 +0000 (18:54 -0700)]
hammer2 - Multitude of SMP contention fixes, work on flush
* Change the hammer2_io RBTREE to a hash table with per-entry locks.
This reduces contention in the hammer2 block I/O subsystem which
used to be protected by a single lock.
* Change the hammer2_inode RBTREE to a hash table with per-entry locks.
This reduces contention in the hammer2 inode cache which used to be
protected by a single lock.
* Replace the hammer2_chain LRU cache with a per-inode cluster cache,
which caches the last cluster-related chain. These caches are designed
to hold a deep chain with 0 refs (and thus its parent recursion) to
avoid having to reconstitute and recheck the chains on every VOP. For
example when doing sequential I/O on a file.
Probably needs more work.
* Use the new trigger_syncer_start() and trigger_syncer_end() API
to fix flush waits when the frontend is be asked to do large bulk
modifying operations (such as file creation).
The old code still worked but could sometimes cause processes to pause
for up to 30 seconds when the flush wait raced the syncer. The flush
wait wound up waiting for the next filesystem sync.
Matthew Dillon [Fri, 20 Oct 2023 01:51:22 +0000 (18:51 -0700)]
systat - Change -pv, add -w option
* Add -w (wide mode) option, currently only affects -pv
* Change -pv to use a wider contention label and to include
the contending lock's address when in wide mode.
* Move the sample_pc (root only) display over to wide-mode.
Matthew Dillon [Fri, 20 Oct 2023 01:49:07 +0000 (18:49 -0700)]
kernel - Clean up cache_hysteresis contention, better trigger_syncer()
* cache_hysteresis() is no longer multi-entrant, which causes
unnecessary contention between cpus. Only one cpu can run it
at a time and it just returns for other cpus if it is already
running.
* Add better trigger_syncer functions. Adding trigger_syncer_start()
and trigger_syncer_stop() to elide filesystem sleeps, ensuring that
a filesystem waiting on a flush due to excessive dirty pages does
not race the flusher and wind up twiddling its fingers while
no flush is happening.