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