Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / net / forwarding / mirror_vlan.sh
blob2f150a414d3839594c38cefc6df3e53152b88e70
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # This test uses standard topology for testing mirroring. See mirror_topo_lib.sh
5 # for more details.
7 # Test for "tc action mirred egress mirror" that mirrors to a vlan device.
9 ALL_TESTS="
10 test_vlan
11 test_tagged_vlan
14 NUM_NETIFS=6
15 source lib.sh
16 source mirror_lib.sh
17 source mirror_topo_lib.sh
19 setup_prepare()
21 h1=${NETIFS[p1]}
22 swp1=${NETIFS[p2]}
24 swp2=${NETIFS[p3]}
25 h2=${NETIFS[p4]}
27 swp3=${NETIFS[p5]}
28 h3=${NETIFS[p6]}
30 vrf_prepare
31 mirror_topo_create
33 vlan_create $swp3 555
35 vlan_create $h3 555 v$h3
36 matchall_sink_create $h3.555
38 vlan_create $h1 111 v$h1 192.0.2.17/28
39 bridge vlan add dev $swp1 vid 111
41 vlan_create $h2 111 v$h2 192.0.2.18/28
42 bridge vlan add dev $swp2 vid 111
44 trap_install $h3 ingress
47 cleanup()
49 pre_cleanup
51 trap_uninstall $h3 ingress
53 vlan_destroy $h2 111
54 vlan_destroy $h1 111
55 vlan_destroy $h3 555
56 vlan_destroy $swp3 555
58 mirror_topo_destroy
59 vrf_cleanup
62 test_vlan_dir()
64 local direction=$1; shift
65 local forward_type=$1; shift
66 local backward_type=$1; shift
68 RET=0
70 mirror_install $swp1 $direction $swp3.555 "matchall"
71 test_span_dir "$h3.555" "$forward_type" "$backward_type"
72 mirror_uninstall $swp1 $direction
74 log_test "$direction mirror to vlan"
77 test_vlan()
79 test_vlan_dir ingress 8 0
80 test_vlan_dir egress 0 8
83 test_tagged_vlan_dir()
85 local direction=$1; shift
86 local forward_type=$1; shift
87 local backward_type=$1; shift
89 RET=0
91 mirror_install $swp1 $direction $swp3.555 "matchall"
92 do_test_span_vlan_dir_ips '>= 10' "$h3.555" 111 ip 192.0.2.17 192.0.2.18
93 do_test_span_vlan_dir_ips 0 "$h3.555" 555 ip 192.0.2.17 192.0.2.18
94 mirror_uninstall $swp1 $direction
96 log_test "$direction mirror tagged to vlan"
99 test_tagged_vlan()
101 test_tagged_vlan_dir ingress 8 0
102 test_tagged_vlan_dir egress 0 8
105 trap cleanup EXIT
107 setup_prepare
108 setup_wait
110 tests_run
112 exit $EXIT_STATUS