#-1# SPDX-License-Identifier: BSD-2-Clause2#3# Copyright (c) 2019 Netflix, Inc.4#5# Redistribution and use in source and binary forms, with or without6# modification, are permitted provided that the following conditions7# are met:8# 1. Redistributions of source code must retain the above copyright9# notice, this list of conditions and the following disclaimer.10# 2. Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13#14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24# SUCH DAMAGE.25#2627. $(atf_get_srcdir)/../common/vnet.subr2829atf_test_case "exthdr" "cleanup"30exthdr_head() {3132atf_set descr 'Test IPv6 extension header code paths'33atf_set require.user root34atf_set require.progs python3 scapy35}3637exthdr_body() {3839ids=6553340id=`printf "%x" ${ids}`41if [ $$ -gt 65535 ]; then42xl=`printf "%x" $(($$ - 65535))`43yl="1"44else45xl=`printf "%x" $$`46yl=""47fi4849vnet_init5051ip6a="2001:db8:6666:0000:${yl}:${id}:1:${xl}"52ip6b="2001:db8:6666:0000:${yl}:${id}:2:${xl}"5354epair=$(vnet_mkepair)55ifconfig ${epair}a up56ifconfig ${epair}a inet6 ${ip6a}/645758jname="v6t-${id}-${yl}-${xl}"59vnet_mkjail ${jname} ${epair}b60jexec ${jname} ifconfig ${epair}b up61jexec ${jname} ifconfig ${epair}b inet6 ${ip6b}/646263# Let IPv6 ND do its thing.64#ping6 -q -c 1 ff02::1%${epair}a65#ping6 -q -c 1 ${ip6b}66sleep 36768# Clear statistics.69jexec ${jname} netstat -z -s > /dev/null7071# Run extension header tests.72pyname=$(atf_get ident)73pyname=${pyname%*_[0-9]}7475atf_check -o ignore -s exit:0 ping -6 -c 3 -q -o ${ip6b}7677atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \78--sendif ${epair}a --recvif ${epair}a \79--src ${ip6a} --to ${ip6b}8081atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \82--sendif ${epair}a --recvif ${epair}a \83--src ${ip6a} --to ${ip6b} \84--hbh8586atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \87--sendif ${epair}a --recvif ${epair}a \88--src ${ip6a} --to ${ip6b} \89--rh9091atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \92--sendif ${epair}a --recvif ${epair}a \93--src ${ip6a} --to ${ip6b} \94--frag69596atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \97--sendif ${epair}a --recvif ${epair}a \98--src ${ip6a} --to ${ip6b} \99--dest100101atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \102--sendif ${epair}a --recvif ${epair}a \103--src ${ip6a} --to ${ip6b} \104--hbh --dest105106atf_check -s exit:1 $(atf_get_srcdir)/${pyname}.py \107--sendif ${epair}a --recvif ${epair}a \108--src ${ip6a} --to ${ip6b} \109--dest --hbhbad110111}112113exthdr_cleanup() {114115vnet_cleanup116}117118atf_init_test_cases()119{120121atf_add_test_case "exthdr"122}123124# end125126127