1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-29 08:08:37 +00:00
Commit Graph

1969 Commits

Author SHA1 Message Date
Kyle Evans
096c39fae4 tests: kern: add some porch(1)-based tty tests
If sysutils/porch is installed, we'll do some basic testing of tty
behavior.  The existing tests primarily cover ICANON-related processing
and corner cases that have been fixed somewhat recently, but I
anticipate growing this out a bit in due time.

Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D46806
2024-10-20 20:32:31 -05:00
Enji Cooper
0077477f21 tests/sys/fs/fusefs: include iomanip header
io.cc relies on `std::setw(..)`, which is exported by the iomanip C++
header. Newer versions of GoogleTest don't export this header, so add
the explicit include.

This unbreaks the build with GoogleTest 1.15.2.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47194
2024-10-19 18:50:48 -07:00
Igor Ostapenko
8829d4cb09 pf tests: Lower chances of false positives for mbuf:inet6_in_mbuf_len
Reviewed by:	kp
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D47175
2024-10-18 16:24:11 +00:00
Igor Ostapenko
cc7ec8fe3b ipfw tests: Add basic coverage of divert(4) use cases
Reviewed by:	kp
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D47163
2024-10-17 14:02:27 +00:00
Kristof Provost
9cd6ab45a4 pf tests: disable epsv for the ftp proxy test
The update to py-twisted 24.7.0 broke EPSV mode in twisted's ftp server.
Work around this by disabling EPSV (and thus using PASV).

PR:		282154
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-10-17 10:17:10 +02:00
Igor Ostapenko
b3e7d4b67c tests: Fix style of netpfil/common/divapp.c
No functional change intended.

Reviewed by:	markj
Approved by:	markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D47132
2024-10-16 16:24:54 +00:00
Warner Losh
ac77b26215 tests: Test endian.h, byteswap.h, sys/endian.h and both endian.h and byteswap.h together
What's required and not required to be defined is complicated. Write
tests to enshrine it:
	endian.h and sys/endian.h:
		[bl]e{16,32,64}toh
		hto[bl]e{16,32,64}
	byteswap.h:
		{__,}bswap_{16,32,64}
	sys/endian.h:
		{__,}bswap{16,32,64}
		_BYTE_ORDER
		_BIG_ENDIAN
		_LITTLE_ENDIAN
		_PDP_ENDIAN
	endian.h:
		__BYTE_ORDER
		__BIG_ENDIAN
		__LITTLE_ENDIAN
		__PDP_ENDIAN
		__FLOAT_WORD_ORDER

We also ensure that the sys/endian.h conditions hold true when
we include both endian.h and sys/endian.h in either order.

NOT TESTED:	deprecated symbols, internal to glibc symbols

Sponsored by:		Netflix
Discussed with:		markj (made the changes he requested)
Differential Revision:	https://reviews.freebsd.org/D32052
2024-10-15 17:14:42 -06:00
Igor Ostapenko
9b86b272bf tests: Move netpfil/pf/divapp to netpfil/common/
It's intended to be used by both ipfw and pf.

Reviewed by:	kp, markj
Approved by:	kp (mentor)
Differential Revision:	https://reviews.freebsd.org/D47110
2024-10-15 17:08:01 +00:00
Kristof Provost
2e13459e2a pf tests: fix plfow:v6 after scapy-2.6.0 update
Avoid receiving ICMPv6 destination unreachable packets, because scapy will
attempt to parse the pflow information from those (partial) packets as well, and
then get confused.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-10-15 16:29:11 +02:00
Kristof Provost
6b8096fa5f netpfil tests: skip checksum verification in pft_ping.py
From scapy 2.6.0 it now removes (sets to None) the IP checksum in its defrag
code. We typically ask for IPv4 or IPv6 defragmentation, which causes check
function failures.

Just skip the checksum verificiation here, because we're going to notice
incorrect checksums even if the tests don't directly verify it.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-10-14 17:54:49 +02:00
Jamie Gritton
b3c2cc7ea9 tests: move sysctl_security_jail_children.sh to the right directory 2024-10-13 13:50:22 -07:00
Mark Johnston
33c2c58f0a shm: Respect PROT_MAX when creating private mappings
We were previously unconditionally adding PROT_WRITE to the maxprot of
private mapping (because a private mapping can be written even if the
fd is read-only), but this might violate the user's PROT_MAX request.

While here, rename cap_maxprot to max_maxprot.  This is the intersection
of the maximum protections imposed by capsicum rights on the fd (not
really relevant for private mappings) and the user-required maximum
protections (which were not being obeyed).  In particular, cap_maxprot
is a misnomer after the introduction of PROT_MAX.

Add some regression test cases.  mmap__maxprot_shm fails without this
patch.

Note: Capsicum's CAP_MMAP_W is a bit ambiguous.  Should it be required
in order to create writeable private mappings?  Currently it is, even
though such mappings don't permit writes to the object referenced by the
fd.

Reported by:	brooks
Reviewed by:	brooks
MFC after:	1 month
Fixes:		c7841c6b8e ("Relax restrictions on private mappings of POSIX shm objects.")
Differential Revision:	https://reviews.freebsd.org/D46741
2024-10-04 15:56:34 +00:00
Alan Somers
618ae939b7 zfsd: replace vdevs with the AUX faulted state
Without this patch, vdevs faulted via AUX state would not be replaced
once the appropriate drive is replaced.  ZFS does not internally use
that state, but a drive can be manually forced into such a state with a
command like zinject.

Submitted by:	Goran Mekić <meka@tilda.center>
Sponsored by:	ConnectWise
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D46866
2024-10-03 16:21:46 -06:00
Kajetan Staszkiewicz
65074f6f31 pf: fix double ruleset evaluation for fragments sent to dummynet
The function `pf_setup_pdesc()` handles ruleset evaluation for non-reassembled
packets. Having it called before `pf_mtag` is checked for flags
`PF_MTAG_FLAG_ROUTE_TO` and `PF_MTAG_FLAG_DUMMYNET` will cause loops for
fragmented packets if reassembly is disabled.

Move `pd` zeroing and `pf_mtag` extraction from `pf_setup_pdesc()` to a separate
function `pf_init_pdesc()` and change the order of function calls: first
call `pf_init_pdesc()`, then check if the currently processed packet has been
reinjected from dummynet, finally call `pf_setup_pdesc()`.

Add functionality of sending UDP packets to `pft_ping.py` with fragmentation
support and fix broken IPv6 reassembly.

Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46880
2024-10-03 13:49:57 +02:00
Kristof Provost
c17a0f62da pf tests: use unique pid files for inetd processes
Ensure that we don't conflict with other inetd processes running in other jails
by setting an explicit pid file (rather than relying on the default /var/run/
inetd.pid). This could lead to failure to start inetd, which in turn could cause
test failures.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2024-10-02 12:03:19 +02:00
Olivier Cochard
215fd38e29 ctl: skip the test if ctladm is missing (WITHOUT_ISCSI)
Reviewed by:	asomers
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D46853
2024-10-01 15:59:47 +02:00
Andrew Turner
e189296153 tests: Add buf_ring overflow checks
Check enqueue works correctly when the offsets overflow

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46156
2024-09-30 12:04:24 +00:00
Andrew Turner
a707b81ccb tests: Add a buf_ring test
Add a simple test for sys/buf_ring.h. This enqueues and dequeues items
in the buf_ring to ensure the simple operations are correct.

There are no checks for multiple threads operating on buf_ring_enqueue
or buf_ring_dequeue_mc as they can be probabilistic and depend on the
architecture memory model.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D46147
2024-09-30 12:04:23 +00:00
Kajetan Staszkiewicz
3ec4fbdd98 pf tests: Add test for max-src-states
Reviewed by:	kp
Differential Revision:	https://reviews.freebsd.org/D46840
2024-09-30 09:48:40 +02:00
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