2 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 # Copyright (c) 2020 Ahsan Barkati
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 . $(atf_get_srcdir)/utils.subr
32 atf_test_case "basic_v4" "cleanup"
35 atf_set descr 'add/change/delete route test for v4'
36 atf_set require.user root
37 atf_set require.progs jq
43 ifconfig ${epair}a 192.0.2.2/24 up
44 vnet_mkjail alcatraz ${epair}b
45 jexec alcatraz ifconfig ${epair}b 192.0.2.1/24 up
47 # add a new route in the jail
48 jexec alcatraz route add 192.0.2.3 192.0.2.2
49 gateway=$(check_route "alcatraz" "192.0.2.3")
51 if [ "${gateway}" != "192.0.2.2" ]; then
52 atf_fail "Failed to add new route."
55 # change the added route
56 jexec alcatraz route change 192.0.2.3 192.0.2.4
57 gateway=$(check_route "alcatraz" "192.0.2.3")
59 if [ "${gateway}" != "192.0.2.4" ]; then
60 atf_fail "Failed to change route."
64 jexec alcatraz route delete 192.0.2.3
65 gateway=$(check_route "alcatraz" "192.0.2.3")
67 if [ "${gateway}" != "" ]; then
68 atf_fail "Failed to delete route."
77 atf_test_case "basic_v6" "cleanup"
80 atf_set descr 'add/change/delete route test for v6'
81 atf_set require.user root
82 atf_set require.progs jq
88 ifconfig ${epair}a inet6 2001:db8:cc4b::1/64 up no_dad
89 vnet_mkjail alcatraz ${epair}b
90 jexec alcatraz ifconfig ${epair}b inet6 2001:db8:cc4b::2/64 up no_dad
92 # add a new route in the jail
93 jexec alcatraz route add -6 2001:db8:cc4b::3 2001:db8:cc4b::1
94 gateway=$(check_route "alcatraz" "2001:db8:cc4b::3")
96 if [ "${gateway}" != "2001:db8:cc4b::1" ]; then
97 atf_fail "Failed to add new route."
100 # change the added route
101 jexec alcatraz route change -6 2001:db8:cc4b::3 2001:db8:cc4b::4
102 gateway=$(check_route "alcatraz" "2001:db8:cc4b::3")
103 if [ "${gateway}" != "2001:db8:cc4b::4" ]; then
104 atf_fail "Failed to change route."
108 jexec alcatraz route -6 delete 2001:db8:cc4b::3
109 gateway=$(check_route "alcatraz" "2001:db8:cc4b::3")
111 if [ "${gateway}" != "" ]; then
112 atf_fail "Failed to delete route."
121 atf_init_test_cases()
123 atf_add_test_case "basic_v4"
124 atf_add_test_case "basic_v6"