xref: /freebsd/tests/etc/rc.d/routing_test.sh (revision 30da6877944eb2add9424fe1c65db9f8d6198416)
17afb8adfSEnji Cooper#
27afb8adfSEnji Cooper#  Copyright (c) 2014 Spectra Logic Corporation
37afb8adfSEnji Cooper#  All rights reserved.
47afb8adfSEnji Cooper#
57afb8adfSEnji Cooper#  Redistribution and use in source and binary forms, with or without
67afb8adfSEnji Cooper#  modification, are permitted provided that the following conditions
77afb8adfSEnji Cooper#  are met:
87afb8adfSEnji Cooper#  1. Redistributions of source code must retain the above copyright
97afb8adfSEnji Cooper#     notice, this list of conditions, and the following disclaimer,
107afb8adfSEnji Cooper#     without modification.
117afb8adfSEnji Cooper#  2. Redistributions in binary form must reproduce at minimum a disclaimer
127afb8adfSEnji Cooper#     substantially similar to the "NO WARRANTY" disclaimer below
137afb8adfSEnji Cooper#     ("Disclaimer") and any redistribution must be conditioned upon
147afb8adfSEnji Cooper#     including a substantially similar Disclaimer requirement for further
157afb8adfSEnji Cooper#     binary redistribution.
167afb8adfSEnji Cooper#
177afb8adfSEnji Cooper#  NO WARRANTY
187afb8adfSEnji Cooper#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
197afb8adfSEnji Cooper#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
207afb8adfSEnji Cooper#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
217afb8adfSEnji Cooper#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
227afb8adfSEnji Cooper#  HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
237afb8adfSEnji Cooper#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
247afb8adfSEnji Cooper#  OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
257afb8adfSEnji Cooper#  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
267afb8adfSEnji Cooper#  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
277afb8adfSEnji Cooper#  IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
287afb8adfSEnji Cooper#  POSSIBILITY OF SUCH DAMAGES.
297afb8adfSEnji Cooper#
307afb8adfSEnji Cooper#  Authors: Alan Somers         (Spectra Logic Corporation)
317afb8adfSEnji Cooper#
327afb8adfSEnji Cooper# $FreeBSD$
337afb8adfSEnji Cooper
34*30da6877SAlan Somersatf_test_case static_ipv4_loopback_route_for_each_fib cleanup
35*30da6877SAlan Somersstatic_ipv4_loopback_route_for_each_fib_head()
36*30da6877SAlan Somers{
37*30da6877SAlan Somers	atf_set "descr" "Every FIB should have a static IPv4 loopback route"
38*30da6877SAlan Somers}
39*30da6877SAlan Somersstatic_ipv4_loopback_route_for_each_fib_body()
40*30da6877SAlan Somers{
41*30da6877SAlan Somers	local nfibs fib
42*30da6877SAlan Somers	nfibs=`sysctl -n net.fibs`
43*30da6877SAlan Somers
44*30da6877SAlan Somers	# Check for an IPv4 loopback route
45*30da6877SAlan Somers	for fib in `seq 0 $((${nfibs} - 1))`; do
46*30da6877SAlan Somers		atf_check -o match:"interface: lo0" -s exit:0 \
47*30da6877SAlan Somers			setfib -F ${fib} route -4 get 127.0.0.1
48*30da6877SAlan Somers	done
49*30da6877SAlan Somers}
50*30da6877SAlan Somers
517afb8adfSEnji Cooperatf_test_case static_ipv6_loopback_route_for_each_fib cleanup
527afb8adfSEnji Cooperstatic_ipv6_loopback_route_for_each_fib_head()
537afb8adfSEnji Cooper{
547afb8adfSEnji Cooper	atf_set "descr" "Every FIB should have a static IPv6 loopback route"
557afb8adfSEnji Cooper}
567afb8adfSEnji Cooperstatic_ipv6_loopback_route_for_each_fib_body()
577afb8adfSEnji Cooper{
58*30da6877SAlan Somers	local nfibs fib
59*30da6877SAlan Somers	nfibs=`sysctl -n net.fibs`
607afb8adfSEnji Cooper
617afb8adfSEnji Cooper	# Check for an IPv6 loopback route
62*30da6877SAlan Somers	for fib in `seq 0 $((${nfibs} - 1))`; do
63*30da6877SAlan Somers		atf_check -o match:"interface: lo0" -s exit:0 \
64*30da6877SAlan Somers			setfib -F ${fib} route -6 get ::1
65*30da6877SAlan Somers	done
667afb8adfSEnji Cooper}
677afb8adfSEnji Cooper
687afb8adfSEnji Cooperatf_init_test_cases()
697afb8adfSEnji Cooper{
70*30da6877SAlan Somers	atf_add_test_case static_ipv4_loopback_route_for_each_fib
717afb8adfSEnji Cooper	atf_add_test_case static_ipv6_loopback_route_for_each_fib
727afb8adfSEnji Cooper}
737afb8adfSEnji Cooper
74