Changeset View
Changeset View
Standalone View
Standalone View
tests/sys/netinet6/icmp6.sh
Property | Old Value | New Value |
---|---|---|
svn:eol-style | null | native \ No newline at end of property |
svn:executable | null | * \ No newline at end of property |
svn:keywords | null | FreeBSD=%H \ No newline at end of property |
svn:mime-type | null | text/plain \ No newline at end of property |
#!/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) | |||||
epair2=$(vnet_mkepair) | |||||
ifconfig ${epair1}a up | |||||
ifconfig ${epair1}a inet6 ${ip6a}/${plen} | |||||
jname1="jail1" | |||||
vnet_mkjail ${jname1} ${epair1}b ${epair2}a | |||||
jexec ${jname1} ifconfig ${epair1}b up | |||||
jexec ${jname1} ifconfig ${epair1}b inet6 ${ip6b}/${plen} | |||||
jexec ${jname1} ifconfig ${epair2}a up | |||||
jexec ${jname1} 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} | |||||
# wait for DAD to complete | |||||
while [ `ifconfig ${epair1}a inet6 | grep -c tentative` != "0" ]; do | |||||
sleep 0.1 | |||||
done | |||||
while [ `jexec ${jname1} ifconfig ${epair1}b inet6 | grep -c tentative` != "0" ]; do | |||||
sleep 0.1 | |||||
done | |||||
while [ `jexec ${jname1} ifconfig ${epair2}a inet6 | grep -c tentative` != "0" ]; do | |||||
sleep 0.1 | |||||
done | |||||
while [ `jexec ${jname2} ifconfig ${epair2}b inet6 | grep -c tentative` != "0" ]; do | |||||
sleep 0.1 | |||||
done | |||||
jexec ${jname1} sysctl net.inet6.icmp6.reply_src=${epair2}a | |||||
jexec ${jname1} sysctl net.inet6.ip6.forwarding=1 | |||||
route add -6 2001:db8:6667::/${plen} ${ip6b} | |||||
jexec ${jname2} route add -6 ::/0 ${ip6c} | |||||
# check counters are valid | |||||
atf_check -o match:${ip6c} -e ignore 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 | |||||