Last active
June 28, 2020 20:10
-
-
Save neelchauhan/e830f9cab71f79c81a258b8bdbc295d4 to your computer and use it in GitHub Desktop.
FreeBSD ICMP6 Kyua test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env atf-sh | |
#- | |
# SPDX-License-Identifier: BSD-2-Clause | |
# | |
# Copyright (c) 2020 Neel Chauhan | |
# | |
# Redistribution and use in source and binary forms, with or without | |
# modification, are permitted provided that the following conditions | |
# are met: | |
# 1. Redistributions of source code must retain the above copyright | |
# notice, this list of conditions and the following disclaimer. | |
# 2. Redistributions in binary form must reproduce the above copyright | |
# notice, this list of conditions and the following disclaimer in the | |
# documentation and/or other materials provided with the distribution. | |
# | |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND | |
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
# SUCH DAMAGE. | |
# | |
# $FreeBSD$ | |
# | |
. $(atf_get_srcdir)/../common/vnet.subr | |
atf_test_case "icmp6_reply_src_iface" "cleanup" | |
icmp6_reply_src_iface_head() { | |
atf_set descr 'Test ICMP6 reply src interface sysctl' | |
atf_set require.user root | |
} | |
icmp6_reply_src_iface_body() { | |
vnet_init | |
ip6a="2001:db8:6666::1" | |
ip6b="2001:db8:6666::2" | |
ip6c="2001:db8:6667::1" | |
ip6d="2001:db8:6667::2" | |
plen=64 | |
epair1=$(vnet_mkepair) | |
ifconfig ${epair1}a up | |
ifconfig ${epair1}a inet6 ${ip6a}/${plen} | |
jname1="jail1" | |
vnet_mkjail ${jname1} ${epair1}b | |
jexec ${jname1} ifconfig ${epair1}b up | |
jexec ${jname1} ifconfig ${epair1}b inet6 ${ip6b}/${plen} | |
epair2=$(vnet_mkepair) | |
ifconfig ${epair2}a up | |
ifconfig ${epair2}a inet6 ${ip6c}/${plen} | |
jname2="jail2" | |
vnet_mkjail ${jname2} ${epair2}b | |
jexec ${jname2} ifconfig ${epair2}b up | |
jexec ${jname2} ifconfig ${epair2}b inet6 ${ip6d}/${plen} | |
sysctl net.inet6.icmp6.reply_src=${epair2}a | |
sysctl net.inet6.ip6.forwarding=1 | |
jexec ${jname1} route add -6 ::/0 ${ip6a} | |
jexec ${jname2} route add -6 ::/0 ${ip6c} | |
# check counters are valid | |
atf_check -o match:${ip6c} jexec ${jname1} traceroute6 ${ip6d} | |
} | |
icmp6_reply_src_iface_cleanup() { | |
sysctl net.inet6.icmp6.reply_src= | |
vnet_cleanup | |
} | |
atf_init_test_cases() | |
{ | |
atf_add_test_case "icmp6_reply_src_iface" | |
} | |
# end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment