tests/net/if_clone_test: Add a test for races between if_detach() and if_vmove_reclaim()

Ideally we shall have tests for all possible races. It is races between
if_detach(), if_vmove_loan(), if_vmove_reclaim() and vnet_if_return().
Well that requires too many tests and it appears to be less valuable to
have them all. So focus on potential in future regressions related to
recent fixes [1] and [2] only.

[1] ee9456ce37 ifnet: Fix races in if_vmove_reclaim()
[2] ba7f47d47d ifnet: if_detach(): Fix races with vmove operations

MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D56606
This commit is contained in:
Zhenlei Huang
2026-04-28 03:17:21 +08:00
parent 80c73c89dc
commit f4be16983d
+29
View File
@@ -96,6 +96,34 @@ epair_destroy_race_cleanup()
cleanup_ifaces
}
atf_test_case epair_destroy_race2 cleanup
epair_destroy_race2_head()
{
atf_set "descr" "Race if_detach() and if_vmove_reclaim()"
atf_set "require.user" "root"
}
epair_destroy_race2_body()
{
jid=$(jail -ic vnet host.hostname="epair_destroy2" persist path=/)
for i in `seq 1 10`
do
epair_a=$(ifconfig epair create)
epair_b=${epair_a%a}b
ifconfig $epair_b vnet $jid
ifconfig $epair_a destroy & pid1=$!
ifconfig $epair_b -vnet $jid & pid2=$!
wait $pid1
wait $pid2
done
jail -R $jid
true
}
epair_destroy_race2_cleanup()
{
}
atf_test_case epair_ipv6_up_stress cleanup
epair_ipv6_up_stress_head()
{
@@ -432,6 +460,7 @@ atf_init_test_cases()
atf_add_test_case epair_stress
atf_add_test_case epair_up_stress
atf_add_test_case epair_destroy_race
atf_add_test_case epair_destroy_race2
atf_add_test_case faith_ipv6_up_stress
atf_add_test_case faith_stress
atf_add_test_case faith_up_stress