Commit Graph

1260 Commits

Author SHA1 Message Date
Kristof Provost
08851be187 ndp tests: fix cleanup
Fix the cleanup function name so we actually remove our test jail and
interfaces.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-13 18:14:59 +01:00
Kristof Provost
4826406b30 pf tests: log additional information when a test ends
Log information from the running jails (routing, interfaces and pf) as
well as interfaces on the host.

This information is expected to be useful in debugging test failures.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-13 15:54:03 +01:00
Konstantin Belousov
b49b6e0f95 swapon(8): adapt to the new swapoff(2) interface
also fix test sys/audit/administrative.c.

Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33343
2021-12-09 02:48:59 +02:00
Alan Somers
41ae9f9e64 fusefs: invalidate the cache during copy_file_range
FUSE_COPY_FILE_RANGE instructs the server to write data to a file.
fusefs must invalidate any cached data within the written range.

PR:		260242
MFC after:	2 weeks
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D33280
2021-12-06 21:41:50 -07:00
Alan Somers
25927e068f fusefs: correctly handle an inode that changes file types
Correctly handle the situation where a FUSE server unlinks a file, then
creates a new file of a different type but with the same inode number.
Previously fuse_vnop_lookup in this situation would return EAGAIN.  But
since it didn't call vgone(), the vnode couldn't be reused right away.
Fix this by immediately calling vgone() and reallocating a new vnode.

This problem can occur in three code paths, during VOP_LOOKUP,
VOP_SETATTR, or following FUSE_GETATTR, which usually happens during
VOP_GETATTR but can occur during other vops, too.  Note that the correct
response actually doesn't depend on whether the entry cache has expired.
In fact, during VOP_LOOKUP, we can't even tell.  Either it has expired
already, or else the vnode got reclaimed by vnlru.

Also, correct the error code during the VOP_SETATTR path.

PR:		258022
Reported by:	chogata@moosefs.pro
MFC after:	2 weeks
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D33283
2021-12-06 21:36:46 -07:00
Kristof Provost
5fecc5a79a dummynet tests: disable for now
Disable the dummynet tests when running the ci tests. This avoids
running into the panic described in https://reviews.freebsd.org/D33064
(where an interface is removed but a dummynet queued packet still has a
pointer to it).

These tests can be re-enabled when the work in
https://reviews.freebsd.org/D33267 lands.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-12-06 18:15:24 +01:00
Kristof Provost
60a3a371af pf tests: more thorough pfsync defer test
Add a somewhat more extensive pfsync defer mode test. Ensure that pfsync
actually delays the state creating packet until after it has sent the
pfsync update and given the peer time to create the state.

Ideally the test should validate the pfsync state update and generate an
ack message, but to keep the test simple we rely on the timeout of the
deferred packet instead.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33245
2021-12-06 13:25:14 +01:00
Stefan Eßer
5e04571cf3 sys/bitset.h: reduce visibility of BIT_* macros
Add two underscore characters "__" to names of BIT_* and BITSET_*
macros to move them to the implementation name space and to prevent
a name space pollution due to BIT_* macros in 3rd party programs with
conflicting parameter signatures.

These prefixed macro names are used in kernel header files to define
macros in e.g. sched.h, sys/cpuset.h and sys/domainset.h.

If C programs are built with either -D_KERNEL (automatically passed
when building a kernel or kernel modules) or -D_WANT_FREENBSD_BITSET
(or this macros is defined in the source code before including the
bitset macros), then all macros are made visible with their previous
names, too. E.g., both __BIT_SET() and BIT_SET() are visible with
either of _KERNEL or _WANT_FREEBSD_BITSET defined.

The main reason for this change is that some 3rd party sources
including sched.h have been found to contain conflicting BIT_*
macros.

As a work-around, parts of shed.h have been made conditional and
depend on _WITH_CPU_SET_T being set when sched.h is included.
Ports that expect the full functionality provided by sched.h need
to be built with -D_WITH_CPU_SET_T. But this leads to conflicts if
BIT_* macros are defined in that program, too.

This patch set makes all of sched.h visible again without this
parameter being passed and without any name space pollution due
to BIT_* macros becoming visible when sched.h is included.

This patch set will be backported to the STABLE branches, but ports
will need to use -D_WITH_CPU_SET_T as long as there are supported
releases that do not contain these patches.

Reviewed by:	kib, markj
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D33235
2021-12-05 23:00:25 +01:00
Mitchell Horne
d99a40e5ba Remove riscv workaround in sys.netgraph.hub.loop test
The test case now passes on this architecture. This reverts commits
d5fd5cdc06 and 168b579a48.

Reviewed by:	lwhsu, imp
Differential Revision:	https://reviews.freebsd.org/D33252
2021-12-05 11:12:40 -04:00
Alan Somers
c2d342c509 fusefs: better debugging for FUSE_RENAME in the tests
MFC after:	2 weeks
2021-12-02 20:26:27 -07:00
Alan Somers
d109559ddb fusefs: fix 32-bit build of the tests after 91972cfcdd
MFC after:	2 weeks
MFC with:	91972cfcdd
2021-11-28 20:35:42 -07:00
Alan Somers
91972cfcdd fusefs: update atime on reads when using cached attributes
When using cached attributes, whether or not the data cache is enabled,
fusefs must update a file's atime whenever it reads from it, so long as
it wasn't mounted with -o noatime.  Update it in-kernel, and flush it to
the server on close or during the next setattr operation.

The downside is that close() will now frequently trigger a FUSE_SETATTR
upcall.  But if you care about performance, you should be using
-o noatime anyway.

MFC after:	2 weeks
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D33145
2021-11-28 18:53:31 -07:00
Alan Somers
65d70b3bae fusefs: fix copy_file_range when extending a file
When copy_file_range extends a file, it must update the cached file
size.

MFC after:	2 weeks
Reviewed by:	rmacklem, pfg
Differential Revision: https://reviews.freebsd.org/D33151
2021-11-28 18:35:58 -07:00
Warner Losh
09f1ead230 Fix copyright to be like all my others in the tree 2021-11-23 21:21:18 -07:00
Warner Losh
afc5ab870d Basic signal tests: Can we deliver a signal?
Basic signal tests that tests can we deliver a signal via raise() and
can we deliver one via SIGALARM asynchronously.

In addition, tests whether or not on ARM T32 (Thumb) code can interrupt
A32 (normal) and vice versa.

While this test is aimed at ensuring basic qemu signals are working,
it's good to have in the base.

Sponsored by:		Netflix
Discussed with:		kevans, cognet
Differential Revision:	https://reviews.freebsd.org/D33078
2021-11-23 13:37:14 -07:00
Ed Maste
8ec4c5dae3 Fix coredump_phnum test with ASLR enabled by default
coredump_phnum intends to generate a core file with many PT_LOAD
segments.  Previously it called mmap() in a loop with alternating
protections, relying on each mapping following the previous, to produce
a core file with many page-sized PT_LOAD segments.  With ASLR on we no
longer have this property of each mmap() following the previous.

Instead, perform a single allocation, and then use mprotect() to set
alternating pages to PROT_READ.

PR:		259970
Reported by:	lwhsu, mw
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33070
2021-11-21 12:57:38 -05:00
Kristof Provost
67573b7a39 net tests: fix if_stf:6to4
This test needs to have the loopback interface enabled, or route lookups
for our own IP addresses will fail.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33041
2021-11-20 19:29:02 +01:00
Kristof Provost
2610dcc1a5 net tests: 6rd to 6rd test
Test traffic between 6rd hosts, without border relay involvement.

PR:		253328
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33040
2021-11-20 19:29:02 +01:00
Kristof Provost
e1b95017d2 net tests: 6rd test for if_stf
Basic test case for 6rd.

PR:		253328
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33039
2021-11-20 19:29:02 +01:00
John Baldwin
694c708d6a ktls tests: Check the return values of close().
Suggested by:	markj
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33004
2021-11-16 09:56:15 -08:00
John Baldwin
d71830cdf0 ktls: Use ATF_REQUIRE instead of assert() for validating TLS header lengths.
The TLS header length field is set by the kernel, so if it is
incorrect that is an indication of a kernel bug, not an internal error
in the tests.

Prompted by:	markj (comment in an earlier review)
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D33003
2021-11-16 09:56:15 -08:00
John Baldwin
83a54b582f ktls: Add tests ensuring unsupported receive cipher suites are rejected.
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32982
2021-11-15 11:32:49 -08:00
John Baldwin
233ce578a4 ktls: Add tests ensuring invalid receive cipher suites are rejected.
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32981
2021-11-15 11:32:15 -08:00
John Baldwin
3e7f8a8da2 ktls: Add simple receive tests of kernel TLS.
Similar to the simple transmit tests added in
a10482ea74, these tests test the kernel
TLS functionality directly by manually encrypting TLS records using
randomly generated keys and writing them to a socket to be processed
by the kernel.

Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32980
2021-11-15 11:31:16 -08:00
John Baldwin
d1c369f926 ktls: Add tests ensuring various invalid cipher suites are rejected.
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32843
2021-11-15 11:30:48 -08:00
John Baldwin
0ff2a12ae3 ktls: Add tests for sending empty fragments for TLS 1.0 connections.
Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32841
2021-11-15 11:28:12 -08:00
John Baldwin
44265dc3da ktls: Add padding tests for AES-CBC MTE cipher suites.
For each AES-CBC MTE cipher suite, test sending records with 1 to 16
bytes of payload.  This ensures that all of the potential padding
values are covered.

Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32840
2021-11-15 11:26:45 -08:00
Gleb Smirnoff
6913bf4c3d tests/divert: fix after 2ce85919bb (IP source address validation)
Just make the test packet more legitimate.

Reviewed by:	melifaro
2021-11-12 11:20:06 -08:00
Kristof Provost
2de49deeca pf tests: Test PR259689
We didn't populate dyncnt/tblcnt, so `pfctl -sr -vv` might not have the
table element count.

PR:		259689
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32893
2021-11-10 11:27:22 +01:00
Ed Maste
e818178e3a tests: do not build ktls_test if WITHOUT_OPENSSL
ktls_test requires libcrypto to build, and fails if it is not available
(which is the case when building WITHOUT_OPENSSL).

Reported by:	Michael Dexter, Build Option Survey
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32895
2021-11-09 13:47:20 -05:00
Kristof Provost
eb5e0755f7 net tests: basic if_stf test
Test the 6to4 code.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32850
2021-11-09 09:39:54 +01:00
Kristof Provost
6e0755b37b net tests: basic if_gif(4) test case
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32836
2021-11-08 12:00:00 +01:00
Kornel Duleba
197ff4c35b ossl: Add support for AES-CBC cipher
AES-CBC OpenSSL assembly is used underneath.
The glue layer(ossl_aes.c) is based on CHACHA20 implementation.
Contrary to the SHA and CHACHA20, AES OpenSSL assembly logic
does not have a fallback implementation in case CPU doesn't
support required instructions.
Because of that CPU caps are checked during initialization and AES
support is advertised only if available.
The feature is available on all architectures that ossl supports:
i386, amd64, arm64.

The biggest advantage of this patch over existing solutions
(aesni(4) and armv8crypto(4)) is that it supports SHA,
allowing for ETA operations.

Sponsored by:		Stormshield
Obtained from:		Semihalf
Reviewed by:		jhb (previous version)
Differential revision:	https://reviews.freebsd.org/D32099
2021-11-08 10:53:31 +01:00
Wojciech Macek
200bc58953 Revert "ossl: Add support for AES-CBC cipher"
This reverts commit 849faf4e0b.
2021-11-06 17:46:01 +01:00
Kornel Duleba
849faf4e0b ossl: Add support for AES-CBC cipher
AES-CBC OpenSSL assembly is used underneath.
The glue layer(ossl_aes.c) is based on CHACHA20 implementation.
Contrary to the SHA and CHACHA20, AES OpenSSL assembly logic
does not have a fallback implementation in case CPU doesn't
support required instructions.
Because of that CPU caps are checked during initialization and AES
support is advertised only if available.
The feature is available on all architectures that ossl supports:
i386, amd64, arm64.

The biggest advantage of this patch over existing solutions
(aesni(4) and armv8crypto(4)) is that it supports SHA,
allowing for ETA operations.

Sponsored by:		Stormshield
Obtained from:		Semihalf
Reviewed by:		jhb
Differential revision:	https://reviews.freebsd.org/D32099
2021-11-06 09:08:44 +01:00
Kristof Provost
508161111d pf tests: basic test for ridentifier
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32751
2021-11-05 09:39:56 +01:00
Kristof Provost
11703705c2 pf tests: route_to:icmp_nat_head requires scapy
Document the requirement so the test is skipped if scapy is not
installed.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2021-11-03 10:35:09 +01:00
John Baldwin
a10482ea74 ktls: Add simple transmit tests of kernel TLS.
Note that these tests test the kernel TLS functionality directly.
Rather than using OpenSSL to perform negotiation and generate keys,
these tests generate random keys send data over a pair of TCP sockets
manually decrypting the TLS records generated by the kernel.

Reviewed by:	markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32652
2021-11-01 11:28:10 -07:00
Marius Halden
847b0d07c4 carp tests: negative demotion
PR:		259528
Reviewed by:	donner
MFC after:	3 weeks
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32760
2021-11-01 17:08:23 +01:00
Kristof Provost
4ee0f6d874 netpfil tests: dummynet+NAT test for pf
Ensure that NAT still works as expected when combined with dummynet.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32666
2021-10-28 10:41:17 +02:00
Kristof Provost
30276ef12c pf tests: test NAT-ed ICMP errors
Ensure that the ICMP error is returned with the correct
source and destination addresses.

MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D32572
2021-10-22 09:52:17 +02:00
Mark Johnston
51425cb210 bitset: Reimplement BIT_FOREACH_IS(SET|CLR)
Eliminate the nested loops and re-implement following a suggestion from
rlibby.

Add some simple regression tests.

Reviewed by:	rlibby, kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32472
2021-10-18 09:56:58 -04:00
Kristof Provost
914ec9c78d pf tests: ensure that $nr expansion is correct
Test the $nr expansion in labels is correct, even if the optimiser
reduces the rule count.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D32489
2021-10-15 22:19:45 +02:00
Li-Wen Hsu
168b579a48
Fix RISC-V build
Fixes:	d5fd5cdc06
2021-10-14 23:20:12 +08:00
Li-Wen Hsu
d5fd5cdc06
Temporarily skip sys.netgraph.hub.loop on RISC-V in CI
This case panics kernel.

PR:		259157
Sponsored by:	The FreeBSD Foundation
2021-10-14 05:31:22 +08:00
Kyle Evans
7259ca3104 fifos: delegate unhandled kqueue filters to underlying filesystem
This gives the vfs layer a chance to provide handling for EVFILT_VNODE,
for instance.  Change pipe_specops to use the default vop_kqfilter to
accommodate fifoops that don't specify the method (i.e. all in-tree).

Based on a patch by Jan Kokemüller.

PR:		225934
Reviewed by:	kib, markj (both pre-KASSERT)
Differential Revision:	https://reviews.freebsd.org/D32271
2021-10-12 02:43:07 -05:00
Li-Wen Hsu
2d827c065a
Skip sys.net.if_lagg_test.status_stress in CI
This case panics the machine fairly often and we should run
stress tests separately.

Sponsored by:	The FreeBSD Foundation
2021-10-12 05:40:24 +08:00
Mitchell Horne
8babb5582e riscv: fix VM_MAXUSER_ADDRESS checks in asm routines
There are two issues with the checks against VM_MAXUSER_ADDRESS. First,
the comparison should consider the values as unsigned, otherwise
addresses with the high bit set will fail to branch. Second, the value
of VM_MAXUSER_ADDRESS is, by convention, one larger than the maximum
mappable user address and invalid itself. Thus, use the bgeu instruction
for these comparisons.

Add a regression test case for copyin(9).

PR:		257193
Reported by:	Robert Morris <rtm@lcs.mit.edu>
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D31209
2021-10-07 18:12:30 -03:00
John Baldwin
668770dc7d crypto: Test all of the AES-CCM KAT vectors.
Previously, only test vectors which used the default nonce and tag
sizes (12 and 16, respectively) were tested.  This now tests all of
the vectors.  This exposed some additional issues around requests with
an empty payload (which wasn't supported) and an empty AAD (which
falls back to CIOCCRYPT instead of CIOCCRYPTAEAD).

- Make use of the 'ivlen' and 'maclen' fields for CIOGSESSION2 to
  test AES-CCM vectors with non-default nonce and tag lengths.

- Permit requests with an empty payload.

- Permit an input MAC for requests without AAD.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32121
2021-10-06 14:08:48 -07:00
Alan Somers
f44a448709 fusefs: fix intermittency in the dev_fuse_poll test
The DevFusePoll::access/select test would occasionally segfault.  The
cause was a file descriptor that was shared between two threads.  The
first thread would kill the second and close the file descriptor.  But
it was possible that the second would read the file descriptor before it
shut down.  That did not cause problems for kqueue, poll, or blocking
operation, but it triggered segfaults in select's macros.

MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D32142
2021-10-06 14:28:48 -06:00