1f08c3bdfSopenharmony_ci#!/bin/sh 2f08c3bdfSopenharmony_ci 3f08c3bdfSopenharmony_ci################################################################################ 4f08c3bdfSopenharmony_ci## ## 5f08c3bdfSopenharmony_ci## Copyright (c) International Business Machines Corp., 2005 ## 6f08c3bdfSopenharmony_ci## ## 7f08c3bdfSopenharmony_ci## This program is free software; you can redistribute it and#or modify ## 8f08c3bdfSopenharmony_ci## it under the terms of the GNU General Public License as published by ## 9f08c3bdfSopenharmony_ci## the Free Software Foundation; either version 2 of the License, or ## 10f08c3bdfSopenharmony_ci## (at your option) any later version. ## 11f08c3bdfSopenharmony_ci## ## 12f08c3bdfSopenharmony_ci## This program is distributed in the hope that it will be useful, but ## 13f08c3bdfSopenharmony_ci## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ## 14f08c3bdfSopenharmony_ci## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ## 15f08c3bdfSopenharmony_ci## for more details. ## 16f08c3bdfSopenharmony_ci## ## 17f08c3bdfSopenharmony_ci## You should have received a copy of the GNU General Public License ## 18f08c3bdfSopenharmony_ci## along with this program; if not, write to the Free Software ## 19f08c3bdfSopenharmony_ci## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## 20f08c3bdfSopenharmony_ci## ## 21f08c3bdfSopenharmony_ci## ## 22f08c3bdfSopenharmony_ci################################################################################ 23f08c3bdfSopenharmony_ci# 24f08c3bdfSopenharmony_ci# File: 25f08c3bdfSopenharmony_ci# icmp4-multi-diffnic01 26f08c3bdfSopenharmony_ci# 27f08c3bdfSopenharmony_ci# Description: 28f08c3bdfSopenharmony_ci# Verify that the kernel is not crashed with receiving and sending ICMP 29f08c3bdfSopenharmony_ci# message at different NIC with the following conditions 30f08c3bdfSopenharmony_ci# - The version of IP is IPv4 31f08c3bdfSopenharmony_ci# - IPsec is not used 32f08c3bdfSopenharmony_ci# 33f08c3bdfSopenharmony_ci# *) This script may be read by the other test case 34f08c3bdfSopenharmony_ci# 35f08c3bdfSopenharmony_ci# Setup: 36f08c3bdfSopenharmony_ci# See testcases/network/stress/README 37f08c3bdfSopenharmony_ci# 38f08c3bdfSopenharmony_ci# Author: 39f08c3bdfSopenharmony_ci# Mitsuru Chinen <mitch@jp.ibm.com> 40f08c3bdfSopenharmony_ci# 41f08c3bdfSopenharmony_ci# History: 42f08c3bdfSopenharmony_ci# Oct 19 2005 - Created (Mitsuru Chinen) 43f08c3bdfSopenharmony_ci# 44f08c3bdfSopenharmony_ci#----------------------------------------------------------------------- 45f08c3bdfSopenharmony_ci# Uncomment line below for debug output. 46f08c3bdfSopenharmony_ci#trace_logic=${trace_logic:-"set -x"} 47f08c3bdfSopenharmony_ci$trace_logic 48f08c3bdfSopenharmony_ci 49f08c3bdfSopenharmony_ci# The test case ID, the test case count and the total number of test case 50f08c3bdfSopenharmony_ciTCID=${TCID:-icmp4-multi-diffnic01} 51f08c3bdfSopenharmony_ciTST_TOTAL=1 52f08c3bdfSopenharmony_ciTST_COUNT=1 53f08c3bdfSopenharmony_ciexport TCID 54f08c3bdfSopenharmony_ciexport TST_COUNT 55f08c3bdfSopenharmony_ciexport TST_TOTAL 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_ci# Test description 58f08c3bdfSopenharmony_citst_resm TINFO "Verify that the kernel is not crashed with receiving and sending various size of ICMP message at different NIC simultaneously with the following conditions" 59f08c3bdfSopenharmony_ci 60f08c3bdfSopenharmony_ci# Make sure the value of LTPROOT 61f08c3bdfSopenharmony_ciLTPROOT=${LTPROOT:-`(cd ../../../../.. ; pwd)`} 62f08c3bdfSopenharmony_ciexport LTPROOT 63f08c3bdfSopenharmony_ci 64f08c3bdfSopenharmony_ci# Check the environmanet variable 65f08c3bdfSopenharmony_ci. check_envval || exit $TST_TOTAL 66f08c3bdfSopenharmony_ci 67f08c3bdfSopenharmony_ci# Dulation of the test [sec] 68f08c3bdfSopenharmony_ciNS_DURATION=${NS_DURATION:-3600} # 1 hour 69f08c3bdfSopenharmony_ci 70f08c3bdfSopenharmony_ci# The version of IP 71f08c3bdfSopenharmony_ciIP_VER=${IP_VER:-4} 72f08c3bdfSopenharmony_ci 73f08c3bdfSopenharmony_ci# true, if ipsec is used 74f08c3bdfSopenharmony_ciDO_IPSEC=${DO_IPSEC:-false} 75f08c3bdfSopenharmony_ci 76f08c3bdfSopenharmony_ci# The value of SPI 77f08c3bdfSopenharmony_ciSPI=${SPI:-1000} 78f08c3bdfSopenharmony_ci 79f08c3bdfSopenharmony_ci# IPsec Protocol ( ah / esp / ipcomp ) 80f08c3bdfSopenharmony_ciIPSEC_PROTO=${IPSEC_PROTO:-ah} 81f08c3bdfSopenharmony_ci 82f08c3bdfSopenharmony_ci# IPsec Mode ( transport / tunnel ) 83f08c3bdfSopenharmony_ciIPSEC_MODE=${IPSEC_MODE:-transport} 84f08c3bdfSopenharmony_ci 85f08c3bdfSopenharmony_ci# Array of the echo request packet size 86f08c3bdfSopenharmony_ciICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"} 87f08c3bdfSopenharmony_ci 88f08c3bdfSopenharmony_ci 89f08c3bdfSopenharmony_ci 90f08c3bdfSopenharmony_ci#----------------------------------------------------------------------- 91f08c3bdfSopenharmony_ci# 92f08c3bdfSopenharmony_ci# Function: do_cleanup 93f08c3bdfSopenharmony_ci# 94f08c3bdfSopenharmony_ci# Description: 95f08c3bdfSopenharmony_ci# Recover the system configuration 96f08c3bdfSopenharmony_ci# 97f08c3bdfSopenharmony_ci#----------------------------------------------------------------------- 98f08c3bdfSopenharmony_cido_cleanup() 99f08c3bdfSopenharmony_ci{ 100f08c3bdfSopenharmony_ci # Kill the icmp traffic server 101f08c3bdfSopenharmony_ci killall_icmp_traffic 102f08c3bdfSopenharmony_ci 103f08c3bdfSopenharmony_ci # Unset SAD/SPD 104f08c3bdfSopenharmony_ci output_ipsec_conf flush | setkey -c >/dev/null 2>&1 105f08c3bdfSopenharmony_ci $LTP_RSH $RHOST ${LTPROOT}/'testcases/bin/output_ipsec_conf flush | PATH=/sbin:/usr/sbin:$PATH setkey -c' >/dev/null 2>&1 106f08c3bdfSopenharmony_ci 107f08c3bdfSopenharmony_ci # Clean up each interface 108f08c3bdfSopenharmony_ci link_num=0 109f08c3bdfSopenharmony_ci while [ $link_num -lt $link_total ]; do 110f08c3bdfSopenharmony_ci initialize_if lhost ${link_num} 111f08c3bdfSopenharmony_ci initialize_if rhost ${link_num} 112f08c3bdfSopenharmony_ci link_num=`expr $link_num + 1` 113f08c3bdfSopenharmony_ci done 114f08c3bdfSopenharmony_ci} 115f08c3bdfSopenharmony_ci 116f08c3bdfSopenharmony_ci 117f08c3bdfSopenharmony_ci#----------------------------------------------------------------------- 118f08c3bdfSopenharmony_ci# 119f08c3bdfSopenharmony_ci# Setup 120f08c3bdfSopenharmony_ci# 121f08c3bdfSopenharmony_ci 122f08c3bdfSopenharmony_ci# Unset the maximum number of processes 123f08c3bdfSopenharmony_ciulimit -u unlimited 124f08c3bdfSopenharmony_ci 125f08c3bdfSopenharmony_ci# Output the informaion 126f08c3bdfSopenharmony_citst_resm TINFO "- Test duration is $NS_DURATION [sec]" 127f08c3bdfSopenharmony_ci 128f08c3bdfSopenharmony_cilink_total=`echo $LHOST_HWADDRS | wc -w` 129f08c3bdfSopenharmony_cirhost_link_total=`echo $RHOST_HWADDRS | wc -w` 130f08c3bdfSopenharmony_ciif [ $link_total -ne $rhost_link_total ]; then 131f08c3bdfSopenharmony_ci tst_resm TBROK "The number of element in LHOST_HWADDRS differs from RHOST_HWADDRS" 132f08c3bdfSopenharmony_ci exit 1 133f08c3bdfSopenharmony_cifi 134f08c3bdfSopenharmony_ciif [ $link_total -lt 2 ]; then 135f08c3bdfSopenharmony_ci tst_resm TBROK "This test case requires plural NICs." 136f08c3bdfSopenharmony_ci exit 1 137f08c3bdfSopenharmony_cifi 138f08c3bdfSopenharmony_citst_resm TINFO "- Target number of the connection is $link_total" 139f08c3bdfSopenharmony_ci 140f08c3bdfSopenharmony_citst_resm TINFO "- Version of IP is IPv${IP_VER}" 141f08c3bdfSopenharmony_citst_resm TINFO "- Size of packets are ( $ICMP_SIZE_ARRAY )" 142f08c3bdfSopenharmony_ci 143f08c3bdfSopenharmony_ciif $DO_IPSEC ; then 144f08c3bdfSopenharmony_ci message=`check_setkey` 145f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 146f08c3bdfSopenharmony_ci tst_resm TBROK "$message" 147f08c3bdfSopenharmony_ci exit 1 148f08c3bdfSopenharmony_ci fi 149f08c3bdfSopenharmony_ci 150f08c3bdfSopenharmony_ci case $IPSEC_PROTO in 151f08c3bdfSopenharmony_ci ah) 152f08c3bdfSopenharmony_ci tst_resm TINFO "- IPsec [ AH / $IPSEC_MODE ]" 153f08c3bdfSopenharmony_ci ;; 154f08c3bdfSopenharmony_ci esp) 155f08c3bdfSopenharmony_ci tst_resm TINFO "- IPsec [ ESP / $IPSEC_MODE ]" 156f08c3bdfSopenharmony_ci ;; 157f08c3bdfSopenharmony_ci ipcomp) 158f08c3bdfSopenharmony_ci tst_resm TINFO "- IPcomp [ $IPSEC_MODE ]" 159f08c3bdfSopenharmony_ci ;; 160f08c3bdfSopenharmony_ci esac 161f08c3bdfSopenharmony_cifi 162f08c3bdfSopenharmony_ci 163f08c3bdfSopenharmony_ci# Initialize the system configuration 164f08c3bdfSopenharmony_cido_cleanup 165f08c3bdfSopenharmony_ci 166f08c3bdfSopenharmony_ci# Call do_cleanup function before exit 167f08c3bdfSopenharmony_citrap do_cleanup 0 168f08c3bdfSopenharmony_ci 169f08c3bdfSopenharmony_ci# Loop for NIC configuration 170f08c3bdfSopenharmony_cilink_num=0 171f08c3bdfSopenharmony_cilhost_addrs="" 172f08c3bdfSopenharmony_ciwhile [ $link_num -lt $link_total ]; do 173f08c3bdfSopenharmony_ci # name of interface of the local/remote host 174f08c3bdfSopenharmony_ci lhost_ifname=`get_ifname lhost $link_num` 175f08c3bdfSopenharmony_ci rhost_ifname=`get_ifname rhost $link_num` 176f08c3bdfSopenharmony_ci 177f08c3bdfSopenharmony_ci # Set the IP address to each interface 178f08c3bdfSopenharmony_ci case $IP_VER in 179f08c3bdfSopenharmony_ci 4) 180f08c3bdfSopenharmony_ci network_part="10.0.${link_num}" 181f08c3bdfSopenharmony_ci network_mask=24 182f08c3bdfSopenharmony_ci lhost_host_part="2" # local host 183f08c3bdfSopenharmony_ci rhost_host_part="1" # remote host 184f08c3bdfSopenharmony_ci set_ipv4addr lhost $link_num $network_part $lhost_host_part 185f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 186f08c3bdfSopenharmony_ci tst_resm TBROK "Failed to set IPv4 address at the local host" 187f08c3bdfSopenharmony_ci exit 1 188f08c3bdfSopenharmony_ci fi 189f08c3bdfSopenharmony_ci set_ipv4addr rhost $link_num $network_part $rhost_host_part 190f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 191f08c3bdfSopenharmony_ci tst_resm TBROK "Failed to set IPv4 address at the remote host" 192f08c3bdfSopenharmony_ci exit 1 193f08c3bdfSopenharmony_ci fi 194f08c3bdfSopenharmony_ci 195f08c3bdfSopenharmony_ci # IPv4 address of the local/remote host 196f08c3bdfSopenharmony_ci lhost_addr="${network_part}.${lhost_host_part}" 197f08c3bdfSopenharmony_ci rhost_addr="${network_part}.${rhost_host_part}" 198f08c3bdfSopenharmony_ci lhost_addrs="${lhost_addrs} ${lhost_addr}" 199f08c3bdfSopenharmony_ci ;; 200f08c3bdfSopenharmony_ci 201f08c3bdfSopenharmony_ci 6) 202f08c3bdfSopenharmony_ci network_part="fd00:1:0:`printf %x ${link_num}`" 203f08c3bdfSopenharmony_ci network_mask=64 204f08c3bdfSopenharmony_ci lhost_host_part=":2" # local host 205f08c3bdfSopenharmony_ci rhost_host_part=":1" # remote host 206f08c3bdfSopenharmony_ci add_ipv6addr lhost $link_num $network_part $lhost_host_part 207f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 208f08c3bdfSopenharmony_ci tst_resm TBROK "Failed to set IPv6 address at the local host" 209f08c3bdfSopenharmony_ci exit 1 210f08c3bdfSopenharmony_ci fi 211f08c3bdfSopenharmony_ci add_ipv6addr rhost $link_num $network_part $rhost_host_part 212f08c3bdfSopenharmony_ci if [ $? -ne 0 ]; then 213f08c3bdfSopenharmony_ci tst_resm TBROK "Failed to set IPv6 address at the remote host" 214f08c3bdfSopenharmony_ci exit 1 215f08c3bdfSopenharmony_ci fi 216f08c3bdfSopenharmony_ci lhost_addr="${network_part}:${lhost_host_part}" 217f08c3bdfSopenharmony_ci rhost_addr="${network_part}:${rhost_host_part}" 218f08c3bdfSopenharmony_ci lhost_addrs="${lhost_addrs} ${lhost_addr}" 219f08c3bdfSopenharmony_ci ;; 220f08c3bdfSopenharmony_ci 221f08c3bdfSopenharmony_ci *) 222f08c3bdfSopenharmony_ci tst_resm TBROK "Unknown IP version" 223f08c3bdfSopenharmony_ci ;; 224f08c3bdfSopenharmony_ci esac 225f08c3bdfSopenharmony_ci 226f08c3bdfSopenharmony_ci # Configure SAD/SPD 227f08c3bdfSopenharmony_ci if $DO_IPSEC ; then 228f08c3bdfSopenharmony_ci ipsec_log=`mktemp -p $TMPDIR` 229f08c3bdfSopenharmony_ci 230f08c3bdfSopenharmony_ci # Set SAD/SPD according to the variables 231f08c3bdfSopenharmony_ci output_ipsec_conf src \ 232f08c3bdfSopenharmony_ci $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr \ 233f08c3bdfSopenharmony_ci | setkey -c 2>&1 | tee $ipsec_log 234f08c3bdfSopenharmony_ci if [ $? -ne 0 -o -s $ipsec_log ]; then 235f08c3bdfSopenharmony_ci rm -f $ipsec_log 236f08c3bdfSopenharmony_ci tst_resm TBROK "Failed to configure SAD/SPD on the local host." 237f08c3bdfSopenharmony_ci exit 1 238f08c3bdfSopenharmony_ci fi 239f08c3bdfSopenharmony_ci 240f08c3bdfSopenharmony_ci $LTP_RSH $RHOST ${LTPROOT}/testcases/bin/output_ipsec_conf dst $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr' | PATH=/sbin:/usr/sbin:$PATH setkey -c' 2>&1 | tee $ipsec_log 241f08c3bdfSopenharmony_ci if [ $? -ne 0 -o -s $ipsec_log ]; then 242f08c3bdfSopenharmony_ci rm -f $ipsec_log 243f08c3bdfSopenharmony_ci tst_resm TBROK "Failed to configure SAD/SPD on the remote host." 244f08c3bdfSopenharmony_ci exit 1 245f08c3bdfSopenharmony_ci fi 246f08c3bdfSopenharmony_ci rm -f $ipsec_log 247f08c3bdfSopenharmony_ci fi 248f08c3bdfSopenharmony_ci 249f08c3bdfSopenharmony_ci # Make sure the connectivity 250f08c3bdfSopenharmony_ci case $IP_VER in 251f08c3bdfSopenharmony_ci 4) 252f08c3bdfSopenharmony_ci ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv4_connectivity $rhost_ifname $lhost_addr' ; echo $?'` 253f08c3bdfSopenharmony_ci if [ $ret -ne 0 ]; then 254f08c3bdfSopenharmony_ci tst_resm TBROK "There is no IPv4 connectivity on Link${link_num}" 255f08c3bdfSopenharmony_ci exit 1 256f08c3bdfSopenharmony_ci fi 257f08c3bdfSopenharmony_ci ;; 258f08c3bdfSopenharmony_ci 259f08c3bdfSopenharmony_ci 6) 260f08c3bdfSopenharmony_ci ret=`$LTP_RSH $RHOST ${LTPROOT}/testcases/bin/check_icmpv6_connectivity $rhost_ifname $lhost_addr' ; echo $?'` 261f08c3bdfSopenharmony_ci if [ $ret -ne 0 ]; then 262f08c3bdfSopenharmony_ci tst_resm TBROK "There is no IPv6 connectivity on Link${link_num}" 263f08c3bdfSopenharmony_ci exit 1 264f08c3bdfSopenharmony_ci fi 265f08c3bdfSopenharmony_ci ;; 266f08c3bdfSopenharmony_ci esac 267f08c3bdfSopenharmony_ci 268f08c3bdfSopenharmony_ci link_num=`expr $link_num + 1` 269f08c3bdfSopenharmony_cidone 270f08c3bdfSopenharmony_ci 271f08c3bdfSopenharmony_ci 272f08c3bdfSopenharmony_ci#----------------------------------------------------------------------- 273f08c3bdfSopenharmony_ci# 274f08c3bdfSopenharmony_ci# Main 275f08c3bdfSopenharmony_ci# 276f08c3bdfSopenharmony_ci# 277f08c3bdfSopenharmony_ci 278f08c3bdfSopenharmony_ciconnection_num=0 279f08c3bdfSopenharmony_ciwhile [ $connection_num -lt $link_total ]; do 280f08c3bdfSopenharmony_ci field=`expr $connection_num + 1` 281f08c3bdfSopenharmony_ci lhost_addr=`echo $lhost_addrs | cut -d ' ' -f $field` 282f08c3bdfSopenharmony_ci 283f08c3bdfSopenharmony_ci lhost_ifname=`get_ifname lhost $connection_num` 284f08c3bdfSopenharmony_ci rhost_ifname=`get_ifname rhost $connection_num` 285f08c3bdfSopenharmony_ci 286f08c3bdfSopenharmony_ci # Run a client 287f08c3bdfSopenharmony_ci $LTP_RSH $RHOST "${LTPROOT}/testcases/bin/ns-echoclient -S $lhost_addr -f $IP_VER -s \"$ICMP_SIZE_ARRAY\"" & 288f08c3bdfSopenharmony_ci connection_num=`expr $connection_num + 1` 289f08c3bdfSopenharmony_cidone 290f08c3bdfSopenharmony_ci 291f08c3bdfSopenharmony_cisleep $NS_DURATION 292f08c3bdfSopenharmony_cikillall_icmp_traffic 293f08c3bdfSopenharmony_ciwait 294f08c3bdfSopenharmony_ci 295f08c3bdfSopenharmony_ci#----------------------------------------------------------------------- 296f08c3bdfSopenharmony_ci# 297f08c3bdfSopenharmony_ci# Clean up 298f08c3bdfSopenharmony_ci# 299f08c3bdfSopenharmony_ci 300f08c3bdfSopenharmony_citst_resm TPASS "Test is finished successfully." 301f08c3bdfSopenharmony_ciexit 0 302