Commit Graph

2561 Commits

Author SHA1 Message Date
Jake Freeland 834c1ba793 timerfd: Add tests
Take Jan Kokemuller's timerfd tests from the epoll-shim project,
stripping out code that isn't directly related to FreeBSD.

Reviewed by:		markj
Differential Revision:	https://reviews.freebsd.org/D55789
MFC after:		2 weeks
2026-03-20 02:15:08 -05:00
Gleb Smirnoff cc6672235c tests/netinet/raw: fix ssize_t printf(3) format
Fixes:	c1481c9f4a
2026-03-18 11:51:42 -07:00
Gleb Smirnoff c1481c9f4a tests/netinet: provide test for raw_ip.c:rip_input()
The test creates differently bound SOCK_RAW sockets and sends different
probe packets.  There is expected results matrix that every probe is
checked against.
2026-03-18 10:38:42 -07:00
Siva Mahadevan 736d8852e1 tests/fusefs: fix sign-compare warning on armv7
Fixes:		7e68af7ce2
Reviewed by:	asomers
Approved by:	emaste (mentor)
Differential Revision:	https://reviews.freebsd.org/D55846
2026-03-14 11:32:16 -04:00
Alan Somers 7e68af7ce2 fusefs: redo vnode attribute locking
Previously most fields in fuse_vnode_data were protected by the vnode
lock.  But because DEBUG_VFS_LOCKS was never enabled by default until
stable/15 the assertions were never checked, and many were wrong.
Others were missing.  This led to panics in stable/15 and 16.0-CURRENT,
when a vnode was expected to be exclusively locked but wasn't, for fuse
file systems that mount with "-o async".

In some places it isn't possible to exclusively lock the vnode when
accessing these fields.  So protect them with a new mutex instead.  This
fixes panics and unprotected field accesses in VOP_READ,
VOP_COPY_FILE_RANGE, VOP_GETATTR, VOP_BMAP, and FUSE_NOTIFY_INVAL_ENTRY.
Add assertions everywhere the protected fields are accessed.

Lock the vnode exclusively when handling FUSE_NOTIFY_INVAL_INODE.

During fuse_vnode_setsize, if the vnode isn't already exclusively
locked, use the vn_delayed_setsize mechanism.  This fixes panics during
VOP_READ or VOP_GETATTR.

Also, ensure that fuse_vnop_rename locks the "from" vnode.

Finally, reorder elements in struct fuse_vnode_data to reduce the
structure size.

Fixes:		283391
Reported by:	kargl, markj, vishwin, Abdelkader Boudih, groenveld@acm.org
MFC after:	2 weeks
Sponsored by:	ConnectWise
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D55230
2026-03-12 10:11:25 -06:00
Gleb Smirnoff ded881f905 tests/kern/ssl_sendfile: fix 'random' and 'basic' flakyness
The read of c.sbytes needs to be synchronized with mutex.  The problem was
fixed for 'truncate' and 'grow' with 8a95085635, but these two suffer
from the same problem.  Provide require_sbytes(), a locked wrapper around
ATF_REQUIRE() to reduce copy and paste.

Submitted by:		olivier
Differential Revision:	https://reviews.freebsd.org/D55781
2026-03-10 14:03:25 -07:00
Gleb Smirnoff 35b976c6ce tests/kern/ssl_sendfile: reduce copy & paste
Provide sendme_locked_wait() for a common pattern.  Not functional change.
2026-03-10 14:02:40 -07:00
Olivier Cochard 9f71153aec carp: fix global demotion counter to VRRP advertisements
When net.inet.carp.preempt=1 and a physical interface goes down, the global
V_carp_demotion counter is incremented. For CARP this was already reflected in
outgoing advertisements via DEMOTE_ADVSKEW(), but VRRP sent the raw
sc_vrrp_prio unchanged, so demotion had no effect.

Add DEMOTE_VRRP_PRIO(), a macro analogous to DEMOTE_ADVSKEW():
It subtracts V_carp_demotion from the configured priority and clamps the result
to [0, 254]. Priority 0 is VRRPv3's "resign" signal and causes backups to
preempt immediately. Priority 255 (IP address owner) is never demoted.

Reviewed by:	kp
Approved by:	kp
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D55558
2026-03-05 12:02:20 +01:00
Gleb Smirnoff 1abb62867f tests/net/bpf: skip the bpf:inject test when RSS is present
With RSS the epair(4) may reorder packets making the test flaky. See
net/if_epair.c:epair_select_queue().
2026-03-04 20:04:11 -08:00
Gleb Smirnoff d4083fb836 tests/net/bpf: hexdump(3) the packets if compare fails 2026-03-04 19:57:59 -08:00
Boris Lytochkin 32cd3ee590 ipfw: add support for masked ip-address lookups
Current radix-based implementation of lookup tables in ipfw does
not support non-contiguous prefixes while this type of lookup is
needed to write CPU-effective firewall configurations.

For some of the cases we can reach the goal using a masked table
lookup by adding masked (e.g. zero non-significant bits) records
into a table and then zero non-significant bits in lookup key
prior to making a table lookup.

Obtained from:  Yandex LLC
MFC after:      3 weeks
Relnotes:       yes
Sponsored by:   Yandex LLC
Differential Revision:  https://reviews.freebsd.org/D53694
2026-03-01 22:04:58 +03:00
Gleb Smirnoff 73d9153fc5 tests/kern: put ssl_sendfile under MK_OPENSSL != no
Reported by:	wosch
2026-02-26 12:30:18 -08:00
Pouria Mousavizadeh Tehrani 49fa0079cf gre tests: Fix gcc warnings on gre netlink tests
Avoid using `snl_add_msg_attr_ip` for now and directly use
`snl_add_msg_attr_ip4` to silence gcc warnings.

Fixes: e1e18cc12e
Differential Revision: https://reviews.freebsd.org/D54443
2026-02-20 20:15:13 +03:30
Pouria Mousavizadeh Tehrani 1635ba9061 gre tests: Add required_kmods to gre netlink test
Fixes: e1e18cc12e
Differential Revision: https://reviews.freebsd.org/D54443
2026-02-20 11:20:20 +03:30
Gleb Smirnoff 38edf96b17 tests/ipfw: fix log:bpf test flakyness
There were several problems:

o Using 'netstat -B' is not a reliable way to make sure that all tcpdumps
  have attached to bpf(4).  The problem is that tcpdump (via libpcap) does
  several ioctl(2)s after the attach including two BIOCSETF.  Each of them
  flushes the input buffer.  So we can see tcpdump attached in 'netstat -B'
  and start sending packets and the packet will be captured by bpf(4)
  before BIOCSETF and freed and tcpdump won't read anything.  Instead of
  using netstat(1), use ps(1) and make sure each tcpdump is blocked on the
  "bpf" wait channel, which guarantees it is done with ioctl(2)s and is now
  blocked in read(2).
o Using 'nc -w 0' sets timeout not only on the connect(2) (as documented)
  but also on poll(2), which is not documented.  There is a race in shell
  that will make stdin not yet filled by 'echo foo' when nc(1) does
  poll(2).  With zero timeout, this poll(2) will immediately return and nc
  will exit.
o The waiting loop had two errors: using wrong variable name as well as
  invoking a subshell, that actually can't wait on the pid.
o The reading tcpdump was lacking '-q' option, that prevents any protocol
  interpretations.  Sometimes, when random port chosen by nc(1) would
  match some well-known (to tcpdump) port, the output would differ from
  the expected.

PR:	293241
2026-02-18 18:53:16 -08:00
Pouria Mousavizadeh Tehrani e1e18cc12e if_gre: Add netlink support with tests
Migrate to new if_clone KPI and implement netlink support
for gre(4). Also refactor some of the gre specific ioctls.

Reviewed by: glebius, zlei
Differential Revision: https://reviews.freebsd.org/D54443
2026-02-18 23:12:29 +03:30
Mark Johnston 1eb727727a ndp tests: Fix flakiness in ndp_slaac_default_route
The test sends RAs in order to test SLAAC handling in another host.
The router needs to also set net.inet6.ip6.forwarding=1, otherwise NAs
sent from it have the ROUTER flag clear, and upon receiving such an NA
the host will automatically delete routes learned from the router.

Fixes:		feda329622 ("netinet6 tests: Add a regression test for default router handling")
MFC after:	1 week
Sponsored by:	Klara, Inc.
2026-02-17 20:22:05 +00:00
Mark Johnston eb425dfab1 ndp tests: Fix an assertion in ndp_prefix_lifetime_extend
Here we have two interface addresses sharing a v6 prefix with finite
lifetime.  The intent was to make sure that adding the second address
didn't cause the prefix's valid lifetime to drop from 20s to 10s, but of
course, while the test is running it may drop from 20s to 19s, causing
the test to fail spuriously.  Relax the check a bit to avoid this.

PR:		293152
Fixes:		74999aac5e ("in6: Modify address prefix lifetimes when updating address lifetimes")
MFC after:	1 week
Sponsored by:	Klara, Inc.
2026-02-17 20:22:05 +00:00
Alan Somers fba81b33aa capsicum-tests: remove Linux support
Now that this project is part of freebsd-src, it no longer needs to be
portable.  Remove Linux-only tests, cross-os compatibility code, and
compatibility with older FreeBSD versions.  Leave in place some
originally Linux-only tests that could now be ported to FreeBSD, like the
pipe2 tests.

Sponsored by:	ConnectWise
Reviewed by:	oshogbo
Differential Revision: https://reviews.freebsd.org/D54985
2026-02-16 17:29:32 -07:00
Alan Somers dc9a8d300b aio(4) tests: do not rely on (int *)-1 being invalid address
Explicitly mmap guard and use it as the invalid address instead.

MFC after:	1 week
2026-02-16 17:27:38 -07:00
Alan Somers 05492ff6f6 pdwait(2) tests: do not rely on (int *)-1 being invalid address
Explicitly mmap guard and use it as the invalid address instead.

MFC after:	1 week
2026-02-16 17:27:38 -07:00
Konstantin Belousov 793e891f4a pdrfork(2) tests: enable on x86
Use pfrfork_thread(3) instead of pdrfork(RFSPAWN) to make tests working
on x86.

Tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55306
2026-02-16 19:57:53 +02:00
Konstantin Belousov f90ee665d0 pdrfork(2) tests: should wait for the child to exit
Tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55306
2026-02-16 19:57:53 +02:00
Konstantin Belousov 94e4de77de pdrfork(2) tests: split basic_usage
into pdrfork(2) call itself, and basic_usage_tail() that checks the
pdrfork(2) results.

Tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55306
2026-02-16 19:57:53 +02:00
Konstantin Belousov 44843695bc pdrfork(2) tests: catch runaway child for EFAULT test
Reported and tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55306
2026-02-16 19:57:52 +02:00
Konstantin Belousov d6bf2d14a9 pdrfork(2) tests: do not rely on (int *)-1 being invalid address
Explicitly mmap guard and use it as the invalid address instead.

Tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55306
2026-02-16 19:57:52 +02:00
Konstantin Belousov 68ba270f4f pdrfork(2) tests: RFPROCDESC|RFPROC are required
Tested by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D55306
2026-02-16 19:57:52 +02:00
Kristof Provost 281282e935 pf: convert DIOCRTSTADDRS to netlink
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2026-02-16 13:42:50 +01:00
Mark Johnston a8b8feced9 atf_python/vnet: Make it possible to set the FIB of vnet interfaces
Reviewed by:	zlei, ngie
MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54972
2026-02-13 16:02:09 +00:00
Kristof Provost d03b6bb766 pf tests: verify blocked count on log interface
Also check the IPv6 pass/block numbers.

PR:		291763
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2026-02-12 17:05:16 +01:00
Kristof Provost fe9e4eb6f3 pf: fix use of uninitialised variable
In pf_match_rule() we attempt to append matching rules to the end of
'match_rules'. We want to preserve the order to make the multiple
pflog entries easier to understand. So we keep track of the last added
rule item in 'rt'. However, that assumed that 'match_rules' was only
ever added to in that one call to pf_match_rules(). This isn't always
the case, for example if we have match rules in different anchors.
In that case we'd end up using the uninitialised 'rt' variable in the
SLIST_INSERT_AFTER call.

Instead track the match rules and the last matching rule (to enable
easy appending) in the struct pf_test_ctx.
This also allows us to reduce the number of arguments for some
functions, because we passed a ctx to most functions that needed
'match_rules'.

While here also make pf_match_rules() static, because it's only ever
used in pf.c

Add a test case to exercise the relevant code path.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2026-02-03 23:51:28 +01:00
Gleb Smirnoff 32c3723f06 tests/netgraph: fix tests that depended on connect(in6addr_any)
Fixes:	627e126dbb
2026-02-02 12:15:26 -08:00
Mark Johnston 07940d1d85 atf_python: Run vnet handlers in $HOME
When kyua runs a test, it creates a temp directory and sets $HOME to
point to it.  Tests are run with the cwd set to that temp directory.

When a process attaches to a jail, its cwd is set to the root of the
jail.  Modify atf_python to cd to $HOME instead, so that it's easier for
tests to share files.

Reviewed by:	zlei, ngie
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54971
2026-02-02 16:54:54 +00:00
Alan Somers df68a09ea2 tests: sys/capsicum/functional requires mqueuefs
Skip this test if mqueuefs isn't loaded.  Unfortunately, that will skip
the entire googletest test program, including test cases that don't
require mqueuefs.  But the test's own skipping logic doesn't work, and
we don't yet have a googletest-compatible require_kmods() function.

MFC after:	2 weeks
Sponsored by:	ConnectWise
Reviewed by:	emaste, ngie
Differential Revision: https://reviews.freebsd.org/D54902
2026-01-31 08:46:35 -07:00
Gleb Smirnoff 9df110b11f tests/netinet: fix tests that depended on connect(in6addr_any)
Fixes:	627e126dbb
2026-01-30 13:31:13 -08:00
Mark Johnston 1539a657ad ip6_output tests: Remove an unused import
No functional change intended.

MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
2026-01-30 15:27:22 +00:00
Ed Maste 670b568ec1 capsicum-test: Move out of contrib
Google developed the Capsicum unit test suite[1] as part of the
Capsicum-Linux[2] project, based on unit tests that existed in FreeBSD
and unit tests developed as part of the initial Capsicum-Linux port.

Capsicum-Linux was archived as of October 31, 2022 and is no longer
being maintained.  FreeBSD is currently the only consumer of and
contributor to the test suite.  Move the src into tests/sys/capsicum to
simplify ongoing maintenance.

The makefiles were deleted as we (continue to) use the existing bespoke
FreeBSD Makefile, and CONTRIBUTING.md was removed as the Google CLA is
no longer applicable.

[1] https://github.com/google/capsicum-test
[2] https://github.com/google/capsicum-linux

Reviewed by:	asomers, oshogbo
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D54917
2026-01-28 16:23:26 -05:00
Gleb Smirnoff 8a95085635 tests/kern: make ssl_sendfile:truncate and ssl_sendfile:grow less flaky
First problem is a trivial race that the client thread doesn't see updated
c.sbytes.  Second problem applies only to the truncate test.  On a machine
with huge default buffer sizes, there is a chance that sendfile(2) will
fill both buffers with amount of data that is larger than the size we plan
to truncate.  To minimise chances for this scenario, increase file size
and truncate it less aggressively, also try to decrease buffer sizes.
2026-01-27 13:17:08 -08:00
Mark Johnston ef389b7f58 atf_python: Fix a typo in a type annotation
No functional change intended.

MFC after:	1 week
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
2026-01-27 14:57:31 +00:00
Mark Johnston b0d9970950 pf: Pass v6 packets to the divert socket
There is no particular limitation of divert sockets with respect to
IPv6, and the pf.conf man page does not mention the restriction to IPv4.

Extend the divert-to regression tests to exercise the v6 case.

Reviewed by:	igoro, kp, glebius
MFC after:	3 weeks
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54847
2026-01-27 14:04:48 +00:00
Mark Johnston 8934c3dc78 pf tests: Set require.kmods in divert-to tests
Tests should declare their dependencies rather than testing for them at
runtime.

Reviewed by:	igoro, kp, glebius
MFC after:	2 weeks
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D54846
2026-01-26 17:24:25 +00:00
Alan Somers 277539ae7f Add tests for pdwait
MFC With:	4d707825bf
Sponsored by:	ConnectWise
2026-01-26 07:37:16 -07:00
Alan Somers d1e6057fa4 Add tests for pdrfork
MFC With:	5c2ee618d5
Sponsored by:	ConnectWise
2026-01-26 07:37:08 -07:00
Alan Somers e35df41f68 procdesc: Add a test for pid recycling behavior
MFC With:	09984871d8
Sponsored by:	ConnectWise
2026-01-26 07:36:57 -07:00
Enji Cooper da59b3147b Account for the ctl test needing the ctl(4) module
This testcase does not function unless the /dev/ctl/... node exists,
which is created by the ctl(4) module. Require the ctl(4) module to be
loaded so the test can be executed.

MFC after: 1 week
Differential Revision:	https://reviews.freebsd.org/D54518
2026-01-24 16:18:45 -08:00
Alan Somers ffb747d587 fusefs: Add tests for the new -o auto_unmount feature
Add tests for mount_fusefs's new -o auto_unmount feature, recently added
by arrowd.

MFC with:	10037d0978 "fusefs: Implement support for the auto_unmount"
2026-01-24 09:02:33 -07:00
Gleb Smirnoff 37d11fde8f tests/kern: add test for SSL_sendfile() 2026-01-23 11:00:49 -08:00
Kristof Provost 2e0e45a516 pfctl(8): change default limiter action from no-match to block
pf(4) users who use limiters in current should update the rules
accordingly to reflect the change in default behavior. The existing
rule which reads as follows:

    pass in from any to any state limiter test

needs to be changed to:

    pass in from any to any state limiter test (no-match)

OK dlg@

Obtained from:	OpenBSD, sashan <sashan@openbsd.org>, c600931321
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2026-01-19 23:04:55 +01:00
Jose Luis Duran 964d91ee1d pflog: tests: Fix rdr_action_head()
Fix a typo in the rdr_action_head() test.

Fixes:		685fb42538 ("pf: Log the intended action when a NAT rule matches a packet")
MFC after:	1 week
2026-01-17 23:33:04 +00:00
Jose Luis Duran a4f0a60e05 tarfs: tests: Increase timeout (again 2)
Bump the timeout value (for the third time), to avoid cutoff on emulated
architectures on ci.freebsd.org.  One of the runners will take
considerably more time to complete this test.

Reported by:	Jenkins
Fixes:		a551b05249 ("tarfs: tests: Increase timeout (again)")
MFC after:	3 days
2026-01-17 18:01:21 +00:00