WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / mirror_vlan.sh
blob9ab2ce77b332cb133640a4c055d12b1fe65076f8
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
45 cleanup()
47 pre_cleanup
49 vlan_destroy $h2 111
50 vlan_destroy $h1 111
51 vlan_destroy $h3 555
52 vlan_destroy $swp3 555
54 mirror_topo_destroy
55 vrf_cleanup
58 test_vlan_dir()
60 local direction=$1; shift
61 local forward_type=$1; shift
62 local backward_type=$1; shift
64 RET=0
66 mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
67 test_span_dir "$h3.555" "$direction" "$forward_type" "$backward_type"
68 mirror_uninstall $swp1 $direction
70 log_test "$direction mirror to vlan ($tcflags)"
73 test_vlan()
75 test_vlan_dir ingress 8 0
76 test_vlan_dir egress 0 8
79 test_tagged_vlan_dir()
81 local direction=$1; shift
82 local forward_type=$1; shift
83 local backward_type=$1; shift
85 RET=0
87 mirror_install $swp1 $direction $swp3.555 "matchall $tcflags"
88 do_test_span_vlan_dir_ips 10 "$h3.555" 111 "$direction" \
89 192.0.2.17 192.0.2.18
90 do_test_span_vlan_dir_ips 0 "$h3.555" 555 "$direction" \
91 192.0.2.17 192.0.2.18
92 mirror_uninstall $swp1 $direction
94 log_test "$direction mirror tagged to vlan ($tcflags)"
97 test_tagged_vlan()
99 test_tagged_vlan_dir ingress 8 0
100 test_tagged_vlan_dir egress 0 8
103 test_all()
105 slow_path_trap_install $swp1 ingress
106 slow_path_trap_install $swp1 egress
107 trap_install $h3 ingress
109 tests_run
111 trap_uninstall $h3 ingress
112 slow_path_trap_uninstall $swp1 egress
113 slow_path_trap_uninstall $swp1 ingress
116 trap cleanup EXIT
118 setup_prepare
119 setup_wait
121 tcflags="skip_hw"
122 test_all
124 if ! tc_offload_check; then
125 echo "WARN: Could not test offloaded functionality"
126 else
127 tcflags="skip_sw"
128 test_all
131 exit $EXIT_STATUS