freebsd-dev/tests/sys
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
..
acl acl tests: Serialize 2023-03-30 19:35:59 -04:00
aio aio tests: Use unique names for zvols 2023-03-30 19:35:59 -04:00
audit tests/sys/audit: Remove MIPS-specific sysarch(2) test. 2023-03-29 15:06:03 -07:00
auditpipe Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
capsicum Fix MK_TESTS build with MK_ASAN/MK_UBSAN 2021-08-02 14:33:24 +01:00
cddl zfsd: add support for hotplugging spares 2023-04-06 11:58:55 -06:00
common pf tests: properly destroy renamed interfaces 2023-01-16 07:23:07 +01:00
devrandom Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
fifo Avoid hard-coding pipe buffer sizes in the pipe and fifo kqueue tests. 2020-05-20 17:48:18 +00:00
file path_test: Add a test case for openat(O_EMPTY_PATH) in capability mode 2023-03-22 09:19:27 -04:00
fs makefs: add missing break for 'g' case in tarfs test 2023-03-23 09:10:31 -04:00
geom Skip sys.geom.class.multipath.failloop.failloop if dtrace fails to run 2022-03-08 18:12:40 +08:00
kern ktls_test: specify OpenSSL 1.1 API 2023-05-11 10:30:51 -04:00
kqueue kqueue tests: Simplify the test runner 2022-05-24 20:17:41 -04:00
mac Resolve conflict between the fusefs(5) and mac_bsdextended(4) tests 2020-05-02 20:14:59 +00:00
mqueue Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
net vlan: fix setting flags on a QinQ interface 2023-05-12 11:12:51 +02:00
netgraph netgraph tests: Serialize 2023-03-18 16:57:11 -04:00
netinet netinet tests: test carp source MAC address 2023-04-07 17:56:45 +02:00
netinet6 testing: improve python vnet wrapper. 2022-12-29 19:59:11 +00:00
netipsec netipsec tests: Serialize 2023-03-20 12:21:17 -04:00
netlink netlink: temporary skip snl(3) capped test. 2023-05-09 14:59:41 +00:00
netmap netmap: fix copyin/copyout of nmreq options list 2023-03-21 23:23:18 +00:00
netpfil pf tests: add tests for the new scrub syntax 2023-04-14 09:04:06 +02:00
opencrypto test/sys/opencrypto: Fix NIST KAT parser iterator 2022-10-06 16:42:31 +02:00
pjdfstest Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
posixshm posixshm tests: Correct page size index checks 2023-03-03 11:16:51 -05:00
ses ses: cleanup ses tests 2023-03-27 14:06:51 -06:00
sys rb_tree: test rank balance 2022-09-07 21:40:05 -05:00
vfs capsicum: Verify that openat("/", "..") fails with ENOTCAPABLE 2023-04-25 09:54:47 -04:00
vm shared_shadow_inval_test: fix copy-pasto in error message 2022-08-24 13:03:11 -05:00
vmm vmm: Add credential to cdev object 2021-08-18 13:41:33 -04:00
Makefile netlink: connect netlink tests to the build 2022-12-16 12:02:50 +00:00
Makefile.depend
Makefile.inc Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00