Path: blob/main/tests/sys/netinet6/frag6/frag6_01.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.subr2829atf_test_case "frag6_01" "cleanup"30frag6_01_head() {31frag6_head 132}3334frag6_01_check_stats() {3536local jname ifname37jname=$138ifname=$23940case "${jname}" in41"") echo "ERROR: jname is empty"; return ;;42esac43case "${ifname}" in44"") echo "ERROR: ifname is empty"; return ;;45esac4647# Defaults are: IPV6_FRAGTTL 120 slowtimo ticks.48# pfslowtimo() is run at hz/2. So this takes 60s.49# This is awefully long for a test case.50# The Python script has to wait for this already to get the ICMPv651# hence we do not sleep here anymore.5253nf=`jexec ${jname} sysctl -n net.inet6.ip6.frag6_nfragpackets`54case ${nf} in550) break ;;56*) atf_fail "VNET frag6_nfragpackets not 0 but: ${nf}" ;;57esac58nf=`sysctl -n net.inet6.ip6.frag6_nfrags`59case ${nf} in600) break ;;61*) atf_fail "Global frag6_nfrags not 0 but: ${nf}" ;;62esac6364#65# Check selection of global UDP stats.66#67cat <<EOF > ${HOME}/filter-${jname}.txt68<received-datagrams>0</received-datagrams>69<dropped-incomplete-headers>0</dropped-incomplete-headers>70<dropped-bad-data-length>0</dropped-bad-data-length>71<dropped-bad-checksum>0</dropped-bad-checksum>72<dropped-no-checksum>0</dropped-no-checksum>73<dropped-no-socket>0</dropped-no-socket>74<dropped-broadcast-multicast>0</dropped-broadcast-multicast>75<dropped-full-socket-buffer>0</dropped-full-socket-buffer>76<not-for-hashed-pcb>0</not-for-hashed-pcb>77EOF78count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`79rm -f ${HOME}/filter-${jname}.txt80case ${count} in819) ;;82*) jexec ${jname} netstat -s -p udp --libxo xml,pretty83atf_fail "Global UDP statistics do not match: ${count} != 9" ;;84esac8586#87# Check selection of global IPv6 stats.88#89cat <<EOF > ${HOME}/filter-${jname}.txt90<dropped-below-minimum-size>0</dropped-below-minimum-size>91<dropped-short-packets>0</dropped-short-packets>92<dropped-bad-options>1</dropped-bad-options>93<dropped-bad-version>0</dropped-bad-version>94<received-fragments>0</received-fragments>95<dropped-fragment>0</dropped-fragment>96<dropped-fragment-after-timeout>0</dropped-fragment-after-timeout>97<dropped-fragments-overflow>0</dropped-fragments-overflow>98<atomic-fragments>0</atomic-fragments>99<reassembled-packets>0</reassembled-packets>100<forwarded-packets>0</forwarded-packets>101<packets-not-forwardable>0</packets-not-forwardable>102<sent-redirects>0</sent-redirects>103<send-packets-fabricated-header>0</send-packets-fabricated-header>104<discard-no-mbufs>0</discard-no-mbufs>105<discard-no-route>0</discard-no-route>106<sent-fragments>0</sent-fragments>107<fragments-created>0</fragments-created>108<discard-cannot-fragment>0</discard-cannot-fragment>109<discard-scope-violations>0</discard-scope-violations>110EOF111count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`112rm -f ${HOME}/filter-${jname}.txt113case ${count} in11420) ;;115*) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty116atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;;117esac118119#120# Check selection of global ICMPv6 stats.121#122cat <<EOF > ${HOME}/filter-${jname}.txt123<icmp6-calls>1</icmp6-calls>124<no-route>0</no-route>125<admin-prohibited>0</admin-prohibited>126<beyond-scope>0</beyond-scope>127<address-unreachable>0</address-unreachable>128<port-unreachable>0</port-unreachable>129<packet-too-big>0</packet-too-big>130<time-exceed-transmit>0</time-exceed-transmit>131<time-exceed-reassembly>0</time-exceed-reassembly>132<bad-header>1</bad-header>133<bad-next-header>0</bad-next-header>134<bad-option>0</bad-option>135<redirects>0</redirects>136<unknown>0</unknown>137<reflect>0</reflect>138<too-many-nd-options>0</too-many-nd-options>139<bad-nd-options>0</bad-nd-options>140<bad-neighbor-solicitation>0</bad-neighbor-solicitation>141<bad-neighbor-advertisement>0</bad-neighbor-advertisement>142<bad-router-solicitation>0</bad-router-solicitation>143<bad-router-advertisement>0</bad-router-advertisement>144<bad-redirect>0</bad-redirect>145EOF146count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`147rm -f ${HOME}/filter-${jname}.txt148case ${count} in14922) ;;150*) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty151atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;;152esac153154#155# Check selection of interface IPv6 stats.156# XXX-BZ TODO FIXME reassembly-failed should be 1?157#158cat <<EOF > ${HOME}/filter-${jname}.txt159<dropped-invalid-header>0</dropped-invalid-header>160<dropped-mtu-exceeded>0</dropped-mtu-exceeded>161<dropped-no-route>0</dropped-no-route>162<dropped-invalid-destination>0</dropped-invalid-destination>163<dropped-unknown-protocol>0</dropped-unknown-protocol>164<dropped-truncated>0</dropped-truncated>165<sent-forwarded>0</sent-forwarded>166<discard-packets>0</discard-packets>167<discard-fragments>0</discard-fragments>168<fragments-failed>0</fragments-failed>169<fragments-created>0</fragments-created>170<reassembly-required>0</reassembly-required>171<reassembled-packets>0</reassembled-packets>172<reassembly-failed>0</reassembly-failed>173EOF174count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`175rm -f ${HOME}/filter-${jname}.txt176case ${count} in17714) ;;178*) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty179atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;180esac181182#183# Check selection of interface ICMPv6 stats.184#185cat <<EOF > ${HOME}/filter-${jname}.txt186<received-errors>0</received-errors>187<received-destination-unreachable>0</received-destination-unreachable>188<received-admin-prohibited>0</received-admin-prohibited>189<received-time-exceeded>0</received-time-exceeded>190<received-bad-parameter>0</received-bad-parameter>191<received-packet-too-big>0</received-packet-too-big>192<received-echo-requests>0</received-echo-requests>193<received-echo-replies>0</received-echo-replies>194<received-router-solicitation>0</received-router-solicitation>195<received-router-advertisement>0</received-router-advertisement>196<sent-errors>1</sent-errors>197<sent-destination-unreachable>0</sent-destination-unreachable>198<sent-admin-prohibited>0</sent-admin-prohibited>199<sent-time-exceeded>0</sent-time-exceeded>200<sent-bad-parameter>1</sent-bad-parameter>201<sent-packet-too-big>0</sent-packet-too-big>202<sent-echo-requests>0</sent-echo-requests>203<sent-echo-replies>0</sent-echo-replies>204<sent-router-solicitation>0</sent-router-solicitation>205<sent-router-advertisement>0</sent-router-advertisement>206<sent-redirects>0</sent-redirects>207EOF208count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`209rm -f ${HOME}/filter-${jname}.txt210case ${count} in21121) ;;212*) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty213atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;214esac215}216217frag6_01_body() {218219atf_skip "Sending IPv6 Jumbograms needs 1 kernel changes and BPF fixes"220221frag6_body 1 frag6_01_check_stats222}223224frag6_01_cleanup() {225frag6_cleanup 1226}227228atf_init_test_cases()229{230atf_add_test_case "frag6_01"231}232233234