3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2019 Netflix, Inc.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
10 # 1. Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
12 # 2. Redistributions in binary form must reproduce the above copyright
13 # notice, this list of conditions and the following disclaimer in the
14 # documentation and/or other materials provided with the distribution.
16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 . $(atf_get_srcdir)/frag6.subr
31 atf_test_case "frag6_10" "cleanup"
36 frag6_10_check_stats() {
43 "") echo "ERROR: jname is empty"; return ;;
46 "") echo "ERROR: ifname is empty"; return ;;
49 # Defaults are: IPV6_FRAGTTL 120 slowtimo ticks.
50 # pfslowtimo() is run at hz/2. So this takes 60s.
51 # This is awefully long for a test case.
52 # The Python script has to wait for this already to get the ICMPv6
53 # hence we do not sleep here anymore.
55 nf=`jexec ${jname} sysctl -n net.inet6.ip6.frag6_nfragpackets`
58 *) atf_fail "VNET frag6_nfragpackets not 0 but: ${nf}" ;;
60 nf=`sysctl -n net.inet6.ip6.frag6_nfrags`
63 *) atf_fail "Global frag6_nfrags not 0 but: ${nf}" ;;
67 # Check selection of global UDP stats.
69 cat <<EOF > ${HOME}/filter-${jname}.txt
70 <received-datagrams>0</received-datagrams>
71 <dropped-incomplete-headers>0</dropped-incomplete-headers>
72 <dropped-bad-data-length>0</dropped-bad-data-length>
73 <dropped-bad-checksum>0</dropped-bad-checksum>
74 <dropped-no-checksum>0</dropped-no-checksum>
75 <dropped-no-socket>0</dropped-no-socket>
76 <dropped-broadcast-multicast>0</dropped-broadcast-multicast>
77 <dropped-full-socket-buffer>0</dropped-full-socket-buffer>
78 <not-for-hashed-pcb>0</not-for-hashed-pcb>
80 count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
81 rm -f ${HOME}/filter-${jname}.txt
84 *) jexec ${jname} netstat -s -p udp --libxo xml,pretty
85 atf_fail "Global UDP statistics do not match: ${count} != 9" ;;
89 # Check selection of global IPv6 stats.
90 # We do not sent a timeout ICMPv6 for this one
91 # as it is not an off=0 segment.
93 cat <<EOF > ${HOME}/filter-${jname}.txt
94 <dropped-below-minimum-size>0</dropped-below-minimum-size>
95 <dropped-short-packets>0</dropped-short-packets>
96 <dropped-bad-options>0</dropped-bad-options>
97 <dropped-bad-version>0</dropped-bad-version>
98 <received-fragments>1</received-fragments>
99 <dropped-fragment>0</dropped-fragment>
100 <dropped-fragment-after-timeout>1</dropped-fragment-after-timeout>
101 <dropped-fragments-overflow>0</dropped-fragments-overflow>
102 <atomic-fragments>0</atomic-fragments>
103 <reassembled-packets>0</reassembled-packets>
104 <forwarded-packets>0</forwarded-packets>
105 <packets-not-forwardable>0</packets-not-forwardable>
106 <sent-redirects>0</sent-redirects>
107 <send-packets-fabricated-header>0</send-packets-fabricated-header>
108 <discard-no-mbufs>0</discard-no-mbufs>
109 <discard-no-route>0</discard-no-route>
110 <sent-fragments>0</sent-fragments>
111 <fragments-created>0</fragments-created>
112 <discard-cannot-fragment>0</discard-cannot-fragment>
113 <discard-scope-violations>0</discard-scope-violations>
115 count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
116 rm -f ${HOME}/filter-${jname}.txt
119 *) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty
120 atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;;
124 # Check selection of global ICMPv6 stats.
126 cat <<EOF > ${HOME}/filter-${jname}.txt
127 <icmp6-calls>0</icmp6-calls>
128 <no-route>0</no-route>
129 <admin-prohibited>0</admin-prohibited>
130 <beyond-scope>0</beyond-scope>
131 <address-unreachable>0</address-unreachable>
132 <port-unreachable>0</port-unreachable>
133 <packet-too-big>0</packet-too-big>
134 <time-exceed-transmit>0</time-exceed-transmit>
135 <time-exceed-reassembly>0</time-exceed-reassembly>
136 <bad-header>0</bad-header>
137 <bad-next-header>0</bad-next-header>
138 <bad-option>0</bad-option>
139 <redirects>0</redirects>
142 <too-many-nd-options>0</too-many-nd-options>
143 <bad-nd-options>0</bad-nd-options>
144 <bad-neighbor-solicitation>0</bad-neighbor-solicitation>
145 <bad-neighbor-advertisement>0</bad-neighbor-advertisement>
146 <bad-router-solicitation>0</bad-router-solicitation>
147 <bad-router-advertisement>0</bad-router-advertisement>
148 <bad-redirect>0</bad-redirect>
150 count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
151 rm -f ${HOME}/filter-${jname}.txt
154 *) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty
155 atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;;
159 # Check selection of interface IPv6 stats.
161 cat <<EOF > ${HOME}/filter-${jname}.txt
162 <dropped-invalid-header>0</dropped-invalid-header>
163 <dropped-mtu-exceeded>0</dropped-mtu-exceeded>
164 <dropped-no-route>0</dropped-no-route>
165 <dropped-invalid-destination>0</dropped-invalid-destination>
166 <dropped-unknown-protocol>0</dropped-unknown-protocol>
167 <dropped-truncated>0</dropped-truncated>
168 <sent-forwarded>0</sent-forwarded>
169 <discard-packets>0</discard-packets>
170 <discard-fragments>0</discard-fragments>
171 <fragments-failed>0</fragments-failed>
172 <fragments-created>0</fragments-created>
173 <reassembly-required>1</reassembly-required>
174 <reassembled-packets>0</reassembled-packets>
175 <reassembly-failed>0</reassembly-failed>
177 count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
178 rm -f ${HOME}/filter-${jname}.txt
181 *) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty
182 atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;
186 # Check selection of interface ICMPv6 stats.
188 cat <<EOF > ${HOME}/filter-${jname}.txt
189 <received-errors>0</received-errors>
190 <received-destination-unreachable>0</received-destination-unreachable>
191 <received-admin-prohibited>0</received-admin-prohibited>
192 <received-time-exceeded>0</received-time-exceeded>
193 <received-bad-parameter>0</received-bad-parameter>
194 <received-packet-too-big>0</received-packet-too-big>
195 <received-echo-requests>0</received-echo-requests>
196 <received-echo-replies>0</received-echo-replies>
197 <received-router-solicitation>0</received-router-solicitation>
198 <received-router-advertisement>0</received-router-advertisement>
199 <sent-errors>0</sent-errors>
200 <sent-destination-unreachable>0</sent-destination-unreachable>
201 <sent-admin-prohibited>0</sent-admin-prohibited>
202 <sent-time-exceeded>0</sent-time-exceeded>
203 <sent-bad-parameter>0</sent-bad-parameter>
204 <sent-packet-too-big>0</sent-packet-too-big>
205 <sent-echo-requests>0</sent-echo-requests>
206 <sent-echo-replies>0</sent-echo-replies>
207 <sent-router-solicitation>0</sent-router-solicitation>
208 <sent-router-advertisement>0</sent-router-advertisement>
209 <sent-redirects>0</sent-redirects>
211 count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
212 rm -f ${HOME}/filter-${jname}.txt
215 *) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty
216 atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;
221 frag6_body 10 frag6_10_check_stats
228 atf_init_test_cases()
230 atf_add_test_case "frag6_10"