Path: blob/main/tests/sys/netinet6/frag6/frag6_15.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_15_pre_test() {3031local jname ifname32jname=$13334case "${jname}" in35"") echo "ERROR: jname is empty"; return ;;36esac3738# Accept 3 fragments per fragmented packet.39jexec ${jname} sysctl net.inet6.ip6.maxfragsperpacket=340}414243frag6_15_check_stats() {4445local jname ifname46jname=$147ifname=$24849case "${jname}" in50"") echo "ERROR: jname is empty"; return ;;51esac52case "${ifname}" in53"") echo "ERROR: ifname is empty"; return ;;54esac5556# Defaults are: IPV6_FRAGTTL 120 slowtimo ticks.57# pfslowtimo() is run at hz/2. So this takes 60s.58# This is awefully long for a test case.59# The Python script has to wait for this already to get the ICMPv660# hence we do not sleep here anymore.6162nf=`jexec ${jname} sysctl -n net.inet6.ip6.frag6_nfragpackets`63case ${nf} in640) break ;;65*) atf_fail "VNET frag6_nfragpackets not 0 but: ${nf}" ;;66esac67nf=`sysctl -n net.inet6.ip6.frag6_nfrags`68case ${nf} in690) break ;;70*) atf_fail "Global frag6_nfrags not 0 but: ${nf}" ;;71esac7273#74# Check that the sysctl is set to what we expect.75#76sn=`jexec ${jname} sysctl -n net.inet6.ip6.maxfragsperpacket`77case "${sn}" in783) ;;79*) atf_fail "Sysctl net.inet6.ip6.maxfragsperpacket is ${sn} and not 3" ;;80esac8182#83# Check selection of global UDP stats.84#85cat <<EOF > ${HOME}/filter-${jname}.txt86<received-datagrams>0</received-datagrams>87<dropped-incomplete-headers>0</dropped-incomplete-headers>88<dropped-bad-data-length>0</dropped-bad-data-length>89<dropped-bad-checksum>0</dropped-bad-checksum>90<dropped-no-checksum>0</dropped-no-checksum>91<dropped-no-socket>0</dropped-no-socket>92<dropped-broadcast-multicast>0</dropped-broadcast-multicast>93<dropped-full-socket-buffer>0</dropped-full-socket-buffer>94<not-for-hashed-pcb>0</not-for-hashed-pcb>95EOF96count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`97rm -f ${HOME}/filter-${jname}.txt98case ${count} in999) ;;100*) jexec ${jname} netstat -s -p udp --libxo xml,pretty101atf_fail "Global UDP statistics do not match: ${count} != 9" ;;102esac103104105#106# Check selection of global IPv6 stats.107#108cat <<EOF > ${HOME}/filter-${jname}.txt109<dropped-below-minimum-size>0</dropped-below-minimum-size>110<dropped-short-packets>0</dropped-short-packets>111<dropped-bad-options>0</dropped-bad-options>112<dropped-bad-version>0</dropped-bad-version>113<received-fragments>8</received-fragments>114<dropped-fragment>8</dropped-fragment>115<dropped-fragment-after-timeout>0</dropped-fragment-after-timeout>116<dropped-fragments-overflow>0</dropped-fragments-overflow>117<atomic-fragments>0</atomic-fragments>118<reassembled-packets>0</reassembled-packets>119<forwarded-packets>0</forwarded-packets>120<packets-not-forwardable>0</packets-not-forwardable>121<sent-redirects>0</sent-redirects>122<send-packets-fabricated-header>0</send-packets-fabricated-header>123<discard-no-mbufs>0</discard-no-mbufs>124<discard-no-route>0</discard-no-route>125<sent-fragments>0</sent-fragments>126<fragments-created>0</fragments-created>127<discard-cannot-fragment>0</discard-cannot-fragment>128<discard-scope-violations>0</discard-scope-violations>129EOF130count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`131rm -f ${HOME}/filter-${jname}.txt132case ${count} in13320) ;;134*) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty135atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;;136esac137138#139# Check selection of global ICMPv6 stats.140# XXX-TODO check output histogram (just too hard to parse [no multi-line-grep])141#142cat <<EOF > ${HOME}/filter-${jname}.txt143<icmp6-calls>1</icmp6-calls>144<no-route>0</no-route>145<admin-prohibited>0</admin-prohibited>146<beyond-scope>0</beyond-scope>147<address-unreachable>0</address-unreachable>148<port-unreachable>0</port-unreachable>149<packet-too-big>0</packet-too-big>150<time-exceed-transmit>0</time-exceed-transmit>151<time-exceed-reassembly>1</time-exceed-reassembly>152<bad-header>0</bad-header>153<bad-next-header>0</bad-next-header>154<bad-option>0</bad-option>155<redirects>0</redirects>156<unknown>0</unknown>157<reflect>0</reflect>158<too-many-nd-options>0</too-many-nd-options>159<bad-nd-options>0</bad-nd-options>160<bad-neighbor-solicitation>0</bad-neighbor-solicitation>161<bad-neighbor-advertisement>0</bad-neighbor-advertisement>162<bad-router-solicitation>0</bad-router-solicitation>163<bad-router-advertisement>0</bad-router-advertisement>164<bad-redirect>0</bad-redirect>165EOF166count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`167rm -f ${HOME}/filter-${jname}.txt168case ${count} in16922) ;;170*) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty171atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;;172esac173174#175# Check selection of interface IPv6 stats.176# XXX-BZ no reassembly failed stats.#177#178cat <<EOF > ${HOME}/filter-${jname}.txt179<dropped-invalid-header>0</dropped-invalid-header>180<dropped-mtu-exceeded>0</dropped-mtu-exceeded>181<dropped-no-route>0</dropped-no-route>182<dropped-invalid-destination>0</dropped-invalid-destination>183<dropped-unknown-protocol>0</dropped-unknown-protocol>184<dropped-truncated>0</dropped-truncated>185<sent-forwarded>0</sent-forwarded>186<discard-packets>0</discard-packets>187<discard-fragments>0</discard-fragments>188<fragments-failed>0</fragments-failed>189<fragments-created>0</fragments-created>190<reassembly-required>8</reassembly-required>191<reassembled-packets>0</reassembled-packets>192<reassembly-failed>0</reassembly-failed>193EOF194count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`195rm -f ${HOME}/filter-${jname}.txt196case ${count} in19714) ;;198*) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty199atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;200esac201202#203# Check selection of interface ICMPv6 stats.204#205cat <<EOF > ${HOME}/filter-${jname}.txt206<received-errors>0</received-errors>207<received-destination-unreachable>0</received-destination-unreachable>208<received-admin-prohibited>0</received-admin-prohibited>209<received-time-exceeded>0</received-time-exceeded>210<received-bad-parameter>0</received-bad-parameter>211<received-packet-too-big>0</received-packet-too-big>212<received-echo-requests>0</received-echo-requests>213<received-echo-replies>0</received-echo-replies>214<received-router-solicitation>0</received-router-solicitation>215<received-router-advertisement>0</received-router-advertisement>216<sent-errors>1</sent-errors>217<sent-destination-unreachable>0</sent-destination-unreachable>218<sent-admin-prohibited>0</sent-admin-prohibited>219<sent-time-exceeded>1</sent-time-exceeded>220<sent-bad-parameter>0</sent-bad-parameter>221<sent-packet-too-big>0</sent-packet-too-big>222<sent-echo-requests>0</sent-echo-requests>223<sent-echo-replies>0</sent-echo-replies>224<sent-router-solicitation>0</sent-router-solicitation>225<sent-router-advertisement>0</sent-router-advertisement>226<sent-redirects>0</sent-redirects>227EOF228count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`229rm -f ${HOME}/filter-${jname}.txt230case ${count} in23121) ;;232*) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty233atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;234esac235}236237atf_test_case "frag6_15" "cleanup"238frag6_15_head() {239frag6_head 15240}241242frag6_15_body() {243frag6_body 15 frag6_15_check_stats frag6_15_pre_test244}245246frag6_15_cleanup() {247frag6_cleanup 15248249# No need to restore the sysctl back to default as the jail is gone.250}251252atf_init_test_cases()253{254atf_add_test_case "frag6_15"255}256257258