2 # SPDX-License-Identifier: BSD-2-Clause
4 # Copyright (c) 2019 Netflix, Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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.
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
28 . $(atf_get_srcdir)/frag6.subr
30 frag6_07_check_stats() {
37 "") echo "ERROR: jname is empty"; return ;;
40 "") echo "ERROR: ifname is empty"; return ;;
43 # Defaults are: IPV6_FRAGTTL 120 slowtimo ticks.
44 # pfslowtimo() is run at hz/2. So this takes 60s.
45 # This is awefully long for a test case.
46 # The Python script has to wait for this already to get the ICMPv6
47 # hence we do not sleep here anymore.
49 nf=`jexec ${jname} sysctl -n net.inet6.ip6.frag6_nfragpackets`
52 *) atf_fail "VNET frag6_nfragpackets not 0 but: ${nf}" ;;
54 nf=`sysctl -n net.inet6.ip6.frag6_nfrags`
57 *) atf_fail "Global frag6_nfrags not 0 but: ${nf}" ;;
61 # Check selection of global UDP stats.
63 cat <<EOF > ${HOME}/filter-${jname}.txt
64 <received-datagrams>0</received-datagrams>
65 <dropped-incomplete-headers>0</dropped-incomplete-headers>
66 <dropped-bad-data-length>0</dropped-bad-data-length>
67 <dropped-bad-checksum>0</dropped-bad-checksum>
68 <dropped-no-checksum>0</dropped-no-checksum>
69 <dropped-no-socket>0</dropped-no-socket>
70 <dropped-broadcast-multicast>0</dropped-broadcast-multicast>
71 <dropped-full-socket-buffer>0</dropped-full-socket-buffer>
72 <not-for-hashed-pcb>0</not-for-hashed-pcb>
74 count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
75 rm -f ${HOME}/filter-${jname}.txt
78 *) jexec ${jname} netstat -s -p udp --libxo xml,pretty
79 atf_fail "Global UDP statistics do not match: ${count} != 9" ;;
84 # Check selection of global IPv6 stats.
85 # XXX-BZ Only ICMPv6 errors and no proper stats!
87 cat <<EOF > ${HOME}/filter-${jname}.txt
88 <dropped-below-minimum-size>0</dropped-below-minimum-size>
89 <dropped-short-packets>0</dropped-short-packets>
90 <dropped-bad-options>0</dropped-bad-options>
91 <dropped-bad-version>0</dropped-bad-version>
92 <received-fragments>3</received-fragments>
93 <dropped-fragment>0</dropped-fragment>
94 <dropped-fragment-after-timeout>1</dropped-fragment-after-timeout>
95 <dropped-fragments-overflow>0</dropped-fragments-overflow>
96 <atomic-fragments>0</atomic-fragments>
97 <reassembled-packets>0</reassembled-packets>
98 <forwarded-packets>0</forwarded-packets>
99 <packets-not-forwardable>0</packets-not-forwardable>
100 <sent-redirects>0</sent-redirects>
101 <send-packets-fabricated-header>0</send-packets-fabricated-header>
102 <discard-no-mbufs>0</discard-no-mbufs>
103 <discard-no-route>0</discard-no-route>
104 <sent-fragments>0</sent-fragments>
105 <fragments-created>0</fragments-created>
106 <discard-cannot-fragment>0</discard-cannot-fragment>
107 <discard-scope-violations>0</discard-scope-violations>
109 count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
110 rm -f ${HOME}/filter-${jname}.txt
113 *) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty
114 atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;;
118 # Check selection of global ICMPv6 stats.
119 # XXX-TODO check output histogram (just too hard to parse [no multi-line-grep])
121 cat <<EOF > ${HOME}/filter-${jname}.txt
122 <icmp6-calls>3</icmp6-calls>
123 <no-route>0</no-route>
124 <admin-prohibited>0</admin-prohibited>
125 <beyond-scope>0</beyond-scope>
126 <address-unreachable>0</address-unreachable>
127 <port-unreachable>0</port-unreachable>
128 <packet-too-big>0</packet-too-big>
129 <time-exceed-transmit>0</time-exceed-transmit>
130 <time-exceed-reassembly>1</time-exceed-reassembly>
131 <bad-header>2</bad-header>
132 <bad-next-header>0</bad-next-header>
133 <bad-option>0</bad-option>
134 <redirects>0</redirects>
137 <too-many-nd-options>0</too-many-nd-options>
138 <bad-nd-options>0</bad-nd-options>
139 <bad-neighbor-solicitation>0</bad-neighbor-solicitation>
140 <bad-neighbor-advertisement>0</bad-neighbor-advertisement>
141 <bad-router-solicitation>0</bad-router-solicitation>
142 <bad-router-advertisement>0</bad-router-advertisement>
143 <bad-redirect>0</bad-redirect>
145 count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
146 rm -f ${HOME}/filter-${jname}.txt
149 *) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty
150 atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;;
154 # Check selection of interface IPv6 stats.
156 cat <<EOF > ${HOME}/filter-${jname}.txt
157 <dropped-invalid-header>0</dropped-invalid-header>
158 <dropped-mtu-exceeded>0</dropped-mtu-exceeded>
159 <dropped-no-route>0</dropped-no-route>
160 <dropped-invalid-destination>0</dropped-invalid-destination>
161 <dropped-unknown-protocol>0</dropped-unknown-protocol>
162 <dropped-truncated>0</dropped-truncated>
163 <sent-forwarded>0</sent-forwarded>
164 <discard-packets>0</discard-packets>
165 <discard-fragments>0</discard-fragments>
166 <fragments-failed>0</fragments-failed>
167 <fragments-created>0</fragments-created>
168 <reassembly-required>3</reassembly-required>
169 <reassembled-packets>0</reassembled-packets>
170 <reassembly-failed>0</reassembly-failed>
172 count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
173 rm -f ${HOME}/filter-${jname}.txt
176 *) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty
177 atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;
181 # Check selection of interface ICMPv6 stats.
183 cat <<EOF > ${HOME}/filter-${jname}.txt
184 <received-errors>0</received-errors>
185 <received-destination-unreachable>0</received-destination-unreachable>
186 <received-admin-prohibited>0</received-admin-prohibited>
187 <received-time-exceeded>0</received-time-exceeded>
188 <received-bad-parameter>0</received-bad-parameter>
189 <received-packet-too-big>0</received-packet-too-big>
190 <received-echo-requests>0</received-echo-requests>
191 <received-echo-replies>0</received-echo-replies>
192 <received-router-solicitation>0</received-router-solicitation>
193 <received-router-advertisement>0</received-router-advertisement>
194 <sent-errors>3</sent-errors>
195 <sent-destination-unreachable>0</sent-destination-unreachable>
196 <sent-admin-prohibited>0</sent-admin-prohibited>
197 <sent-time-exceeded>1</sent-time-exceeded>
198 <sent-bad-parameter>2</sent-bad-parameter>
199 <sent-packet-too-big>0</sent-packet-too-big>
200 <sent-echo-requests>0</sent-echo-requests>
201 <sent-echo-replies>0</sent-echo-replies>
202 <sent-router-solicitation>0</sent-router-solicitation>
203 <sent-router-advertisement>0</sent-router-advertisement>
204 <sent-redirects>0</sent-redirects>
206 count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`
207 rm -f ${HOME}/filter-${jname}.txt
210 *) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty
211 atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;
215 atf_test_case "frag6_07" "cleanup"
221 if [ "$(atf_config_get ci false)" = "true" ]; then
222 atf_skip "https://bugs.freebsd.org/244170"
224 frag6_body 7 frag6_07_check_stats
231 atf_init_test_cases()
233 atf_add_test_case "frag6_07"