aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/netinet
diff options
context:
space:
mode:
authorZhenlei Huang <zlei@FreeBSD.org>2026-05-03 11:02:15 +0000
committerZhenlei Huang <zlei@FreeBSD.org>2026-05-03 11:02:15 +0000
commit9137c66c2ea6cc09e3a6f8a042ecdc5a62e0f39e (patch)
treebf25da1f9329a94b30a2be6b1cfce4282767f83e /tests/sys/netinet
parent5a6d9479ae2271a97dd23ceee8ad284770302874 (diff)
Diffstat (limited to 'tests/sys/netinet')
-rwxr-xr-xtests/sys/netinet/carp.sh80
1 files changed, 44 insertions, 36 deletions
diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh
index e0ef2fd97583..7b484a21d8cf 100755
--- a/tests/sys/netinet/carp.sh
+++ b/tests/sys/netinet/carp.sh
@@ -169,58 +169,66 @@ unicast_v4_body()
epair_one=$(vnet_mkepair)
epair_two=$(vnet_mkepair)
- vnet_mkjail carp_uni_v4_one ${epair_one}a ${epair_two}a
- vnet_mkjail carp_uni_v4_two ${epair_one}b
- vnet_mkjail carp_uni_v4_three ${epair_two}b
+ j="carp_uni_v4_"
- jexec carp_uni_v4_one sysctl net.inet.ip.forwarding=1
- jexec carp_uni_v4_one ifconfig ${epair_one}a inet 198.51.100.1/25
- jexec carp_uni_v4_one ifconfig ${epair_two}a inet 198.51.100.129/25
+ # The router
+ vnet_mkjail ${j}one ${epair_one}a ${epair_two}a
+ # The hosts
+ vnet_mkjail ${j}two ${epair_one}b
+ vnet_mkjail ${j}three ${epair_two}b
- jexec carp_uni_v4_two sysctl net.inet.ip.forwarding=1
- jexec carp_uni_v4_two ifconfig ${epair_one}b 198.51.100.2/25 up
- jexec carp_uni_v4_two route add 198.51.100.224 198.51.100.1
- # A peer address x.x.x.224 to catch PR 284872
- jexec carp_uni_v4_two ifconfig ${epair_one}b add vhid 1 \
- peer 198.51.100.224 192.0.2.1/32
+ atf_check -o ignore sysctl -j ${j}one net.inet.ip.forwarding=1
+ atf_check ifconfig -j ${j}one ${epair_one}a inet 198.51.100.1/25
+ atf_check ifconfig -j ${j}one ${epair_two}a inet 198.51.100.129/25
- sleep 0.2
- jexec carp_uni_v4_three sysctl net.inet.ip.forwarding=1
- jexec carp_uni_v4_three ifconfig ${epair_two}b 198.51.100.224/25 up
- jexec carp_uni_v4_three route add 198.51.100.2 198.51.100.129
- jexec carp_uni_v4_three ifconfig ${epair_two}b add vhid 1 \
- peer 198.51.100.2 192.0.2.1/32
+ atf_check ifconfig -j ${j}two ${epair_one}b 198.51.100.2/25 up
+ atf_check -o ignore route -j ${j}two -n add default 198.51.100.1
+ atf_check ifconfig -j ${j}three ${epair_two}b 198.51.100.224/25 up
+ atf_check -o ignore route -j ${j}three -n add default 198.51.100.129
+
+ sleep 0.1
# Sanity check
- atf_check -s exit:0 -o ignore jexec carp_uni_v4_two \
+ atf_check -o ignore jexec ${j}one \
+ ping -c 1 198.51.100.2
+ atf_check -o ignore jexec ${j}one \
+ ping -c 1 198.51.100.224
+ atf_check -o ignore jexec ${j}two \
ping -c 1 198.51.100.224
- wait_for_carp carp_uni_v4_two ${epair_one}b \
- carp_uni_v4_three ${epair_two}b
+ # A peer address x.x.x.224 to catch PR 284872
+ atf_check ifconfig -j ${j}two ${epair_one}b add vhid 1 \
+ peer 198.51.100.224 192.0.2.1/32
+ sleep 0.2
+ atf_check ifconfig -j ${j}three ${epair_two}b add vhid 1 \
+ peer 198.51.100.2 192.0.2.1/32
- # Setup RIPv2 route daemon
- jexec carp_uni_v4_two routed -s -Pripv2
- jexec carp_uni_v4_three routed -s -Pripv2
- jexec carp_uni_v4_one routed -Pripv2
+ wait_for_carp ${j}two ${epair_one}b \
+ ${j}three ${epair_two}b
- # XXX Wait for route propagation
- sleep 3
+ if is_master ${j}two ${epair_one}b ; then
+ atf_check -o ignore \
+ route -j ${j}one -n add 192.0.2.1 198.51.100.2
+ fi
- atf_check -s exit:0 -o ignore jexec carp_uni_v4_one \
- ping -c 3 192.0.2.1
+ if is_master ${j}three ${epair_two}b ; then
+ atf_check -o ignore \
+ route -j ${j}one -n add 192.0.2.1 198.51.100.224
+ fi
+
+ # Not necessarily required, but just in case
+ atf_check -o ignore jexec ${j}one \
+ ping -c 1 192.0.2.1
# Check that we remain in unicast when tweaking settings
- atf_check -s exit:0 -o ignore \
- jexec carp_uni_v4_two ifconfig ${epair_one}b vhid 1 advskew 2
- atf_check -s exit:0 -o match:"peer 198.51.100.224" \
- jexec carp_uni_v4_two ifconfig ${epair_one}b
+ atf_check -o ignore \
+ ifconfig -j ${j}two ${epair_one}b vhid 1 advskew 2
+ atf_check -o match:"peer 198.51.100.224" \
+ ifconfig -j ${j}two ${epair_one}b
}
unicast_v4_cleanup()
{
- jexec carp_uni_v4_one killall routed
- jexec carp_uni_v4_two killall routed
- jexec carp_uni_v4_three killall routed
vnet_cleanup
}