3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2022 KUROSAWA Takahiro <takahiro.kurosawa@gmail.com>
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
31 . $(atf_get_srcdir)/../common/vnet.subr
33 atf_test_case "pndp_add_gu_success" "cleanup"
34 pndp_add_gu_success_head() {
35 atf_set descr 'Test proxy ndp record addition'
36 atf_set require.user root
39 pndp_add_gu_success_body() {
43 jname="v6t-pndp_add_success"
45 epair0=$(vnet_mkepair)
47 vnet_mkjail ${jname} ${epair0}a
48 jexec ${jname} ndp -i ${epair0}a -- -disabled
49 jexec ${jname} ifconfig ${epair0}a up
51 jexec ${jname} ifconfig ${epair0}a inet6 2001:db8::1/64
52 proxy_mac=`jexec ${jname} ifconfig ${epair0}a ether | awk '$1~/ether/{print$2}'`
54 # wait for DAD to complete
55 while [ `jexec ${jname} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
59 atf_check jexec ${jname} ndp -s 2001:db8::2 ${proxy_mac} proxy
60 while [ `jexec ${jname} ifmcstat | grep -c undefined` != "0" ]; do
64 # checking the output of ndp -an is covered by ndp.sh.
65 # we check the output of ifmcstat output here.
66 t=`jexec ${jname} ifmcstat -i ${epair0}a -f inet6 | grep -A1 'group ff02::1:ff00:2'`
67 atf_check -o match:'mcast-macaddr 33:33:ff:00:00:02' echo $t
70 pndp_add_gu_success_cleanup() {
74 atf_test_case "pndp_del_gu_success" "cleanup"
75 pndp_del_gu_success_head() {
76 atf_set descr 'Test proxy ndp record deletion'
77 atf_set require.user root
80 pndp_del_gu_success_body() {
84 jname="v6t-pndp_del_gu_success"
86 epair0=$(vnet_mkepair)
88 vnet_mkjail ${jname} ${epair0}a
90 jexec ${jname} ndp -i ${epair0}a -- -disabled
91 jexec ${jname} ifconfig ${epair0}a up
93 jexec ${jname} ifconfig ${epair0}a inet6 2001:db8::1/64
94 proxy_mac=`jexec ${jname} ifconfig ${epair0}a ether | awk '$1~/ether/{print$2}'`
96 # wait for DAD to complete
97 while [ `jexec ${jname} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
101 atf_check jexec ${jname} ndp -s 2001:db8::2 ${proxy_mac} proxy
102 while [ `jexec ${jname} ifmcstat | grep -c undefined` != "0" ]; do
105 jexec ${jname} ping -c1 -t1 2001:db8::2
107 atf_check -o match:"2001:db8::2 \(2001:db8::2\) deleted" jexec ${jname} ndp -nd 2001:db8::2
108 while [ `jexec ${jname} ifmcstat | grep -c undefined` != "0" ]; do
112 -o not-match:'group ff02::1:ff00:2' \
113 -o not-match:'mcast-macaddr 33:33:ff:00:00:02' \
114 jexec ${jname} ifmcstat -i ${epair0}a -f inet6
117 pndp_del_gu_success_cleanup() {
121 atf_test_case "pndp_ifdestroy_success" "cleanup"
122 pndp_ifdetroy_success_head() {
123 atf_set descr 'Test interface destruction with proxy ndp'
124 atf_set require.user root
127 pndp_ifdestroy_success_body() {
131 jname="v6t-pndp_ifdestroy_success"
133 epair0=$(vnet_mkepair)
135 vnet_mkjail ${jname} ${epair0}a
137 jexec ${jname} ndp -i ${epair0}a -- -disabled
138 jexec ${jname} ifconfig ${epair0}a up
140 jexec ${jname} ifconfig ${epair0}a inet6 2001:db8::1/64
141 proxy_mac=`jexec ${jname} ifconfig ${epair0}a ether | awk '$1~/ether/{print$2}'`
143 # wait for DAD to complete
144 while [ `jexec ${jname} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
148 atf_check jexec ${jname} ndp -s 2001:db8::2 ${proxy_mac} proxy
149 while [ `jexec ${jname} ifmcstat | grep -c undefined` != "0" ]; do
153 atf_check jexec ${jname} ifconfig ${epair0}a destroy
156 pndp_ifdestroy_success_cleanup() {
160 atf_test_case "pndp_neighbor_advert" "cleanup"
161 pndp_neighbor_advert_head() {
162 atf_set descr 'Test Neighbor Advertisement for proxy ndp'
163 atf_set require.user root
166 pndp_neighbor_advert_body() {
170 jname_a="v6t-pndp_neighbor_advert_a" # NA sender (w/proxy ndp entry)
171 jname_b="v6t-pndp_neighbor_advert_b" # NA receiver (checker)
172 proxy_addr="2001:db8::aaaa"
174 epair0=$(vnet_mkepair)
176 vnet_mkjail ${jname_a} ${epair0}a
177 jexec ${jname_a} ndp -i ${epair0}a -- -disabled
178 jexec ${jname_a} ifconfig ${epair0}a up
179 jexec ${jname_a} ifconfig ${epair0}a inet6 2001:db8::1/64
180 proxy_mac=`jexec ${jname_a} ifconfig ${epair0}a ether | awk '$1~/ether/{print$2}'`
181 # wait for DAD to complete
182 while [ `jexec ${jname_a} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
185 atf_check jexec ${jname_a} ndp -s ${proxy_addr} ${proxy_mac} proxy
186 while [ `jexec ${jname_a} ifmcstat | grep -c undefined` != "0" ]; do
190 vnet_mkjail ${jname_b} ${epair0}b
191 jexec ${jname_b} ndp -i ${epair0}b -- -disabled
192 jexec ${jname_b} ifconfig ${epair0}b up
193 jexec ${jname_b} ifconfig ${epair0}b inet6 2001:db8::2/64
194 # wait for DAD to complete
195 while [ `jexec ${jname_b} ifconfig | grep inet6 | grep -c tentative` != "0" ]; do
199 jexec ${jname_b} ndp -nc
200 # jname_b sends a NS before ICMPv6 Echo Request for the proxy address.
201 # jname_a responds with a NA resolving the proxy address.
202 # Then there must be a NDP entry of the proxy address in jname_b.
203 jexec ${jname_b} ping -c1 -t1 ${proxy_addr}
204 atf_check -o match:"${proxy_addr} +${proxy_mac} +${epair0}b" \
205 jexec ${jname_b} ndp -an
208 pndp_neighbor_advert_cleanup() {
212 atf_init_test_cases()
215 atf_add_test_case "pndp_add_gu_success"
216 atf_add_test_case "pndp_del_gu_success"
217 atf_add_test_case "pndp_ifdestroy_success"
218 atf_add_test_case "pndp_neighbor_advert"