Commit Graph

1689 Commits

Author SHA1 Message Date
Mark Johnston
da8c3d2149 tests: Fix format strings
Reported by:	Jenkins
Fixes:		844942888f ("tests: Add a simple regression test for ptrace(PT_SC_REMOTE)")
2023-05-26 17:38:06 -04:00
Mark Johnston
844942888f tests: Add a simple regression test for ptrace(PT_SC_REMOTE)
MFC after:	1 week
2023-05-26 15:38:08 -04:00
Alexander V. Chernikov
7eee0eaf16 netlink: automatically generate broadcast for IPv4 ifa if not set.
MFC after:	2 weeks
2023-05-20 10:42:08 +00:00
Kristof Provost
6408d025cf carp test: improve jail names for unicast_ll_v6 test
Rename the jails used in the unicast_ll_v6 test, to ensure the jail
names are unique to this test.
That is one of the requirements for running these tests in parallel.
2023-05-18 22:12:08 +02:00
Kristof Provost
0d574d8ba8 pfsync tests: check for the correct IP address
When checking if the state synced over we should look for
198.51.100.254, not 198.51.100.2. The test worked because the incorrect
address is a substring of the correct one, but we should fix it anyway.

Reported by:	Naman Sood <naman@freebsdfoundation.org>
MFC after:	1 week
2023-05-18 22:12:07 +02:00
Kristof Provost
33ff01cebc carp tests: test unicast carp via link-local addresses
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-18 17:47:04 +02:00
Alexander V. Chernikov
10b94e4064 netlink: add support for adding/deleting interface addresses
Differential Revision: https://reviews.freebsd.org/D40103
MFC after:	2 weeks
2023-05-16 19:39:13 +00:00
Alexander V. Chernikov
584ad4126c testing: improve vnet support in pytest
* Allow vnet object to be directly referenced
 (self.vnet1 vs self.vnet_map["vnet1"])
* Allow iface object to be directly reference
 (vnet.bridge vs vnet.iface_alias_map["bridge"])
* Allow arbitrary interface alias names insted of ifX
* Add wait_objects_any() method for waiting object from
 multiple vnets
* Add wait() method for indefinite sleep on vnet handlers

MFC after:	2 weeks
2023-05-16 15:00:45 +00:00
Jessica Clarke
816129210a tests: Don't recurse into sys/compat32
Stubbing out the whole file means it has no targets, so recursive makes
fail with "don't know how to make X". We could fix that, but because the
level above is adding it to TESTS_SUBDIRS it'll generate an include line
for the subdirectory in its Kyuafile, which won't work (the problem that
was previously seen on non-aarch64 in CI). Thus we really need to not
even add it to TESTS_SUBDIRS in the first place.

Reported by:	Dan Mack <mack@macktronics.com>
Fixes:		28f66935d4 ("tests: Disable sys/compat32 and sys/compat32/aarch64 tests")
2023-05-16 02:06:34 +01:00
Jessica Clarke
28f66935d4 tests: Disable sys/compat32 and sys/compat32/aarch64 tests
The former has build system issues, with missing Kyuafiles, presumably
due to not using TESTS_SUBDIRS and bsd.test.mk (and possibly some issues
on top of that around TESTSDIR and related variables). The latter has
issues with GCC and cut-down LLVM builds.

Requested by:	kevans
Fixes:		ccb59683b9 ("arm64: add tests for swp/swpb emulation")
2023-05-15 23:16:40 +01:00
Kyle Evans
ccb59683b9 arm64: add tests for swp/swpb emulation
One test is suitable to be hooked up to the build, so I've done this
here.  The other test lives in tools/regression because failure is a
bit more subjective -- generally, one runs it for some unbounded amount
of time and observe if it eventually exits because two threads acquired
the same mutex.

Reviewed by:	imp, mmel
Sponsored by:   Stormshield
Sponsored by:   Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D39668
2023-05-15 10:42:16 -05:00
Alexander V. Chernikov
d91f8db5f1 testing: rename IfattrType to IfaAttrType for consistency
All other attribute classes are named as 'type'AttrType and 'type'
 int this case is ifa (interface address).

MFC after:	2 weeks
2023-05-15 11:47:07 +00:00
Alexander V. Chernikov
97760572a0 testing: add public method for requiring module presense in pytest
MFC after:	2 weeks
2023-05-15 10:50:55 +00:00
Alexander V. Chernikov
f0ffe1ce0f testing: add support for handling Netlink carp messages
MFC after:	2 weeks
2023-05-15 10:48:45 +00:00
Alexander V. Chernikov
f3065e767d testing: add support for using custom interfaces in pytest framework.
MFC after:	2 weeks
2023-05-15 10:44:20 +00:00
Warner Losh
4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Kristof Provost
92c23f6d9c vlan: fix setting flags on a QinQ interface
Setting vlan flags needlessly takes the exclusive VLAN_XLOCK().

If we have stacked vlan devices (i.e. QinQ) and we set vlan flags (e.g.
IFF_PROMISC) we call rtnl_handle_ifevent() to send a notification about
the interface.
This ends up calling SIOCGIFMEDIA, which requires the VLAN_SLOCK().
Trying to take that one with the VLAN_XLOCK() held deadlocks us.

There's no need for the exclusive lock though, as we're only accessing
parent/trunk information, not modifying it, so a shared lock is
sufficient.

While here also add a test case for this issue.

Backtrace:
	shared lock of (sx) vlan_sx @ /usr/src/sys/net/if_vlan.c:2192
	while exclusively locked from /usr/src/sys/net/if_vlan.c:2307
	panic: excl->share
	cpuid = 29
	time = 1683873033
	KDB: stack backtrace:
	db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe015d4ad4b0
	vpanic() at vpanic+0x152/frame 0xfffffe015d4ad500
	panic() at panic+0x43/frame 0xfffffe015d4ad560
	witness_checkorder() at witness_checkorder+0xcb5/frame 0xfffffe015d4ad720
	_sx_slock_int() at _sx_slock_int+0x67/frame 0xfffffe015d4ad760
	vlan_ioctl() at vlan_ioctl+0xf8/frame 0xfffffe015d4ad7c0
	dump_iface() at dump_iface+0x12f/frame 0xfffffe015d4ad840
	rtnl_handle_ifevent() at rtnl_handle_ifevent+0xab/frame 0xfffffe015d4ad8c0
	if_setflag() at if_setflag+0xf6/frame 0xfffffe015d4ad930
	ifpromisc() at ifpromisc+0x2a/frame 0xfffffe015d4ad960
	vlan_setflags() at vlan_setflags+0x60/frame 0xfffffe015d4ad990
	vlan_ioctl() at vlan_ioctl+0x216/frame 0xfffffe015d4ad9f0
	if_setflag() at if_setflag+0xe4/frame 0xfffffe015d4ada60
	ifpromisc() at ifpromisc+0x2a/frame 0xfffffe015d4ada90
	bridge_ioctl_add() at bridge_ioctl_add+0x499/frame 0xfffffe015d4adb10
	bridge_ioctl() at bridge_ioctl+0x328/frame 0xfffffe015d4adbc0
	ifioctl() at ifioctl+0x972/frame 0xfffffe015d4adcc0
	kern_ioctl() at kern_ioctl+0x1fe/frame 0xfffffe015d4add30
	sys_ioctl() at sys_ioctl+0x154/frame 0xfffffe015d4ade00
	amd64_syscall() at amd64_syscall+0x140/frame 0xfffffe015d4adf30
	fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe015d4adf30
	--- syscall (54, FreeBSD ELF64, ioctl), rip = 0x22b0f0ef8d8a, rsp = 0x22b0ec63f2c8, rbp = 0x22b0ec63f380 ---
	KDB: enter: panic
	[ thread pid 5715 tid 101132 ]

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-05-12 11:12:51 +02:00
Pierre Pronchery
74192f9b2d ktls_test: specify OpenSSL 1.1 API
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2023-05-11 10:30:51 -04:00
Alexander V. Chernikov
04dacd5691 netlink: temporary skip snl(3) capped test. 2023-05-09 14:59:41 +00:00
Kristof Provost
f76df4718d if_ovpn tests: fix route_to test case
* Move the .254 address to the tunnel device so we reply through the
  tunnel.
* Remove the network route to 'break' routing, which we then 'fix' with
  pf's route-to, which is the functionality we wanted to test in the
  first place.

Reported by:	markj
Sponsored by:   Rubicon Communications, LLC ("Netgate")
2023-05-08 17:44:47 +02:00
Mark Johnston
2d252934da capsicum: Verify that openat("/", "..") fails with ENOTCAPABLE
Add a regression test for a718431c30 ("lookup(): ensure that
openat("/", "..", O_RESOLVE_BENEATH) fails").

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-04-25 09:54:47 -04:00
Mark Johnston
8a271827e7 tests: Add ATF_REQUIRE_SYSCTL_BOOL
Modify a capability mode test to use it for kern.trap_enotcap, to avoid
false positives.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2023-04-25 09:54:23 -04:00
Alexander V. Chernikov
089104e0e0 netlink: add netlink interfaces to if_clone
This change adds netlink create/modify/dump interfaces to the `if_clone.c`.
The previous attempt with storing the logic inside `netlink/route/iface_drivers.c`
 did not quite work, as, for example, dumping interface-specific state
 (like vlan id or vlan parent) required some peeking into the private interfaces.

The new interfaces are added in a compatible way - callers don't have to do anything
unless they are extended with Netlink.

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D39032
MFC after:	1 month
2023-04-25 12:34:46 +00:00
Alexander V. Chernikov
04a036601e tests: fix netlink type parsing.
Netlink attribute type field is 2 bytes, not one.

MFC after:	2 weeks
2023-04-18 14:09:47 +00:00
Alexander V. Chernikov
3e5d0784b9 Testing: add framework for the kernel unit tests.
This changes intends to reduce the bar to the kernel unit-testing by
 introducing a new kernel-testing framework ("ktest") based on Netlink,
 loadable test modules and python test suite integration.

This framework provides the following features:
* Integration to the FreeBSD test suite
* Automatic test discovery
* Automatic test module loading
* Minimal boiler-plate code in both kernel and userland
* Passing any metadata to the test
* Convenient environment pre-setup using python testing framework
* Streaming messages from the kernel to the userland
* Running tests in the dedicated taskqueues
* Skipping or parametrizing tests

Differential Revision: https://reviews.freebsd.org/D39385
MFC after:	2 weeks
2023-04-14 15:47:55 +00:00
Kristof Provost
f97802a35e bridge tests: test cross-vlan bridging
Ensure that the bridge takes VLAN IDs into account when learning
addresses.

PR:		270559
Differential Revision:	https://reviews.freebsd.org/D39379
2023-04-14 13:17:02 +02:00
Kajetan Staszkiewicz
b800be9780 pf tests: add tests for the new scrub syntax
Add functions for testing new scrub option syntax and for packet
fragmentation and route tables, because this was modified too. When
testing of both the new and the compatible syntax is necessary, move
original tests into _compat.sh file.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38129
2023-04-14 09:04:06 +02:00
Kristof Provost
d116b8430b epair tests: test PCP tagged packets
PR:		270736
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39483
2023-04-10 15:55:53 +02:00
Kristof Provost
5e2e3615d9 netinet tests: test carp source MAC address
Ensure that (multicast) CARP packets are sent with the expected source
MAC address.

Reviewed by:	melifaro
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39454
2023-04-07 17:56:45 +02:00
Alan Somers
f698c1e99b zfsd: add support for hotplugging spares
If you remove an unused spare and then reinsert it, zfsd will now online
it in all pools.

Do not MFC without 2a58b312b6 (but it's ok to MFC that one without this
one).

Submitted by:	Ameer Hamza <ahamza@ixsystems.com> (zfsd), Me (tests)
MFC after:	2 weeks
MFC with:	2a58b312b6
Sponsored by:	iX Systems, Axcient
Pull Request:	https://github.com/freebsd/freebsd-src/pull/697
2023-04-06 11:58:55 -06:00
Alexander V. Chernikov
388420e613 tests: fix utils import in netlink tests
MFC after:	2 weeks
2023-04-02 10:17:37 +00:00
Alexander V. Chernikov
d9af4219d6 tests: refactor atf_python a bit
* Move more logic from conftest.py to the actual atf_pytest handler
* Move nodeid_to_method_name() to the utils.py so it can be shared

MFC after:	2 weeks
2023-04-01 19:44:37 +00:00
Alexander V. Chernikov
fc2538cb7b tests: add support for parsing generic netlink families.
MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D39370
2023-04-01 19:33:47 +00:00
Alexander V. Chernikov
fee65b7e21 tests: split netlink.py into multiple files to impove maintainability.
This diff does not contain any functional changes.
Its sole purpose is splitting netlink.py into smaller chunks.
The new code simplifies the upcoming generic netlink support
introduction.

MFC after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D39365
2023-04-01 19:31:38 +00:00
Mark Johnston
b60600ceeb pf tests: Serialize
These tests reuse jail names and cannot run in parallel.  Until this is
fixed - which is desirable since these takes take a while to run - tell
kyua to serialize them.

MFC after:	1 week
2023-03-30 19:35:59 -04:00
Mark Johnston
196f390121 if_ovpn tests: Serialize
These tests reuse jail names and so cannot run in parallel.

MFC after:	1 week
2023-03-30 19:35:59 -04:00
Mark Johnston
34b696e412 acl tests: Serialize
Some of these tests import a ZFS pool with a hard-coded name, so they
cannot run in parallel.

MFC after:	1 week
2023-03-30 19:35:59 -04:00
Mark Johnston
9cefc0fb13 aio tests: Use unique names for zvols
Otherwise tests which create zvols cannot be run in parallel.

MFC after:	1 week
2023-03-30 19:35:59 -04:00
Mark Johnston
cdb192434c netpfil tests: Serialize
These tests reuse jail names and so cannot run in parallel.

MFC after:	1 week
2023-03-30 19:35:59 -04:00
Mark Johnston
889b5662ce fdgrowtable tests: Address a set-but-not-used warning
MFC after:	1 week
2023-03-30 13:55:06 -04:00
Mark Johnston
5ea1e35d7d ktls tests: Populate sockaddr fields before binding
Reported by:	Jenkins
Fixes:		b4b33821fa ("ktls: Fix interlocking between ktls_enable_rx() and listen(2)")
2023-03-30 13:52:04 -04:00
John Baldwin
60d0871dbf tests/sys/audit: Remove MIPS-specific sysarch(2) test.
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39330
2023-03-29 15:06:03 -07:00
Alexander V. Chernikov
badcb3fd57 routing: fix panic when adding an interface route to the p2p interface
without and inet/inet6 addresses attached.

MFC after:      3 days
2023-03-29 20:28:24 +00:00
Alan Somers
b37d1deb04 ses: cleanup ses tests
Address mav's feedback RE eea7c61590

See also: https://reviews.freebsd.org/D31809

Reported by:	mav
MFC after:	2 weeks
MFC with:	eea7c61590
Sponsored by:	Axcient
Reviewed by:	mav
Differential Revision: https://reviews.freebsd.org/D33954
2023-03-27 14:06:51 -06:00
Ed Maste
2af158ae83 makefs: add missing break for 'g' case in tarfs test
Reported by:	Coverity Scan
CID:		1506954
Fixes: 6cb78fa479 ("tarfs: Repeat tests using GNU tar if available.")
Sponsored by:	The FreeBSD Foundation
2023-03-23 09:10:31 -04:00
Mark Johnston
e5e1d9c7b7 path_test: Add a test case for openat(O_EMPTY_PATH) in capability mode
MFC after:	1 week
2023-03-22 09:19:27 -04:00
Vincenzo Maffione
e2a431a0ff netmap: fix copyin/copyout of nmreq options list
The previous code unsuccesfully attempted to report a precise error for
each option in the user list. Moreover, commit 253b2ec199 broke some
ctrl-api-test (see https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260547).

With this patch we bail out as soon as an unrecoverable error is detected and
we properly check for copy boundaries. EOPNOTSUPP no longer immediately
returns an error, so that any other option in the list may be examined
by the caller code and a precise report of the (un)supported options can
be returned to the user.

With this patch, all ctrl-api-test unit tests pass again.

PR:			260547
Submitted by:		giuseppe.lettieri@unipi.it
Reviewed by:		vmaffione
MFC after:		14 days
2023-03-21 23:23:18 +00:00
Mark Johnston
b4b33821fa ktls: Fix interlocking between ktls_enable_rx() and listen(2)
The TCP_TXTLS_ENABLE and TCP_RXTLS_ENABLE socket option handlers check
whether the socket is listening socket and fail if so, but this check is
racy.  Since we have to lock the socket buffer later anyway, defer the
check to that point.

ktls_enable_tx() locks the send buffer's I/O lock, which will fail if
the socket is a listening socket, so no explicit checks are needed.  In
ktls_enable_rx(), which does not acquire the I/O lock (see the review
for some discussion on this), use an explicit SOLISTENING() check after
locking the recv socket buffer.

Otherwise, a concurrent solisten_proto() call can trigger crashes and
memory leaks by wiping out socket buffers as ktls_enable_*() is
modifying them.

Also make sure that a KTLS-enabled socket can't be converted to a
listening socket, and use SOCK_(SEND|RECV)BUF_LOCK macros instead of the
old ones while here.

Add some simple regression tests involving listen(2).

Reported by:	syzkaller
MFC after:	2 weeks
Reviewed by:	gallatin, glebius, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D38504
2023-03-21 16:04:00 -04:00
Kristof Provost
a6719858a4 pf tests: try to trigger locking issues in pfsync_timeout()
PR:		268246
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC (Netgate)
2023-03-20 16:39:14 +01:00
Mark Johnston
cc9158d74d netipsec tests: Serialize
The tunnel mode tests use VNET jails and reuse jail names.  Until this
is addressed, serialize them.

MFC after:	1 week
2023-03-20 12:21:17 -04:00
Kristof Provost
ddbd3a2b7c carp tests: unicast tests (IPv6)
Test the new unicast carp mode for IPv6.

There's a routing hop between the peers, to ensure that the TTL check is
correctly disabled for unicast carp.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D38942
2023-03-20 14:37:09 +01:00
Kristof Provost
92c5dbbb13 carp tests: unicast tests (IPv4)
Test the new unicast carp mode for IPv4.

There's a routing hop between the peers, to ensure that the TTL check is
correctly disabled for unicast carp.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D38941
2023-03-20 14:37:09 +01:00
Kristof Provost
9d48283d60 carp tests: test manually switch between backup and master
There's been at least one issue where we failed to correctly enter
NET_EPOCH that was triggered in this scenario.
Add a test case for it to make it easier to detect issues like this in
the future.

Reviewed by:	zlei
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39115
2023-03-20 10:52:53 +01:00
Mark Johnston
bad8f86843 netgraph tests: Serialize
Some tests share names for netgraph nodes, so they cannot be run in
parallel.

MFC after:	1 week
2023-03-18 16:57:11 -04:00
Alexander V. Chernikov
568a645ba5 netlink: fix capped uncapped ack handling in snl(3).
Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D39144
MFC after:	2 weeks
2023-03-18 11:35:56 +00:00
Mark Johnston
a7ba32e6bc tun tests: Fix cleanup definitions
Without this, vnet jails for the tests don't get torn down.

Fixes:	fe701c39e8 ("if_tun: Add basic connectivity test with nc tun support")
2023-03-16 13:27:24 -04:00
Dag-Erling Smørgrav
ef184e989b tarfs: Fix backtracking during node creation.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39082
2023-03-16 11:31:22 +00:00
Dag-Erling Smørgrav
e81d55b439 tarfs: Support tar files which include file modes with permissions.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39020
2023-03-16 11:31:22 +00:00
Dag-Erling Smørgrav
fd8c98a52f tarfs: Correctly track link count.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D39019
2023-03-16 11:31:22 +00:00
Dag-Erling Smørgrav
6cb78fa479 tarfs: Repeat tests using GNU tar if available.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	ngie, asomers
Differential Revision:	https://reviews.freebsd.org/D39018
2023-03-16 11:31:22 +00:00
Kristof Provost
225e85513f pf tests: test IPv6 fragmentation with link-local addresses
We've observed a panic after pf_refragment6() with link-local addresses,
because pf_refragment6() calls ip6_forward() even for a simple output
case.
That results in us entering ip6_forward() with an mbuf with a NULL
m->m_pkthdr.rcvif, which can cause a NULL deref (but seemingly not for
GUAs.

Test sending fragmented link-local packets to pf.

MFC after:	3 days
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D39063
2023-03-16 10:59:04 +01:00
Alexander V. Chernikov
73ae25c174 netlink: improve snl(3)
Summary:
* add snl_send_message() as a convenient send wrapper
* add signed integer parsers
* add snl_read_reply_code() to simplify operation result checks
* add snl_read_reply_multi() to simplify reading multipart messages
* add snl_create_genl_msg_request()
* add snl_get_genl_family() to simplify family name->id resolution
* add tests for some of the functionality

Reviewed by:	kp
Differential Revision: https://reviews.freebsd.org/D39092
MFC after:	2 weeks
2023-03-15 20:53:20 +00:00
Mark Johnston
683853a924 sendfile tests: Mount filesystems under the test workdir
Otherwise they can't be run in parallel as they share a mount point.

MFC after:	1 week
2023-03-13 10:45:35 -04:00
Alexander V. Chernikov
90bc2120b5 tests: fix python parsing of netlink nested attributes
MFC after:	2 weeks
2023-03-13 10:17:36 +00:00
Alexander V. Chernikov
595d23f777 netlink: add snl(3) default parsers for routes and links.
This change adds the "default" parsers of _all_ route/link attributes
 exported by the kernel.
It removes the need to declare similar parsers in the userland applications,
 simplifying their logic.

Differential Revision: https://reviews.freebsd.org/D38979
MFC after:	2 weeks
2023-03-09 14:46:27 +00:00
Alexander V. Chernikov
c57dfd92c8 tests: add more netlink tests for neighbors/routes
Differential Revision: https://reviews.freebsd.org/D38912
MFC after:	2 weeks
2023-03-07 17:31:26 +00:00
Dag-Erling Smørgrav
b1218349ed tarfs: Set mountedfrom correctly.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	sjg, kib
Differential Revision:	https://reviews.freebsd.org/D38930
2023-03-07 17:20:49 +00:00
Kristof Provost
f427703f16 carp tests: ensure exactly one jail is master
Verify that we only have one master, not two.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-07 10:51:44 +01:00
Kristof Provost
38e2d5db2a netpfil tests: Add functions for testing routing scenarios
Many pf tests use identical setup where one jail is a router and
optionally another jail is a server. Add functions to create such jails
for IPv6 and IPv4 and functions to perform tests on such setup.

Add tests using those functions: scrub actions, routing table, tcp
sequence number modulation.

Reviewed by:	kp
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38126
2023-03-04 14:35:24 +01:00
Mark Johnston
560f9cd5e1 posixshm tests: Correct page size index checks
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
2023-03-03 11:16:51 -05:00
Alexander V. Chernikov
ce9f95bd83 netlink: fix vlan interface creation
MFC after:	2 weeks
2023-03-03 16:02:05 +00:00
Olivier Cochard
e78dc78e51 testing: skip tarfs tests if module is not loadable.
Approved by:	asomers
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D38828
2023-03-01 22:23:07 +01:00
Kristof Provost
2a02d3dad3 pf tests: test pfsync over IPSec
Test that we can transport pfsync (unicast) over IPSec.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-01 16:10:12 +01:00
Kristof Provost
69361b8785 if_ovpn tests: skip the if_ovpn_c test if if_ovpn.ko isn't loaded
Skip the test (rather than loading it) if if_ovpn.ko isn't loaded. Match
the behaviour of other tests.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-03-01 10:07:34 +01:00
Gleb Smirnoff
a170657108 unix/dgram tests: match the kernel behavior
In CURRENT for some time an overflowed unix/dgram socket would
return EAGAIN if it has O_NONBLOCK set.  This proved to be
undesired.  See 71e70c25c0 for details.  Update tests to match
the "new" behavior, which actually is the historical behavior.
2023-02-22 20:44:46 -08:00
Alan Somers
5f51c9c328 fusefs: add some more test cases for bad fuse servers
MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38719
2023-02-22 10:03:58 -07:00
Alan Somers
0c9df4afc2 fusefs: fix a buffer overflow in the tests
The actual overflow occured in the ReadAhead.readahead test.
Surprisingly it has never segfaulted or resulted in any bad behavior.

MFC after:	1 week
Sponsored by:	Axcient
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38718
2023-02-22 10:03:01 -07:00
Dag-Erling Smørgrav
d481dcee72 tarfs: Really prevent descending into a non-directory.
The previous fix was incorrect: we need to verify that the current node, if it exists, is not a directory, but we were checking the parent node instead.  Address this, add more tests, and fix the test cleanup routines.

PR:		269519, 269561
Fixes:		ae6cff8973
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D38645
2023-02-20 21:29:19 +00:00
Alexander V. Chernikov
828d3c6c4c tests: add netlink large dump buffer check
Differential Revision: https://reviews.freebsd.org/D38665
MFC after:	2 weeks
2023-02-20 10:20:54 +00:00
Alexander V. Chernikov
79748cec1f tests: fix netlink test_dump_ifaces_many test.
Consider only loopback interfaces when counting.
Otherwise, if pf is loaded, 'pflog0' gets added to the vnet,
 breaking the test.

MFC after:	2 weeks
2023-02-18 22:28:01 +00:00
Alexander V. Chernikov
ff8da9b2ba netlink: improve attribute decoding in python tests
MFC after:	2 weeks
2023-02-17 18:16:08 +00:00
Alexander V. Chernikov
86fd0bdba5 netlink: fix interface dump.
The current code missed interface addition when reallocating
 temporary buffer.
Tweak the code to perform the reallocation first and add
 interface afterwards unconditionally.

Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
MFC after:	3 days
2023-02-16 13:20:45 +00:00
Dag-Erling Smørgrav
ae6cff8973 tarfs: Don't panic if the parent of a new node is not a directory.
PR:		269519
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D38587
2023-02-15 02:13:11 +00:00
Kyle Evans
e63dcbe7a2 wg: tests: remove an obsolete workaround
PR 254212 was resolved to avoid issues with not having IPv6 addresses
present in the jail, so we can safely drop this workaround now...

Reviewed by:	jhb, markj
Differential Revision:	https://reviews.freebsd.org/D37755
2023-02-12 23:59:46 -06:00
Kyle Evans
96f4ab2663 wg: add a test for the home jail socket feature
This adds a test for a semantic that we added to mirror a feature of
the Linux implementation w/ netns: if a wg interface is moved into a
jail, we still create the socket in the context of the home vnet.  With
this added, one can actually create vnet jails that only have a wg
tunnel to the outside world providing network connectivity without any
epairs in the setup.

Reviewed by:	jhb, markj (both earlier version)
Differential Revision:	https://reviews.freebsd.org/D37755
2023-02-12 23:59:35 -06:00
Dag-Erling Smørgrav
ce6a0c776b tarfs: Fix issues revealed by static analysis and testing.
* tarfs_alloc_mount(): Remove an unnecessary null check (CID 1504505) and an unused variable.

* tarfs_alloc_one(): Verify that the file size is not negative (CID 1504506).  While there, also validate the mode, owner and group.

* tarfs_vget(), tarfs_zio_init(): Explicitly ignore return value from getnewvnode(), which cannot fail (CID 1504508)

* tarfs_lookup_path(): Fix a case where a specially-crafted tarball could trigger a null pointer dereference by first descending into, and then backing out of, a previously unknown directory. (CID 1504515)

* mktar: Construct a tarball that triggers the aforementioned null pointer dereference.

Reported by:	Coverity
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D38463
2023-02-09 17:35:47 +00:00
Alexander V. Chernikov
25c2dd2f2c netlink: return optional metadata with the operation result.
Some operations like interface creation may need to return metadata
 - in this case, interface name - back to the caller if the operation
 is successful.
This change implements attaching an `NLMSGERR_ATTR_COOKIE` nla to the
operation reply message via `nlmsg_report_cookie()`.
Additionally, on successful interface creation, interface index and
 interface name are returned in the `IFLA_NEW_IFINDEX` and `IFLA_IFNAME
 TLVs, encapsulated in the `NLMSGERR_ATTR_COOKIE`.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38283
MFC after:	1 week
2023-02-09 15:30:00 +00:00
Alexander V. Chernikov
6332ef8941 testing: handling non-root users with VNETs in pytest-based tests.
Currently isolation and resource requirements are handled directly
 by the kyua runner, based on the requirements specified by the test.
It works well for simple tests, but may cause discrepancy with tests
 doing complex pre-setups. For example, all tests that perform
 VNET setups require root access to properly function.

This change adds additional handling of the "require_user" property
 within the python testing framework. Specifically, it requests
 root access if the test class signals its root requirements and
 drops privileges to the desired user after performing the pre-setup.

Differential Revision: https://reviews.freebsd.org/D37923
MFC after:	2 weeks
2023-02-09 14:49:27 +00:00
Olivier Cochard
d22c5c42e8 Skip if_wg regression tests if module doesn't exist
Approved by:	jhb
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D38406
2023-02-07 00:06:48 +01:00
Kristof Provost
afa77b6996 pf tests: improve pfsync:basic_defer test
Create state on output only, to ensure we trigger the defer code.

MFC after:	2 weeks
2023-02-03 09:39:21 +01:00
Dag-Erling Smørgrav
69d94f4c76 Add tarfs, a filesystem backed by tarballs.
Sponsored by:	Juniper Networks, Inc.
Sponsored by:	Klara, Inc.
Reviewed by:	pauamma, imp
Differential Revision:	https://reviews.freebsd.org/D37753
2023-02-02 18:19:29 +01:00
Dmitry Chagin
02f7670ed2 sched.h: Fix _S macros for better compatibility with glibc.
In e2650af157 was added "_S" macros for compatibility with glibc, but it's still
incompatible as under glibc the macros whose names end with "_S" operate on the
dynamically allocated CPU set(s) whose size is in bytes, not in bits.

While here remove limiting ifdef to non-kernel case.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D38110
MFC after:		1 week
2023-01-29 15:34:10 +03:00
Alexander V. Chernikov
20ea7f26e4 pytest: delete interfaces from inside the jail.
This change follows the approach used in 80fc25025f, to
 minimise the impact of the delayed interface migration.

MFC after:	2 weeks
2023-01-25 16:34:17 +00:00
Alexander V. Chernikov
864ea9abfb pytest: add an example test fetching test directory and ATF vars.
MFC after:	2 weeks
2023-01-25 13:55:33 +00:00
Kajetan Staszkiewicz
06012728be netpfil tests: improve pfsync_defer.py
Return different exit code depending on which failure was encountered.
The pfsync test expect a very particular failure, not just any.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38123
2023-01-22 04:26:32 +01:00
Kajetan Staszkiewicz
f57218e469 netpfil tests: improve pft_ping.py
Multiple improvements to pft_ping.py:

* Automatically use IPv6 when IPv6 addresses are used, --ip6 is not needed.
* Building of ping requests and parsing of ping replies is done layer by
  layer. This way most arguments are available both for IPv6 and IPv4,
  for ICMP and TCP.
* Use argument groups for improved readability.
* Change ToS and TTL argument name to TC and HL to reflect the modern
  IPv6 nomenclature. The argument still set related IPv4 header fields
  properly.
* Instead of sniffing for the very specific case of duplicated packets,
  allow for sniffing on multiple interfaces.
* Report which sniffer has failed by setting bits of error code.
* Raise meaningful exceptions when irrecoverable errors happen.
* Make IPv4 fragmentation flags configurable.
* Make IPv6 HL / IPv4 TTL configurable.
* Make TCP MSS configurable.
* Make TCP sequence number configurable.
* Make ICMP payload size configurable.
* Add debug output.
* Move command line argument parsing out of network functions.
* Make the code somehow PEP-8 compliant.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38122
2023-01-22 04:26:32 +01:00
Kajetan Staszkiewicz
a39dedeb31 netpfil tests: improve sniffer.py
Multiple improvements to sniffer.py:

* Remove ambiguity of configuring recvif, it must be now explicitly specified.
* Don't catch exceptions around creating the sniffer, let it properly
  fail and display the whole stack trace.
* Count correct packets so that duplicates can be found.

MFC after:	1 week
Sponsored by:	InnoGames GmbH
Differential Revision:	https://reviews.freebsd.org/D38120
2023-01-22 04:26:32 +01:00
Alexander V. Chernikov
0079d177ab netlink: allow creating sockets with SOCK_DGRAM.
Some existing applications setup Netlink socket with
SOCK_DGRAM instead of SOCK_RAW. Update the manpage to clarify
that the default way of creating the socket should be with
SOCK_RAW. Update the code to support both SOCK_RAW and SOCK_DGRAM.

Reviewed By: pauamma
Differential Revision: https://reviews.freebsd.org/D38075
2023-01-21 14:58:19 +00:00
Tom Jones
fe701c39e8 if_tun: Add basic connectivity test with nc tun support
Reviewed by:    kevans
Sponsored by:   Zenarmor
Sponsored by:   OPNsense
Sponsored by:   Klara, Inc.
Differential Revision:  https://reviews.freebsd.org/D37435
2023-01-17 10:05:50 +00:00
Alexander V. Chernikov
228c632ab3 netlink: fix compatibility with older netlink applications.
Some apps try to provide only the non-zero part of the required message
 header instead of the full one. It happens when fetching routes or
 interface addresses, where the first header byte is the family.
This behavior is "illegal" under the "strict" Netlink socket option,
 however there are many applications out there doing things in the
 "old" way.

Support this usecase by copying the provided bytes into the temporary
 zero-filled header and running the parser on this header instead.

Reported by:	Goran Mekić <meka@tilda.center>
2023-01-16 12:21:40 +00:00