3 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 # Copyright (c) 2020 Kristof Provost <kp@FreeBSD.org>
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 . $(atf_get_srcdir)/../common/vnet.subr
35 jexec ${jail} ifconfig ${itf} | grep carp | grep MASTER
45 while [ -z "$(is_master ${jail1} ${itf1})" ] &&
46 [ -z "$(is_master ${jail2} ${itf2})" ]; do
51 atf_test_case "basic_v4" "cleanup"
54 atf_set descr 'Basic CARP test (IPv4)'
55 atf_set require.user root
60 if ! kldstat -q -m carp; then
61 atf_skip "This test requires carp"
65 bridge=$(vnet_mkbridge)
66 epair_one=$(vnet_mkepair)
67 epair_two=$(vnet_mkepair)
69 vnet_mkjail carp_basic_v4_one ${bridge} ${epair_one}a ${epair_two}a
70 vnet_mkjail carp_basic_v4_two ${epair_one}b
71 vnet_mkjail carp_basic_v4_three ${epair_two}b
73 jexec carp_basic_v4_one ifconfig ${bridge} 192.0.2.4/29 up
74 jexec carp_basic_v4_one ifconfig ${bridge} addm ${epair_one}a \
76 jexec carp_basic_v4_one ifconfig ${epair_one}a up
77 jexec carp_basic_v4_one ifconfig ${epair_two}a up
79 jexec carp_basic_v4_two ifconfig ${epair_one}b 192.0.2.202/29 up
80 jexec carp_basic_v4_two ifconfig ${epair_one}b add vhid 1 192.0.2.1/29
82 jexec carp_basic_v4_three ifconfig ${epair_two}b 192.0.2.203/29 up
83 jexec carp_basic_v4_three ifconfig ${epair_two}b add vhid 1 \
86 wait_for_carp carp_basic_v4_two ${epair_one}b \
87 carp_basic_v4_three ${epair_two}b
89 atf_check -s exit:0 -o ignore jexec carp_basic_v4_one \
98 atf_test_case "basic_v6" "cleanup"
101 atf_set descr 'Basic CARP test (IPv6)'
102 atf_set require.user root
107 if ! kldstat -q -m carp; then
108 atf_skip "This test requires carp"
112 bridge=$(vnet_mkbridge)
113 epair_one=$(vnet_mkepair)
114 epair_two=$(vnet_mkepair)
116 vnet_mkjail carp_basic_v6_one ${bridge} ${epair_one}a ${epair_two}a
117 vnet_mkjail carp_basic_v6_two ${epair_one}b
118 vnet_mkjail carp_basic_v6_three ${epair_two}b
120 jexec carp_basic_v6_one ifconfig ${bridge} inet6 2001:db8::0:4/64 up \
122 jexec carp_basic_v6_one ifconfig ${bridge} addm ${epair_one}a \
124 jexec carp_basic_v6_one ifconfig ${epair_one}a up
125 jexec carp_basic_v6_one ifconfig ${epair_two}a up
127 jexec carp_basic_v6_two ifconfig ${epair_one}b inet6 \
128 2001:db8::1:2/64 up no_dad
129 jexec carp_basic_v6_two ifconfig ${epair_one}b inet6 add vhid 1 \
132 jexec carp_basic_v6_three ifconfig ${epair_two}b inet6 2001:db8::1:3/64 up no_dad
133 jexec carp_basic_v6_three ifconfig ${epair_two}b inet6 add vhid 1 \
136 wait_for_carp carp_basic_v6_two ${epair_one}b \
137 carp_basic_v6_three ${epair_two}b
139 atf_check -s exit:0 -o ignore jexec carp_basic_v6_one \
140 ping6 -c 3 2001:db8::0:1
148 atf_init_test_cases()
150 atf_add_test_case "basic_v4"
151 atf_add_test_case "basic_v6"