Commit Graph

1621 Commits

Author SHA1 Message Date
John Baldwin
883d1742d3 ktls_tests: Log more details when a test fails.
- Make use of ATF_REQUIRE_INTEQ to log the values of integers for
  unexpected mismatches.

- Use ATF_REQUIRE_MSG in a few more places to log values when a
  requirement fails.

- Consistently use ATF_REQUIRE_ERRNO when checking for an expected
  errno value.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37691
2022-12-15 12:06:09 -08:00
Alexander V. Chernikov
80f03e63d6 netlink: improve interface handling
* Separate interface creation from interface modification code
* Support setting some interface attributes (ifdescr, mtu, up/down, promisc)
* Improve interaction with the cloners requiring to parse/write custom
 interface attributes
* Add bitmask-based way of checking if the attribute is present in the
message
* Don't use multipart RTM_GETLINK replies when searching for the
specific interface names
* Use ENODEV instead of ENOENT in case of failed RTM_GETLINK search
* Add python netlink test helpers
* Add some netlink interface tests

Differential Revision: https://reviews.freebsd.org/D37668
2022-12-14 19:52:35 +00:00
Kristof Provost
654e8d84ec pf tests: check that we clean up unused kifs
The previous commit fixed a memory leak, where we'd fail to clean up
removed groups (and interfaces).
Check that we now clean those up as expected.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37570
2022-12-14 10:19:01 +01:00
John Baldwin
1656007e4c ptrace_test: Remove another MIPS remnant. 2022-12-13 14:51:52 -08:00
Konstantin Belousov
91ddfd352f posixshm_test: add naive page accounting test
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37097
2022-12-09 14:17:12 +02:00
Konstantin Belousov
f1f030246f posixshm_test: small style fixes
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D37097
2022-12-09 14:17:12 +02:00
John Baldwin
70bb22868d ktls_test: Add debug option to hexdump keys, nonces, and buffers.
Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37509
2022-12-07 16:57:28 -08:00
Gleb Smirnoff
78ec113617 tests/netinet: mark more tests that require python 2022-12-07 11:51:49 -08:00
John Baldwin
8dd8d56d95 posixshm_test: Fix sign mismatches in ?: results.
GCC 12's -Wsign-compare complains if the two alternative results of
the ?: operator are differently signed.  Cast the small, sub-page
off_t values to size_t to quiet the warning.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D37539
2022-12-04 16:31:05 -08:00
John Baldwin
f4db390553 netmap tests: Reset ctx->nmctx to NULL in nmreq_parsing.
This avoids leaking a pointer to the on-stack test_nmctx which
triggers a -Wdangling-pointer warning from GCC.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37536
2022-12-04 16:29:25 -08:00
Kristof Provost
7a6bcfb44d pf tests: test that reassembly is or is not performed as expected
We can now tell scrub rules to not reassemble packets. Test that this
affects packets being passed or dropped as expected.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-28 20:19:12 +01:00
John Baldwin
65bd3adbed ktls: Add tests for receiving corrupted or invalid records.
These should all trigger errors when reading from the socket.

Tests include truncated records (socket closed early on the other
side), corrupted records (bits flipped in explicit IVs, ciphertext, or
MAC), invalid header fields, and various invalid record lengths.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37373
2022-11-15 12:03:19 -08:00
John Baldwin
64811651aa ktls: Add tests for software AES-CBC decryption for TLS 1.1+.
Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37371
2022-11-15 12:02:28 -08:00
Eric van Gyzen
11ed0a95bf zfs tests: stop writing to arbitrary devices
TL;DR:  Three ZFS tests created ZFS pools on all unmounted devices listed
in /etc/fstab, corrupting their contents.  Stop that.

Imagine my surprise when the ESP on my main dev/test VM would "randomly"
become corrupted, making it unbootable.  Three tests collect various devices
from the system and try to add them to a test pool.  The test expects this
to fail because it _assumes_ these devices are in use and ZFS will correctly
reject the request.

My /etc/fstab has two entries for devices in /dev:

    /dev/gpt/swap0  none        swap    sw,trimonce,late
    /dev/gpt/esp0   /boot/efi   msdosfs rw,noauto

Note the `noauto` on the ESP.  In a remarkable example of irony, I chose
this because it should keep the ESP more protected from corruption;
in fact, mounting it would have protected it from this case.

The tests added all of these devices to a test pool in a _single command_,
expecting the command to fail.  The swap device was in use, so the command
correctly failed, but the ESP was added and therefore corrupted.  However,
since the command correctly failed, the test didn't notice the ESP problem.
If each device had been added with its own command, the test _might_ have
noticed that one of them incorrectly succeeded.  However, two of these
tests would not have noticed:

hotspare_create_001_neg was incorrectly specified as needing the Solaris
dumpadm command, so it was skipped.  _Some_ of the test needs that command,
but it checks for its presence and runs fine without it.

Due to bug 241070, zpool_add_005_pos was marked as an expected failure.
Due to the coarse level of integration with ATF, this test would still
"pass" even if it failed for the wrong reason.  I wrote bug 267554 to
reconsider the use of atf_expect_fail in these tests.

Let's further consider the use of various devices found around the system.
In addition to devices in /etc/fstab, the tests also used mounted devices
listed by the `mount` command.  If ZFS behaves correctly, it will refuse
to added mounted devices and swap devices to a pool.  However, these are
unit tests used by developers to ensure that ZFS still works after they
modify it, so it's reasonable to expect ZFS to do the _wrong_ thing
sometimes.  Using random host devices is unsafe.

Fix the root problem by using only the disks provided via the "disks"
variable in kyua.conf.  Use one to create a UFS file system and mount it.
Use another as a swap device.  Use a third as a dump device, but expect
it to fail due to bug 241070.

While I'm here:

Due to commit 6b6e2954dd, we can simply add a second dump device and
remove it in cleanup.  We no longer need to save, replace, and restore the
pre-existing dump device.

The cleanup_devices function used `camcontrol inquiry` to distinguish disks
from other devices, such as partitions.  That works fine for SCSI, but not
for ATA or VirtIO block.  Use `geom disk list` instead.

PR:		241070
PR:		267554
Reviewed by:	asomers
Sponsored by:	Dell Inc.
Differential Revision:	https://reviews.freebsd.org/D37257
2022-11-11 14:43:47 -06:00
Kristof Provost
c90b9a5ebb netpfil tests: add dummynet fq_codel test case
fq_codel was broken due to a missing m_rcvif_serialize() in the enqueue
path.
Add a simple test case to ensure it at least passes traffic.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-11 11:55:59 +01:00
Kristof Provost
832c8a58e1 if_ovpn tests: add aes-128-gcm test case
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-11 11:17:39 +01:00
Kristof Provost
e838ed7ca1 if_ovpn tests: fix typo in test description
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-10 14:34:25 +01:00
Ed Maste
185efcc376 tests: also remove sparc64 case
Followup to commit d6273acf56, which removed MIPS.

Reported by:	mhorne
2022-11-08 18:55:00 -05:00
Ed Maste
d6273acf56 tests: retire now-unused MIPS case 2022-11-08 09:17:53 -05:00
Kristof Provost
a7222b3cc3 pf tests: bridge-to test case
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37194
2022-11-02 15:45:23 +01:00
Kristof Provost
20777f79b8 ipsec tests: add test case for chacha20_poly1305
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37181
2022-11-02 14:19:37 +01:00
Kristof Provost
e1274b5b26 bridge tests: re-enable span test
The root cause of the intermittent span test failures has been
identified as a race between sending the packet and starting the bpf
capture.
This is now resolved, so the test can be re-enabled.

PR:		260461
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-02 11:59:11 +01:00
Kristof Provost
67557372df tests: make sniffer more robust
The Sniffer class is often used by test tools such as pft_ping to verify
that packets actually get sent where they're expected.

It starts a background thread to capture packets, but this thread needs
some time to start, leading to intermittent test failures when the
capture doesn't start before the relevant packet is sent.

Add a semaphore to ensure the Sniffer constructor doesn't return until
the capture is actually running.

PR:		260461
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-02 11:59:10 +01:00
Kristof Provost
45258e1bc7 pf tests: make killstate tests more robust
Rather than using a Scapy-based Python script only check if the state
still exists. Scapy tends to be slow to start, it appears because it
lists all interfaces and gets their (IPv6) addresses a couple of times
at startup. This can be sufficient for the ICMP state to time out and
the test to fail.

We now only check if the state exists or is removed as expected, which
makes things faster, and should mean the test is more robust on slower
machines (such as CI VMs).

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-01 18:47:05 +01:00
Kristof Provost
b0bf430310 pf tests: verify syncookie status report
Verify that pfctl -si -v correctly shows syncookies to be
active/inactive.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-10-31 18:14:10 +01:00
John Baldwin
9e0aaedd70 Split netinet shell tests into one per line.
This makes diffs when adding or removing tests easier to read.

While here, sort the list of tests.

Reviewed by:	kevans, melifaro, asomers, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36908
2022-10-28 13:36:12 -07:00
Alan Somers
f6e5319550 fusefs: fix VOP_ADVLOCK with SEEK_END
When the user specifies SEEK_END, unlike SEEK_CUR, VOP_ADVLOCK must
adjust lock offsets itself.

Sort-of related to bug 266886.

MFC after:	2 weeks
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37040
2022-10-18 19:11:49 -06:00
Kristof Provost
713efe0542 if_ovpn tests: fix timeout test case
Use the management interface to work out if we've timed out the client,
rather than looking for an openvpn process to die (with incorrect
syntax).

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-10-18 10:12:23 +02:00
Kristof Provost
188e069670 if_ovpn tests: test explicit exit notifications
Test that when a client exits the server notices this, even without
keepalive traffic.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-10-18 10:12:22 +02:00
Alan Somers
3c3b906b54 fusefs: After successful F_GETLK, l_whence should be SEEK_SET
PR:		266886
Reported by:	John Millikin <jmillikin@gmail.com>
MFC after:	2 weeks
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37014
2022-10-17 07:09:50 -06:00
Alan Somers
46fcf947c6 fusefs: during F_GETLK, don't change l_pid if no lock is found
PR:		266885
MFC after:	2 weeks
Submitted by:	John Millikin <jmillikin@gmail.com>
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D36905
2022-10-07 09:09:21 -06:00
Kornel Dulęba
fdbd0ba75d test/sys/opencrypto: Fix NIST KAT parser iterator
When yield a.k.a "generator" iterator is used we need to return all
data using "yield", before returning from the function.
Because of that only encryption tests were run for AES-CBC, other modes
were affected as well.
Add one more loop to the iterator "next" routine to fix that.
This unveiled a problem in the GCM AEAD parser logic, which didn't
correctly handle tests cases with empty plaintext, i.e. AAD only.
Include the fix in this patch as it's a rather trivial one.

Obtained from:	Semihalf
Differential Revision: https://reviews.freebsd.org/D36861
2022-10-06 16:42:31 +02:00
Gleb Smirnoff
69d79ceb2c tests/unix_passfd: add test case against 636420bde3 2022-09-30 13:43:37 -07:00
Gleb Smirnoff
0421ff5ab1 tests/unix_passfd: factor out sysctl(3) read into separate function 2022-09-30 13:43:08 -07:00
Alan Somers
52360ca32f copy_file_range: truncate write if it would exceed RLIMIT_FSIZE
PR:		266611
MFC after:	2 weeks
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D36706
2022-09-26 15:22:29 -06:00
Mark Johnston
e4eedf8c31 posixshm tests: Map the large pages in the madvise test
This improves test coverage and was unintentionally omitted when the
tests were written.

MFC after:	1 week
2022-09-26 08:58:10 -04:00
Kristof Provost
76e1c9c671 if_ovpn: fix address family check when traffic class bits are set
When the tunneled (IPv6) traffic had traffic class bits set (but only >=
16) the packet got lost on the receive side.

This happened because the address family check in ovpn_get_af() failed
to mask correctly, so the version check didn't match, causing us to drop
the packet.

While here also extend the existing 6-in-6 test case to trigger this
issue.

PR:		266598
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-09-26 13:54:20 +02:00
Alan Somers
be280f60dd fusefs: truncate write if it would exceed RLIMIT_FSIZE
PR:		164793
MFC after:	2 weeks
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D36703
2022-09-25 15:02:59 -06:00
Alan Somers
0a192b3aba fusefs: respect RLIMIT_FSIZE during truncate
PR:		164793
MFC after:	2 weeks
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D36703
2022-09-25 15:02:23 -06:00
Mitchell Horne
c387c23098 tests/sys/fs: remove mips workaround
MIPS is gone, so we no longer require this check.

Reviewed by:	imp, asomers
Differential Revision:	https://reviews.freebsd.org/D36566
2022-09-15 10:58:42 -03:00
Mitchell Horne
80dadb9c1a pf tests: require scapy for ether:short_pkt
The pft_ether.py script requires both python and scapy to be installed.
Check for this so we properly skip the test when it is unavailable.

Reviewed by:	kp
Fixes:	07ffa50ba0 ("pf tests: test short packets")
Differential Revision:	https://reviews.freebsd.org/D36561
2022-09-15 10:58:42 -03:00
Kristof Provost
95d5a656a2 pf tests: syncookie limits test
Test that we can successfuly set syncookie high/low watermarks for very
low or very high state limits.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36498
2022-09-12 09:32:02 +02:00
Doug Moore
2c545cf3b0 rb_tree: test rank balance
With _RB_DIAGNOSTIC defined, provide an RB_RANK method to compute the
rank of a node in an rb-tree, if the subtree rooted at that node is
rank-balanced, and -1 otherwise.

In rb_test, rewrite a bit to avoid malloc/free and nondeterministic
running times because of randomness. Allocate all the nodes on the
stack, and shuffle a set of keys to get randomness for the testing.

Add a rank-balance check for the completed tree.

Reviewed by:	markj
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D36484
2022-09-07 21:40:05 -05:00
Gleb Smirnoff
322b5b7c16 tests: partial revert of 4627bc1e90
Python's socketmodule isn't able to construct sockaddr when it doesn't
recognize the address family.  Until this is solved in python let the
tests use the compatibility way to create divert(4) socket.
2022-09-06 20:54:49 -07:00
Kristof Provost
d5a0bf4517 pf tests: test wildcard anchors
Ensure that a wildcard anchor actually includes any nested anchors (i.e.
foo/* will call into foo/bar).

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36414
2022-09-06 10:42:09 +02:00
Gleb Smirnoff
4627bc1e90 tests: use PF_DIVERT/SOCK_RAW instead of PF_INET/SOCK_RAW/IPPROTO_DIVERT 2022-08-30 16:24:37 -07:00
Li-Wen Hsu
9ea2716b77
Reenable basic_signal:trap_signal_test on i386
This is fixed in dc4a2d1d0e

PR:		265889
Sponsored by:	The FreeBSD Foundation
MFC with:	dc4a2d1d0e
2022-08-25 12:09:00 +08:00
Eric van Gyzen
3b0f105ce3 shared_shadow_inval_test: fix copy-pasto in error message
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-08-24 13:03:11 -05:00
Mark Johnston
4b8feb5d61 tests: Handle platforms with MAXPAGESIZES < 2
Reported by:	Jenkins
Fixes:		1dfa8b73f6 ("tests: Add more shared shadow regression tests")
2022-08-23 19:48:06 -04:00
Eric van Gyzen
3d268c19ef Fix shared_shadow_inval_test when superpages are disabled
In that case, there is only one page size.

Reviewed by:	kib
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D36265
2022-08-23 09:12:51 -05:00
Kristof Provost
eed634d113 if_ovpn tests: fix WITHOUT_PF
At least one if_ovpn.sh test relies on pf, so the file includes
netpfil/pf/utils.subr, which doesn't exist if WITHOUT_PF is set.

Do not install the if_ovpn.sh tests if pf is disabled.

Suggested by:	Olivier Cochard-Labbé <olivier@freebsd.org>
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-08-18 11:25:51 +02:00
Li-Wen Hsu
beeeb40bca
basic_signal test: really skip trap_signal_test on i386
PR:		265889
Fixes:		c04721e35f
Sponsored by:	The FreeBSD Foundation
2022-08-17 08:15:10 +08:00
Li-Wen Hsu
c04721e35f
basic_signal test: temporarily skip trap_signal_test on i386
This case crashes a bhyve VM.

PR:		265889
Sponsored by:	The FreeBSD Foundation
2022-08-17 06:03:37 +08:00
Dimitry Andric
ab28cc352b Adjust function definition in if_ovpn_c.c to avoid clang 15 warning
With clang 15, the following -Werror warning is produced:

    tests/sys/net/if_ovpn/if_ovpn_c.c:19:14: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    fake_sockaddr()
		 ^
		  void

This is because fake_sockaddr() is declared with a (void) argument list,
but defined with an empty argument list. Make the definition match the
declaration.

MFC after:      3 days
2022-08-14 13:11:52 +02:00
Kristof Provost
248da7940a if_ovpn tests: Test using a TCP socket for DCO
This used to trigger panics, so try to reproduce it.
Create an if_ovpn interface, set a new peer on it with a TCP fd (as
opposed to the expected UDP) and ensure that this is rejected.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-08-11 10:40:03 +02:00
Mark Johnston
1dfa8b73f6 tests: Add more shared shadow regression tests
The new tests exercise simulated COW that occurs when the protections on
a wired, copy-on-write mapping are changed from read-only to read-write.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35636
2022-08-09 18:34:01 -04:00
Kristof Provost
b77d581535 if_ovpn tests: remote access test case
Add a (multi-client) test case where we route traffic beyond the ovpn
server, onto a shared LAN.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-08-09 15:14:14 +02:00
Mike Karels
ec00e95190 netinet tests: Add test for IPv6 mapped-v4 bind problem
Test fix in 637f317c6d, verifying that when ports run out, we get
an EADDRNOTAVAIL error from bind() rather than an EADDRINUSE error
from connect().  Use small port range to exhaust ports and see which
error happens.

Reviewed by:	tuexen, glebius, melifaro
Differential Revision:	https://reviews.freebsd.org/D36056
MFC after:	3 days (with 637f317c6d)
2022-08-09 07:08:09 -05:00
Gleb Smirnoff
e87ff1ea22 tests/socket: add accept_filter(9) test
Test basic functionality of accf_data(9) and accf_http(9)
2022-08-08 14:10:18 -07:00
John Baldwin
cc13c98302 ktls_test: Add a require_toe option similar to require_ifnet.
This skips tests that send and receive records that do not use TOE TLS.

Sponsored by:	Chelsio Communications
2022-08-08 11:21:54 -07:00
Alexander V. Chernikov
7064c94a02 tests: add routing tests for switching between same prefixes
Differential Revision: https://reviews.freebsd.org/D36055
MFC after:	2 weeks
2022-08-07 19:45:25 +00:00
Mark Johnston
121e120883 bridge tests: Tests using pft_ping.py require scapy
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-08-04 09:41:52 -04:00
Alexander V. Chernikov
f28532a0f3 tests: fix unix_passfd_dgram:rights_creds_payload after be1f485d7d
The test was failing due to the assert on lack of MSG_TRUNC flag in the
 output flags of recvmsg().
The code passed MSG_TRUNC, along with sufficient-size buffer to hold the
 message to-be-received to the recvmsg(), and expected MSG_TRUNC to be
 returned as well.

This is not exactly correct as a) MSG_TRUNC was not even a supported
 recvmsg() flag before be1f485d7d and b) it violates POSIX, as
 POSIX states it should be set only "If a message is too long to fit in
 the supplied buffers,".
The test was working before as the kernel copied input flags to the
 output flags. be1f485d7d changed that behaviour to clear MSG_TRUNC
 if it was present on the input.

Fix the test by checking POSIX-defined behaviour.

Discussed with:	glebius
2022-08-01 09:20:45 +00:00
Alexander V. Chernikov
be1f485d7d sockets: add MSG_TRUNC flag handling for recvfrom()/recvmsg().
Implement Linux-variant of MSG_TRUNC input flag used in recv(), recvfrom() and recvmsg().
Posix defines MSG_TRUNC as an output flag, indicating packet/datagram truncation.
Linux extended it a while (~15+ years) ago to act as input flag,
resulting in returning the full packet size regarless of the input
buffer size.
It's a (relatively) popular pattern to do recvmsg( MSG_PEEK | MSG_TRUNC) to get the
packet size, allocate the buffer and issue another call to fetch the packet.
In particular, it's popular in userland netlink code, which is the primary driving factor of this change.

This commit implements the MSG_TRUNC support for SOCK_DGRAM sockets (udp, unix and all soreceive_generic() users).

PR:		kern/176322
Reviewed by:	pauamma(doc)
Differential Revision: https://reviews.freebsd.org/D35909
MFC after:	1 month
2022-07-30 18:21:51 +00:00
Alan Somers
f10dd8af4b Reap dead code in lio_kqueue_test and aio_kqueue_test
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D35358
2022-07-24 09:31:40 -06:00
Alan Somers
57082ce8c4 Add more aio tests
* Add tests for kqueue completion with all file types.
* Add a test for kqueue completion with EV_ONESHOT.
* Cleanup an unused variable.

MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D35359
2022-07-24 09:27:19 -06:00
Kristof Provost
cfee1417fb if_vlan tests: Test changing vlan ID
We can now change the vlan ID of an if_vlan interface without
disassociating it from the parent interface.

Test that this works.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35847
2022-07-21 18:36:01 +02:00
Kornel Dulęba
939f0b6323 Implement shared page address randomization
It used to be mapped at the top of the UVA.
If the randomization is enabled any address above .data section will be
randomly chosen and a guard page will be inserted in the shared page
default location.
The shared page is now mapped in exec_map_stack, instead of
exec_new_vmspace. The latter function is called before image activator
has a chance to parse ASLR related flags.
The KERN_PROC_VM_LAYOUT sysctl was extended to provide shared page
address.
The feature is enabled by default for 64 bit applications on all
architectures.
It can be toggled kern.elf64.aslr.shared_page sysctl.

Approved by:	mw(mentor)
Sponsored by:	Stormshield
Obtained from:	Semihalf
Reviewed by:	kib
Differential Revision: https://reviews.freebsd.org/D35349
2022-07-18 16:27:37 +02:00
Dimitry Andric
47be484573 Merge fix for zfs readmmap test from CheriBSD
Merge commit 1737d8397a0 by Brooks Davis:

  time() is declared in time.h

This fixes a -Werror warning from clang 15:

  tests/sys/cddl/zfs/bin/readmmap.c:97:9: error: call to undeclared function 'time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Obtained from:	https://github.com/CTSRD-CHERI/cheribsd/commit/1737d8397a0
MFC after:	3 days
2022-07-15 21:10:09 +02:00
Kristof Provost
6d1471fda8 pf tests: support packet size range in pft_ether.py
Teach pft_ether.py to send a range of packet sizes. Use this to move the
size sweep into Python, removing the repeated Python startup overhead
and greatly speeding up the pf.ether.short_pkt test.

This should fix test timeouts seen on ci.freebsd.org.

While here also extend the range of packet sizes tested, because it adds
very little runtime now.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-07-11 19:55:26 +02:00
Alexander V. Chernikov
50fa27e795 netinet6: fix interface handling for loopback traffic
Currently, processing of IPv6 local traffic is partially broken:
 link-local connection fails and global unicast connect() takes
 3 seconds to complete.
This happens due to the combination of multiple factors.
IPv6 code passes original interface "origifp" when passing
traffic via loopack to retain the scope that is mandatory for the
correct hadling of link-local traffic. First problem is that the logic
of passing source interface is not working correcly for TCP connections,
resulting in passing "origifp" on the first 2 connection attempts and
lo0 on the subsequent ones. Second problem is that source address
validation logic skips its checks iff the source interface is loopback,
which doesn't cover "origifp" case.
More detailed description is available at https://reviews.freebsd.org/D35732

Fix the first problem by untangling&simplifying ifp/origifp logic.
Fix the second problem by switching source address validation check to
using M_LOOP mbuf flag instead of interface type.

PR:		265089
Reviewed by:	ae, bz(previous version)
Differential Revision:	https://reviews.freebsd.org/D35732
MFC after:	2 weeks
2022-07-10 12:47:47 +00:00
Alexander V. Chernikov
81a235ecde netinet6: factor out cached route lookups from selectroute().
Currently selectroute() contains two nearly-identical versions of
 the route lookup logic - one for original destination and another
for the case when IPV6_NEXTHOP option was set on the socket.

Factor out handling these route lookups in a separation function to
 improve readability.
This change also fixes handling of link-local IPV6_NEXTHOPs.

Differential Revision: https://reviews.freebsd.org/D35710
MFC after:	2 weeks
2022-07-08 08:58:55 +00:00
Alexander V. Chernikov
78d11a3508 netinet6: add ip6_output() scope tests
Differential Revision: https://reviews.freebsd.org/D35742
2022-07-08 08:54:25 +00:00
Alexander V. Chernikov
ce414d02c1 netinet6: add ip6_output() tests.
Differential Revision: https://reviews.freebsd.org/D35708
2022-07-07 10:09:28 +00:00
Alexander V. Chernikov
cfc9cf9baf testing: add ability to specify multi-vnet topologies in the pytest framework.
Notable amount of tests related to the packet IO require two VNET jails
 for proper testing and avoiding side effects for the host system.
Additionally, it is often required to run actions in the jails seme-sequentially
- waiting for the listener initialisation can be an example of such
  dependency.

This change extends pytest vnet framework to allow defining multi-vnet
 multi-epair topologies in declarative style, without any need to bother
 about jail or repair names. All jail creation/teardown, interface
 creation/teardown and address assignments are handled automatically.

Example:

TOPOLOGY = {
  "vnet1": {"ifaces": ["if1", "if2", "if3"]},
  "vnet2": {"ifaces": ["if1", "if2", "if3"]},
  "if1": {"prefixes6": [("2001:db8:a::1/64", "2001:db8:a::2/64")]},
  "if2": {"prefixes6": [("2001:db8:b::1/64", "2001:db8:b::2/64")]},
  "if3": {"prefixes6": [("2001:db8:c::1/64", "2001:db8:c::2/64")]},
}
def vnet2_handler(self, vnet, obj_map, pipe):
  ss = VerboseSocketServer("::", self.DEFAULT_PORT)
  pipe.send("READY")

def test_output6_base(self):
  self.wait_object(second_vnet.pipe)

The definitions above will create 2 vnets ("jail_test_output6_base",
 "jail_test_output6_base_2"), 3 epairs, attached to both first and
 second jails, set up the IP addresses for each epair, spawn another
 process for vnet2_handler and pass control to vnet2_handler and
 test_output6_base. Both processes can pass objects between each
 other using pre-created pipes.

Differential Revision: https://reviews.freebsd.org/D35708
2022-07-07 10:05:06 +00:00
Kristof Provost
6ba6c05cb2 if_ovpn: deal with short packets
If we receive a UDP packet (directed towards an active OpenVPN socket)
which is too short to contain an OpenVPN header ('struct
ovpn_wire_header') we wound up making m_copydata() read outside the
mbuf, and panicking the machine.

Explicitly check that the packet is long enough to copy the data we're
interested in. If it's not we will pass the packet to userspace, just
like we'd do for an unknown peer.

Extend a test case to provoke this situation.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-07-05 19:27:00 +02:00
Kristof Provost
ba3b6b938d pf: handle dummynet for non-IP packets
Do not panic if we try to dummynet an Ethernet packet that's not IPv4 or
IPv6. Simply give it to dummynet.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-07-01 14:31:57 +02:00
Kristof Provost
5fb35badc0 if_ovpn tests: IPv4-mapped IPv6 address test
OpenVPN uses IPv4-mapped IPv6 addresses by default (if we don't specify
'proto udp4', or an IPv4 address to bind to). Test that this works.

Sponsored by:   Rubicon Communications, LLC ("Netgate")
2022-07-01 10:02:32 +02:00
Gleb Smirnoff
48a55bbfe9 unix: change error code for recvmsg() failed due to RLIMIT_NOFILE
Instead of returning EMSGSIZE pass the error code from fdallocn() directly
to userland.  That would be EMFILE, which makes much more sense.  This
error code is not listed in the specification[1], but the specification
doesn't cover such edge case at all.  Meanwhile the specification lists
EMSGSIZE as the error code for invalid value of msg_iovlen, and FreeBSD
follows that, see sys_recmsg().  Differentiating these two cases will make
a developer/admin life much easier when debugging.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35640
2022-06-29 09:42:58 -07:00
Alexander V. Chernikov
513ce835b5 testing: pass ATF vars to pytest via env instead of arguments.
This change is a continuation of 9c42645a1e workaround.
Apparently pytest argument parser is not happy when parsing values
 with spaces or just more than one --atf-var argument.
Switch wrapper to send these kv pairs as env variables. Specifically,
 use _ATF_VAR_key=value format to distinguish from the other vars.

Add the `atf_vars` fixture returning all passed kv pairs as a dict.

Reviewed by:	lwhsu
Differential Revision: https://reviews.freebsd.org/D35625
MFC after:	2 weeks
2022-06-28 12:20:16 +00:00
Kristof Provost
1e5ef2a7e1 if_ovpn tests: extend multi_client test with an iroute test
OpenVPN allows us to push routes for client networks with the 'iroute'
directive. Test that this works as expected.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:41 +02:00
Kristof Provost
a7a273546e if_ovpn tests: test multiple simultaneous clients
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:41 +02:00
Kristof Provost
2fc1fc66c7 if_ovpn tests: Test if_ovpn when there's no route
In client mode (i.e. if there's only one peer) we should be able to
route to the correct peer even if the routing table is incorrect.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:30 +02:00
Kristof Provost
f8b1ddbfb1 if_ovpn tests: tunnel with CHACHA20-POLY1305
Sponsored by:   Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:24 +02:00
Kristof Provost
c09e62cd91 if_ovpn tests: test pf's route-to
Ensure that pf's route-to works with if_ovpn.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:24 +02:00
Kristof Provost
85a15e4704 if_ovpn tests: IPv6 in IPv4 and IPv4 in IPv6 tunnels
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 13:51:15 +02:00
Kristof Provost
3d4f61350d if_ovpn tests: tunnel over IPv6
Set up a tunnel over IPv6 carrying IPv6 traffic.

Sponsored by:   Rubicon Communications, LLC ("Netgate")
2022-06-28 13:50:58 +02:00
Kristof Provost
08926ae328 if_ovpn tests: timeout on clients
Test that openvpn (DCO) clients are notified and handle timeout events.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35091
2022-06-28 13:50:45 +02:00
Kristof Provost
067acae2f3 if_ovpn tests: basic test case
Set up an OpenVPN tunnel between two jails, send traffic through them to
confirm basic function.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35067
2022-06-28 13:50:37 +02:00
Kristof Provost
07ffa50ba0 pf tests: test short packets
Test sending very short packets (i.e. too short for an IP header)
packets in the Ethernet filtering code.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-06-28 10:31:23 +02:00
Kristof Provost
1e824ee84f if_bridge tests: test adding interfaces with different MTU
We now allow new bridge members to be added with a different MTU from
the bridge. We change the interface MTU to match the bridge.
Test this.

PR:	264883
2022-06-27 08:27:28 +02:00
Alexander V. Chernikov
924226fba1 testing: move atf-pytest-wrapper to /usr/libexec
Move pytest wrapper to the collection of the other atf wrappers
 in libexec. It solves the problem of combining bits & pieces from
 bsd.test.mk and bgs.prog.mk to address "test binary, but not the
 suite binary".

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D35604
MFC after:	2 weeks
2022-06-26 13:25:47 +00:00
Alexander V. Chernikov
bd03f10a60 routing: add multipath pytest tests
Differential Revision:	https://reviews.freebsd.org/D31084
2022-06-25 19:29:11 +00:00
Alexander V. Chernikov
8eb2bee6c0 testing: Add basic atf support to pytest.
Implementation consists of the pytest plugin implementing ATF format and
a simple C++ wrapper, which reorders the provided arguments from ATF format
to the format understandable by pytest. Each test has this wrapper specified
after the shebang. When kyua executes the test, wrapper calls pytest, which
loads atf plugin, does the work and returns the result. Additionally, a
separate python "package", `/usr/tests/atf_python` has been added to collect
code that may be useful across different tests.

Current limitations:
* Opaque metadata passing via X-Name properties. Require some fixtures to write
* `-s srcdir` parameter passed by the runner is ignored.
* No `atf-c-api(3)` or similar - relying on pytest framework & existing python libraries
* No support for `atf_tc_<get|has>_config_var()` & `atf_tc_set_md_var()`.
 Can be probably implemented with env variables & autoload fixtures

Differential Revision: https://reviews.freebsd.org/D31084
Reviewed by:	kp, ngie
2022-06-25 19:25:15 +00:00
Gleb Smirnoff
235d960aae tests/unix_passfd: compile SOCK_STREAM and SOCK_DGRAM versions
Most test pass identically on different kinds of sockets. However,
few edge cases work differently on stream and datagram sockets. We
want to exercise this and document.

Differential revision:	https://reviews.freebsd.org/D35420
2022-06-24 09:09:11 -07:00
Gleb Smirnoff
458f475df8 unix/dgram: smart socket buffers for one-to-many sockets
A one-to-many unix/dgram socket is a socket that has been bound
with bind(2) and can get multiple connections.  A typical example
is /var/run/log bound by syslogd(8) and receiving multiple
connections from libc syslog(3) API.  Until now all of these
connections shared the same receive socket buffer of the bound
socket.  This made the socket vulnerable to overflow attack.
See 240d5a9b1c for a historical attempt to workaround the problem.

This commit creates a per-connection socket buffer for every single
connected socket and eliminates the problem.  The new behavior will
optimize seldom writers over frequent writers.  See added test case
scenarios and code comments for more detailed description of the
new behavior.

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35303
2022-06-24 09:09:11 -07:00
Claudio Jeker
7958889716 Add tests for TCP_MD5 getsockopt
Add tests for TCP_MD5 getsockopt for ipv6 and ipv4. These will only run
when the kernel module is loaded, but will be in place if further
regressions are found.

Reviewed by:	rscheff
MFC after:	3 days
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D35532
2022-06-23 15:57:56 +01:00
Li-Wen Hsu
b256d2dc0c
Temporarily skip flaky test case: sys.netpfil.common.dummynet.ipfw_queue
PR:		264805
Sponsored by:	The FreeBSD Foundation
2022-06-21 20:00:07 +08:00
Kristof Provost
3fccdfab64 pf tests: basic 'tagged' test for Ethernet rules
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D35364
2022-06-20 10:16:20 +02:00
Kristof Provost
7b271afd62 pf tests: basic 'tagged' test for Ethernet rules
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35363
2022-06-20 10:16:20 +02:00
Andrew Turner
2ff6e4ee97 Remove PAGE_SIZE from the kcov tests
To allow for a dynamic page size on arm64 remove the static valud from
the kcov tests

Sponsored by:	The FreeBSD Foundation
2022-06-17 10:43:30 +01:00
John Baldwin
ea4ebdcb4d ktls_test: Permit an option to skip tests not using ifnet TLS.
If ktls.require_ifnet is set to true, then check the TLS offload mode
for tests sending and receiving records and skip the test if the
offload mode is not ifnet mode.

This can be used along with ktls.host to run KTLS tests against a NIC
supporting ifnet TLS and verify that expected cipher suites and
directions used ifnet TLS rather than software TLS.  Receive tests may
result in a false positive as receive ifnet TLS can use software as a
fallback.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D35427
2022-06-14 10:35:01 -07:00
John Baldwin
2400a7b18f ktls_test: Permit connecting to a remote echo server for tests.
Previously ktls tests always executed over a local socket pair.
ktls.host can be set to a host to connect to with a single socket
instead.  The remote end is expected to echo back any data received
(such as the echo service).  The port can be set with ktls.port which
defaults to "echo".

This is primarily useful to permit testing NIC TLS offload use cases
where the traffic needs to transit the NIC.

Note that the variables must be set via
'kyua -v test_suites.FreeBSD.ktls.host=host'.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D35426
2022-06-14 10:34:51 -07:00
John Baldwin
2c10520533 ktls_test: Add a helper function to close sockets.
Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D35425
2022-06-14 10:34:38 -07:00
Gleb Smirnoff
d97922c6c6 unix/*: rewrite unp_internalize() cmsg parsing cycle
Make it a complex, but a single for(;;) statement.  The previous cycle
with some loop logic in the beginning and some loop logic at the end
was confusing.  Both me and markj@ were misleaded to a conclusion that
some checks are unnecessary, while they actually were necessary.

While here, handle an edge case found by Mark, when on 64-bit platform
an incorrect message from userland would underflow length counter, but
return without any error.  Provide a test case for such message.

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35375
2022-06-06 10:05:28 -07:00
Thomas Pasqualini
536e1da18b pf tests: pfsync and route_to test case
Test pfsync in a more realistic scenario with carp and route_to rules.

Build this topology and initiate a single ping session from client to
server:
		   ┌──────┐
		   │client│
		   └───┬──┘
		       │
		   ┌───┴───┐
		   │bridge0│
		   └┬─────┬┘
		    │     │
   ┌────────────────┴─┐ ┌─┴────────────────┐
   │gw_route_to_master├─┤gw_route_to_backup│
   └────────────────┬─┘ └─┬────────────────┘
		    │     │
		   ┌┴─────┴┐
		   │bridge1│
		   └┬─────┬┘
		    │     │
   ┌────────────────┴─┐ ┌─┴────────────────┐
   │gw_reply_to_master├─┤gw_reply_to_backup│
   └────────────────┬─┘ └─┬────────────────┘
		    │     │
		   ┌┴─────┴┐
		   │bridge2│
		   └───┬───┘
		       │
		   ┌───┴──┐
		   │server│
		   └──────┘

gw* jails forward traffic through pf route-to rules, not fib lookups.
If backup_promotion arg is given (as in the pfsync_pbr test case), a
carp failover event occurs during the ping session on both gateways.

Verify that ping messages still go where we expect them to go.

MFC after:	2 weeks
Sponsored by:	Orange Business Services
2022-06-04 14:23:17 +02:00
Gleb Smirnoff
70d07b2089 tests/unix_dgram: add test for event dispatchers
Put some data into a socket and check that:

o select(2) sees readable data
o kevent(2) sees data, and correctly sees data size
o ioctl(FIONREAD) sees correct size
o aio(4) successfully reads the data

Repeat the test twice for a connected socket and not-connected.  With
future implementation these two cases would exercise different code.
2022-06-03 12:55:44 -07:00
KUROSAWA Takahiro
d6cd20cc5c netinet6: fix ndp proxying
We could insert proxy NDP entries by the ndp command, but the host
with proxy ndp entries had not responded to Neighbor Solicitations.
Change the following points for proxy NDP to work as expected:
* join solicited-node multicast addresses for proxy NDP entries
  in order to receive Neighbor Solicitations.
* look up proxy NDP entries not on the routing table but on the
  link-level address table when receiving Neighbor Solicitations.

Reviewed By: melifaro
Differential Revision: https://reviews.freebsd.org/D35307
MFC after:	2 weeks
2022-05-30 10:53:33 +00:00
Cy Schubert
05882e28fb tests: Fix i386 and powerpc build
Fix:

tests/sys/kern/unix_passfd_test.c:414:24: error: comparison of integers
of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]
        ATF_REQUIRE(getnfds() == nfds + MAXFDS);
        ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
powerpc.powerpc/tmp/usr/include/atf-c/macros.h:144:15: note: expanded
from macro 'ATF_REQUIRE'
        if (!(expression)) \
              ^~~~~~~~~~
1 error generated.
--- unix_passfd_test.o ---
2022-05-27 14:04:17 -07:00
Gleb Smirnoff
23402c83f4 tests/unix_passfd: sending many and too many SCM_RIGHTS
o Exercise bounds checking when sending large set of file descriptors,
  that can't fit into single control mbuf.
o Exercise resource limits checks when receiving a large sets.
o Check that socket isn't left in a completely stuck state when we can't
  receive SCM_RIGHTS due to limits.  Current SOCK_STREAM socket would
  free the control, but leave the data in.  This seems to be a legit
  behavior for a stream socket, as we don't want holes in the data.

PR:			239250
Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35315
2022-05-25 13:28:40 -07:00
Mark Johnston
68fe988a40 kqueue tests: Simplify the test runner
Just invoke the test program directly instead of trying to convert its
output to TAP format.  The test suite is all or nothing; there's no way
to enumerate individual test cases, so there's no advantage in trying to
massage its output, and doing so throws away information that's useful
when diagnosing test failures.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2022-05-24 20:17:41 -04:00
Mark Johnston
d6d4f9b45e kqueue tests: Add new EVFILT_TIMER regression tests from upstream
One of the tests exposes the regression reported in PR 264131.

One test is disabled because FreeBSD does not support setting EV_ONESHOT
on an already-added periodic timer.  Though, in this case the flag is
simply ignored, which isn't ideal.

One test is slightly modified to set EV_ADD when reconfiguring a
disabled timer per some commentary in PR 258412.

Ideally we would re-import the test suite from libkqueue but there is a
fair bit of divergence so this will require some effort.  This just gets
us one small step closer while increasing test coverage.

PR:		258412
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2022-05-24 20:16:32 -04:00
Mark Johnston
c728c56c87 kqueue tests: Add file and line info to some test failure output
This brings us slightly closer to upstream and is useful when debugging
test failures.

MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2022-05-24 20:14:20 -04:00
Mark Johnston
bc7512cc58 kqueue tests: Re-enable kqueue proc tests
- Some EVFILT_PROC bugs were fixed around the time that the tests were
  disabled.
- I can't reproduce any failures locally.
- Jenkins logs referenced from the PR are gone, so let's re-enable the
  tests and see whether a problem persists.

PR:		233586
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2022-05-24 20:14:10 -04:00
Olivier Cochard
2d896da92a tests/unix_passfd: Prevent running them in parallel
Only the send_and_shutdown test is exclusive, but kyua doesn't allow
to prevent parallel execution of a single test.

Approved by:	glebius
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D35260
2022-05-23 15:44:10 +02:00
Mark Johnston
670be460e4 bitstring_test: Add regression tests for bit_ff(c|s)_area_at()
Validate the cases where a match can be found immediately and where no
match can be found.  This extends the existing test cases and is enough
to catch the bug fixed in commit 6e7a585348 ("bitstring: fix ff_area()
when start!=0").

Reviewed by:	dougm
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35259
2022-05-20 10:36:05 -04:00
Kristof Provost
b3fa36efe7 pf tests: extend ethernet dummynet test
Extend the existing ethernet dummynet test to also test dummynet on the
outbound direction.
This used to be a problem as traffic shaping wasn't done in the ethernet
code. It merely tagged the packet and left shaping up to the layer 3 pf
code. This works in the inbound direction, but not for outbound traffic
where we hit the L3 code first and only then the L2 code.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35258
2022-05-20 14:49:31 +02:00
Olivier Cochard
c678572e76 Prevent running sigwait tests in parallel
test_sig_discard_ign_* could not run at the same time.

Approved by:	dchagin
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D35236
2022-05-17 23:33:39 +02:00
Gleb Smirnoff
aa9f97af93 tests/unix_dgram: account for size of sender address in the filling cycle
This fixes test failure with large net.local.dgram.recvspace values.
2022-05-16 19:08:21 -07:00
Dmitry Chagin
d966efcc08 fusefs tests: Remove an unused variable.
Reviewed by:		asomers
Differential revision:	https://reviews.freebsd.org/D35185
MFC after:		2 weeks
2022-05-13 20:52:14 +03:00
Alan Somers
0bef4927ea fusefs: handle evil servers that return illegal inode numbers
* If during FUSE_CREATE, FUSE_MKDIR, etc the server returns the same
  inode number for the new file as for its parent directory, reject it.
  Previously this would triggers a recurse-on-non-recursive lock panic.

* If during FUSE_LINK the server returns a different inode number for
  the new name as for the old one, reject it.  Obviously, that can't be
  a hard link.

* If during FUSE_LOOKUP the server returns the same inode number for the
  new file as for its parent directory, reject it.  Nothing good can
  come of this.

PR:		263662
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	2 weeks
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D35128
2022-05-12 14:32:26 -06:00
Alan Somers
8b582b1640 fusefs: make the mknod.cc tests a bit more general.
MFC after:      2 weeks
Reviewed by:    pfg
2022-05-12 14:31:57 -06:00
Kristof Provost
920c341087 pf tests: test dummynet on route-to'd packets
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35161
2022-05-12 21:50:10 +02:00
Kristof Provost
1977d9a37b pf tests: factor out common dummynet check
Reviewed by:	glebius
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D35160
2022-05-12 21:50:10 +02:00
Dmitry Chagin
e4a257058c tests: Get rid of invalid since 3e11d3f6 testcase
MFC after:		2 weeks
2022-05-12 22:14:41 +03:00
Gleb Smirnoff
6d31772360 tests/kern: add tests for PF_UNIX/SOCK_DGRAM 2022-05-12 11:02:41 -07:00
Dmitry Chagin
c8b5c478f6 Add tests for affinity syscalls.
MFC after:		2 weeks
2022-05-11 10:39:18 +03:00
Alan Somers
10f44229dc Fix overflow errors in sbttous and sbttoms
Both of these functions would overflow for very large inputs.  Add tests
for them.  Also, add tests for the inverse functions, *stosbt, whose
overflow errors were fixed by 4c30b9ecd4.

PR:		263073
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D34809
2022-05-09 16:38:59 -06:00
Gleb Smirnoff
2400c536b4 tests/unix_passfd: add test for shutdown(2) on a buffer with an fd
This has two goals:
- Exercize call to unp_dispose() via soshutdown() instead of sofree()
- Make sure that shutdown indeed dereferences the fd stored

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35122
2022-05-09 10:42:48 -07:00
Kristof Provost
868bf82153 if: avoid interface destroy race
When we destroy an interface while the jail containing it is being
destroyed we risk seeing a race between if_vmove() and the destruction
code, which results in us trying to move a destroyed interface.

Protect against this by using the ifnet_detach_sxlock to also covert
if_vmove() (and not just detach).

PR:		262829
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D34704
2022-05-06 13:55:08 +02:00
Ed Maste
adbe6e6435 Reenable vnet tests in CI
After restoring the associated commits the tests can be enabled again.

This reverts commit 711524d961.
This reverts commit c4585b938a.

PR:		263767
2022-05-05 14:38:08 -04:00
Alan Somers
4ac4b12699 fusefs: annotate more file descriptor leaks in the tests
The fusefs tests intentionally leak file descriptors.  Annotate all of
the leakages in order to hopefully pacify Coverity.

Reported by:	Coverity (20 different CIDs)
MFC after:	2 weeks
Sponsored by:	Axcient
2022-05-05 09:06:04 -06:00
Marko Zec
c4585b938a tests: vnet tests started failing in CI, disable temporarily
As a fallout of backing out 91f44749c6, vnet tests started
failing in CI.  Temporarily broadly disable vnet tests until
specific cases can be resolved, and file a bug.

PR:		263767
Differential Revision:	https://reviews.freebsd.org/D35119
Submitted by:	kbowling
2022-05-04 06:19:46 +02:00
Marko Zec
711524d961 tests/dummynet: disable since mbuf pointer serialization KPI to be backed out
Obtained from:	github.com/glebius/FreeBSD/commits/backout-ifindex
2022-05-03 19:11:39 +02:00
Alan Somers
2f6362484c fusefs: use the fsname mount option if set
The daemon can specify fsname=XXX in its mount options.  If so, the file
system should report f_mntfromname as XXX during statfs.  This will show
up in the output of commands like mount and df.

Submitted by:	Ali Abdallah <ali.abdallah@suse.com>
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35090
2022-04-29 11:10:03 -06:00
Alan Somers
616eaa66aa fusefs: add a test for the subtype= option
At mount time server can set, for example, "subtype=xfs", so that
mount(8) will later show the mountpoint's file system as "fusefs.xfs".
fusefs has had this feature ever since the original GSoC commit in 2012,
but there's never been a test for it.

MFC after:	2 weeks
2022-04-29 07:59:29 -06:00
Alan Somers
45825a12f9 fusefs: fix FUSE_CREATE with file handles and fuse protocol < 7.9
Prior to fuse protocol version 7.9, the fuse_entry_out structure had a
smaller size.  But fuse_vnop_create did not take that into account when
working with servers that use older protocols.  The bug does not matter
for servers which don't use file handles or open flags (the only fields
affected).

PR:		263625
Submitted by:	Ali Abdallah <ali.abdallah@suse.com>
MFC after:	2 weeks
2022-04-28 15:13:09 -06:00
Dmitry Chagin
0ced2aef06 Fix build after 128b9bf9
MFC after:	2 weeks
2022-04-25 14:45:05 +03:00
Dmitry Chagin
128b9bf96c Add tests for sigwait family syscalls.
MFC after:		2 weeks
2022-04-25 13:20:12 +03:00
Andrew Turner
d3aabde979 Have posixshm_test ask the kernel for the page size
It may be dynamic so we can't rely on PAGE_SIZE being present or
correct.

Reviewed by:	markj, kib, imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34961
2022-04-20 14:44:52 +01:00
Andrew Turner
05d173587b Fill the page size array in one posix shm test
The largepage_config posix shared memory test was failing on arm64 as
the page size array is never filled out. Fix this by calling
getpagesizes(3), via pagesizes.

Reviewed by:	markj, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34960
2022-04-20 13:38:05 +01:00
Kristof Provost
812839e5aa pf: allow the use of tables in ethernet rules
Allow tables to be used for the l3 source/destination matching.
This requires taking the PF_RULES read lock.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D34917
2022-04-20 13:01:12 +02:00
Alan Somers
3a1b3c6a1e fusefs: correctly handle servers that report too much data written
During a FUSE_WRITE, the kernel requests the server to write a certain
amount of data, and the server responds with the amount that it actually
did write.  It is obviously an error for the server to write more than
it was provided, and we always treated it as such, but there were two
problems:

* If the server responded with a huge amount, greater than INT_MAX, it
  would trigger an integer overflow which would cause a panic.

* When extending the file, we wrongly set the file's size before
  validing the amount written.

PR:		263263
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D34955
2022-04-18 18:59:10 -06:00
Mark Johnston
b13ac67842 path_test: Verify that operations on unlinked files work
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2022-04-18 17:55:24 -04:00
Mark Johnston
333f668468 path_test: Correct the kevent test
Perhaps surprisingly, and contrary to the expectations of
path_test:path_event, NOTE_LINK events are not raised when a file is
unlinked.  Prior to commit bf13db086b, the test happened to work
because unlinking the file would cause the vnode to be recycled, and
EVFILT_VNODE knotes deliver an event with EV_EOF set when the vnode is
doomed.  Since the test did not verify the note type, the test
succeeded.  After commit bf13db086b, the vnode is not recycled after
being unlinked and so the test hangs.

Fix the test by waiting for NOTE_DELETE instead, and check that we got
the note that we expected.

Reported by:	Jenkins
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-04-18 11:45:45 -04:00
Alan Somers
155ac516c6 fusefs: validate servers' error values
Formerly fusefs would pass up the stack any error value returned by the
fuse server.  However, some values aren't valid for userland, but have
special meanings within the kernel.  One of these, EJUSTRETURN, could
cause a kernel page fault if the server returned it in response to
FUSE_LOOKUP.  Fix by validating all errors returned by the server.

Also, fix a data lifetime bug in the FUSE_DESTROY test.

PR:		263220
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	3 weeks
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D34931
2022-04-15 13:57:32 -06:00
Li-Wen Hsu
4642a6fac2
Disable building kcov test on powerpcspe
It's also 32-bit and lacks support for the needed atomic operations.

Sponsored by:	The FreeBSD Foundation
2022-04-14 23:03:00 +08:00
David Bright
0966fb1b74 Extend the length of dirpath to fix failure in kyua test
When an overlength path is set as the temporary directory for test
case sys/audit/inter-process:shm_unlink_success, the test will fail,
e.g.

```
root@freebsd:/usr/tests/sys/audit # env TMPDIR=/var/tmp/tests/kyua kyua test inter-process:shm_unlink_success
inter-process:shm_unlink_success  ->  failed: shm_unlink.*fileforaudit.*return,success not found in auditpipe within the time limit  [10.452s]

Results file id is usr_tests_sys_audit.20220412-221852-924310
Results saved to /root/.kyua/store/results.usr_tests_sys_audit.20220412-221852-924310.db

0/1 passed (1 failed)
```

The root cause is that dirpath is defined too small to handle it.

Reviewers:	vangyzen, dab
Differential Revision:	https://reviews.freebsd.org/D34885
Submitted by:	Yongbo Yao (yongbo.yao@dell.com)
Sponsored by:	Dell Technologies
2022-04-12 09:23:56 -07:00
Andrew Turner
8d40ee599d Have path_test ask the kernel for the page size
It may be dynamic so we can't rely on PAGE_SIZE being present or
correct.

Sponsored by:	The FreeBSD Foundation
2022-04-07 15:59:38 +01:00
Andrew Turner
df696a2fb6 Have the coredump_phnum test ask for the page size
The page size may be dynamically selected on boot. Have the
coredump_phnum test helper ask the kernel for the correct value.

Sponsored by:	The FreeBSD Foundation
2022-04-07 15:59:32 +01:00