hw_stats_l3_gre.sh (1720B)
1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 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 more 7# details. 8 9ALL_TESTS=" 10 ping_ipv4 11 test_stats_rx 12 test_stats_tx 13" 14NUM_NETIFS=6 15source lib.sh 16source ipip_lib.sh 17 18setup_prepare() 19{ 20 h1=${NETIFS[p1]} 21 ol1=${NETIFS[p2]} 22 23 ul1=${NETIFS[p3]} 24 ul2=${NETIFS[p4]} 25 26 ol2=${NETIFS[p5]} 27 h2=${NETIFS[p6]} 28 29 ol1mac=$(mac_get $ol1) 30 31 forwarding_enable 32 vrf_prepare 33 h1_create 34 h2_create 35 sw1_flat_create gre $ol1 $ul1 36 sw2_flat_create gre $ol2 $ul2 37 ip stats set dev g1a l3_stats on 38 ip stats set dev g2a l3_stats on 39} 40 41cleanup() 42{ 43 pre_cleanup 44 45 ip stats set dev g1a l3_stats off 46 ip stats set dev g2a l3_stats off 47 48 sw2_flat_destroy $ol2 $ul2 49 sw1_flat_destroy $ol1 $ul1 50 h2_destroy 51 h1_destroy 52 53 vrf_cleanup 54 forwarding_restore 55} 56 57ping_ipv4() 58{ 59 RET=0 60 61 ping_test $h1 192.0.2.18 " gre flat" 62} 63 64send_packets_ipv4() 65{ 66 # Send 21 packets instead of 20, because the first one might trap and go 67 # through the SW datapath, which might not bump the HW counter. 68 $MZ $h1 -c 21 -d 20msec -p 100 \ 69 -a own -b $ol1mac -A 192.0.2.1 -B 192.0.2.18 \ 70 -q -t udp sp=54321,dp=12345 71} 72 73test_stats() 74{ 75 local dev=$1; shift 76 local dir=$1; shift 77 78 local a 79 local b 80 81 RET=0 82 83 a=$(hw_stats_get l3_stats $dev $dir packets) 84 send_packets_ipv4 85 b=$(busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $a + 20" \ 86 hw_stats_get l3_stats $dev $dir packets) 87 check_err $? "Traffic not reflected in the counter: $a -> $b" 88 89 log_test "Test $dir packets: $prot" 90} 91 92test_stats_tx() 93{ 94 test_stats g1a tx 95} 96 97test_stats_rx() 98{ 99 test_stats g2a rx 100} 101 102trap cleanup EXIT 103 104setup_prepare 105setup_wait 106 107tests_run 108 109exit $EXIT_STATUS