diff options
author | Marius Halden <marius.halden@modirum.com> | 2021-10-31 20:22:10 +0000 |
---|---|---|
committer | Kristof Provost <kp@FreeBSD.org> | 2021-11-22 01:58:10 +0000 |
commit | d42231181626b2fe0f75514c9b5753083cdf362b (patch) | |
tree | 5993a0f4b33204e6f2717222ae40fa4cb4868d6f | |
parent | 64bb05e04fc3ec16541b6c1fb2074c4df207f173 (diff) | |
download | src-d42231181626b2fe0f75514c9b5753083cdf362b.tar.gz src-d42231181626b2fe0f75514c9b5753083cdf362b.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
(cherry picked from commit 847b0d07c43c1190f0015c4c93a9e8fd953e3ab5)
-rwxr-xr-x | tests/sys/netinet/carp.sh | 67 |
1 files changed, 59 insertions, 8 deletions
diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh index 4c7dbaa022a8..76fc483cd4a4 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" } |