xref: /freebsd/tests/sys/netinet6/mld.sh (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
132af08ecSBjoern A. Zeeb#-
232af08ecSBjoern A. Zeeb# SPDX-License-Identifier: BSD-2-Clause
332af08ecSBjoern A. Zeeb#
432af08ecSBjoern A. Zeeb# Copyright (c) 2019 Netflix, Inc.
532af08ecSBjoern A. Zeeb#
632af08ecSBjoern A. Zeeb# Redistribution and use in source and binary forms, with or without
732af08ecSBjoern A. Zeeb# modification, are permitted provided that the following conditions
832af08ecSBjoern A. Zeeb# are met:
932af08ecSBjoern A. Zeeb# 1. Redistributions of source code must retain the above copyright
1032af08ecSBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer.
1132af08ecSBjoern A. Zeeb# 2. Redistributions in binary form must reproduce the above copyright
1232af08ecSBjoern A. Zeeb#    notice, this list of conditions and the following disclaimer in the
1332af08ecSBjoern A. Zeeb#    documentation and/or other materials provided with the distribution.
1432af08ecSBjoern A. Zeeb#
1532af08ecSBjoern A. Zeeb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1632af08ecSBjoern A. Zeeb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1732af08ecSBjoern A. Zeeb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1832af08ecSBjoern A. Zeeb# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1932af08ecSBjoern A. Zeeb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2032af08ecSBjoern A. Zeeb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2132af08ecSBjoern A. Zeeb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2232af08ecSBjoern A. Zeeb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2332af08ecSBjoern A. Zeeb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2432af08ecSBjoern A. Zeeb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2532af08ecSBjoern A. Zeeb# SUCH DAMAGE.
2632af08ecSBjoern A. Zeeb#
2732af08ecSBjoern A. Zeeb
2832af08ecSBjoern A. Zeeb. $(atf_get_srcdir)/../common/vnet.subr
2932af08ecSBjoern A. Zeeb
3032af08ecSBjoern A. Zeebatf_test_case "mldraw01" "cleanup"
3132af08ecSBjoern A. Zeebmldraw01_head() {
3232af08ecSBjoern A. Zeeb
3332af08ecSBjoern A. Zeeb	atf_set descr 'Test for correct Ethernet Destination MAC address'
3432af08ecSBjoern A. Zeeb	atf_set require.user root
3532af08ecSBjoern A. Zeeb	atf_set require.progs scapy
3632af08ecSBjoern A. Zeeb}
3732af08ecSBjoern A. Zeeb
3832af08ecSBjoern A. Zeebmldraw01_body() {
3932af08ecSBjoern A. Zeeb
4032af08ecSBjoern A. Zeeb	ids=65533
4132af08ecSBjoern A. Zeeb	id=`printf "%x" ${ids}`
4232af08ecSBjoern A. Zeeb	if [ $$ -gt 65535 ]; then
4332af08ecSBjoern A. Zeeb		xl=`printf "%x" $(($$ - 65535))`
4432af08ecSBjoern A. Zeeb		yl="1"
4532af08ecSBjoern A. Zeeb	else
4632af08ecSBjoern A. Zeeb		xl=`printf "%x" $$`
4732af08ecSBjoern A. Zeeb		yl=""
4832af08ecSBjoern A. Zeeb	fi
4932af08ecSBjoern A. Zeeb
5032af08ecSBjoern A. Zeeb	vnet_init
5132af08ecSBjoern A. Zeeb
5232af08ecSBjoern A. Zeeb	ip6a="2001:db8:6666:0000:${yl}:${id}:1:${xl}"
5332af08ecSBjoern A. Zeeb	ip6b="2001:db8:6666:0000:${yl}:${id}:2:${xl}"
5432af08ecSBjoern A. Zeeb
5532af08ecSBjoern A. Zeeb	epair=$(vnet_mkepair)
5632af08ecSBjoern A. Zeeb	ifconfig ${epair}a up
5732af08ecSBjoern A. Zeeb	ifconfig ${epair}a inet6 ${ip6a}/64
5832af08ecSBjoern A. Zeeb
5932af08ecSBjoern A. Zeeb	jname="v6t-${id}-${yl}-${xl}"
6032af08ecSBjoern A. Zeeb	vnet_mkjail ${jname} ${epair}b
6132af08ecSBjoern A. Zeeb	jexec ${jname} ifconfig ${epair}b up
6232af08ecSBjoern A. Zeeb	jexec ${jname} ifconfig ${epair}b inet6 ${ip6b}/64
6332af08ecSBjoern A. Zeeb
6432af08ecSBjoern A. Zeeb	# Let IPv6 ND do its thing.
6532af08ecSBjoern A. Zeeb	#ping6 -q -c 1 ff02::1%${epair}a
6632af08ecSBjoern A. Zeeb	#ping6 -q -c 1 ${ip6b}
6732af08ecSBjoern A. Zeeb	sleep 3
6832af08ecSBjoern A. Zeeb
6932af08ecSBjoern A. Zeeb	pyname=$(atf_get ident)
7032af08ecSBjoern A. Zeeb
7132af08ecSBjoern A. Zeeb	atf_check -s exit:0 $(atf_get_srcdir)/mld.py \
7232af08ecSBjoern A. Zeeb		--sendif ${epair}a --recvif ${epair}a \
7332af08ecSBjoern A. Zeeb		--src ${ip6a} --to  ${ip6b} \
7432af08ecSBjoern A. Zeeb		--${pyname}
7532af08ecSBjoern A. Zeeb}
7632af08ecSBjoern A. Zeeb
7732af08ecSBjoern A. Zeebmldraw01_cleanup() {
7832af08ecSBjoern A. Zeeb
7932af08ecSBjoern A. Zeeb	vnet_cleanup
8032af08ecSBjoern A. Zeeb}
8132af08ecSBjoern A. Zeeb
82*b03012d0SKristof Provostatf_test_case "pr233683" "cleanup"
83*b03012d0SKristof Provostpr233683_head() {
84*b03012d0SKristof Provost
85*b03012d0SKristof Provost	atf_set descr 'Test for PR233683'
86*b03012d0SKristof Provost	atf_set require.user root
87*b03012d0SKristof Provost}
88*b03012d0SKristof Provost
89*b03012d0SKristof Provostpr233683_body() {
90*b03012d0SKristof Provost	j="mld:pr233683"
91*b03012d0SKristof Provost
92*b03012d0SKristof Provost	vnet_init
93*b03012d0SKristof Provost
94*b03012d0SKristof Provost	epair=$(vnet_mkepair)
95*b03012d0SKristof Provost
96*b03012d0SKristof Provost	vnet_mkjail ${j}a ${epair}a
97*b03012d0SKristof Provost	jexec ${j}a ifconfig ${epair}a inet6 2001:db8::1/64 up
98*b03012d0SKristof Provost	sleep 5
99*b03012d0SKristof Provost
100*b03012d0SKristof Provost	jexec ${j}a ifconfig ${epair}a inet6 2001:db8::1/64
101*b03012d0SKristof Provost
102*b03012d0SKristof Provost	vnet_mkjail ${j}b ${epair}b
103*b03012d0SKristof Provost	jexec ${j}b ifconfig ${epair}b inet6 2001:db8::2/64 up
104*b03012d0SKristof Provost
105*b03012d0SKristof Provost	# Allow DAD to run
106*b03012d0SKristof Provost	sleep 5
107*b03012d0SKristof Provost
108*b03012d0SKristof Provost	# Debug output. If the bug is present we'd expect to not see a
109*b03012d0SKristof Provost	# membership for ff02::1:ff00:1
110*b03012d0SKristof Provost	jexec ${j}a ifmcstat -i ${epair}a
111*b03012d0SKristof Provost	jexec ${j}a ifconfig ${epair}a
112*b03012d0SKristof Provost
113*b03012d0SKristof Provost	atf_check -s exit:0 -o ignore \
114*b03012d0SKristof Provost	    jexec ${j}b ping -6 -c 1 2001:db8::1
115*b03012d0SKristof Provost}
116*b03012d0SKristof Provost
117*b03012d0SKristof Provostpr233683_cleanup() {
118*b03012d0SKristof Provost
119*b03012d0SKristof Provost	vnet_cleanup
120*b03012d0SKristof Provost}
12132af08ecSBjoern A. Zeebatf_init_test_cases()
12232af08ecSBjoern A. Zeeb{
12332af08ecSBjoern A. Zeeb
12432af08ecSBjoern A. Zeeb	atf_add_test_case "mldraw01"
125*b03012d0SKristof Provost	atf_add_test_case "pr233683"
12632af08ecSBjoern A. Zeeb}
12732af08ecSBjoern A. Zeeb
12832af08ecSBjoern A. Zeeb# end
129