1277627Swill#
2277627Swill#  Copyright (c) 2014 Spectra Logic Corporation
3277627Swill#  All rights reserved.
4277627Swill# 
5277627Swill#  Redistribution and use in source and binary forms, with or without
6277627Swill#  modification, are permitted provided that the following conditions
7277627Swill#  are met:
8277627Swill#  1. Redistributions of source code must retain the above copyright
9277627Swill#     notice, this list of conditions, and the following disclaimer,
10277627Swill#     without modification.
11277627Swill#  2. Redistributions in binary form must reproduce at minimum a disclaimer
12277627Swill#     substantially similar to the "NO WARRANTY" disclaimer below
13277627Swill#     ("Disclaimer") and any redistribution must be conditioned upon
14277627Swill#     including a substantially similar Disclaimer requirement for further
15277627Swill#     binary redistribution.
16277627Swill# 
17277627Swill#  NO WARRANTY
18277627Swill#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19277627Swill#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20277627Swill#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
21277627Swill#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22277627Swill#  HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23277627Swill#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24277627Swill#  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25277627Swill#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26277627Swill#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27277627Swill#  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28277627Swill#  POSSIBILITY OF SUCH DAMAGES.
29277627Swill# 
30277627Swill#  Authors: Alan Somers         (Spectra Logic Corporation)
31277627Swill#
32277627Swill# $FreeBSD: releng/11.0/tests/etc/rc.d/routing_test.sh 300882 2016-05-27 22:40:40Z asomers $
33277627Swill
34300882Sasomersatf_test_case static_ipv4_loopback_route_for_each_fib cleanup
35300882Sasomersstatic_ipv4_loopback_route_for_each_fib_head()
36300882Sasomers{
37300882Sasomers	atf_set "descr" "Every FIB should have a static IPv4 loopback route"
38300882Sasomers}
39300882Sasomersstatic_ipv4_loopback_route_for_each_fib_body()
40300882Sasomers{
41300882Sasomers	local nfibs fib
42300882Sasomers	nfibs=`sysctl -n net.fibs`
43300882Sasomers
44300882Sasomers	# Check for an IPv4 loopback route
45300882Sasomers	for fib in `seq 0 $((${nfibs} - 1))`; do
46300882Sasomers		atf_check -o match:"interface: lo0" -s exit:0 \
47300882Sasomers			setfib -F ${fib} route -4 get 127.0.0.1
48300882Sasomers	done
49300882Sasomers}
50300882Sasomers
51277627Swillatf_test_case static_ipv6_loopback_route_for_each_fib cleanup
52277627Swillstatic_ipv6_loopback_route_for_each_fib_head()
53277627Swill{
54277627Swill	atf_set "descr" "Every FIB should have a static IPv6 loopback route"
55277627Swill}
56277627Swillstatic_ipv6_loopback_route_for_each_fib_body()
57277627Swill{
58300882Sasomers	local nfibs fib
59300882Sasomers	nfibs=`sysctl -n net.fibs`
60277627Swill
61277627Swill	# Check for an IPv6 loopback route
62300882Sasomers	for fib in `seq 0 $((${nfibs} - 1))`; do
63300882Sasomers		atf_check -o match:"interface: lo0" -s exit:0 \
64300882Sasomers			setfib -F ${fib} route -6 get ::1
65300882Sasomers	done
66277627Swill}
67277627Swill
68277627Swillatf_init_test_cases()
69277627Swill{
70300882Sasomers	atf_add_test_case static_ipv4_loopback_route_for_each_fib
71277627Swill	atf_add_test_case static_ipv6_loopback_route_for_each_fib
72277627Swill}
73277627Swill
74