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