Path: blob/main/tests/sys/netinet6/frag6/frag6_20.sh
39482 views
#-1# SPDX-License-Identifier: BSD-2-Clause2#3# Copyright (c) 2019 Netflix, Inc.4#5# Redistribution and use in source and binary forms, with or without6# modification, are permitted provided that the following conditions7# are met:8# 1. Redistributions of source code must retain the above copyright9# notice, this list of conditions and the following disclaimer.10# 2. Redistributions in binary form must reproduce the above copyright11# notice, this list of conditions and the following disclaimer in the12# documentation and/or other materials provided with the distribution.13#14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE17# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF24# SUCH DAMAGE.25#2627. $(atf_get_srcdir)/frag6.subr2829frag6_20_check_stats() {3031local jname ifname32jname=$133ifname=$23435case "${jname}" in36"") echo "ERROR: jname is empty"; return ;;37esac38case "${ifname}" in39"") echo "ERROR: ifname is empty"; return ;;40esac4142# Defaults are: IPV6_FRAGTTL 120 slowtimo ticks.43# pfslowtimo() is run at hz/2. So this takes 60s.44# This is awefully long for a test case.45# The Python script has to wait for this already to get the ICMPv646# hence we do not sleep here anymore.4748nf=`jexec ${jname} sysctl -n net.inet6.ip6.frag6_nfragpackets`49case ${nf} in500) break ;;51*) atf_fail "VNET frag6_nfragpackets not 0 but: ${nf}" ;;52esac53nf=`sysctl -n net.inet6.ip6.frag6_nfrags`54case ${nf} in550) break ;;56*) atf_fail "Global frag6_nfrags not 0 but: ${nf}" ;;57esac5859#60# Check selection of global UDP stats.61#62cat <<EOF > ${HOME}/filter-${jname}.txt63<received-datagrams>0</received-datagrams>64<dropped-incomplete-headers>0</dropped-incomplete-headers>65<dropped-bad-data-length>0</dropped-bad-data-length>66<dropped-bad-checksum>0</dropped-bad-checksum>67<dropped-no-checksum>0</dropped-no-checksum>68<dropped-no-socket>0</dropped-no-socket>69<dropped-broadcast-multicast>0</dropped-broadcast-multicast>70<dropped-full-socket-buffer>0</dropped-full-socket-buffer>71<not-for-hashed-pcb>0</not-for-hashed-pcb>72EOF73count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`74rm -f ${HOME}/filter-${jname}.txt75case ${count} in769) ;;77*) jexec ${jname} netstat -s -p udp --libxo xml,pretty78atf_fail "Global UDP statistics do not match: ${count} != 9" ;;79esac808182#83# Check selection of global IPv6 stats.84#85cat <<EOF > ${HOME}/filter-${jname}.txt86<dropped-below-minimum-size>0</dropped-below-minimum-size>87<dropped-short-packets>0</dropped-short-packets>88<dropped-bad-options>0</dropped-bad-options>89<dropped-bad-version>0</dropped-bad-version>90<received-fragments>3</received-fragments>91<dropped-fragment>1</dropped-fragment>92<dropped-fragment-after-timeout>2</dropped-fragment-after-timeout>93<dropped-fragments-overflow>0</dropped-fragments-overflow>94<atomic-fragments>0</atomic-fragments>95<reassembled-packets>0</reassembled-packets>96<forwarded-packets>0</forwarded-packets>97<packets-not-forwardable>0</packets-not-forwardable>98<sent-redirects>0</sent-redirects>99<send-packets-fabricated-header>0</send-packets-fabricated-header>100<discard-no-mbufs>0</discard-no-mbufs>101<discard-no-route>0</discard-no-route>102<sent-fragments>0</sent-fragments>103<fragments-created>0</fragments-created>104<discard-cannot-fragment>0</discard-cannot-fragment>105<discard-scope-violations>0</discard-scope-violations>106EOF107count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`108rm -f ${HOME}/filter-${jname}.txt109case ${count} in11020) ;;111*) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty112atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;;113esac114115#116# Check selection of global ICMPv6 stats.117# XXX-TODO check output histogram (just too hard to parse [no multi-line-grep])118#119cat <<EOF > ${HOME}/filter-${jname}.txt120<icmp6-calls>1</icmp6-calls>121<no-route>0</no-route>122<admin-prohibited>0</admin-prohibited>123<beyond-scope>0</beyond-scope>124<address-unreachable>0</address-unreachable>125<port-unreachable>0</port-unreachable>126<packet-too-big>0</packet-too-big>127<time-exceed-transmit>0</time-exceed-transmit>128<time-exceed-reassembly>1</time-exceed-reassembly>129<bad-header>0</bad-header>130<bad-next-header>0</bad-next-header>131<bad-option>0</bad-option>132<redirects>0</redirects>133<unknown>0</unknown>134<reflect>0</reflect>135<too-many-nd-options>0</too-many-nd-options>136<bad-nd-options>0</bad-nd-options>137<bad-neighbor-solicitation>0</bad-neighbor-solicitation>138<bad-neighbor-advertisement>0</bad-neighbor-advertisement>139<bad-router-solicitation>0</bad-router-solicitation>140<bad-router-advertisement>0</bad-router-advertisement>141<bad-redirect>0</bad-redirect>142EOF143count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`144rm -f ${HOME}/filter-${jname}.txt145case ${count} in14622) ;;147*) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty148atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;;149esac150151#152# Check selection of interface IPv6 stats.153#154cat <<EOF > ${HOME}/filter-${jname}.txt155<dropped-invalid-header>0</dropped-invalid-header>156<dropped-mtu-exceeded>0</dropped-mtu-exceeded>157<dropped-no-route>0</dropped-no-route>158<dropped-invalid-destination>0</dropped-invalid-destination>159<dropped-unknown-protocol>0</dropped-unknown-protocol>160<dropped-truncated>0</dropped-truncated>161<sent-forwarded>0</sent-forwarded>162<discard-packets>0</discard-packets>163<discard-fragments>0</discard-fragments>164<fragments-failed>0</fragments-failed>165<fragments-created>0</fragments-created>166<reassembly-required>3</reassembly-required>167<reassembled-packets>0</reassembled-packets>168<reassembly-failed>1</reassembly-failed>169EOF170count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`171rm -f ${HOME}/filter-${jname}.txt172case ${count} in17314) ;;174*) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty175atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;176esac177178#179# Check selection of interface ICMPv6 stats.180#181cat <<EOF > ${HOME}/filter-${jname}.txt182<received-errors>0</received-errors>183<received-destination-unreachable>0</received-destination-unreachable>184<received-admin-prohibited>0</received-admin-prohibited>185<received-time-exceeded>0</received-time-exceeded>186<received-bad-parameter>0</received-bad-parameter>187<received-packet-too-big>0</received-packet-too-big>188<received-echo-requests>0</received-echo-requests>189<received-echo-replies>0</received-echo-replies>190<received-router-solicitation>0</received-router-solicitation>191<received-router-advertisement>0</received-router-advertisement>192<sent-errors>1</sent-errors>193<sent-destination-unreachable>0</sent-destination-unreachable>194<sent-admin-prohibited>0</sent-admin-prohibited>195<sent-time-exceeded>1</sent-time-exceeded>196<sent-bad-parameter>0</sent-bad-parameter>197<sent-packet-too-big>0</sent-packet-too-big>198<sent-echo-requests>0</sent-echo-requests>199<sent-echo-replies>0</sent-echo-replies>200<sent-router-solicitation>0</sent-router-solicitation>201<sent-router-advertisement>0</sent-router-advertisement>202<sent-redirects>0</sent-redirects>203EOF204count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`205rm -f ${HOME}/filter-${jname}.txt206case ${count} in20721) ;;208*) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty209atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;210esac211}212213atf_test_case "frag6_20" "cleanup"214frag6_20_head() {215frag6_head 20216}217218frag6_20_body() {219frag6_body 20 frag6_20_check_stats220}221222frag6_20_cleanup() {223frag6_cleanup 20224}225226atf_init_test_cases()227{228atf_add_test_case "frag6_20"229}230231232