Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Nov 2021 05:16:01 GMT
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: b6237b80891f - stable/13 - carp tests: negative demotion
Message-ID:  <202111220516.1AM5G1LM059381@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=b6237b80891f1a6e9808f630a4626eab6ea203bc

commit b6237b80891f1a6e9808f630a4626eab6ea203bc
Author:     Marius Halden <marius.halden@modirum.com>
AuthorDate: 2021-10-31 20:22:10 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2021-11-22 01:55:07 +0000

    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)
---
 tests/sys/netinet/carp.sh | 67 +++++++++++++++++++++++++++++++++++++++++------
 1 file 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"
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202111220516.1AM5G1LM059381>