Commit graph

2239 commits

Author SHA1 Message Date
Kajetan Staszkiewicz
d2761422eb pf: Use different address family for source and redirection address
The function pf_map_addr() and source tracking operate on a single
address family. This made sense before introducing address family
translation. When combining af-to with route-to or with sticky-address,
the next-hop or the NAT address are of different address family than
the source address. For example in NAT64 scenaro an IPv6 source address
is translated to an IPv4 address and routed over IPv4 gateway.

Make source nodes dual-AF, that is have a separate source AF and
redirection AF. Store route AF in struct pf_kstate, export it to pfctl.
When loading rules with redirection pools with pfctl store address
family of each address. When printing states don't deduce next-hop's
address family from af-to, use the one stored in state.

Reviewed by:	kp
Approved by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D51659
2025-08-01 12:11:30 +02:00
Kristof Provost
e9ca883b12 netinet6: Don't return non-IPv6 enabled interfaces from in6_getlinkifnet()
There are scenarios where we can end up looking up an interface by its scope and
turn up an interface that doesn't have IPv6 enabled on it. If that happens we
could end up dereferencing a NULL pointer accessing ifp->if_afdata[AF_INET6].
Check for this.

One such scenario is if a firewall rewrites a destination address to a
link-local address, with an embedded scope for such an interface. Attach a test
case which provokes this.

PR:		288263
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	zlei
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D51500
2025-07-29 15:13:10 +02:00
Lexi Winter
64f493e664 bridge: do not allow a bridge SVI in a bridge
Disallow this:

	ifconfig bridge0 create
	ifconfig bridge0.1 create
	ifconfig bridge0 addm bridge0.1

Also disallow this:

	ifconfig vlan1 create
	ifconfig bridge0 create
	ifconfig bridge0 addm vlan1
	ifconfig vlan1 vlan 1 vlandev bridge0

Firstly, this panics due to trying to take BRIDGE_LOCK recursively.
Secondly, even if it worked, it could cause packet forwarding loops.

Reviewed by:	des
Differential Revision:	https://reviews.freebsd.org/D51310
2025-07-28 18:38:02 +01:00
Kristof Provost
ad1b5df888 if_ovpn tests: basic float test case
Reviewed by:	markj
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D51469
2025-07-28 16:36:54 +02:00
Lexi Winter
e6ef675de2 tests/sys/net/if_bridge_test: fix MTU test
"ifconfig gif0 ether" doesn't return any output, so this wasn't
correctly checking the MTU on the gif interface.  Remove "ether".

Reviewed by:	zlei, kp
Differential Revision:	https://reviews.freebsd.org/D51245
2025-07-26 00:13:16 +01:00
Siva Mahadevan
9ec37e8ff4
tests/ci: Use QEMU blockdev declaration for all platforms
This patch uses the QEMU manpage-recommended '-blockdev' option instead
of '-drive' to declare block devices. This also makes the mandatory
'-device' declarations constant across all platforms, which fixes the
missing QEMU_DEVICES tarfs device declarations on all Makefile.<arch>
files.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>
Reviewed by:	imp, lwhsu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D51479
2025-07-26 05:52:32 +08:00
Siva Mahadevan
5dadfac51c
tests/mac_portacl: enable is_exclusive for now
Both tests rely on ports 77 and 7777 to be available
and thus cannot be run concurrently. This is a temporary
measure to ensure that they don't conflict with each other.

In the future, these should be rewritten to wait until the
necessary ports are available, or deterministically select a
free port instead.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>
Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1790
2025-07-26 04:55:01 +08:00
Mark Johnston
0bfcfb3cb1 if_ovpn tests: Exercise the multihome option
These test cases are variants of the 4in4 and 6in6 tests wherein the
server interface has an alias assigned and the client is configured to
connect to the alias rather than the primary address.

Reviewed by:	kp
MFC after:	1 month
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D51499
2025-07-25 17:39:01 +00:00
Siva Mahadevan
66fe805070
tests/ci: Fix wrong chflags target path in 'beforeclean' target
Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D51304
2025-07-25 04:12:53 +08:00
Siva Mahadevan
10fb5e7117
tests/ci: Fix race condition with ci-extractmeta
This solves an issue where 'ci-extractmeta' runs in parallel with
'ci-runtest', which would extract an empty test result into the
final test reports output dir. This also cleans up the intermediate
temporary files created along the way.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Reviewed by:	emaste, lwhsu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D51363
2025-07-25 04:01:50 +08:00
Siva Mahadevan
6ff78a63d8
tests/sys/netpfil: unskip tests that no longer need to be skipped
All of these are passing consistently in the latest CI environment
in 15 back-to-back test runs.

Signed-off-by:	Siva Mahadevan <me@svmhdvn.name>

PR:		260458, 260459, 260460, 264805
Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1788
2025-07-24 05:08:37 +08:00
Alan Somers
2a08ae1655 mac_bsdextended: report that all tests require the kernel module
Use the standard required_kmods reporting mechanism to notify Kyua of
which kernel modules are required.

MFC after:	2 weeks
Sponsored by:	ConnectWise
Reviewed by:	Siva Mahadevan <me@svmhdvn.name>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1783
2025-07-23 10:26:09 -06:00
Kristof Provost
13cd0f9c1a pf tests: test truncated IP options in ICMP payload
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-23 15:35:46 +02:00
Kristof Provost
b6d0caa485 pf tests: verify we now allow MLD packets with the Router Alert extention header
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-23 15:35:46 +02:00
Kristof Provost
ad8eabd4d2 pf tests: verify we now allow IGMP packets with the Router Alert IP option
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-23 15:35:45 +02:00
Kristof Provost
92155f8bbe pf tests: don't set interface on scapy's sr1()
That's not supported:
> /usr/local/lib/python3.11/site-packages/scapy/sendrecv.py:726: SyntaxWarning: 'iface' has no effect on L3 I/O sr1().

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-23 15:35:44 +02:00
Kristof Provost
799e21d544 libpfctl: fix reporting of flush address count
The PFNL_CMD_CLR_ADDRS command returns a PF_T_NBR_DELETED, not a PF_TS_NZEO.
Handle this correctly.

While here add a test case to verify we return the expected counts when adding
or flushing addresses to/from a table.

PR:		288353
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-23 13:56:11 +02:00
Alan Somers
d3c9f62862 ctl: delete dead code in the tests
This function has always been dead.  It isn't needed, since ctladm will
automatically load the module, if needed.

MFC after:	2 weeks
Sponsored by:	ConnectWise
2025-07-22 16:55:40 -06:00
Alan Somers
2662fd6a48 fusefs: report that all tests require the fusefs kernel module
Previously the googletest tests would skip themselves if /dev/fuse could
not be found.  But that information would not be passed to Kyua.
Instead it would think that they had passed.  Also, the atf-sh test
would previously fail if the fusefs module weren't loaded.  Now both
tests will correctly report their requirements to Kyua.

Note that fusefs's googletest tests still require that the
mac_bsdextended(4) module _not_ be loaded, but Kyua has no way to report
such a requirement.

MFC after:	2 weeks
Sponsored by:	ConnectWise
Reviewed by:	Siva Mahadevan <me@svmhdvn.name>
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1782
2025-07-22 16:32:39 -06:00
Muhammad Moinur Rahman
7f849b7f4e
tests/ci: Indent Makefile properly
Approved by:	imp, lwhsu
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D51445
2025-07-22 12:40:33 +02:00
Muhammad Moinur Rahman
9f3e4b28f9
tests/ci: Fix missing qemu devices
Fix missing QEMU_DEVICES which in turn is the META_TAR device

Approved by:	imp, lwhsu
Sponsored by:	The FreeBSD Foundation
Pull Request:	https://reviews.freebsd.org/D51445
2025-07-22 12:40:32 +02:00
Kristof Provost
7986051313 pf tests: make mbuf:inet6_in_mbuf_len more robust
The mbuf:inet6_in_mbuf_len test sometimes fails because it encountered
unexpected extra packets. These turn out to be MLD packets, so block these
packets on the host with pf so they don't disturb what we're actually trying
to test.

Reviewed by:	igoro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D51408
2025-07-18 21:12:18 +02:00
Siva Mahadevan
57f725a6a6
tests/ci: fix missing /usr/local/{sbin,bin} in freebsdci rc PATH
Currently, a lot of tests report 'skipped' due to missing binaries
in the PATH. The real issue is that /etc/rc forcibly restricts the
PATH to the base system only.

This patch re-enables a large chunk of skipped tests by adding
the missing LOCALBASE directories to the PATH so that Kyua can
discover third-party packages. It also fixes some minor rc scripting
style as per the official freebsd scripting guide[0].

[0] https://docs.freebsd.org/en/articles/rc-scripting

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>
Sponsored by: The FreeBSD Foundation
Approved by:	lwhsu
Differential Revision:	https://reviews.freebsd.org/D51303
2025-07-16 22:17:09 +02:00
Kristof Provost
cb43e97aea pf: add missing IPv6 length check
We failed to verify that the packet was long enough for the provided IPv6 packet
length. This could result in us walking off the end of the mbuf and panicing.

PR:		288224
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Tested by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	emaste
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D51324
2025-07-16 13:33:51 +02:00
Alan Somers
874385b03f uexterr_gettext: add tests
Add tests for the new extended errno feature.

Sponsored by:	ConnectWise
MFC after:	2 weeks
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D51184
2025-07-15 14:43:52 -06:00
Lexi Winter
7d4673d3a4 netinet6: allow binding a raw socket to an anycast address
Raw sockets have a separate check for this in rip6_bind() that was
missed in the previous change.  This fixes e.g. 'ping -S' using an
anycast address.

Fixes: ca4b046105 ("netinet6: allow binding to anycast addresses")
Reviewed by:	tuexen, kevans, des (previous version)
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D50438
2025-07-15 06:12:45 +01:00
Kajetan Staszkiewicz
2b2ac1aa9a pf tests: Fix rdr pass test to really use 'pass … rdr-to' syntax
Reviewed by:	kp
Event:		Berlin Hackathon 202507
Sponsored by:	InnoGames GmbH
2025-07-13 16:48:01 +02:00
Kajetan Staszkiewicz
04dcbb4434 pf: Prevent infinite looping over tables in round-robin pools
In FreeBSD each redirection pool (struct pf_kpool) consists of multiple
hosts (struct pf_addr_wrap). In OpenBSD that is not the case, and a
round-robin pool having a table as a host loops infinitely only over
that single table.

In FreeBSD once all addresses from a table are returned the pool must
iterate to the next host. Add a custom flag to have pfr_pool_get() break
its loop once it reaches the last index. Use this flag in round-robin
pools. When changing pool's host set index to 0 to always start
iterating each table from beginning.

Reviewed by:  kp
Approved by:  kp
Sponsored by: InnoGames GmbH
Differential Revision:    https://reviews.freebsd.org/D50779
2025-07-13 15:11:21 +02:00
Kajetan Staszkiewicz
c46bf1e3c9 pf tests: Add jail configuration for route_to and ipv6-nexthop tests
Maybe it could later replace previous IPv4 and IPv6 jail configurations.

Reviewed by:  kp
Approved by:  kp
Sponsored by: InnoGames GmbH
Differential Revision:    https://reviews.freebsd.org/D50764
2025-07-13 15:11:18 +02:00
Kajetan Staszkiewicz
cbd06dd2af pf: Fix error handling when pf_map_addr() fails
When pf_map_addr() fails, for example for a NAT pool, we expect packet will
not be forwarded. The error returned by pf_map_addr() has been ignored in
pf_map_addr_sn(), though, causing packets being forwarded without NAT
applied. Catch the error, return the error to caller, let the caller handle
error counters for route-to pools just like it does for NAT pools. Add
tests for NAT and route-to rules.

Improve logging by not hardcoding function name and use __func__
instead.

Reviewed by:  kp
Approved by:  kp
Sponsored by: InnoGames GmbH
Differential Revision:    https://reviews.freebsd.org/D50763
2025-07-13 13:48:39 +02:00
Kristof Provost
f5dba67334 pf tests: fix anchor:nat test
Don't assume that the epair we created is epair0.

Event:	Berlin 2025 Hackathon
2025-07-12 18:29:27 +02:00
Dag-Erling Smørgrav
dd81cc2bc5 getdirentries: Return ENOTDIR if not a directory.
This is both more logical and more useful than EINVAL.

While here, also check for VBAD and return EBADF in that case.  This can
happen if the underlying filesystem got forcibly unmounted after the
directory was opened.  Previously, this would also have returned EINVAL,
which wasn't right but wasn't wrong either; however, ENOTDIR would not
be appropriate.

MFC after:	never
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, kib
Differential Revision:	https://reviews.freebsd.org/D51209
2025-07-09 22:34:18 +02:00
Ronald Klop
9c95fcb7cd tests: Get the MAC from the epairs.
This removes knowledge of the implementation of if_epair.
Makes it easier to modify if_epair in future commits.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D51205
2025-07-09 17:38:08 +02:00
Kristof Provost
f651e87be2 pf tests: sync a state with an rtableid that doesn't exist
Create a state with an rtableid (i.e. fib) that doesn't exist on the receiving
side. This used to not be handled, and could provoke panics. Create such a
situation to ensure we still don't panic.

PR:		287981
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-09 17:38:08 +02:00
Kristof Provost
05c33e5acb pfctl tests: recursive flush test case
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-09 10:57:50 +02:00
Kristof Provost
6b95d258a9 pf tests: test DIOCNATLOOK validation
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-09 10:57:49 +02:00
Siva Mahadevan
2f50ea54c6
tests/ci: fix race condition in bhyveload boot
Currently, there is a race condition where the
Makefile sh invocation of 'bhyveload -c stdio'
exits before receiving any user input in the bootloader
(e.g. in the form of a user typically pressing <enter>),
causing the 'expect' script to wrongly spawn the 'bhyve'
invocation while still in the bootloader.

This patch wraps bhyveload in expect(1) to ensure that
stdio is correctly consumed before the process exits.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1757
2025-07-08 19:32:17 +08:00
Siva Mahadevan
ed4c64bc79
tests/ci: Use suitable variable for qemu-user-static existence check
And simplify a qemu-system existence check.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1751
2025-07-08 04:25:20 +08:00
Mark Johnston
4ea7a920de inotify tests: Use unsigned integers for event masks
Reported by:	gcc
Fixes:		739fc14938 ("tests: Add some regression tests for inotify")
2025-07-07 20:16:31 +00:00
Kristof Provost
95d1b98db1 pf tests: verify the new reset functionality
We can now reset state limit, debug level and others.
Verify reset for at least some of these.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2025-07-07 17:06:51 +02:00
Ricardo Branco
4140012f83 tests: Adapt oclo tests to FreeBSD
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1698
2025-07-06 23:09:10 +00:00
Ricardo Branco
63503cbe5a tests: Adapt existing tests for O_CLOEXEC to O_CLOFORK
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1698
2025-07-06 23:08:46 +00:00
Lexi Winter
c5f5d0cf49 if_bridge_test: add a test for QinQ (802.1ad)
Reviewed by:	kp, des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50577
2025-07-05 08:08:09 +01:00
Lexi Winter
95e7d47a4b bridge: allow vlan(4) interfaces on a bridge
A vlan interface on top of a bridge will act as a layer 3 port for
bridge traffic on that vlan, sometimes called an "SVI".  This allows
the host to send/receive traffic on that vlan without having to create
a separate epair(4) and vlan(4) to tag and untag the traffic.

Reviewed by:	zlei, kp, des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50504
2025-07-05 08:04:31 +01:00
Lexi Winter
032d32c2c2 bridge: add per-interface vlan access list
The new ifconfig options 'tagged', '+tagged' and '-tagged' allow the
vlan access list of a bridge interface to be configured:

- Incoming tagged frames will be dropped if the vlan tag isn't in the
  interface's access list.

- Outgoing frames will be dropped if the vlan tag isn't in the
  interface's access list (e.g., for BUM traffic).

This has no effect if vlan filtering is not enabled on the interface.

Since we now add a tag to untagged frames at ingress, remove the
vlan argument from bridge_vfilter_out() and use VLANTAGOF instead.

Reviewed by:	des, kp, adrian
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50503
2025-07-05 08:04:31 +01:00
Lexi Winter
877a7a325b bridge: transparently add and remove VLAN tags
When vlan filtering is enabled, add or remove tags as required to allow
ports with different configurations to communicate:

- When receiving an untagged frame, insert a new tag based on the
  interface's configured untagged vlan.

- When sending a tagged frame, and the frame's vlan id matches the
  outgoing interface's configured untagged vlan, strip the tag.

Since we now set the vlan id in the mbuf, remove the vlan argument to
bridge_forward() and bridge_broadcast() and take it from VLANTAGOF
instead.

Add tests for the new functionality.

Reviewed by:	kp, des
Approved by:	des (mentor)
Differential Revision:	https://reviews.freebsd.org/D50500
2025-07-05 08:04:31 +01:00
Lexi Winter
65ed1a035c bridge: allow member interface vlan to be configured
Add two new bridge(4) interface options, 'vlanfilter' and 'untagged':

	# ifconfig bridge0 vlanfilter ix0
	# ifconfig bridge0 -vlanfilter ix0
	# ifconfig bridge0 untagged ix0 20
	# ifconfig bridge0 -untagged ix0

Setting 'vlanfilter' causes the bridge to filter ingress and egress
traffic on that interface based on the frame's VLAN, rather than simply
passing all frames.  By default, an interface is not permitted on any
VLANs, so all frames will be dropped.

Setting 'untagged' allows the interface to send and receive untagged
traffic in the given VLAN, allowing two (or more) interfaces in the
same VLAN to communicate with each other, but not with any other
interface.

Setting 'untagged' on an interface automatically enables 'vlanfilter'
as well.  The untagged VLAN may be removed using the '-untagged'
option, but this does not disable VLAN filtering automatically.

Tagged frames may not be sent or received on a port with VLAN filtering
enabled.

Update bridge.4 to document this change, and also add an overview of the
existing vlan/.1q support in if_bridge.

Basic tests for the new functionality are included.

Bump __FreeBSD_version for struct ibfreq ABI change.

Reviewed by:	kevans, kp
Approved by:	kevans (mentor)
Differential Revision:	https://reviews.freebsd.org/D49993
2025-07-05 08:04:22 +01:00
Siva Mahadevan
f6e5bcd471
tests/ci: run ci-full kyua tests in parallel
By default, use all available cpus given to the VM. This can be
controlled with the already available PARALLEL_JOBS make variable.

Signed-off-by: Siva Mahadevan <me@svmhdvn.name>

Pull Request:	https://github.com/freebsd/freebsd-src/pull/1754
2025-07-05 00:27:59 +08:00
Mark Johnston
739fc14938 tests: Add some regression tests for inotify
Reviewed by:	kib
MFC after:	3 months
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50315
2025-07-04 14:42:33 +00:00
Claudiu I. Palincas
6b8f0b4777 fusefs: Upgrade FUSE protocol to version 7.35.
Upgrade the FUSE API from protocol 7.33 to 7.35.
Add support for FOPEN_NOFLUSH, introduced in 7.35.

Also, reduce diffs vis-a-vis upstream by factoring out an ioctl type, a
change missed in d5e3cf41e8.

Signed-off-by:	Claudiu I. Palincas <mscotty@protonmail.ch>
Reviewed by:	asomers
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1744
2025-07-03 10:23:10 -06:00