xref: /freebsd/tests/sys/netinet6/mld.sh (revision d0b2dbfa)
1#-
2# SPDX-License-Identifier: BSD-2-Clause
3#
4# Copyright (c) 2019 Netflix, Inc.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9# 1. Redistributions of source code must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11# 2. Redistributions in binary form must reproduce the above copyright
12#    notice, this list of conditions and the following disclaimer in the
13#    documentation and/or other materials provided with the distribution.
14#
15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27
28. $(atf_get_srcdir)/../common/vnet.subr
29
30atf_test_case "mldraw01" "cleanup"
31mldraw01_head() {
32
33	atf_set descr 'Test for correct Ethernet Destination MAC address'
34	atf_set require.user root
35	atf_set require.progs scapy
36}
37
38mldraw01_body() {
39
40	ids=65533
41	id=`printf "%x" ${ids}`
42	if [ $$ -gt 65535 ]; then
43		xl=`printf "%x" $(($$ - 65535))`
44		yl="1"
45	else
46		xl=`printf "%x" $$`
47		yl=""
48	fi
49
50	vnet_init
51
52	ip6a="2001:db8:6666:0000:${yl}:${id}:1:${xl}"
53	ip6b="2001:db8:6666:0000:${yl}:${id}:2:${xl}"
54
55	epair=$(vnet_mkepair)
56	ifconfig ${epair}a up
57	ifconfig ${epair}a inet6 ${ip6a}/64
58
59	jname="v6t-${id}-${yl}-${xl}"
60	vnet_mkjail ${jname} ${epair}b
61	jexec ${jname} ifconfig ${epair}b up
62	jexec ${jname} ifconfig ${epair}b inet6 ${ip6b}/64
63
64	# Let IPv6 ND do its thing.
65	#ping6 -q -c 1 ff02::1%${epair}a
66	#ping6 -q -c 1 ${ip6b}
67	sleep 3
68
69	pyname=$(atf_get ident)
70
71	atf_check -s exit:0 $(atf_get_srcdir)/mld.py \
72		--sendif ${epair}a --recvif ${epair}a \
73		--src ${ip6a} --to  ${ip6b} \
74		--${pyname}
75}
76
77mldraw01_cleanup() {
78
79	vnet_cleanup
80}
81
82atf_test_case "pr233683" "cleanup"
83pr233683_head() {
84
85	atf_set descr 'Test for PR233683'
86	atf_set require.user root
87}
88
89pr233683_body() {
90	j="mld:pr233683"
91
92	vnet_init
93
94	epair=$(vnet_mkepair)
95
96	vnet_mkjail ${j}a ${epair}a
97	jexec ${j}a ifconfig ${epair}a inet6 2001:db8::1/64 up
98	sleep 5
99
100	jexec ${j}a ifconfig ${epair}a inet6 2001:db8::1/64
101
102	vnet_mkjail ${j}b ${epair}b
103	jexec ${j}b ifconfig ${epair}b inet6 2001:db8::2/64 up
104
105	# Allow DAD to run
106	sleep 5
107
108	# Debug output. If the bug is present we'd expect to not see a
109	# membership for ff02::1:ff00:1
110	jexec ${j}a ifmcstat -i ${epair}a
111	jexec ${j}a ifconfig ${epair}a
112
113	atf_check -s exit:0 -o ignore \
114	    jexec ${j}b ping -6 -c 1 2001:db8::1
115}
116
117pr233683_cleanup() {
118
119	vnet_cleanup
120}
121atf_init_test_cases()
122{
123
124	atf_add_test_case "mldraw01"
125	atf_add_test_case "pr233683"
126}
127
128# end
129