xref: /freebsd/tests/etc/rc.d/routing_test.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
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
3330da6877SAlan Somersatf_test_case static_ipv4_loopback_route_for_each_fib cleanup
3430da6877SAlan Somersstatic_ipv4_loopback_route_for_each_fib_head()
3530da6877SAlan Somers{
3630da6877SAlan Somers	atf_set "descr" "Every FIB should have a static IPv4 loopback route"
3730da6877SAlan Somers}
3830da6877SAlan Somersstatic_ipv4_loopback_route_for_each_fib_body()
3930da6877SAlan Somers{
4030da6877SAlan Somers	local nfibs fib
4130da6877SAlan Somers	nfibs=`sysctl -n net.fibs`
4230da6877SAlan Somers
4330da6877SAlan Somers	# Check for an IPv4 loopback route
4430da6877SAlan Somers	for fib in `seq 0 $((${nfibs} - 1))`; do
4530da6877SAlan Somers		atf_check -o match:"interface: lo0" -s exit:0 \
4630da6877SAlan Somers			setfib -F ${fib} route -4 get 127.0.0.1
4730da6877SAlan Somers	done
4830da6877SAlan Somers}
4930da6877SAlan Somers
507afb8adfSEnji Cooperatf_test_case static_ipv6_loopback_route_for_each_fib cleanup
517afb8adfSEnji Cooperstatic_ipv6_loopback_route_for_each_fib_head()
527afb8adfSEnji Cooper{
537afb8adfSEnji Cooper	atf_set "descr" "Every FIB should have a static IPv6 loopback route"
547afb8adfSEnji Cooper}
557afb8adfSEnji Cooperstatic_ipv6_loopback_route_for_each_fib_body()
567afb8adfSEnji Cooper{
5730da6877SAlan Somers	local nfibs fib
5830da6877SAlan Somers	nfibs=`sysctl -n net.fibs`
597afb8adfSEnji Cooper
60*3a970562SRuslan Bukin	if [ "`sysctl -in kern.features.inet6`" != "1" ]; then
61*3a970562SRuslan Bukin		atf_skip "This test requires IPv6 support"
62*3a970562SRuslan Bukin	fi
63*3a970562SRuslan Bukin
647afb8adfSEnji Cooper	# Check for an IPv6 loopback route
6530da6877SAlan Somers	for fib in `seq 0 $((${nfibs} - 1))`; do
6630da6877SAlan Somers		atf_check -o match:"interface: lo0" -s exit:0 \
6730da6877SAlan Somers			setfib -F ${fib} route -6 get ::1
6830da6877SAlan Somers	done
697afb8adfSEnji Cooper}
707afb8adfSEnji Cooper
717afb8adfSEnji Cooperatf_init_test_cases()
727afb8adfSEnji Cooper{
7330da6877SAlan Somers	atf_add_test_case static_ipv4_loopback_route_for_each_fib
747afb8adfSEnji Cooper	atf_add_test_case static_ipv6_loopback_route_for_each_fib
757afb8adfSEnji Cooper}
767afb8adfSEnji Cooper
77