|
| 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 | + |
| 11 | +ALL_TESTS=" |
| 12 | + test_gretap |
| 13 | + test_ip6gretap |
| 14 | +" |
| 15 | + |
| 16 | +NUM_NETIFS=6 |
| 17 | +source lib.sh |
| 18 | +source mirror_lib.sh |
| 19 | +source mirror_gre_lib.sh |
| 20 | +source mirror_gre_topo_lib.sh |
| 21 | + |
| 22 | +setup_prepare() |
| 23 | +{ |
| 24 | + h1=${NETIFS[p1]} |
| 25 | + swp1=${NETIFS[p2]} |
| 26 | + |
| 27 | + swp2=${NETIFS[p3]} |
| 28 | + h2=${NETIFS[p4]} |
| 29 | + |
| 30 | + swp3=${NETIFS[p5]} |
| 31 | + h3=${NETIFS[p6]} |
| 32 | + |
| 33 | + vrf_prepare |
| 34 | + mirror_gre_topo_create |
| 35 | + |
| 36 | + ip link add name br2 type bridge vlan_filtering 0 |
| 37 | + ip link set dev br2 up |
| 38 | + |
| 39 | + vlan_create $swp3 555 |
| 40 | + |
| 41 | + ip link set dev $swp3.555 master br2 |
| 42 | + ip route add 192.0.2.130/32 dev br2 |
| 43 | + ip -6 route add 2001:db8:2::2/128 dev br2 |
| 44 | + |
| 45 | + ip address add dev br2 192.0.2.129/32 |
| 46 | + ip address add dev br2 2001:db8:2::1/128 |
| 47 | + |
| 48 | + vlan_create $h3 555 v$h3 192.0.2.130/28 2001:db8:2::2/64 |
| 49 | +} |
| 50 | + |
| 51 | +cleanup() |
| 52 | +{ |
| 53 | + pre_cleanup |
| 54 | + |
| 55 | + vlan_destroy $h3 555 |
| 56 | + ip link del dev br2 |
| 57 | + vlan_destroy $swp3 555 |
| 58 | + |
| 59 | + mirror_gre_topo_destroy |
| 60 | + vrf_cleanup |
| 61 | +} |
| 62 | + |
| 63 | +test_vlan_match() |
| 64 | +{ |
| 65 | + local tundev=$1; shift |
| 66 | + local vlan_match=$1; shift |
| 67 | + local what=$1; shift |
| 68 | + |
| 69 | + full_test_span_gre_dir_vlan $tundev ingress "$vlan_match" 8 0 "$what" |
| 70 | + full_test_span_gre_dir_vlan $tundev egress "$vlan_match" 0 8 "$what" |
| 71 | +} |
| 72 | + |
| 73 | +test_gretap() |
| 74 | +{ |
| 75 | + test_vlan_match gt4 'vlan_id 555 vlan_ethtype ip' "mirror to gretap" |
| 76 | +} |
| 77 | + |
| 78 | +test_ip6gretap() |
| 79 | +{ |
| 80 | + test_vlan_match gt6 'vlan_id 555 vlan_ethtype ipv6' "mirror to ip6gretap" |
| 81 | +} |
| 82 | + |
| 83 | +test_all() |
| 84 | +{ |
| 85 | + slow_path_trap_install $swp1 ingress |
| 86 | + slow_path_trap_install $swp1 egress |
| 87 | + |
| 88 | + tests_run |
| 89 | + |
| 90 | + slow_path_trap_uninstall $swp1 egress |
| 91 | + slow_path_trap_uninstall $swp1 ingress |
| 92 | +} |
| 93 | + |
| 94 | +trap cleanup EXIT |
| 95 | + |
| 96 | +setup_prepare |
| 97 | +setup_wait |
| 98 | + |
| 99 | +tcflags="skip_hw" |
| 100 | +test_all |
| 101 | + |
| 102 | +if ! tc_offload_check; then |
| 103 | + echo "WARN: Could not test offloaded functionality" |
| 104 | +else |
| 105 | + tcflags="skip_sw" |
| 106 | + test_all |
| 107 | +fi |
| 108 | + |
| 109 | +exit $EXIT_STATUS |
0 commit comments