1#!/bin/bash 2# SPDX-License-Identifier: GPL-2.0 3 4# This test uses standard topology for testing gretap. See 5# mirror_gre_topo_lib.sh for more details. 6# 7# Test for "tc action mirred egress mirror" when the underlay route points at a 8# bridge device without vlan filtering (802.1d). The device attached to that 9# bridge is a VLAN. 10 11ALL_TESTS=" 12 test_gretap 13 test_ip6gretap 14 test_gretap_stp 15 test_ip6gretap_stp 16" 17 18NUM_NETIFS=6 19source lib.sh 20source mirror_lib.sh 21source mirror_gre_lib.sh 22source mirror_gre_topo_lib.sh 23 24setup_prepare() 25{ 26 h1=${NETIFS[p1]} 27 swp1=${NETIFS[p2]} 28 29 swp2=${NETIFS[p3]} 30 h2=${NETIFS[p4]} 31 32 swp3=${NETIFS[p5]} 33 h3=${NETIFS[p6]} 34 35 vrf_prepare 36 mirror_gre_topo_create 37 38 ip link add name br2 type bridge vlan_filtering 0 39 ip link set dev br2 up 40 41 vlan_create $swp3 555 42 43 ip link set dev $swp3.555 master br2 44 ip route add 192.0.2.130/32 dev br2 45 ip -6 route add 2001:db8:2::2/128 dev br2 46 47 ip address add dev br2 192.0.2.129/32 48 ip address add dev br2 2001:db8:2::1/128 49 50 vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64 51} 52 53cleanup() 54{ 55 pre_cleanup 56 57 vlan_destroy $h3 555 58 ip link del dev br2 59 vlan_destroy $swp3 555 60 61 mirror_gre_topo_destroy 62 vrf_cleanup 63} 64 65test_vlan_match() 66{ 67 local tundev=$1; shift 68 local vlan_match=$1; shift 69 local what=$1; shift 70 71 full_test_span_gre_dir_vlan $tundev ingress "$vlan_match" 8 0 "$what" 72 full_test_span_gre_dir_vlan $tundev egress "$vlan_match" 0 8 "$what" 73} 74 75test_gretap() 76{ 77 test_vlan_match gt4 'skip_hw vlan_id 555 vlan_ethtype ip' \ 78 "mirror to gretap" 79} 80 81test_ip6gretap() 82{ 83 test_vlan_match gt6 'skip_hw vlan_id 555 vlan_ethtype ip' \ 84 "mirror to ip6gretap" 85} 86 87test_gretap_stp() 88{ 89 full_test_span_gre_stp gt4 $swp3.555 "mirror to gretap" 90} 91 92test_ip6gretap_stp() 93{ 94 full_test_span_gre_stp gt6 $swp3.555 "mirror to ip6gretap" 95} 96 97test_all() 98{ 99 slow_path_trap_install $swp1 ingress 100 slow_path_trap_install $swp1 egress 101 102 tests_run 103 104 slow_path_trap_uninstall $swp1 egress 105 slow_path_trap_uninstall $swp1 ingress 106} 107 108trap cleanup EXIT 109 110setup_prepare 111setup_wait 112 113tcflags="skip_hw" 114test_all 115 116if ! tc_offload_check; then 117 echo "WARN: Could not test offloaded functionality" 118else 119 tcflags="skip_sw" 120 test_all 121fi 122 123exit $EXIT_STATUS 124