diff --git a/tests/sys/netinet/carp.py b/tests/sys/netinet/carp.py --- a/tests/sys/netinet/carp.py +++ b/tests/sys/netinet/carp.py @@ -51,3 +51,17 @@ carp_pkts = sc.sniff(iface=if1.name, stop_filter=filter_f, timeout=5) self.check_carp_src_mac(carp_pkts) + + def test_source_mac_vrrp(self): + "Test VRRP packets source address" + + if1 = self.vnet.iface_alias_map["if1"] + + ToolsHelper.print_output( + "ifconfig {} add vhid 1 carpver 3 192.0.2.203/24".format(if1.name) + ) + + carp_pkts = sc.sniff(iface=if1.name, stop_filter=filter_f, timeout=5) + + self.check_carp_src_mac(carp_pkts) + diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh --- a/tests/sys/netinet/carp.sh +++ b/tests/sys/netinet/carp.sh @@ -31,7 +31,7 @@ jail=$1 itf=$2 - jexec ${jail} ifconfig ${itf} | grep carp | grep MASTER + jexec ${jail} ifconfig ${itf} | grep -E '(carp|vrrp)' | grep MASTER } wait_for_carp() @@ -105,6 +105,51 @@ vnet_cleanup } +atf_test_case "vrrp_v4" "cleanup" +vrrp_v4_head() +{ + atf_set descr 'Basic VRRP test (IPv4)' + atf_set require.user root +} + +vrrp_v4_body() +{ + carp_init + + j=vrrp_basic_v4 + + bridge=$(vnet_mkbridge) + epair_one=$(vnet_mkepair) + epair_two=$(vnet_mkepair) + + vnet_mkjail ${j}_one ${bridge} ${epair_one}a ${epair_two}a + vnet_mkjail ${j}_two ${epair_one}b + vnet_mkjail ${j}_three ${epair_two}b + + jexec ${j}_one ifconfig ${bridge} 192.0.2.4/29 up + jexec ${j}_one ifconfig ${bridge} addm ${epair_one}a \ + addm ${epair_two}a + jexec ${j}_one ifconfig ${epair_one}a up + jexec ${j}_one ifconfig ${epair_two}a up + + jexec ${j}_two ifconfig ${epair_one}b 192.0.2.202/29 up + jexec ${j}_two ifconfig ${epair_one}b add vhid 1 carpver 3 192.0.2.1/29 + + jexec ${j}_three ifconfig ${epair_two}b 192.0.2.203/29 up + jexec ${j}_three ifconfig ${epair_two}b add vhid 1 carpver 3 \ + 192.0.2.1/29 + + wait_for_carp ${j}_two ${epair_one}b \ + ${j}_three ${epair_two}b + + atf_check -s exit:0 -o ignore jexec ${j}_one \ + ping -c 3 192.0.2.1 +} + +vrrp_v4_cleanup() +{ + vnet_cleanup +} atf_test_case "unicast_v4" "cleanup" unicast_v4_head() @@ -210,6 +255,55 @@ vnet_cleanup } +atf_test_case "vrrp_v6" "cleanup" +vrrp_v6_head() +{ + atf_set descr 'Basic VRRP test (IPv6)' + atf_set require.user root +} + +vrrp_v6_body() +{ + carp_init + + j=carp_basic_v6 + + bridge=$(vnet_mkbridge) + epair_one=$(vnet_mkepair) + epair_two=$(vnet_mkepair) + + vnet_mkjail ${j}_one ${bridge} ${epair_one}a ${epair_two}a + vnet_mkjail ${j}_two ${epair_one}b + vnet_mkjail ${j}_three ${epair_two}b + + jexec ${j}_one ifconfig ${bridge} inet6 2001:db8::0:4/64 up \ + no_dad + jexec ${j}_one ifconfig ${bridge} addm ${epair_one}a \ + addm ${epair_two}a + jexec ${j}_one ifconfig ${epair_one}a up + jexec ${j}_one ifconfig ${epair_two}a up + + jexec ${j}_two ifconfig ${epair_one}b inet6 \ + 2001:db8::1:2/64 up no_dad + jexec ${j}_two ifconfig ${epair_one}b inet6 add vhid 1 carpver 3 \ + 2001:db8::0:1/64 + + jexec ${j}_three ifconfig ${epair_two}b inet6 2001:db8::1:3/64 up no_dad + jexec ${j}_three ifconfig ${epair_two}b inet6 add vhid 1 carpver 3 \ + 2001:db8::0:1/64 + + wait_for_carp ${j}_two ${epair_one}b \ + ${j}_three ${epair_two}b + + atf_check -s exit:0 -o ignore jexec ${j}_one \ + ping -6 -c 3 2001:db8::0:1 +} + +vrrp_v6_cleanup() +{ + vnet_cleanup +} + atf_test_case "unicast_v6" "cleanup" unicast_v6_head() { @@ -469,8 +563,10 @@ atf_init_test_cases() { atf_add_test_case "basic_v4" + atf_add_test_case "vrrp_v4" atf_add_test_case "unicast_v4" atf_add_test_case "basic_v6" + atf_add_test_case "vrrp_v6" atf_add_test_case "unicast_v6" atf_add_test_case "unicast_ll_v6" atf_add_test_case "negative_demotion"