Commit Graph

1623 Commits

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