1# $FreeBSD$ 2#- 3# SPDX-License-Identifier: BSD-2-Clause 4# 5# Copyright (c) 2019 Netflix, Inc. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 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. 15# 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 26# SUCH DAMAGE. 27# 28 29. $(atf_get_srcdir)/frag6.subr 30 31atf_test_case "frag6_10" "cleanup" 32frag6_10_head() { 33 frag6_head 10 34} 35 36frag6_10_check_stats() { 37 38 local jname ifname 39 jname=$1 40 ifname=$2 41 42 case "${jname}" in 43 "") echo "ERROR: jname is empty"; return ;; 44 esac 45 case "${ifname}" in 46 "") echo "ERROR: ifname is empty"; return ;; 47 esac 48 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. 54 55 56 # 57 # Check selection of global UDP stats. 58 # 59 cat <<EOF > ${HOME}/filter-${jname}.txt 60 <received-datagrams>0</received-datagrams> 61 <dropped-incomplete-headers>0</dropped-incomplete-headers> 62 <dropped-bad-data-length>0</dropped-bad-data-length> 63 <dropped-bad-checksum>0</dropped-bad-checksum> 64 <dropped-no-checksum>0</dropped-no-checksum> 65 <dropped-no-socket>0</dropped-no-socket> 66 <dropped-broadcast-multicast>0</dropped-broadcast-multicast> 67 <dropped-full-socket-buffer>0</dropped-full-socket-buffer> 68 <not-for-hashed-pcb>0</not-for-hashed-pcb> 69EOF 70 count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt` 71 rm -f ${HOME}/filter-${jname}.txt 72 case ${count} in 73 9) ;; 74 *) jexec ${jname} netstat -s -p udp --libxo xml,pretty 75 atf_fail "Global UDP statistics do not match: ${count} != 9" ;; 76 esac 77 78 # 79 # Check selection of global IPv6 stats. 80 # We do not seem to sent a timeout ICMPv6 for this one? 81 # No, as it is not an off=0 segment. 82 # 83 cat <<EOF > ${HOME}/filter-${jname}.txt 84 <dropped-below-minimum-size>0</dropped-below-minimum-size> 85 <dropped-short-packets>0</dropped-short-packets> 86 <dropped-bad-options>0</dropped-bad-options> 87 <dropped-bad-version>0</dropped-bad-version> 88 <received-fragments>1</received-fragments> 89 <dropped-fragment>0</dropped-fragment> 90 <dropped-fragment-after-timeout>0</dropped-fragment-after-timeout> 91 <dropped-fragments-overflow>0</dropped-fragments-overflow> 92 <atomic-fragments>0</atomic-fragments> 93 <reassembled-packets>0</reassembled-packets> 94 <forwarded-packets>0</forwarded-packets> 95 <packets-not-forwardable>0</packets-not-forwardable> 96 <sent-redirects>0</sent-redirects> 97 <send-packets-fabricated-header>0</send-packets-fabricated-header> 98 <discard-no-mbufs>0</discard-no-mbufs> 99 <discard-no-route>0</discard-no-route> 100 <sent-fragments>0</sent-fragments> 101 <fragments-created>0</fragments-created> 102 <discard-cannot-fragment>0</discard-cannot-fragment> 103 <discard-scope-violations>0</discard-scope-violations> 104EOF 105 count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt` 106 rm -f ${HOME}/filter-${jname}.txt 107 case ${count} in 108 20) ;; 109 *) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty 110 atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;; 111 esac 112 113 # 114 # Check selection of global ICMPv6 stats. 115 # 116 cat <<EOF > ${HOME}/filter-${jname}.txt 117 <icmp6-calls>0</icmp6-calls> 118 <no-route>0</no-route> 119 <admin-prohibited>0</admin-prohibited> 120 <beyond-scope>0</beyond-scope> 121 <address-unreachable>0</address-unreachable> 122 <port-unreachable>0</port-unreachable> 123 <packet-too-big>0</packet-too-big> 124 <time-exceed-transmit>0</time-exceed-transmit> 125 <time-exceed-reassembly>0</time-exceed-reassembly> 126 <bad-header>0</bad-header> 127 <bad-next-header>0</bad-next-header> 128 <bad-option>0</bad-option> 129 <redirects>0</redirects> 130 <unknown>0</unknown> 131 <reflect>0</reflect> 132 <too-many-nd-options>0</too-many-nd-options> 133 <bad-nd-options>0</bad-nd-options> 134 <bad-neighbor-solicitation>0</bad-neighbor-solicitation> 135 <bad-neighbor-advertisement>0</bad-neighbor-advertisement> 136 <bad-router-solicitation>0</bad-router-solicitation> 137 <bad-router-advertisement>0</bad-router-advertisement> 138 <bad-redirect>0</bad-redirect> 139EOF 140 count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt` 141 rm -f ${HOME}/filter-${jname}.txt 142 case ${count} in 143 22) ;; 144 *) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty 145 atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;; 146 esac 147 148 # 149 # Check selection of interface IPv6 stats. 150 # 151 cat <<EOF > ${HOME}/filter-${jname}.txt 152 <dropped-invalid-header>0</dropped-invalid-header> 153 <dropped-mtu-exceeded>0</dropped-mtu-exceeded> 154 <dropped-no-route>0</dropped-no-route> 155 <dropped-invalid-destination>0</dropped-invalid-destination> 156 <dropped-unknown-protocol>0</dropped-unknown-protocol> 157 <dropped-truncated>0</dropped-truncated> 158 <sent-forwarded>0</sent-forwarded> 159 <discard-packets>0</discard-packets> 160 <discard-fragments>0</discard-fragments> 161 <fragments-failed>0</fragments-failed> 162 <fragments-created>0</fragments-created> 163 <reassembly-required>1</reassembly-required> 164 <reassembled-packets>0</reassembled-packets> 165 <reassembly-failed>0</reassembly-failed> 166EOF 167 count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt` 168 rm -f ${HOME}/filter-${jname}.txt 169 case ${count} in 170 14) ;; 171 *) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty 172 atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;; 173 esac 174 175 # 176 # Check selection of interface ICMPv6 stats. 177 # 178 cat <<EOF > ${HOME}/filter-${jname}.txt 179 <received-errors>0</received-errors> 180 <received-destination-unreachable>0</received-destination-unreachable> 181 <received-admin-prohibited>0</received-admin-prohibited> 182 <received-time-exceeded>0</received-time-exceeded> 183 <received-bad-parameter>0</received-bad-parameter> 184 <received-packet-too-big>0</received-packet-too-big> 185 <received-echo-requests>0</received-echo-requests> 186 <received-echo-replies>0</received-echo-replies> 187 <received-router-solicitation>0</received-router-solicitation> 188 <received-router-advertisement>0</received-router-advertisement> 189 <sent-errors>0</sent-errors> 190 <sent-destination-unreachable>0</sent-destination-unreachable> 191 <sent-admin-prohibited>0</sent-admin-prohibited> 192 <sent-time-exceeded>0</sent-time-exceeded> 193 <sent-bad-parameter>0</sent-bad-parameter> 194 <sent-packet-too-big>0</sent-packet-too-big> 195 <sent-echo-requests>0</sent-echo-requests> 196 <sent-echo-replies>0</sent-echo-replies> 197 <sent-router-solicitation>0</sent-router-solicitation> 198 <sent-router-advertisement>0</sent-router-advertisement> 199 <sent-redirects>0</sent-redirects> 200EOF 201 count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt` 202 rm -f ${HOME}/filter-${jname}.txt 203 case ${count} in 204 21) ;; 205 *) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty 206 atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;; 207 esac 208} 209 210frag6_10_body() { 211 frag6_body 10 frag6_10_check_stats 212} 213 214frag6_10_cleanup() { 215 frag6_cleanup 10 216} 217 218atf_init_test_cases() 219{ 220 atf_add_test_case "frag6_10" 221} 222