2 # Copyright (c) 2014 Spectra Logic Corporation
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions, and the following disclaimer,
10 # without modification.
11 # 2. Redistributions in binary form must reproduce at minimum a disclaimer
12 # substantially similar to the "NO WARRANTY" disclaimer below
13 # ("Disclaimer") and any redistribution must be conditioned upon
14 # including a substantially similar Disclaimer requirement for further
15 # binary redistribution.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGES.
30 # Authors: Alan Somers (Spectra Logic Corporation)
34 atf_test_case static_ipv6_loopback_route_for_each_fib cleanup
35 static_ipv6_loopback_route_for_each_fib_head()
37 atf_set "descr" "Every FIB should have a static IPv6 loopback route"
38 atf_set "require.user" "root"
39 atf_set "require.config" "fibs"
40 atf_set "require.progs" "sysrc"
42 static_ipv6_loopback_route_for_each_fib_body()
44 # Configure the TAP interface to use an RFC5737 nonrouteable address
45 # and a non-default fib
50 # Check system configuration
51 if [ 0 != `sysctl -n net.add_addr_allfibs` ]; then
52 atf_skip "This test requires net.add_addr_allfibs=0"
58 # Configure a TAP interface in /etc/rc.conf. Register the sysrc
59 # variable for cleanup.
60 echo "ifconfig_${TAP}" >> "sysrc_vars_to_cleanup"
61 sysrc ifconfig_${TAP}="${ADDR}/${MASK} fib ${FIB0}"
64 service netif start ${TAP}
65 # Check for an IPv6 loopback route
66 setfib ${FIB0} netstat -rn -f inet6 | grep -q "^::1.*lo0$"
70 setfib ${FIB0} netstat -rn -f inet6
71 atf_fail "Did not find an IPv6 loopback route"
74 static_ipv6_loopback_route_for_each_fib_cleanup()
82 atf_add_test_case static_ipv6_loopback_route_for_each_fib
85 # Looks up one or more fibs from the configuration data and validates them.
86 # Returns the results in the env varilables FIB0, FIB1, etc.
87 # parameter numfibs The number of fibs to lookup
91 net_fibs=`sysctl -n net.fibs`
93 while [ $i -lt "$NUMFIBS" ]; do
94 fib=`atf_config_get "fibs" | \
95 awk -v i=$(( i + 1 )) '{print $i}'`
98 if [ "$fib" -ge "$net_fibs" ]; then
99 msg="The ${i}th configured fib is ${fub}, which is "
100 msg="$msg not less than net.fibs (${net_fibs})"
108 # Creates a new tap(4) interface, registers it for cleanup, and returns the
109 # name via the environment variable TAP
113 while ! ifconfig tap${TAPN} create > /dev/null 2>&1; do
114 if [ "$TAPN" -ge 8 ]; then
115 atf_skip "Could not create a tap(4) interface"
120 local TAPD=tap${TAPN}
121 # Record the TAP device so we can clean it up later
122 echo ${TAPD} >> "tap_devices_to_cleanup"
128 for var in `cat "sysrc_vars_to_cleanup"`; do
135 for TAPD in `cat "tap_devices_to_cleanup"`; do
136 ifconfig ${TAPD} destroy