freebsd-src/tests/sys/net
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
..
if_ovpn if_ovpn tests: fix route_to test case 2023-05-08 17:44:47 +02:00
routing routing: fix panic when adding an interface route to the p2p interface 2023-03-29 20:28:24 +00:00
dhclient_pcp.conf net tests: basic test case for bpf(4)'s ability to set vlan pcp 2021-07-26 23:13:31 +02:00
if_bridge_test.sh bridge tests: test cross-vlan bridging 2023-04-14 13:17:02 +02:00
if_clone_test.sh if: avoid interface destroy race 2022-05-06 13:55:08 +02:00
if_epair_test.sh epair tests: test PCP tagged packets 2023-04-10 15:55:53 +02:00
if_epair.c tests/sys/net/epair: don't leak the interface after the test 2022-01-26 21:08:50 -08:00
if_gif.sh net tests: basic if_gif(4) test case 2021-11-08 12:00:00 +01:00
if_lagg_test.sh Skip sys.net.if_lagg_test.status_stress in CI 2021-10-12 05:40:24 +08:00
if_stf.sh net tests: fix if_stf:6to4 2021-11-20 19:29:02 +01:00
if_tun_test.sh tun tests: Fix cleanup definitions 2023-03-16 13:27:24 -04:00
if_vlan.sh vlan: fix setting flags on a QinQ interface 2023-05-12 11:12:51 +02:00
if_wg.sh wg: tests: remove an obsolete workaround 2023-02-12 23:59:46 -06:00
Makefile epair tests: test PCP tagged packets 2023-04-10 15:55:53 +02:00
pcp.py netpfil tests: improve sniffer.py 2023-01-22 04:26:32 +01:00
randsleep.c
stp.py netpfil tests: improve sniffer.py 2023-01-22 04:26:32 +01:00