WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / tc_mpls_l2vpn.sh
blob03743f04e17882d369a3cc30d8b58a592623e302
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 # +-----------------------+
5 # | H1 (v$h1) |
6 # | 192.0.2.1/24 |
7 # | 2001:db8::1/124 |
8 # | + $h1 |
9 # +-----------------|-----+
10 # |
11 # | (Plain Ethernet traffic)
12 # |
13 # +-----------------|-----------------------------------------+
14 # | LER1 + $edge1 |
15 # | -ingress: |
16 # | -encapsulate Ethernet into MPLS |
17 # | -add outer Ethernet header |
18 # | -redirect to $mpls1 (egress) |
19 # | |
20 # | + $mpls1 |
21 # | | -ingress: |
22 # | | -remove outer Ethernet header |
23 # | | -remove MPLS header |
24 # | | -redirect to $edge1 (egress) |
25 # +-----------------|-----------------------------------------+
26 # |
27 # | (Ethernet over MPLS traffic)
28 # |
29 # +-----------------|-----------------------------------------+
30 # | LER2 + $mpls2 |
31 # | -ingress: |
32 # | -remove outer Ethernet header |
33 # | -remove MPLS header |
34 # | -redirect to $edge2 (egress) |
35 # | |
36 # | + $edge2 |
37 # | | -ingress: |
38 # | | -encapsulate Ethernet into MPLS |
39 # | | -add outer Ethernet header |
40 # | | -redirect to $mpls2 (egress) |
41 # +-----------------|-----------------------------------------|
42 # |
43 # | (Plain Ethernet traffic)
44 # |
45 # +-----------------|-----+
46 # | H2 (v$h2) | |
47 # | + $h2 |
48 # | 192.0.2.2/24 |
49 # | 2001:db8::2/124 |
50 # +-----------------------+
52 # LER1 and LER2 logically represent two different routers. However, no VRF is
53 # created for them, as they don't do any IP routing.
55 ALL_TESTS="mpls_forward_eth"
56 NUM_NETIFS=6
57 source lib.sh
59 h1_create()
61 simple_if_init $h1 192.0.2.1/24 2001:db8::1/124
64 h1_destroy()
66 simple_if_fini $h1 192.0.2.1/24 2001:db8::1/124
69 h2_create()
71 simple_if_init $h2 192.0.2.2/24 2001:db8::2/124
74 h2_destroy()
76 simple_if_fini $h2 192.0.2.2/24 2001:db8::2/124
79 ler1_create()
81 tc qdisc add dev $edge1 ingress
82 tc filter add dev $edge1 ingress \
83 matchall \
84 action mpls mac_push label 102 \
85 action vlan push_eth dst_mac $mpls2mac src_mac $mpls1mac \
86 action mirred egress redirect dev $mpls1
87 ip link set dev $edge1 up
89 tc qdisc add dev $mpls1 ingress
90 tc filter add dev $mpls1 ingress \
91 protocol mpls_uc \
92 flower mpls_label 101 \
93 action vlan pop_eth \
94 action mpls pop protocol teb \
95 action mirred egress redirect dev $edge1
96 ip link set dev $mpls1 up
99 ler1_destroy()
101 ip link set dev $mpls1 down
102 tc qdisc del dev $mpls1 ingress
104 ip link set dev $edge1 down
105 tc qdisc del dev $edge1 ingress
108 ler2_create()
110 tc qdisc add dev $edge2 ingress
111 tc filter add dev $edge2 ingress \
112 matchall \
113 action mpls mac_push label 101 \
114 action vlan push_eth dst_mac $mpls1mac src_mac $mpls2mac \
115 action mirred egress redirect dev $mpls2
116 ip link set dev $edge2 up
118 tc qdisc add dev $mpls2 ingress
119 tc filter add dev $mpls2 ingress \
120 protocol mpls_uc \
121 flower mpls_label 102 \
122 action vlan pop_eth \
123 action mpls pop protocol teb \
124 action mirred egress redirect dev $edge2
125 ip link set dev $mpls2 up
128 ler2_destroy()
130 ip link set dev $mpls2 down
131 tc qdisc del dev $mpls2 ingress
133 ip link set dev $edge2 down
134 tc qdisc del dev $edge2 ingress
137 mpls_forward_eth()
139 ping_test $h1 192.0.2.2
140 ping6_test $h1 2001:db8::2
143 setup_prepare()
145 h1=${NETIFS[p1]}
146 edge1=${NETIFS[p2]}
148 mpls1=${NETIFS[p3]}
149 mpls2=${NETIFS[p4]}
151 edge2=${NETIFS[p5]}
152 h2=${NETIFS[p6]}
154 mpls1mac=$(mac_get $mpls1)
155 mpls2mac=$(mac_get $mpls2)
157 vrf_prepare
159 h1_create
160 h2_create
161 ler1_create
162 ler2_create
165 cleanup()
167 pre_cleanup
169 ler2_destroy
170 ler1_destroy
171 h2_destroy
172 h1_destroy
174 vrf_cleanup
177 trap cleanup EXIT
179 setup_prepare
180 setup_wait
182 tests_run
184 tc_offload_check
185 if [[ $? -ne 0 ]]; then
186 log_info "Could not test offloaded functionality"
187 else
188 tcflags="skip_sw"
189 tests_run
192 exit $EXIT_STATUS