aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Halden <marius.halden@modirum.com>2021-10-31 20:22:10 +0000
committerKristof Provost <kp@FreeBSD.org>2021-11-01 16:08:23 +0000
commit847b0d07c43c1190f0015c4c93a9e8fd953e3ab5 (patch)
tree4424df867afb18a65735553a0640fb4df10b02ce
parent1019354b54161c140d10a8203ff1e849c09c8010 (diff)
downloadsrc-847b0d07c43c1190f0015c4c93a9e8fd953e3ab5.tar.gz
src-847b0d07c43c1190f0015c4c93a9e8fd953e3ab5.zip
carp tests: negative demotion
PR: 259528 Reviewed by: donner MFC after: 3 weeks Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D32760
-rwxr-xr-xtests/sys/netinet/carp.sh67
1 files changed, 59 insertions, 8 deletions
diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh
index 30ae79c93c8d..267e70ebf0dc 100755
--- a/tests/sys/netinet/carp.sh
+++ b/tests/sys/netinet/carp.sh
@@ -48,6 +48,15 @@ wait_for_carp()
done
}
+carp_init()
+{
+ if ! kldstat -q -m carp; then
+ atf_skip "This test requires carp"
+ fi
+
+ vnet_init
+}
+
atf_test_case "basic_v4" "cleanup"
basic_v4_head()
{
@@ -57,11 +66,8 @@ basic_v4_head()
basic_v4_body()
{
- if ! kldstat -q -m carp; then
- atf_skip "This test requires carp"
- fi
+ carp_init
- vnet_init
bridge=$(vnet_mkbridge)
epair_one=$(vnet_mkepair)
epair_two=$(vnet_mkepair)
@@ -104,11 +110,8 @@ basic_v6_head()
basic_v6_body()
{
- if ! kldstat -q -m carp; then
- atf_skip "This test requires carp"
- fi
+ carp_init
- vnet_init
bridge=$(vnet_mkbridge)
epair_one=$(vnet_mkepair)
epair_two=$(vnet_mkepair)
@@ -145,8 +148,56 @@ basic_v6_cleanup()
vnet_cleanup
}
+atf_test_case "negative_demotion" "cleanup"
+negative_demotion_head()
+{
+ atf_set descr 'Test PR #259528'
+ atf_set require.user root
+}
+
+negative_demotion_body()
+{
+ carp_init
+
+ epair=$(vnet_mkepair)
+
+ vnet_mkjail one ${epair}a
+ jexec one sysctl net.inet.carp.preempt=1
+ jexec one ifconfig ${epair}a 192.0.2.1/24 up
+ jexec one ifconfig ${epair}a add vhid 1 192.0.2.254/24 \
+ advskew 0 pass foobar
+
+ vnet_mkjail two ${epair}b
+ jexec two sysctl net.inet.carp.preempt=1
+ jexec two ifconfig ${epair}b 192.0.2.2/24 up
+ jexec two ifconfig ${epair}b add vhid 1 192.0.2.254/24 \
+ advskew 100 pass foobar
+
+ # Allow things to settle
+ wait_for_carp one ${epair}a two ${epair}b
+
+ if is_master one ${epair}a && is_master two ${epair}b
+ then
+ atf_fail "Two masters!"
+ fi
+
+ jexec one sysctl net.inet.carp.demotion=-1
+ sleep 3
+
+ if is_master one ${epair}a && is_master two ${epair}b
+ then
+ atf_fail "Two masters!"
+ fi
+}
+
+negative_demotion_cleanup()
+{
+ vnet_cleanup
+}
+
atf_init_test_cases()
{
atf_add_test_case "basic_v4"
atf_add_test_case "basic_v6"
+ atf_add_test_case "negative_demotion"
}