Path: blob/main/tests/sys/netinet6/frag6/frag6_08.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_08_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# XXX-BZ Only ICMPv6 errors and no proper stats!85#86cat <<EOF > ${HOME}/filter-${jname}.txt87<dropped-below-minimum-size>0</dropped-below-minimum-size>88<dropped-short-packets>0</dropped-short-packets>89<dropped-bad-options>0</dropped-bad-options>90<dropped-bad-version>0</dropped-bad-version>91<received-fragments>2</received-fragments>92<dropped-fragment>0</dropped-fragment>93<dropped-fragment-after-timeout>1</dropped-fragment-after-timeout>94<dropped-fragments-overflow>0</dropped-fragments-overflow>95<atomic-fragments>0</atomic-fragments>96<reassembled-packets>0</reassembled-packets>97<forwarded-packets>0</forwarded-packets>98<packets-not-forwardable>0</packets-not-forwardable>99<sent-redirects>0</sent-redirects>100<send-packets-fabricated-header>0</send-packets-fabricated-header>101<discard-no-mbufs>0</discard-no-mbufs>102<discard-no-route>0</discard-no-route>103<sent-fragments>0</sent-fragments>104<fragments-created>0</fragments-created>105<discard-cannot-fragment>0</discard-cannot-fragment>106<discard-scope-violations>0</discard-scope-violations>107EOF108count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`109rm -f ${HOME}/filter-${jname}.txt110case ${count} in11120) ;;112*) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty113atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;;114esac115116#117# Check selection of global ICMPv6 stats.118# XXX-TODO check output histogram (just too hard to parse [no multi-line-grep])119#120cat <<EOF > ${HOME}/filter-${jname}.txt121<icmp6-calls>2</icmp6-calls>122<no-route>0</no-route>123<admin-prohibited>0</admin-prohibited>124<beyond-scope>0</beyond-scope>125<address-unreachable>0</address-unreachable>126<port-unreachable>0</port-unreachable>127<packet-too-big>0</packet-too-big>128<time-exceed-transmit>0</time-exceed-transmit>129<time-exceed-reassembly>1</time-exceed-reassembly>130<bad-header>1</bad-header>131<bad-next-header>0</bad-next-header>132<bad-option>0</bad-option>133<redirects>0</redirects>134<unknown>0</unknown>135<reflect>0</reflect>136<too-many-nd-options>0</too-many-nd-options>137<bad-nd-options>0</bad-nd-options>138<bad-neighbor-solicitation>0</bad-neighbor-solicitation>139<bad-neighbor-advertisement>0</bad-neighbor-advertisement>140<bad-router-solicitation>0</bad-router-solicitation>141<bad-router-advertisement>0</bad-router-advertisement>142<bad-redirect>0</bad-redirect>143EOF144count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`145rm -f ${HOME}/filter-${jname}.txt146case ${count} in14722) ;;148*) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty149atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;;150esac151152#153# Check selection of interface IPv6 stats.154#155cat <<EOF > ${HOME}/filter-${jname}.txt156<dropped-invalid-header>0</dropped-invalid-header>157<dropped-mtu-exceeded>0</dropped-mtu-exceeded>158<dropped-no-route>0</dropped-no-route>159<dropped-invalid-destination>0</dropped-invalid-destination>160<dropped-unknown-protocol>0</dropped-unknown-protocol>161<dropped-truncated>0</dropped-truncated>162<sent-forwarded>0</sent-forwarded>163<discard-packets>0</discard-packets>164<discard-fragments>0</discard-fragments>165<fragments-failed>0</fragments-failed>166<fragments-created>0</fragments-created>167<reassembly-required>2</reassembly-required>168<reassembled-packets>0</reassembled-packets>169<reassembly-failed>0</reassembly-failed>170EOF171count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`172rm -f ${HOME}/filter-${jname}.txt173case ${count} in17414) ;;175*) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty176atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;177esac178179#180# Check selection of interface ICMPv6 stats.181#182cat <<EOF > ${HOME}/filter-${jname}.txt183<received-errors>0</received-errors>184<received-destination-unreachable>0</received-destination-unreachable>185<received-admin-prohibited>0</received-admin-prohibited>186<received-time-exceeded>0</received-time-exceeded>187<received-bad-parameter>0</received-bad-parameter>188<received-packet-too-big>0</received-packet-too-big>189<received-echo-requests>0</received-echo-requests>190<received-echo-replies>0</received-echo-replies>191<received-router-solicitation>0</received-router-solicitation>192<received-router-advertisement>0</received-router-advertisement>193<sent-errors>2</sent-errors>194<sent-destination-unreachable>0</sent-destination-unreachable>195<sent-admin-prohibited>0</sent-admin-prohibited>196<sent-time-exceeded>1</sent-time-exceeded>197<sent-bad-parameter>1</sent-bad-parameter>198<sent-packet-too-big>0</sent-packet-too-big>199<sent-echo-requests>0</sent-echo-requests>200<sent-echo-replies>0</sent-echo-replies>201<sent-router-solicitation>0</sent-router-solicitation>202<sent-router-advertisement>0</sent-router-advertisement>203<sent-redirects>0</sent-redirects>204EOF205count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`206rm -f ${HOME}/filter-${jname}.txt207case ${count} in20821) ;;209*) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty210atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;211esac212}213214atf_test_case "frag6_08" "cleanup"215frag6_08_head() {216frag6_head 8217}218219frag6_08_body() {220frag6_body 8 frag6_08_check_stats221}222223frag6_08_cleanup() {224frag6_cleanup 8225}226227atf_init_test_cases()228{229atf_add_test_case "frag6_08"230}231232233