Path: blob/main/tests/sys/netinet6/frag6/frag6_19.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_19_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.4748#49# Check selection of global UDP stats.50#51cat <<EOF > ${HOME}/filter-${jname}.txt52<received-datagrams>0</received-datagrams>53<dropped-incomplete-headers>0</dropped-incomplete-headers>54<dropped-bad-data-length>0</dropped-bad-data-length>55<dropped-bad-checksum>0</dropped-bad-checksum>56<dropped-no-checksum>0</dropped-no-checksum>57<dropped-no-socket>0</dropped-no-socket>58<dropped-broadcast-multicast>0</dropped-broadcast-multicast>59<dropped-full-socket-buffer>0</dropped-full-socket-buffer>60<not-for-hashed-pcb>0</not-for-hashed-pcb>61EOF62count=`jexec ${jname} netstat -s -p udp --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`63rm -f ${HOME}/filter-${jname}.txt64case ${count} in659) ;;66*) jexec ${jname} netstat -s -p udp --libxo xml,pretty67atf_fail "Global UDP statistics do not match: ${count} != 9" ;;68esac697071#72# Check selection of global IPv6 stats.73#74cat <<EOF > ${HOME}/filter-${jname}.txt75<dropped-below-minimum-size>0</dropped-below-minimum-size>76<dropped-short-packets>0</dropped-short-packets>77<dropped-bad-options>0</dropped-bad-options>78<dropped-bad-version>0</dropped-bad-version>79<received-fragments>127</received-fragments>80<dropped-fragment>0</dropped-fragment>81<dropped-fragment-after-timeout>0</dropped-fragment-after-timeout>82<dropped-fragments-overflow>0</dropped-fragments-overflow>83<atomic-fragments>0</atomic-fragments>84<reassembled-packets>0</reassembled-packets>85<forwarded-packets>0</forwarded-packets>86<packets-not-forwardable>0</packets-not-forwardable>87<sent-redirects>0</sent-redirects>88<send-packets-fabricated-header>0</send-packets-fabricated-header>89<discard-no-mbufs>0</discard-no-mbufs>90<discard-no-route>0</discard-no-route>91<sent-fragments>0</sent-fragments>92<fragments-created>0</fragments-created>93<discard-cannot-fragment>0</discard-cannot-fragment>94<discard-scope-violations>0</discard-scope-violations>95EOF96count=`jexec ${jname} netstat -s -p ip6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`97rm -f ${HOME}/filter-${jname}.txt98case ${count} in9920) ;;100*) jexec ${jname} netstat -s -p ip6 --libxo xml,pretty101atf_fail "Global IPv6 statistics do not match: ${count} != 20" ;;102esac103104#105# Check selection of global ICMPv6 stats.106# XXX-TODO check output histogram (just too hard to parse [no multi-line-grep])107#108cat <<EOF > ${HOME}/filter-${jname}.txt109<icmp6-calls>0</icmp6-calls>110<no-route>0</no-route>111<admin-prohibited>0</admin-prohibited>112<beyond-scope>0</beyond-scope>113<address-unreachable>0</address-unreachable>114<port-unreachable>0</port-unreachable>115<packet-too-big>0</packet-too-big>116<time-exceed-transmit>0</time-exceed-transmit>117<time-exceed-reassembly>0</time-exceed-reassembly>118<bad-header>0</bad-header>119<bad-next-header>0</bad-next-header>120<bad-option>0</bad-option>121<redirects>0</redirects>122<unknown>0</unknown>123<reflect>0</reflect>124<too-many-nd-options>0</too-many-nd-options>125<bad-nd-options>0</bad-nd-options>126<bad-neighbor-solicitation>0</bad-neighbor-solicitation>127<bad-neighbor-advertisement>0</bad-neighbor-advertisement>128<bad-router-solicitation>0</bad-router-solicitation>129<bad-router-advertisement>0</bad-router-advertisement>130<bad-redirect>0</bad-redirect>131EOF132count=`jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`133rm -f ${HOME}/filter-${jname}.txt134case ${count} in13522) ;;136*) jexec ${jname} netstat -s -p icmp6 --libxo xml,pretty137atf_fail "Global ICMPv6 statistics do not match: ${count} != 22" ;;138esac139140#141# Check selection of interface IPv6 stats.142# XXX-BZ no reassembly failed stats.#143#144cat <<EOF > ${HOME}/filter-${jname}.txt145<dropped-invalid-header>0</dropped-invalid-header>146<dropped-mtu-exceeded>0</dropped-mtu-exceeded>147<dropped-no-route>0</dropped-no-route>148<dropped-invalid-destination>0</dropped-invalid-destination>149<dropped-unknown-protocol>0</dropped-unknown-protocol>150<dropped-truncated>0</dropped-truncated>151<sent-forwarded>0</sent-forwarded>152<discard-packets>0</discard-packets>153<discard-fragments>0</discard-fragments>154<fragments-failed>0</fragments-failed>155<fragments-created>0</fragments-created>156<reassembly-required>127</reassembly-required>157<reassembled-packets>0</reassembled-packets>158<reassembly-failed>0</reassembly-failed>159EOF160count=`jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`161rm -f ${HOME}/filter-${jname}.txt162case ${count} in16314) ;;164*) jexec ${jname} netstat -s -p ip6 -I ${ifname} --libxo xml,pretty165atf_fail "Interface IPv6 statistics do not match: ${count} != 14" ;;166esac167168#169# Check selection of interface ICMPv6 stats.170#171cat <<EOF > ${HOME}/filter-${jname}.txt172<received-errors>0</received-errors>173<received-destination-unreachable>0</received-destination-unreachable>174<received-admin-prohibited>0</received-admin-prohibited>175<received-time-exceeded>0</received-time-exceeded>176<received-bad-parameter>0</received-bad-parameter>177<received-packet-too-big>0</received-packet-too-big>178<received-echo-requests>0</received-echo-requests>179<received-echo-replies>0</received-echo-replies>180<received-router-solicitation>0</received-router-solicitation>181<received-router-advertisement>0</received-router-advertisement>182<sent-errors>0</sent-errors>183<sent-destination-unreachable>0</sent-destination-unreachable>184<sent-admin-prohibited>0</sent-admin-prohibited>185<sent-time-exceeded>0</sent-time-exceeded>186<sent-bad-parameter>0</sent-bad-parameter>187<sent-packet-too-big>0</sent-packet-too-big>188<sent-echo-requests>0</sent-echo-requests>189<sent-echo-replies>0</sent-echo-replies>190<sent-router-solicitation>0</sent-router-solicitation>191<sent-router-advertisement>0</sent-router-advertisement>192<sent-redirects>0</sent-redirects>193EOF194count=`jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty | grep -E -x -c -f ${HOME}/filter-${jname}.txt`195rm -f ${HOME}/filter-${jname}.txt196case ${count} in19721) ;;198*) jexec ${jname} netstat -s -p icmp6 -I ${ifname} --libxo xml,pretty199atf_fail "Interface ICMPv6 statistics do not match: ${count} != 21" ;;200esac201}202203atf_test_case "frag6_19" "cleanup"204frag6_19_head() {205frag6_head 19206}207208frag6_19_body() {209if [ "$(atf_config_get ci false)" = "true" ]; then210atf_skip "https://bugs.freebsd.org/274941"211fi212frag6_body 19 frag6_19_check_stats213}214215frag6_19_cleanup() {216frag6_cleanup 19217}218219atf_init_test_cases()220{221atf_add_test_case "frag6_19"222}223224225