Commit graph

1950 commits

Author SHA1 Message Date
Kajetan Staszkiewicz 6ffd4aeba5 pf tests: add a test for max-src-conn
Switch tests using pft_ping.py to inetd. Netcat can only accept a single
connection, we need multiple parallel connections to test max-src-conn. Use the
discard service and modify pft_ping.py to use proper port number.

Implement functionality of 3-way handshake test in pft_ping.py. Make send_params
accessible to sniffer, because answers to SYN+ACK packets should be send with
the same parameters as the original SYN packet.

Finally add a test for max-src-conn and overload.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46798
2024-09-28 18:54:50 +02:00
Kajetan Staszkiewicz f28d5ac5c4 pf tests: fix max_states test
Ensure our rule with '(max 3)' only matches the TCP states we're counting.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46795
2024-09-26 16:50:45 +02:00
Kajetan Staszkiewicz 67bd1d0721 pf tests: Add max states test
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46774
2024-09-25 17:26:17 +02:00
Kajetan Staszkiewicz 85ea699293 pf tests: Make TCP port numbers configurable
This will be useful for state maximums testing.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46773
2024-09-25 12:46:48 +02:00
Kajetan Staszkiewicz 6aeaadf68d pf tests: Remove nargs from single arguments
Using nargs=1 causes arguments to produce lists from which we must then
get the real value. The same applies to defaults, the must be provided
as arrays too.

Remove nargs=1 so that values and defaults can be accessed directly.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46772
2024-09-25 12:43:27 +02:00
Igor Ostapenko 7b7e39221e pf tests: Speed up divert-to.sh test cases
Reviewed by:	kp
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D46671
2024-09-25 09:18:06 +00:00
Mark Johnston c9c2452a25 unix tests: Skip random_eor_and_waitall unconditionally
This test always fails, I don't see any reason to make it conditional on
the "CI" test parameter.

There is at least one test bug here, we're using the wrong sysctl to
obtain the receive buffer size, but fixing that is not sufficient.

PR:		279354
Reviewed by:	glebius
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D46726
2024-09-25 07:44:14 -04:00
Kristof Provost 9746c1e288 pf tests: ensure we don't NAT to link-local addresses
Reviewed by:	zlei
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46595
2024-09-19 22:20:15 +02:00
Kristof Provost 7309c551a5 pf tests: test the new log(matches) feature
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46589
2024-09-19 22:20:13 +02:00
Kristof Provost 357c95ea46 pf tests: ensure we correctly optimize { any, 192.0.2.3 }
Reviewed by:	zlei
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46581
2024-09-16 13:48:54 +02:00
Kristof Provost 661d0031bb pf tests: test the new received-on feature
Reviewed by:	zlei
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46578
2024-09-16 13:48:20 +02:00
Igor Ostapenko 641fbfc828 pf tests: Do not handle ipfw presence
Initially, it was added to cover a conflicting case of ipfw and pf used
together. But there are more drawbacks than benefits:
- A half of these tests are always skipped. That leads to
  misunderstanding, while the test suite strives to avoid ambiguous
  situations.
- Handling enabled ipfw on the test level is tedious, error-prone, and
  less maintainable.
- CI and similar parties already know how to deal with ipfw for the test
  suite, like making it open by default. Extra complexity is not needed.

In addition, ipfw+pf use cases are not officially supported.

Reviewed by:	kp, markj
Approved by:	kp (mentor), markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D46655
2024-09-14 08:08:06 +00:00
Kristof Provost b27d3f71c2 pf tests: improved test for CVE-2019-5598
Ensure that we verify that the inner and outer IP address matches for ICMP error
messages. This is a more detailed test for CVE-2019-5598, which was fixed back
in 2019.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46573
2024-09-11 13:17:49 +02:00
Kristof Provost 136b8134a4 if_ovpn tests: destroy an if_ovpn interface before it's been used
Ensure that we correctly clean up even if the interface never gets a socket
assigned.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46617
2024-09-10 20:34:23 +02:00
Mark Johnston 877cf210c0 tests: Add some test cases for SO_SPLICE
Reviewed by:	gallatin
MFC after:	3 months
Sponsored by:	Klara, Inc.
Sponsored by:	Stormshield
Differential Revision:	https://reviews.freebsd.org/D46412
2024-09-10 16:52:01 +00:00
Mark Johnston b103fc49ae netinet tests: Make some tests more reliable when run in parallel
Many of the modified tests add epair interfaces to the host, though most
of the tests themselves run in a VNET jail.  scapy in particular becomes
unhappy when the list of interfaces changes as it is running, so, to
improve reliability of parallel test runs, isolate tests which add
epairs to the host.

Also serialize arp tests, as they examine the dmesg as part of the test.

The list of modified tests is not exhaustive, it was determined by
running the test suite with parallelization enabled and looking at
failures.  It may be easier to just automatically enable VNET jailing of
all netinet tests, but let's be more particular for now.

Reviewed by:	kp
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D46606
2024-09-09 15:28:24 +00:00
Alan Somers f93a50d69d fusefs: fix an uninitialized memory access in fuse_vnop_deallocate
If the FUSE_GETATTR issued to query a file's size during
fuse_vnop_deallocate failed for any reason, then fuse_vnop_deallocate
would attempt to destroy an uninitialized fuse_dispatcher struct, with a
crash the likely result.  This bug only affects FUSE file systems that
implement FUSE_FALLOCATE, and is unlikely to be seen on those that don't
disable attribute caching.

Reported by:	Coverity Scan
CID:		1505308
MFC after:	2 weeks
2024-09-08 15:50:40 -06:00
Kristof Provost a05decec2d if_ovpn tests: allow these tests to run in parallel
Now that kyua can isolate tests in their own vnets we can run these tests in
parallel.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46600
2024-09-08 19:56:20 +02:00
Mark Johnston 24affded3d src.conf: Add a MK_ZFS_TESTS knob
The in-tree ZFS test suite is somewhat outdated and I see a number of
failures there.  I tend to think that we want to integrate the OpenZFS
test suite somehow, replacing the legacy one, though it's also possible
to run that as a separate test suite.

In any case, if one wants to run the OpenZFS test suite separately, it's
useful to be able to disable installation of the legacy ZFS test suite,
so let's provide a src.conf option to do that.

Reviewed by:	asomers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D46476
2024-09-07 14:36:28 +00:00
Tom Jones 390dc369ef pf: Add support for endpoint independent NAT bindings for UDP
With Endpoint Independent NAT bindings for UDP flows from a NATed source
address are always mapped to the same ip:port pair on the NAT router.
This allows a client to connect to multiple external servers while
appearing as the same host and enables NAT traversal without requiring
the client to use a middlebox traversal protocol such as STUN or TURN.

Introduce the 'endpoint-independent' option to NAT rules to allow
configuration of endpoint independent without effecting existing
deployments.

This change satisfies REQ 1 and 3 of RFC 4787 also known as 'full cone'
NAT.

Using Endpoint Independent NAT changes NAT exhaustion behaviour it does
not introduce any additional security considerations compared to other
forms of NAT.

PR:             219803
Co-authored-by: Damjan Jovanovic <damjan.jov@gmail.com>
Co-authored-by: Naman Sood <mail@nsood.in>
Reviewed-by:	kp
Sponsored-by:   Tailscale
Sponsored-by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D11137
2024-09-06 13:48:04 +01:00
Alan Somers e234a72bb8 ctl: add tests for PREVENT ALLOW MEDIUM REMOVAL
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:    emaste, markj
Pull Request:   https://github.com/freebsd/freebsd-src/pull/1409
2024-09-05 09:10:09 -06:00
Alan Somers fe1755fa6b ctl: add tests for START STOP UNIT
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	emaste, markj
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1409
2024-09-05 09:09:41 -06:00
Alan Somers 60d717baf2 ctl: add some ATF tests for READ BUFFER
Reviewed by:	Pierre Pronchery <pierre@freebsdfoundation.org>
Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Axcient
2024-09-04 14:38:12 +00:00
Mark Johnston 41ece3c036 capsicum tests: Serialize functional tests
The test suite runs the same tests twice, as different users, and these
can trample over each other when run in parallel, causing spurious test
failures.

MFC after:	1 week
2024-09-04 14:28:28 +00:00
Mark Johnston b5d3f8252f ggate tests: Use unique ports among tests
This helps avoid failures when running tests in parallel.

MFC after:	1 week
2024-09-04 14:28:28 +00:00
Kristof Provost d154dc2113 pf tests: ensure that neighbour discovery works as expected
Also check repeated calls.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-09-01 17:05:28 +02:00
Kristof Provost fff6212513 pf tests: ensure that 'quick' on anchor rules works as expected
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-08-26 18:50:02 +02:00
Christos Margiolis 2668e76d6e sound tests: Add SNDSTIOC_ADD_USER_DEVS test
Test whether the SNDSTIOC_ADD_USER_DEVS IOCTL (registers a userland
device to /dev/sndstat) works properly.

Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D46228
2024-08-24 15:07:29 +03:00
Igor Ostapenko e7f9171b67 pf: Handle m_len < sizeof(struct ether_header) case
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46391
2024-08-21 14:10:03 +02:00
Igor Ostapenko 22a632c366 pf: Make pf_test6 handle m_len < sizeof(struct ip6_hdr) case
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46312
2024-08-19 18:02:20 +02:00
Kristof Provost 6a88e22728 pfctl: pfik_ifp is always NULL
The pfik_ifp field is not provided by the kernel, it is always NULL. Do not
check for it. This caused us to not clear the skip flag on interfaces, leading
to unexpected behaviour when a 'set skip' was removed.

PR:		280834
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46311
2024-08-19 18:02:15 +02:00
Mark Johnston 9897a66923 pf: Let rdr rules modify the src port if doing so would avoid a conflict
If NAT rules cause inbound connections to different external IPs to be
mapped to the same internal IP, and some application uses the same
source port for multiple such connections, rdr translation may result in
conflicts that cause some of the connections to be dropped.

Address this by letting rdr rules detect state conflicts and modulate
the source port to avoid them.

Reviewed by:	kp, allanjude
MFC after:	3 months
Sponsored by:	Klara, Inc.
Sponsored by:	Modirum
Differential Revision:	https://reviews.freebsd.org/D44488
2024-08-19 14:37:27 +00:00
Kristof Provost 9aeee9486a pf tests: basic test for sticky-address configuration on rules
There was a bug in pf_handle_get_addr() where it confused the counter and
pointer in the pf_addr_wrap.p union, causing panics. Test for this.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-08-15 11:11:59 +02:00
Igor Ostapenko 09b7a03862 pf tests: Add 'mbuf' test for (*m0)->m_len < sizeof(struct ip) cases
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D45927
2024-08-15 09:28:13 +02:00
Kristof Provost 89f6723288 pf: invert direction for inner icmp state lookups
(e.g. traceroute with icmp)
ok henning, jsing

Also extend the test case to cover this scenario.

PR:		280701
Obtained from:	OpenBSD
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-08-14 14:15:07 +02:00
Igor Ostapenko d1deb682f2 pf tests: Make if_enc.sh stick to utils.subr interface
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46280
2024-08-13 14:14:08 +02:00
Kristof Provost 34063cb714 pf tests: ensure that traceroutes using ICMP work
PR:		280701
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-08-13 13:24:17 +02:00
Kristof Provost 82e021443a pf: cope with SCTP port re-use
Some SCTP implementations will abort connections and then later re-use the same
port numbers (i.e. both src and dst) for a new connection, before pf has fully
purged the old connection.

Apply the same hack we already have for similarly misbehaving TCP
implementations and forcibly remove the old state so we can create a new one.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-08-13 13:16:12 +02:00
Mark Johnston 3852a5a226 ktrace tests: Add a test case for handling of exec+setuid binaries
MFC after:	1 week
2024-08-07 15:53:37 +00:00
Ed Maste 5c2bc3db20 Remove "All Rights Reserved" from FreeBSD Foundation copyrights
These ones were unambiguous cases where the Foundation was the only
listed copyright holder.

Sponsored by:	The FreeBSD Foundation
2024-07-30 12:16:36 -04:00
Kristof Provost b9f0dbc3d0 pf tests: ensure we don't confuse different ICMP types
When creating a state for ICMP (v4 or v6) packets we only used the ID, which
means that we could confuse different ICMP types. For example, if we allowed
neighbour discovery but not ICMPv6 echo requests an ND packet could create a
state that the echo request would match.

Test that this is now fixed.

Reported by:	Enrico Bassetti <e.bassetti@tudelft.nl>
MFC after:	1 day
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-07-29 19:42:26 +02:00
Mark Johnston 9cc67e4361 ktrace tests: Add a missing mode in open(O_CREAT)
MFC after:	1 week
2024-07-28 15:31:40 +00:00
Christos Margiolis 95eb4b873b sound tests: Add sndstat nvlist ATF test
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D45901
2024-07-27 14:55:03 +03:00
Mark Johnston feda329622 netinet6 tests: Add a regression test for default router handling
This serves as a regression test for commit a48df53e42.

Reviewed by:	bz, allanjude
MFC after:	2 weeks
Sponsored by:	Klara, Inc.
Sponsored by:	Bell Tower Integration
Differential Revision:	https://reviews.freebsd.org/D46136
2024-07-25 17:01:11 -04:00
Kristof Provost 4f752a1583 netpfil tests: run in parallel
Run these tests in their own (vnet) jail so we don't have to worry about IP
range or jail name conflicts.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46040
2024-07-23 16:59:44 +02:00
Kristof Provost b0fcf4d522 pf tests: ensure temporary files end up in the atf working directory
Many of the tests create temporary files. pid files, log files, tcpdump
captures, ... We should take care to ensure they're stored in the temporary
working directory Kyua creates rather than in the root directory.

This ensures there are no conflicts between simultaneously running tests, and
also keeps the root directory clean.

MFC after:	1 month
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-07-23 16:59:31 +02:00
Kristof Provost ae8d588140 vnet tests: verify that we can load if_epair and if_bridge
We're going to start running many of the vnet tests in nested jails (so they
can run in parallel). That means the tests won't be able to load kernel modules,
which we commonly do for if_epair and if_bridge.

Just assume that all vnet tests need this, because so many of them do that we
don't want to manually annotate all of them.
This is essentially a no-op on non-nested tests.

Do the same for the python test framework.

While here also have pflog_init actually call pft_init. While having pflog
loaded implies we have pf too pft_init also checks for vimage support, and now
for if_epair.

Reviewed by:	markj
MFC after:	1 month
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46039
2024-07-23 15:57:25 +02:00
Kristof Provost fe0c82a603 pf tests: fix sctp:timeout test
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, amd64, amd64) (push) Waiting to run
The test body somehow wound up in the cleanup function.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-07-17 16:01:24 +02:00
Warner Losh e9ac41698b Remove residual blank line at start of Makefile
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-13, /opt/homebrew/opt/llvm@13/bin, macos-latest, bmake libarchive llvm@13, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-12, /usr/lib/llvm-12/bin, ubuntu-20.04, bmake libarchive-dev clang-12 lld-12, amd64, amd64) (push) Waiting to run
This is a residual of the $FreeBSD$ removal.

MFC After: 3 days (though I'll just run the command on the branches)
Sponsored by: Netflix
2024-07-15 16:43:39 -06:00
Mark Johnston dc8357de60 gnop tests: Serialize
Some of these tests make use of test disk devices, but then they can't
run in parallel.

MFC after:	2 weeks
2024-07-14 14:29:15 -04:00