1*9c9331d3Smrg# $NetBSD: t_repeated_mtu.sh,v 1.2 2020/12/10 08:16:59 mrg Exp $ 2e643f0eaSjruoho# 3e643f0eaSjruoho# Copyright (c) 2020 The NetBSD Foundation, Inc. 4e643f0eaSjruoho# All rights reserved. 5e643f0eaSjruoho# 6e643f0eaSjruoho# This code is derived from software contributed to The NetBSD Foundation 7e643f0eaSjruoho# by Jukka Ruohonen. 8e643f0eaSjruoho# 9e643f0eaSjruoho# Redistribution and use in source and binary forms, with or without 10e643f0eaSjruoho# modification, are permitted provided that the following conditions 11e643f0eaSjruoho# are met: 12e643f0eaSjruoho# 1. Redistributions of source code must retain the above copyright 13e643f0eaSjruoho# notice, this list of conditions and the following disclaimer. 14e643f0eaSjruoho# 2. Redistributions in binary form must reproduce the above copyright 15e643f0eaSjruoho# notice, this list of conditions and the following disclaimer in the 16e643f0eaSjruoho# documentation and/or other materials provided with the distribution. 17e643f0eaSjruoho# 18e643f0eaSjruoho# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19e643f0eaSjruoho# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20e643f0eaSjruoho# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21e643f0eaSjruoho# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22e643f0eaSjruoho# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23e643f0eaSjruoho# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24e643f0eaSjruoho# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25e643f0eaSjruoho# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26e643f0eaSjruoho# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27e643f0eaSjruoho# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28e643f0eaSjruoho# POSSIBILITY OF SUCH DAMAGE. 29e643f0eaSjruoho# 30e643f0eaSjruoho 31e643f0eaSjruohoatf_test_case repeated_mtu 32e643f0eaSjruohorepeated_mtu_head() { 33e643f0eaSjruoho atf_set "require.user" "root" 34e643f0eaSjruoho atf_set "descr" "Check with ifconfig(8) that setting MTUs works" 35e643f0eaSjruoho} 36e643f0eaSjruoho 37e643f0eaSjruohorepeated_mtu_body() { 38e643f0eaSjruoho 39*9c9331d3Smrg if ! [ $(atf_config_get "run_unsafe" "no") = "yes" ] 40*9c9331d3Smrg then 41*9c9331d3Smrg atf_skip "can disrupt networking; also PR port-evbarm/55521" 42*9c9331d3Smrg fi 43*9c9331d3Smrg 44e643f0eaSjruoho # This sequence covers both valid and invalid MTUs; we are 45e643f0eaSjruoho # only interested in testing that the system does not hang. 46e643f0eaSjruoho # 47e643f0eaSjruoho mtus=$(seq -10000 1000 90000) 48e643f0eaSjruoho 49e643f0eaSjruoho for i in $(ifconfig -l); do 50e643f0eaSjruoho 51e643f0eaSjruoho mtu=$(ifconfig $i | grep "mtu" | sed "s/.*mtu //") 52e643f0eaSjruoho 53e643f0eaSjruoho if [ -z $mtu ]; then 54e643f0eaSjruoho echo "Skipping $i" 55e643f0eaSjruoho continue 56e643f0eaSjruoho fi 57e643f0eaSjruoho 58e643f0eaSjruoho for j in $mtus; do 59e643f0eaSjruoho echo "Request: ifconfig $i mtu $j" 60e643f0eaSjruoho ifconfig $i mtu $j >/dev/null 2>&1 61e643f0eaSjruoho done 62e643f0eaSjruoho 63e643f0eaSjruoho ifconfig $i mtu $mtu 64e643f0eaSjruoho echo "Restored the MTU of $i to $mtu" 65e643f0eaSjruoho done 66e643f0eaSjruoho} 67e643f0eaSjruoho 68e643f0eaSjruohoatf_init_test_cases() { 69e643f0eaSjruoho atf_add_test_case repeated_mtu 70e643f0eaSjruoho} 71