1ed91ae7fSBjoern A. Zeeb#- 2ed91ae7fSBjoern A. Zeeb# SPDX-License-Identifier: BSD-2-Clause 3ed91ae7fSBjoern A. Zeeb# 4ed91ae7fSBjoern A. Zeeb# Copyright (c) 2019 Netflix, Inc. 5ed91ae7fSBjoern A. Zeeb# 6ed91ae7fSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without 7ed91ae7fSBjoern A. Zeeb# modification, are permitted provided that the following conditions 8ed91ae7fSBjoern A. Zeeb# are met: 9ed91ae7fSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright 10ed91ae7fSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer. 11ed91ae7fSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright 12ed91ae7fSBjoern A. Zeeb# notice, this list of conditions and the following disclaimer in the 13ed91ae7fSBjoern A. Zeeb# documentation and/or other materials provided with the distribution. 14ed91ae7fSBjoern A. Zeeb# 15ed91ae7fSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16ed91ae7fSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17ed91ae7fSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18ed91ae7fSBjoern A. Zeeb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19ed91ae7fSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20ed91ae7fSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21ed91ae7fSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22ed91ae7fSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23ed91ae7fSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24ed91ae7fSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25ed91ae7fSBjoern A. Zeeb# SUCH DAMAGE. 26ed91ae7fSBjoern A. Zeeb# 27ed91ae7fSBjoern A. Zeeb 28ed91ae7fSBjoern A. Zeeb. $(atf_get_srcdir)/../common/vnet.subr 29ed91ae7fSBjoern A. Zeeb 30ed91ae7fSBjoern A. Zeebatf_test_case "scapyi386" "cleanup" 31ed91ae7fSBjoern A. Zeebscapyi386_head() { 32ed91ae7fSBjoern A. Zeeb 33ed91ae7fSBjoern A. Zeeb atf_set descr 'Test for correct Ethernet Destination MAC address' 34ed91ae7fSBjoern A. Zeeb atf_set require.user root 35*c46af893SJose Luis Duran atf_set require.progs python3 scapy 36ed91ae7fSBjoern A. Zeeb} 37ed91ae7fSBjoern A. Zeeb 38ed91ae7fSBjoern A. Zeebscapyi386_body() { 39ed91ae7fSBjoern A. Zeeb 40ed91ae7fSBjoern A. Zeeb ids=65533 41ed91ae7fSBjoern A. Zeeb id=`printf "%x" ${ids}` 42ed91ae7fSBjoern A. Zeeb if [ $$ -gt 65535 ]; then 43ed91ae7fSBjoern A. Zeeb xl=`printf "%x" $(($$ - 65535))` 44ed91ae7fSBjoern A. Zeeb yl="1" 45ed91ae7fSBjoern A. Zeeb else 46ed91ae7fSBjoern A. Zeeb xl=`printf "%x" $$` 47ed91ae7fSBjoern A. Zeeb yl="" 48ed91ae7fSBjoern A. Zeeb fi 49ed91ae7fSBjoern A. Zeeb 50ed91ae7fSBjoern A. Zeeb vnet_init 51ed91ae7fSBjoern A. Zeeb 52ed91ae7fSBjoern A. Zeeb ip6a="2001:db8:6666:0000:${yl}:${id}:1:${xl}" 53ed91ae7fSBjoern A. Zeeb ip6b="2001:db8:6666:0000:${yl}:${id}:2:${xl}" 54ed91ae7fSBjoern A. Zeeb 55ed91ae7fSBjoern A. Zeeb epair=$(vnet_mkepair) 56ed91ae7fSBjoern A. Zeeb ifconfig ${epair}a up 57ed91ae7fSBjoern A. Zeeb ifconfig ${epair}a inet6 ${ip6a}/64 58ed91ae7fSBjoern A. Zeeb 59ed91ae7fSBjoern A. Zeeb jname="v6t-${id}-${yl}-${xl}" 60ed91ae7fSBjoern A. Zeeb vnet_mkjail ${jname} ${epair}b 61ed91ae7fSBjoern A. Zeeb jexec ${jname} ifconfig ${epair}b up 62ed91ae7fSBjoern A. Zeeb jexec ${jname} ifconfig ${epair}b inet6 ${ip6b}/64 63ed91ae7fSBjoern A. Zeeb 64ed91ae7fSBjoern A. Zeeb # Let IPv6 ND do its thing. 65ed91ae7fSBjoern A. Zeeb #ping6 -q -c 1 ff02::1%${epair}a 66ed91ae7fSBjoern A. Zeeb #ping6 -q -c 1 ${ip6b} 67ed91ae7fSBjoern A. Zeeb sleep 3 68ed91ae7fSBjoern A. Zeeb 69ed91ae7fSBjoern A. Zeeb pyname=$(atf_get ident) 70ed91ae7fSBjoern A. Zeeb pyname=${pyname%*_[0-9]} 71ed91ae7fSBjoern A. Zeeb 72ed91ae7fSBjoern A. Zeeb atf_check -s exit:0 $(atf_get_srcdir)/${pyname}.py \ 73ed91ae7fSBjoern A. Zeeb --sendif ${epair}a --recvif ${epair}a \ 74ed91ae7fSBjoern A. Zeeb --src ${ip6a} --to ${ip6b} 75ed91ae7fSBjoern A. Zeeb} 76ed91ae7fSBjoern A. Zeeb 77ed91ae7fSBjoern A. Zeebscapyi386_cleanup() { 78ed91ae7fSBjoern A. Zeeb 79ed91ae7fSBjoern A. Zeeb vnet_cleanup 80ed91ae7fSBjoern A. Zeeb} 81ed91ae7fSBjoern A. Zeeb 82ed91ae7fSBjoern A. Zeebatf_init_test_cases() 83ed91ae7fSBjoern A. Zeeb{ 84ed91ae7fSBjoern A. Zeeb 85ed91ae7fSBjoern A. Zeeb atf_add_test_case "scapyi386" 86ed91ae7fSBjoern A. Zeeb} 87ed91ae7fSBjoern A. Zeeb 88ed91ae7fSBjoern A. Zeeb# end 89