Path: blob/main/tests/sys/netinet6/frag6/frag6_16.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.subr282930frag6_16_check_stats() {3132local jname ifname33jname=$134ifname=$23536case "${jname}" in37"") echo "ERROR: jname is empty"; return ;;38esac39case "${ifname}" in40"") echo "ERROR: ifname is empty"; return ;;41esac4243# 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 ICMPv647# hence we do not sleep here anymore.4849nf=`jexec ${jname} sysctl -n net.inet6.ip6.frag6_nfragpackets`50case ${nf} in510) break ;;52*) atf_fail "VNET frag6_nfragpackets not 0 but: ${nf}" ;;53esac54nf=`sysctl -n net.inet6.ip6.frag6_nfrags`55case ${nf} in560) break ;;57*) atf_fail "Global frag6_nfrags not 0 but: ${nf}" ;;58esac5960#61# Check selection of global UDP stats.62#63cat <<EOF > ${HOME}/filter-${jname}.txt64<received-datagrams>1</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>1</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>73EOF74count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`75rm -f ${HOME}/filter-${jname}.txt76case ${count} in779) ;;78*) jexec ${jname} netstat -s -p udp --libxo xml,pretty79atf_fail "Global UDP statistics do not match: ${count} != 9" ;;80esac818283#84# Check selection of global IPv6 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>30</received-fragments>92<dropped-fragment>0</dropped-fragment>93<dropped-fragment-after-timeout>0</dropped-fragment-after-timeout>94<dropped-fragments-overflow>0</dropped-fragments-overflow>95<atomic-fragments>0</atomic-fragments>96<reassembled-packets>1</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>1</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>1</port-unreachable>127<packet-too-big>0</packet-too-big>128<time-exceed-transmit>0</time-exceed-transmit>129<time-exceed-reassembly>0</time-exceed-reassembly>130<bad-header>0</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# XXX-BZ no reassembly failed stats.#155#156cat <<EOF > ${HOME}/filter-${jname}.txt157<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>30</reassembly-required>169<reassembled-packets>1</reassembled-packets>170<reassembly-failed>0</reassembly-failed>171EOF172count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`173rm -f ${HOME}/filter-${jname}.txt174case ${count} in17514) ;;176*) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty177atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;178esac179180#181# Check selection of interface ICMPv6 stats.182#183cat <<EOF > ${HOME}/filter-${jname}.txt184<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>1</sent-errors>195<sent-destination-unreachable>1</sent-destination-unreachable>196<sent-admin-prohibited>0</sent-admin-prohibited>197<sent-time-exceeded>0</sent-time-exceeded>198<sent-bad-parameter>0</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>205EOF206count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`207rm -f ${HOME}/filter-${jname}.txt208case ${count} in20921) ;;210*) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty211atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;212esac213}214215atf_test_case "frag6_16" "cleanup"216frag6_16_head() {217frag6_head 16218}219220frag6_16_body() {221frag6_body 16 frag6_16_check_stats222}223224frag6_16_cleanup() {225frag6_cleanup 16226}227228atf_init_test_cases()229{230atf_add_test_case "frag6_16"231}232233234