Commit graph

1159 commits

Author SHA1 Message Date
Kristof Provost
b0010a4931 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

(cherry picked from commit 30276ef12c)
2021-11-14 00:15:37 +01:00
Mark Johnston
c5bd130deb 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
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 51425cb210)
2021-11-01 09:20:11 -04:00
Kristof Provost
9365113e89 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

(cherry picked from commit 914ec9c78d)
2021-10-22 09:34:33 +02:00
John Baldwin
dffa7f13db 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

(cherry picked from commit 668770dc7d)
2021-10-21 14:19:24 -07:00
Mark Johnston
54a01b5326 vfs: Permit unix sockets to be opened with O_PATH
As with FIFOs, a path descriptor for a unix socket cannot be used with
kevent().

In principle connectat(2) and bindat(2) could be modified to support an
AT_EMPTY_PATH-like mode which operates on the socket referenced by an
O_PATH fd referencing a unix socket.  That would eliminate the path
length limit imposed by sockaddr_un.

Update O_PATH tests.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2bd9826995)
2021-10-17 17:15:44 -04:00
Mitchell Horne
d925085dcd 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

(cherry picked from commit 8babb5582e)
2021-10-15 12:22:13 -03:00
Konstantin Belousov
5018dfb90f tests/sys/fs/fusefs/read.cc: fix build on powerpc64
There sig_atomic_t is shorter than void *.
As result, it cannot keep pointer.

Assigning to void * is actually safe for us in a signal handler.

(cherry picked from commit 3fcbde5e88)
2021-10-08 00:15:05 -05:00
Alan Somers
5dc6fedeb4 fusefs: don't panic if FUSE_GETATTR fails durint VOP_GETPAGES
During VOP_GETPAGES, fusefs needs to determine the file's length, which
could require a FUSE_GETATTR operation.  If that fails, it's better to
SIGBUS than panic.

Sponsored by:	Axcient
Reviewed by: 	markj, kib
Differential Revision: https://reviews.freebsd.org/D31994

(cherry picked from commit 4f917847c9)
2021-10-07 15:43:45 -06:00
Alan Somers
4bfd530cca aio: revert the workaround for bug 251828 in the tests
This bug is no longer reproducible in 14.0-CURRENT and 13.0-RELEASE

PR:		251828
Reported by:	markj
Reviewed by:	markj
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D31535

(cherry picked from commit 825fb07c55)
2021-10-07 15:38:25 -06:00
Kristof Provost
4747ec0839 pf tests: Basic adaptive mode syncookie test
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32139

(cherry picked from commit 2f20d80692)
2021-10-06 10:46:54 +02:00
Kristof Provost
767b29877e pf tests: Basic syncookie test
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32138

(cherry picked from commit dc0636636b)
2021-10-06 10:46:54 +02:00
Kyle Evans
121740e185 kqueue: don't arbitrarily restrict long-past values for NOTE_ABSTIME
NOTE_ABSTIME values are converted to values relative to boottime in
filt_timervalidate(), and negative values are currently rejected.  We
don't reject times in the past in general, so clamp this up to 0 as
needed such that the timer fires immediately rather than imposing what
looks like an arbitrary restriction.

Another possible scenario is that the system clock had to be adjusted
by ~minutes or ~hours and we have less than that in terms of uptime,
making a reasonable short-timeout suddenly invalid. Firing it is still
a valid choice in this scenario so that applications can at least
expect a consistent behavior.

(cherry picked from commit 9c999a259f)
(cherry picked from commit 2f4dbe279f)
2021-10-06 02:03:53 -05:00
Mark Johnston
8b1039f918 tests/sys/sys: Raise WARNS
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit d7cf1b262f)
2021-10-01 10:06:41 -04:00
Li-Wen Hsu
60921d4b2d
gmultipath failloop test: Add a checker for dtrace executes successfully or not
To provide a more informative error message.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 819961c580)
(cherry picked from commit 38dac71d0a)
(cherry picked from commit b9b5a4dd59)
2021-09-30 11:57:06 +08:00
Li-Wen Hsu
095d3f98fb
Temporarily skip flaky tset cases under sys.aio.aio_test in CI
- sys.aio.aio_test.vectored_unaligned
- sys.aio.aio_test.vectored_zvol_poll

PR:		258766
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 0b159faaca)
2021-09-30 03:38:35 +08:00
Kristof Provost
2134d9f05f pf tests: synproxy to localhost test
Test syn-proxying a connection to the local host.

Sponsored by:	Modirum MDPay
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31854

(cherry picked from commit 6598cababf)
2021-09-17 17:55:40 +02:00
Mark Johnston
4bfe0d4059 path_test: Fix test sorting
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c4c6615324)
2021-09-15 09:09:32 -04:00
Mark Johnston
91533b4cd4 path_test: Fix the unix socket test
The intent was to specify O_PATH to open(2).

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8b83b656a5)
2021-09-15 09:09:18 -04:00
Kristof Provost
d14ea58c22 netpfil tests: IPv6 dummynet queue test
Same as the v4 test, but with IPv6.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31789

(cherry picked from commit 12184311c1)
2021-09-14 22:00:25 +02:00
Kristof Provost
7674a7e404 netpfil tests: dummynet queue test
Test prioritisation and dummynet queues.
We need to give the pipe sufficient bandwidth for dummynet to work.
Given that we can't rely on the TCP connection failing alltogether, but
we can measure the effect of dummynet by imposing a time limit on a
larger data transfer.

If TCP is prioritised it'll get most of the pipe bandwidth and easily
manage to transfer the data in 3 seconds or less. When not prioritised
this will not succeed.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31788

(cherry picked from commit cb6bfef9ca)
2021-09-14 22:00:25 +02:00
Kristof Provost
c7e2400924 dummynet tests: pipe test for IPv6
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31787

(cherry picked from commit 5fda5913e1)
2021-09-14 22:00:24 +02:00
Kristof Provost
119806a6b7 pf tests: altq:codel_bridge requires if_bridge
Check that the bridge module is loaded before running this test.
It likely will be (as a result of running the bridge tests), but if it's
not we'll get spurious failures.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d491b42535)
2021-09-04 14:25:49 +02:00
Kristof Provost
518ea72e95 pf tests: Test ALTQ on top of if_bridge
Reviewed by:	donner
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31676

(cherry picked from commit 062463698e)
2021-09-01 15:27:01 +02:00
Kristof Provost
4defcd9078 pf tests: ALTQ priority test
Test that ALTQ can prioritise one type of traffic over another. Do this
by establishing a slow link and saturating it with ICMP echos.
When prioritised TCP connections reliably go through. When not
prioritised TCP connections reliably fail.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit cd46399b9c)
2021-09-01 15:27:01 +02:00
Kristof Provost
f610aafaed pf tests: test ALTQ CBQ on top of if_vlan
The main purpose of this test is to verify that we can use ALTQ on top
of if_vlan, but while we're here we also exercise the CBQ code. There's
already a basis test for HFSC, so it makes sense to test another
algorithm while we test if_vlan.

Reviewed by:	donner
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31649

(cherry picked from commit e62175df4e)
2021-09-01 15:27:01 +02:00
Cyril Zhang
2d4c599e7d vmm: Add credential to cdev object
Add a credential to the cdev object in sysctl_vmm_create(), then check
that we have the correct credentials in sysctl_vmm_destroy(). This
prevents a process in one jail from opening or destroying the /dev/vmm
file corresponding to a VM in a sibling jail.

Add regression tests.

Reviewed by:	jhb, markj
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a85404906b)
2021-09-01 09:07:42 -04:00
Dimitry Andric
e9dbd59b30 Silence more gtest warnings, now in fusefs tests
Follow-up d396c67f26 by also silencing warnings about deprecated
implicit copy constructors in the fusefs tests, which use googletest.

Fixes:		d396c67f26

(cherry picked from commit 5a3a8cb01a)
2021-08-31 21:05:47 +02:00
Kristof Provost
5b7336a489 pf tests: test killing states by ID
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit bbf832f344)
2021-08-31 09:47:27 +02:00
Kristof Provost
c2a5910552 netinet tests: delete an interface with pending lookups
This has been known to trigger panics. It currently doesn't, but we may
as well have a test for it.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit e86469075c)
2021-08-24 09:03:21 +02:00
Alexander V. Chernikov
a6daf4d500 Add arp/ndp tests in addition to rtsock ll tests.
(cherry picked from commit f17f94cd1b)
2021-08-24 09:02:15 +02:00
Vladimir Kondratyev
8f559509a2 bitstring(3): Add bitstring traversal macros.
The macro bit_foreach() traverses all set bits in the bitstring in the
forward direction, assigning each location in turn to variable.

The macro bit_foreach_at() traverses all set bits in the bitstring in
the forward direction at or after the zero-based bit index, assigning
each location in turn to variable.

The bit_foreach_unset() and bit_foreach_unset_at() macros which
traverses unset bits are implemented for completeness.

Reviewed by:	asomers, dougm

(cherry picked from commit 14a4d6d013)
2021-08-24 01:23:10 +03:00
Konstantin Belousov
21edf70b8c Add test for fstatat(pipefd, AT_EMPTY_PATH)
(cherry picked from commit b42df9dafb)
2021-08-19 14:21:57 +03:00
Kristof Provost
3bedd8a3b6 pf tests: test locally originated connections with route-to
PR:		257106
Submitted by:	Mark Cammidge <mark@peralex.com>
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D31178

(cherry picked from commit f808bb9b7e)
2021-08-07 09:08:19 +02:00
Kristof Provost
60c9798db7 net tests: basic test case for bpf(4)'s ability to set vlan pcp
Use dhclient with its 'vlan-pcp' option to set a VLAN PCP value and
verify that it actually gets set.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31276

(cherry picked from commit 3e87f800f0)
2021-08-02 16:50:32 +02:00
Kristof Provost
096cacc811 bridge tests: test linking bridges with a gif tunnel
Fairly basic test case for using gif(4)'s ability to tunnel Ethernet
traffic between bridges.

MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4b765ab4cd)
2021-08-02 16:50:32 +02:00
Kristof Provost
c1bb4edaa0 pf tests: Test the match keyword
The new match keyword can currently only assign queues, so we can only
test it with ALTQ.
Set up a basic scenario where we use 'match' to assign ICMP traffic to a
slow queue, and confirm that it's really getting slowed down.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D31116

(cherry picked from commit d363ebc78c)
2021-07-31 10:12:02 +02:00
Kristof Provost
2400173b93 altq tests: Basic ALTQ test
Activate ALTQ_HFSC, crudely check if it really limits bandwidth as we'd expect.

Reviewed by:		donner@
Differential Revision:	https://reviews.freebsd.org/D28303

(cherry picked from commit 16b3833344)
2021-07-31 10:12:02 +02:00
Kristof Provost
efe3bf0fb0 pf tests: make killstate:match more robust
Only lists the states relevant to the connection we're killing.
Sometimes there are IPv6 related states (due to the usual IPv6
background traffic of router solicitations, DAD, ...) that causes us to
think we failed to kill the state, which in turn caused the test to fail
intermittently.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4e860bd5da)
2021-07-30 09:51:04 +02:00
Mark Johnston
9ac0aec3a3 lio_listio: Don't post a completion notification if none was requested
One is allowed to use LIO_NOWAIT without specifying a sigevent.  In this
case, lj->lioj_signal is left uninitialized, but several code paths
examine liov_signal.sigev_notify to figure out which notification to
post.  Unconditionally initialize that field to SIGEV_NONE.

Add a dumb test case which triggers the bug.

Reported by:	KMSAN+syzkaller
Reviewed by:	asomers
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 2e5f615295)
2021-07-29 20:32:58 -04:00
Alan Somers
c7fe00ae40 fusefs: correctly set lock owner during FUSE_SETLK
During FUSE_SETLK, the owner field should uniquely identify the calling
process.  The fusefs module now sets it to the process's pid.
Previously, it expected the calling process to set it directly, which
was wrong.

libfuse also apparently expects the owner field to be set during
FUSE_GETLK, though I'm not sure why.

PR:		256005
Reported by:	Agata <chogata@moosefs.pro>
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D30622

(cherry picked from commit 18b19f8c6e)
2021-07-27 11:44:28 -06:00
Kristof Provost
4aa52f90f7 pf tests: ensure syncookie does not create state
Test that with syncookies enabled pf does not create state for
connections before the remote peer has replied to the SYN|ACK message.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31142

(cherry picked from commit 27ab791a55)
2021-07-27 09:44:06 +02:00
Kristof Provost
1156a429eb pf tests: Forwarding syncookie test
Test syncookies on a forwarding host. That is, in a setup where the
machine (or vnet) running pf is not the same as the machine (or vnet)
running the server it's protecting.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D31141

(cherry picked from commit 3be9301a7e)
2021-07-27 09:43:58 +02:00
Ed Maste
ae2e05423d Skip netgraph tests when WITHOUT_NETGRAPH is set
PR:		256986
Reported by:	John Marshall
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c9144ec14d)
2021-07-12 20:27:19 -04:00
Kristof Provost
1f4a640396 netpfil tests: Basic dummynet pipe test
Test dummynet pipes (i.e. bandwidth limitation) with ipfw. This is put
in the common tests because we hope to add dummynet support to pf in the
near future.

MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30380

(cherry picked from commit ea3eca5cb6)
2021-07-09 10:09:34 +02:00
Kristof Provost
36c08263b7 pf tests: Stress state retrieval
Create and retrieve 20.000 states. There have been issues with nvlists
causing very slow state retrieval. We don't impose a specific limit on
the time required to retrieve the states, but do log it. In excessive
cases the Kyua timeout will fail this test.

Reviewed by:	donner
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D30943

(cherry picked from commit d8d43b2de1)
2021-07-09 10:07:10 +02:00
Kristof Provost
f6d448caf6 pf tests: ftp-proxy test
Basic test case for ftp-proxy

PR:		256917
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit dd82fd3543)
2021-07-08 08:47:09 +02:00
Lutz Donnerhacke
dc42a0503b tests/libalias: Bugfix in used variables
Fix two copy and waste errors (referencing the wrong variable).

(cherry picked from commit b3dc6f137b)
2021-07-05 07:58:02 +02:00
Alan Somers
27d5544166 fusefs: ensure that FUSE ops' headers' unique values are actually unique
Every FUSE operation has a unique value in its header.  As the name
implies, these values are supposed to be unique among all outstanding
operations.  And since FUSE_INTERRUPT is asynchronous and racy, it is
desirable that the unique values be unique among all operations that are
"close in time".

Ensure that they are actually unique by incrementing them whenever we
reuse a fuse_dispatcher object, for example during fsync, write, and
listextattr.

PR:		244686
Reviewed by:	pfg
Differential Revision: https://reviews.freebsd.org/D30810

(cherry picked from commit 5403f2c163)
2021-07-03 18:05:13 -06:00
Alan Somers
fd9bab551b fusefs: also debug INIT operations in the test suite
Reviewed by:	pfg

(cherry picked from commit 77b040c993)
2021-07-03 18:03:54 -06:00
Alan Somers
7b096a997f fusefs: support EVFILT_WRITE on /dev/fuse
/dev/fuse is always ready for writing, so it's kind of dumb to poll it.
But some applications do it anyway.  Better to return ready than EINVAL.

Reviewed by:	emaste, pfg
Differential Revision: https://reviews.freebsd.org/D30784

(cherry picked from commit 7b8622fa22)

Simplify fuse_device_filt_write

It always returns 1, so why bother having a variable.

Pull Request:	https://github.com/freebsd/freebsd-src/pull/478

(cherry picked from commit 9b876fbd50)
2021-07-03 17:57:51 -06:00