git: 4a178afb4aa9 - main - tests/netinet: add test for IPv6 NS and CARP

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 25 Jan 2022 05:03:26 UTC
The branch main has been updated by glebius:

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

commit 4a178afb4aa9876094c19faf6d3bf065a5ebe163
Author:     Thomas Steen Rasmussen <thomas@gibfest.dk>
AuthorDate: 2022-01-25 05:02:47 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2022-01-25 05:02:47 +0000

    tests/netinet: add test for IPv6 NS and CARP
    
    PR:                     193280
    Reviewed by:            melifaro
    Differential revision:  https://reviews.freebsd.org/D33859
---
 tests/sys/netinet/carp.sh | 64 +++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh
index 267e70ebf0dc..95cb7847ae28 100755
--- a/tests/sys/netinet/carp.sh
+++ b/tests/sys/netinet/carp.sh
@@ -195,9 +195,73 @@ negative_demotion_cleanup()
 	vnet_cleanup
 }
 
+
+
+atf_test_case "nd6_ns_source_mac" "cleanup"
+nd6_ns_source_mac_head()
+{
+        atf_set descr 'CARP ndp neighbor solicitation MAC source test (IPv6)'
+        atf_set require.user root
+}
+
+nd6_ns_source_mac_body()
+{
+        carp_init
+
+        bridge=$(vnet_mkbridge)
+        epair_one=$(vnet_mkepair)
+        epair_two=$(vnet_mkepair)
+
+        vnet_mkjail carp_ndp_v6_bridge ${bridge} ${epair_one}a ${epair_two}a
+        vnet_mkjail carp_ndp_v6_master ${epair_one}b
+        vnet_mkjail carp_ndp_v6_slave ${epair_two}b
+
+        jexec carp_ndp_v6_bridge ifconfig ${bridge} inet6 2001:db8::0:4/64 up \
+            no_dad
+        jexec carp_ndp_v6_bridge ifconfig ${bridge} addm ${epair_one}a \
+            addm ${epair_two}a
+        jexec carp_ndp_v6_bridge ifconfig ${epair_one}a up
+        jexec carp_ndp_v6_bridge ifconfig ${epair_two}a up
+
+        jexec carp_ndp_v6_master ifconfig ${epair_one}b inet6 \
+            2001:db8::1:2/64 up no_dad
+        jexec carp_ndp_v6_master ifconfig ${epair_one}b inet6 add vhid 1 \
+            advskew 0 2001:db8::0:1/64
+
+        jexec carp_ndp_v6_slave ifconfig ${epair_two}b inet6 \
+	    2001:db8::1:3/64 up no_dad
+        jexec carp_ndp_v6_slave ifconfig ${epair_two}b inet6 add vhid 1 \
+            advskew 100 2001:db8::0:1/64
+
+        wait_for_carp carp_ndp_v6_master ${epair_one}b \
+            carp_ndp_v6_slave ${epair_two}b
+
+	# carp_ndp_v6_master is MASTER
+
+	# trigger a NS from the virtual IP from the BACKUP
+        atf_check -s exit:2 -o ignore jexec carp_ndp_v6_slave \
+            ping -6 -c 3 -S 2001:db8::0:1 2001:db8::0:4
+
+	# trigger a NS from the virtual IP from the MASTER,
+	# this ping should work
+        atf_check -s exit:0 -o ignore jexec carp_ndp_v6_master \
+            ping -6 -c 3 -S 2001:db8::0:1 2001:db8::0:4
+
+        # ndp entry should be for the virtual mac
+        atf_check -o match:'2001:db8::1 +00:00:5e:00:01:01' \
+	    jexec carp_ndp_v6_bridge ndp -an
+}
+
+nd6_ns_source_mac_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"
+	atf_add_test_case "nd6_ns_source_mac"
 }