brintos

brintos / linux-shallow public Read only

0
0
Text · 1.8 KiB · a94d92e Raw
112 lines · bash
1#!/bin/bash2# SPDX-License-Identifier: GPL-2.03 4# Test L3 stats on IP-in-IP GRE tunnel without key.5 6# This test uses flat topology for IP tunneling tests. See ipip_lib.sh for more7# details.8 9ALL_TESTS="10	ping_ipv411	test_stats_rx12	test_stats_tx13"14NUM_NETIFS=615lib_dir=$(dirname "$0")16source "$lib_dir"/../../../net/forwarding/lib.sh17source "$lib_dir"/../../../net/forwarding/ipip_lib.sh18source "$lib_dir"/../../../net/forwarding/tc_common.sh19 20setup_prepare()21{22	h1=${NETIFS[p1]}23	ol1=${NETIFS[p2]}24 25	ul1=${NETIFS[p3]}26	ul2=${NETIFS[p4]}27 28	ol2=${NETIFS[p5]}29	h2=${NETIFS[p6]}30 31	ol1mac=$(mac_get $ol1)32 33	forwarding_enable34	vrf_prepare35	h1_create36	h2_create37	sw1_flat_create gre $ol1 $ul138	sw2_flat_create gre $ol2 $ul239	ip stats set dev g1a l3_stats on40	ip stats set dev g2a l3_stats on41}42 43cleanup()44{45	pre_cleanup46 47	ip stats set dev g1a l3_stats off48	ip stats set dev g2a l3_stats off49 50	sw2_flat_destroy $ol2 $ul251	sw1_flat_destroy $ol1 $ul152	h2_destroy53	h1_destroy54 55	vrf_cleanup56	forwarding_restore57}58 59ping_ipv4()60{61	RET=062 63	ping_test $h1 192.0.2.18 " gre flat"64}65 66send_packets_ipv4()67{68	# Send 21 packets instead of 20, because the first one might trap and go69	# through the SW datapath, which might not bump the HW counter.70	$MZ $h1 -c 21 -d 20msec -p 100 \71	    -a own -b $ol1mac -A 192.0.2.1 -B 192.0.2.18 \72	    -q -t udp sp=54321,dp=1234573}74 75test_stats()76{77	local dev=$1; shift78	local dir=$1; shift79 80	local a81	local b82 83	RET=084 85	a=$(hw_stats_get l3_stats $dev $dir packets)86	send_packets_ipv487	b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \88		     hw_stats_get l3_stats $dev $dir packets)89	check_err $? "Traffic not reflected in the counter: $a -> $b"90 91	log_test "Test $dir packets: $prot"92}93 94test_stats_tx()95{96	test_stats g1a tx97}98 99test_stats_rx()100{101	test_stats g2a rx102}103 104trap cleanup EXIT105 106setup_prepare107setup_wait108 109tests_run110 111exit $EXIT_STATUS112