Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame^] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Pier | 23784aa | 2016-09-19 20:08:21 -0700 | [diff] [blame] | 17 | """ |
| 18 | Check README file |
| 19 | """ |
| 20 | import Queue |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 21 | import time |
Pier | 23784aa | 2016-09-19 20:08:21 -0700 | [diff] [blame] | 22 | |
| 23 | from oftest import config |
| 24 | import inspect |
| 25 | import logging |
| 26 | import oftest.base_tests as base_tests |
| 27 | import ofp |
| 28 | from oftest.testutils import * |
| 29 | from accton_util import * |
| 30 | from utils import * |
| 31 | |
| 32 | class UntaggedPWInitiation_2_Labels( base_tests.SimpleDataPlane ): |
| 33 | """ |
| 34 | This is meant to test the PW Initiation. The traffic |
| 35 | arrives untagged to the MPLS-TP CE device, it goes out |
| 36 | untagged, with a new ethernet header and 2 mpls labels. |
| 37 | """ |
| 38 | def runTest( self ): |
| 39 | |
| 40 | Groups = Queue.LifoQueue( ) |
| 41 | Groups2 = Queue.LifoQueue( ) |
| 42 | try: |
| 43 | if len( config[ "port_map" ] ) < 1: |
| 44 | logging.info( "Port count less than 1, can't run this case" ) |
| 45 | assert (False) |
| 46 | return |
| 47 | ports = config[ "port_map" ].keys( ) |
| 48 | |
| 49 | for pair in itertools.product(ports, ports): |
| 50 | # we generate all possible products |
| 51 | in_port = pair[0] |
| 52 | out_port = pair[1] |
| 53 | if out_port == in_port: |
| 54 | continue |
| 55 | # we fill the pipeline for the initiation |
| 56 | ( |
| 57 | port_to_mpls_label_2, |
| 58 | port_to_mpls_label_1, |
| 59 | port_to_mpls_label_pw, |
| 60 | port_to_in_vlan_3, |
| 61 | port_to_in_vlan_2, |
| 62 | port_to_in_vlan_1, |
| 63 | port_to_src_mac_str, |
| 64 | port_to_dst_mac_str, |
| 65 | Groups ) = fill_pw_initiation_pipeline( |
| 66 | controller=self.controller, |
| 67 | logging=logging, |
| 68 | in_port=in_port, |
| 69 | out_port=out_port, |
| 70 | ingress_tags=0, |
| 71 | egress_tag=EGRESS_UNTAGGED, |
| 72 | mpls_labels=1 |
| 73 | ) |
| 74 | # we fill the pipeline for the termination |
| 75 | # on the reverse path |
| 76 | ( |
| 77 | port_to_mpls_label_pw_x, |
| 78 | port_to_vlan_2_x, |
| 79 | port_to_vlan_1_x, |
| 80 | port_to_switch_mac_str_x, |
| 81 | Groups2 ) = fill_pw_termination_pipeline( |
| 82 | controller=self.controller, |
| 83 | logging=logging, |
| 84 | in_port=out_port, |
| 85 | out_port=in_port, |
| 86 | egress_tags=0 |
| 87 | ) |
| 88 | # we send a simple tcp packet |
| 89 | parsed_pkt = simple_tcp_packet( |
| 90 | pktlen=104, |
| 91 | ) |
| 92 | pkt = str( parsed_pkt ) |
| 93 | self.dataplane.send( in_port, pkt ) |
| 94 | # we verify the pw packet has been generated |
| 95 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 96 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 97 | cw = (0, 0, 0, 0) |
| 98 | parsed_pkt = pw_packet( |
| 99 | pktlen=130, |
| 100 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 101 | out_eth_src=port_to_src_mac_str[out_port], |
| 102 | label=[label_1, label_pw], |
| 103 | cw=cw |
| 104 | ) |
| 105 | pkt = str( parsed_pkt ) |
| 106 | # Assertions |
| 107 | verify_packet( self, pkt, out_port ) |
| 108 | verify_no_packet( self, pkt, in_port ) |
| 109 | verify_no_other_packets( self ) |
| 110 | # Flush all the rules for the next couple |
| 111 | delete_all_flows( self.controller ) |
| 112 | delete_groups( self.controller, Groups ) |
| 113 | delete_groups( self.controller, Groups2 ) |
| 114 | delete_all_groups( self.controller ) |
| 115 | |
| 116 | finally: |
| 117 | delete_all_flows( self.controller ) |
| 118 | delete_groups( self.controller, Groups ) |
| 119 | delete_groups( self.controller, Groups2 ) |
| 120 | delete_all_groups( self.controller ) |
| 121 | |
| 122 | class Untagged2PWInitiation_2_Labels( base_tests.SimpleDataPlane ): |
| 123 | """ |
| 124 | This is meant to test the PW Initiation. The traffic |
| 125 | arrives untagged to the MPLS-TP CE device, it goes out |
| 126 | tagged, with a new ethernet header and 2 mpls labels. |
| 127 | """ |
| 128 | def runTest( self ): |
| 129 | |
| 130 | Groups = Queue.LifoQueue( ) |
| 131 | Groups2 = Queue.LifoQueue( ) |
| 132 | try: |
| 133 | if len( config[ "port_map" ] ) < 1: |
| 134 | logging.info( "Port count less than 1, can't run this case" ) |
| 135 | assert (False) |
| 136 | return |
| 137 | ports = config[ "port_map" ].keys( ) |
| 138 | |
| 139 | for pair in itertools.product(ports, ports): |
| 140 | # we generate all possible products |
| 141 | in_port = pair[0] |
| 142 | out_port = pair[1] |
| 143 | if out_port == in_port: |
| 144 | continue |
| 145 | # we fill the pipeline for the initiation |
| 146 | ( |
| 147 | port_to_mpls_label_2, |
| 148 | port_to_mpls_label_1, |
| 149 | port_to_mpls_label_pw, |
| 150 | port_to_in_vlan_3, |
| 151 | port_to_in_vlan_2, |
| 152 | port_to_in_vlan_1, |
| 153 | port_to_src_mac_str, |
| 154 | port_to_dst_mac_str, |
| 155 | Groups ) = fill_pw_initiation_pipeline( |
| 156 | controller=self.controller, |
| 157 | logging=logging, |
| 158 | in_port=in_port, |
| 159 | out_port=out_port, |
| 160 | ingress_tags=0, |
| 161 | egress_tag=EGRESS_TAGGED, |
| 162 | mpls_labels=1 |
| 163 | ) |
| 164 | # we fill the pipeline for the termination |
| 165 | # on the reverse path |
| 166 | ( |
| 167 | port_to_mpls_label_pw_x, |
| 168 | port_to_vlan_2_x, |
| 169 | port_to_vlan_1_x, |
| 170 | port_to_switch_mac_str_x, |
| 171 | Groups2 ) = fill_pw_termination_pipeline( |
| 172 | controller=self.controller, |
| 173 | logging=logging, |
| 174 | in_port=out_port, |
| 175 | out_port=in_port, |
| 176 | egress_tags=0 |
| 177 | ) |
| 178 | # we send a simple tcp packet |
| 179 | parsed_pkt = simple_tcp_packet( |
| 180 | pktlen=104, |
| 181 | ) |
| 182 | pkt = str( parsed_pkt ) |
| 183 | self.dataplane.send( in_port, pkt ) |
| 184 | # we verify the pw packet has been generated |
| 185 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 186 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 187 | cw = (0, 0, 0, 0) |
| 188 | parsed_pkt = pw_packet( |
| 189 | pktlen=134, |
| 190 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 191 | out_eth_src=port_to_src_mac_str[out_port], |
| 192 | label=[label_1, label_pw], |
| 193 | cw=cw, |
| 194 | out_dl_vlan_enable=True, |
| 195 | out_vlan_vid=port_to_in_vlan_1[in_port], |
| 196 | ) |
| 197 | pkt = str( parsed_pkt ) |
| 198 | # Assertions |
| 199 | verify_packet( self, pkt, out_port ) |
| 200 | verify_no_packet( self, pkt, in_port ) |
| 201 | verify_no_other_packets( self ) |
| 202 | # Flush all the rules for the next couple |
| 203 | delete_all_flows( self.controller ) |
| 204 | delete_groups( self.controller, Groups ) |
| 205 | delete_groups( self.controller, Groups2 ) |
| 206 | delete_all_groups( self.controller ) |
| 207 | |
| 208 | finally: |
| 209 | delete_all_flows( self.controller ) |
| 210 | delete_groups( self.controller, Groups ) |
| 211 | delete_groups( self.controller, Groups2 ) |
| 212 | delete_all_groups( self.controller ) |
| 213 | |
| 214 | class UntaggedPWInitiation_3_Labels( base_tests.SimpleDataPlane ): |
| 215 | """ |
| 216 | This is meant to test the PW Initiation. The traffic |
| 217 | arrives untagged to the MPLS-TP CE device, it goes out |
| 218 | untagged, with a new ethernet header and 3 mpls labels. |
| 219 | """ |
| 220 | def runTest( self ): |
| 221 | |
| 222 | Groups = Queue.LifoQueue( ) |
| 223 | Groups2 = Queue.LifoQueue( ) |
| 224 | try: |
| 225 | if len( config[ "port_map" ] ) < 1: |
| 226 | logging.info( "Port count less than 1, can't run this case" ) |
| 227 | assert (False) |
| 228 | return |
| 229 | ports = config[ "port_map" ].keys( ) |
| 230 | |
| 231 | for pair in itertools.product(ports, ports): |
| 232 | # we generate all possible products |
| 233 | in_port = pair[0] |
| 234 | out_port = pair[1] |
| 235 | if out_port == in_port: |
| 236 | continue |
| 237 | # we fill the pipeline for the pw initiation |
| 238 | ( |
| 239 | port_to_mpls_label_2, |
| 240 | port_to_mpls_label_1, |
| 241 | port_to_mpls_label_pw, |
| 242 | port_to_in_vlan_3, |
| 243 | port_to_in_vlan_2, |
| 244 | port_to_in_vlan_1, |
| 245 | port_to_src_mac_str, |
| 246 | port_to_dst_mac_str, |
| 247 | Groups ) = fill_pw_initiation_pipeline( |
| 248 | controller=self.controller, |
| 249 | logging=logging, |
| 250 | in_port=in_port, |
| 251 | out_port=out_port, |
| 252 | ingress_tags=0, |
| 253 | egress_tag=EGRESS_UNTAGGED, |
| 254 | mpls_labels=2 |
| 255 | ) |
| 256 | # we fill the pipeline for the pw termination |
| 257 | # on the reverse path |
| 258 | ( |
| 259 | port_to_mpls_label_pw_x, |
| 260 | port_to_vlan_2_x, |
| 261 | port_to_vlan_1_x, |
| 262 | port_to_switch_mac_str_x, |
| 263 | Groups2 ) = fill_pw_termination_pipeline( |
| 264 | controller=self.controller, |
| 265 | logging=logging, |
| 266 | in_port=out_port, |
| 267 | out_port=in_port, |
| 268 | egress_tags=0 |
| 269 | ) |
| 270 | # we generate a simple tcp packet |
| 271 | parsed_pkt = simple_tcp_packet( |
| 272 | pktlen=104, |
| 273 | ) |
| 274 | pkt = str( parsed_pkt ) |
| 275 | self.dataplane.send( in_port, pkt ) |
| 276 | # we generate the pw packet we expect on the out port |
| 277 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63) |
| 278 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 279 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 280 | cw = (0, 0, 0, 0) |
| 281 | parsed_pkt = pw_packet( |
| 282 | pktlen=134, |
| 283 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 284 | out_eth_src=port_to_src_mac_str[out_port], |
| 285 | label=[label_2, label_1, label_pw], |
| 286 | cw=cw |
| 287 | ) |
| 288 | pkt = str( parsed_pkt ) |
| 289 | # Assertions |
| 290 | verify_packet( self, pkt, out_port ) |
| 291 | verify_no_packet( self, pkt, in_port ) |
| 292 | verify_no_other_packets( self ) |
| 293 | delete_all_flows( self.controller ) |
| 294 | delete_groups( self.controller, Groups ) |
| 295 | delete_groups( self.controller, Groups2 ) |
| 296 | delete_all_groups( self.controller ) |
| 297 | |
| 298 | finally: |
| 299 | delete_all_flows( self.controller ) |
| 300 | delete_groups( self.controller, Groups ) |
| 301 | delete_groups( self.controller, Groups2 ) |
| 302 | delete_all_groups( self.controller ) |
| 303 | |
| 304 | class Untagged2PWInitiation_3_Labels( base_tests.SimpleDataPlane ): |
| 305 | """ |
| 306 | This is meant to test the PW Initiation. The traffic |
| 307 | arrives untagged to the MPLS-TP CE device, it goes out |
| 308 | tagged with a new ethernet header and 3 mpls labels. |
| 309 | """ |
| 310 | def runTest( self ): |
| 311 | |
| 312 | Groups = Queue.LifoQueue( ) |
| 313 | Groups2 = Queue.LifoQueue( ) |
| 314 | try: |
| 315 | if len( config[ "port_map" ] ) < 1: |
| 316 | logging.info( "Port count less than 1, can't run this case" ) |
| 317 | assert (False) |
| 318 | return |
| 319 | ports = config[ "port_map" ].keys( ) |
| 320 | |
| 321 | for pair in itertools.product(ports, ports): |
| 322 | # we generate all possible products |
| 323 | in_port = pair[0] |
| 324 | out_port = pair[1] |
| 325 | if out_port == in_port: |
| 326 | continue |
| 327 | # we fill the pipeline for the pw initiation |
| 328 | ( |
| 329 | port_to_mpls_label_2, |
| 330 | port_to_mpls_label_1, |
| 331 | port_to_mpls_label_pw, |
| 332 | port_to_in_vlan_3, |
| 333 | port_to_in_vlan_2, |
| 334 | port_to_in_vlan_1, |
| 335 | port_to_src_mac_str, |
| 336 | port_to_dst_mac_str, |
| 337 | Groups ) = fill_pw_initiation_pipeline( |
| 338 | controller=self.controller, |
| 339 | logging=logging, |
| 340 | in_port=in_port, |
| 341 | out_port=out_port, |
| 342 | ingress_tags=0, |
| 343 | egress_tag=EGRESS_TAGGED, |
| 344 | mpls_labels=2 |
| 345 | ) |
| 346 | # we fill the pipeline for the pw termination |
| 347 | # on the reverse path |
| 348 | ( |
| 349 | port_to_mpls_label_pw_x, |
| 350 | port_to_vlan_2_x, |
| 351 | port_to_vlan_1_x, |
| 352 | port_to_switch_mac_str_x, |
| 353 | Groups2 ) = fill_pw_termination_pipeline( |
| 354 | controller=self.controller, |
| 355 | logging=logging, |
| 356 | in_port=out_port, |
| 357 | out_port=in_port, |
| 358 | egress_tags=0 |
| 359 | ) |
| 360 | # we generate a simple tcp packet |
| 361 | parsed_pkt = simple_tcp_packet( |
| 362 | pktlen=104, |
| 363 | ) |
| 364 | pkt = str( parsed_pkt ) |
| 365 | self.dataplane.send( in_port, pkt ) |
| 366 | # we generate the pw packet we expect on the out port |
| 367 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63) |
| 368 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 369 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 370 | cw = (0, 0, 0, 0) |
| 371 | parsed_pkt = pw_packet( |
| 372 | pktlen=138, |
| 373 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 374 | out_eth_src=port_to_src_mac_str[out_port], |
| 375 | label=[label_2, label_1, label_pw], |
| 376 | cw=cw, |
| 377 | out_dl_vlan_enable=True, |
| 378 | out_vlan_vid=port_to_in_vlan_1[in_port], |
| 379 | ) |
| 380 | pkt = str( parsed_pkt ) |
| 381 | # Asserions |
| 382 | verify_packet( self, pkt, out_port ) |
| 383 | verify_no_packet( self, pkt, in_port ) |
| 384 | verify_no_other_packets( self ) |
| 385 | delete_all_flows( self.controller ) |
| 386 | delete_groups( self.controller, Groups ) |
| 387 | delete_groups( self.controller, Groups2 ) |
| 388 | delete_all_groups( self.controller ) |
| 389 | |
| 390 | finally: |
| 391 | delete_all_flows( self.controller ) |
| 392 | delete_groups( self.controller, Groups ) |
| 393 | delete_groups( self.controller, Groups2 ) |
| 394 | delete_all_groups( self.controller ) |
| 395 | |
| 396 | class TaggedPWInitiation_2_Labels( base_tests.SimpleDataPlane ): |
| 397 | """ |
| 398 | This is meant to test the PW Initiation. The traffic |
| 399 | arrives tagged to the MPLS-TP CE device, it goes out |
| 400 | with the same tag, a new ethernet header and 2 mpls labels. |
| 401 | """ |
| 402 | def runTest( self ): |
| 403 | |
| 404 | Groups = Queue.LifoQueue( ) |
| 405 | Groups2 = Queue.LifoQueue( ) |
| 406 | try: |
| 407 | if len( config[ "port_map" ] ) < 1: |
| 408 | logging.info( "Port count less than 1, can't run this case" ) |
| 409 | assert (False) |
| 410 | return |
| 411 | ports = config[ "port_map" ].keys( ) |
| 412 | for pair in itertools.product(ports, ports): |
| 413 | # we generate all possible products |
| 414 | in_port = pair[0] |
| 415 | out_port = pair[1] |
| 416 | if out_port == in_port: |
| 417 | continue |
| 418 | # we fill the pipeline for the pw initiation |
| 419 | ( |
| 420 | port_to_mpls_label_2, |
| 421 | port_to_mpls_label_1, |
| 422 | port_to_mpls_label_pw, |
| 423 | port_to_in_vlan_3, |
| 424 | port_to_in_vlan_2, |
| 425 | port_to_in_vlan_1, |
| 426 | port_to_src_mac_str, |
| 427 | port_to_dst_mac_str, |
| 428 | Groups ) = fill_pw_initiation_pipeline( |
| 429 | controller=self.controller, |
| 430 | logging=logging, |
| 431 | in_port=in_port, |
| 432 | out_port=out_port, |
| 433 | ingress_tags=1, |
| 434 | egress_tag=EGRESS_TAGGED, |
| 435 | mpls_labels=1 |
| 436 | ) |
| 437 | # we fill the pipeline for the pw termination |
| 438 | # on the reverse path |
| 439 | ( |
| 440 | port_to_mpls_label_pw_x, |
| 441 | port_to_vlan_2_x, |
| 442 | port_to_vlan_1_x, |
| 443 | port_to_switch_mac_str_x, |
| 444 | Groups2 ) = fill_pw_termination_pipeline( |
| 445 | controller=self.controller, |
| 446 | logging=logging, |
| 447 | in_port=out_port, |
| 448 | out_port=in_port, |
| 449 | egress_tags=1 |
| 450 | ) |
| 451 | # we generate a simple tcp packet tagged |
| 452 | parsed_pkt = simple_tcp_packet( |
| 453 | pktlen=104, |
| 454 | dl_vlan_enable=True, |
| 455 | vlan_vid=port_to_in_vlan_1[in_port] |
| 456 | ) |
| 457 | pkt = str( parsed_pkt ) |
| 458 | self.dataplane.send( in_port, pkt ) |
| 459 | # we generate the expected pw packet |
| 460 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 461 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 462 | cw = (0, 0, 0, 0) |
| 463 | parsed_pkt = pw_packet( |
| 464 | pktlen=130, |
| 465 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 466 | out_eth_src=port_to_src_mac_str[out_port], |
| 467 | label=[label_1, label_pw], |
| 468 | cw=cw, |
| 469 | out_dl_vlan_enable=True, |
| 470 | out_vlan_vid=port_to_in_vlan_1[in_port], |
| 471 | ) |
| 472 | pkt = str( parsed_pkt ) |
| 473 | # Assertions |
| 474 | verify_packet( self, pkt, out_port ) |
| 475 | verify_no_packet( self, pkt, in_port ) |
| 476 | verify_no_other_packets( self ) |
| 477 | delete_all_flows( self.controller ) |
| 478 | delete_groups( self.controller, Groups ) |
| 479 | delete_groups( self.controller, Groups2 ) |
| 480 | delete_all_groups( self.controller ) |
| 481 | |
| 482 | finally: |
| 483 | delete_all_flows( self.controller ) |
| 484 | delete_groups( self.controller, Groups ) |
| 485 | delete_groups( self.controller, Groups2 ) |
| 486 | delete_all_groups( self.controller ) |
| 487 | |
| 488 | class Tagged2PWInitiation_2_Labels( base_tests.SimpleDataPlane ): |
| 489 | """ |
| 490 | This is meant to test the PW Initiation. The traffic |
| 491 | arrives tagged to the MPLS-TP CE device, it goes out |
| 492 | with a different vlan, with a new ethernet header and 2 mpls labels. |
| 493 | """ |
| 494 | def runTest( self ): |
| 495 | |
| 496 | Groups = Queue.LifoQueue( ) |
| 497 | Groups2 = Queue.LifoQueue( ) |
| 498 | try: |
| 499 | if len( config[ "port_map" ] ) < 1: |
| 500 | logging.info( "Port count less than 1, can't run this case" ) |
| 501 | assert (False) |
| 502 | return |
| 503 | ports = config[ "port_map" ].keys( ) |
| 504 | |
| 505 | for pair in itertools.product(ports, ports): |
| 506 | # we generate all possible products |
| 507 | in_port = pair[0] |
| 508 | out_port = pair[1] |
| 509 | if out_port == in_port: |
| 510 | continue |
| 511 | # we fill the pipeline for the pw initiation |
| 512 | ( |
| 513 | port_to_mpls_label_2, |
| 514 | port_to_mpls_label_1, |
| 515 | port_to_mpls_label_pw, |
| 516 | port_to_in_vlan_3, |
| 517 | port_to_in_vlan_2, |
| 518 | port_to_in_vlan_1, |
| 519 | port_to_src_mac_str, |
| 520 | port_to_dst_mac_str, |
| 521 | Groups ) = fill_pw_initiation_pipeline( |
| 522 | controller=self.controller, |
| 523 | logging=logging, |
| 524 | in_port=in_port, |
| 525 | out_port=out_port, |
| 526 | ingress_tags=1, |
| 527 | egress_tag=EGRESS_TAGGED_TRANS, |
| 528 | mpls_labels=1 |
| 529 | ) |
| 530 | # we fill the pipeline for the pw termination |
| 531 | # on the reverse path |
| 532 | ( |
| 533 | port_to_mpls_label_pw_x, |
| 534 | port_to_vlan_2_x, |
| 535 | port_to_vlan_1_x, |
| 536 | port_to_switch_mac_str_x, |
| 537 | Groups2 ) = fill_pw_termination_pipeline( |
| 538 | controller=self.controller, |
| 539 | logging=logging, |
| 540 | in_port=out_port, |
| 541 | out_port=in_port, |
| 542 | egress_tags=1 |
| 543 | ) |
| 544 | # we generate a simple tcp packet tagged |
| 545 | parsed_pkt = simple_tcp_packet( |
| 546 | pktlen=104, |
| 547 | dl_vlan_enable=True, |
| 548 | vlan_vid=port_to_in_vlan_1[in_port] |
| 549 | ) |
| 550 | pkt = str( parsed_pkt ) |
| 551 | self.dataplane.send( in_port, pkt ) |
| 552 | # we generate the expected pw packet |
| 553 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 554 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 555 | cw = (0, 0, 0, 0) |
| 556 | parsed_pkt = pw_packet( |
| 557 | pktlen=130, |
| 558 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 559 | out_eth_src=port_to_src_mac_str[out_port], |
| 560 | label=[label_1, label_pw], |
| 561 | cw=cw, |
| 562 | out_dl_vlan_enable=True, |
| 563 | out_vlan_vid=port_to_in_vlan_3[in_port], |
| 564 | ) |
| 565 | pkt = str( parsed_pkt ) |
| 566 | # Assertions |
| 567 | verify_packet( self, pkt, out_port ) |
| 568 | verify_no_packet( self, pkt, in_port ) |
| 569 | verify_no_other_packets( self ) |
| 570 | delete_all_flows( self.controller ) |
| 571 | delete_groups( self.controller, Groups ) |
| 572 | delete_groups( self.controller, Groups2 ) |
| 573 | delete_all_groups( self.controller ) |
| 574 | |
| 575 | finally: |
| 576 | delete_all_flows( self.controller ) |
| 577 | delete_groups( self.controller, Groups ) |
| 578 | delete_groups( self.controller, Groups2 ) |
| 579 | delete_all_groups( self.controller ) |
| 580 | |
| 581 | class TaggedPWInitiation_3_Labels( base_tests.SimpleDataPlane ): |
| 582 | """ |
| 583 | This is meant to test the PW Initiation. The traffic |
| 584 | arrives tagged to the MPLS-TP CE device, it goes out |
| 585 | with the same vlan, with a new ethernet header and 3 mpls labels. |
| 586 | """ |
| 587 | def runTest( self ): |
| 588 | |
| 589 | Groups = Queue.LifoQueue( ) |
| 590 | Groups2 = Queue.LifoQueue( ) |
| 591 | try: |
| 592 | if len( config[ "port_map" ] ) < 1: |
| 593 | logging.info( "Port count less than 1, can't run this case" ) |
| 594 | assert (False) |
| 595 | return |
| 596 | ports = config[ "port_map" ].keys( ) |
| 597 | |
| 598 | for pair in itertools.product(ports, ports): |
| 599 | # we generate all possible products |
| 600 | in_port = pair[0] |
| 601 | out_port = pair[1] |
| 602 | if out_port == in_port: |
| 603 | continue |
| 604 | # we fill the pipeline for the pw initiation |
| 605 | ( |
| 606 | port_to_mpls_label_2, |
| 607 | port_to_mpls_label_1, |
| 608 | port_to_mpls_label_pw, |
| 609 | port_to_in_vlan_3, |
| 610 | port_to_in_vlan_2, |
| 611 | port_to_in_vlan_1, |
| 612 | port_to_src_mac_str, |
| 613 | port_to_dst_mac_str, |
| 614 | Groups ) = fill_pw_initiation_pipeline( |
| 615 | controller=self.controller, |
| 616 | logging=logging, |
| 617 | in_port=in_port, |
| 618 | out_port=out_port, |
| 619 | ingress_tags=1, |
| 620 | egress_tag=EGRESS_TAGGED, |
| 621 | mpls_labels=2 |
| 622 | ) |
| 623 | # we fill the pipeline for the pw termination |
| 624 | # on the reverse path |
| 625 | ( |
| 626 | port_to_mpls_label_pw_x, |
| 627 | port_to_vlan_2_x, |
| 628 | port_to_vlan_1_x, |
| 629 | port_to_switch_mac_str_x, |
| 630 | Groups2 ) = fill_pw_termination_pipeline( |
| 631 | controller=self.controller, |
| 632 | logging=logging, |
| 633 | in_port=out_port, |
| 634 | out_port=in_port, |
| 635 | egress_tags=1 |
| 636 | ) |
| 637 | # we generate a simple tcp packet tagged |
| 638 | parsed_pkt = simple_tcp_packet( |
| 639 | pktlen=104, |
| 640 | dl_vlan_enable=True, |
| 641 | vlan_vid=port_to_in_vlan_1[in_port] |
| 642 | ) |
| 643 | pkt = str( parsed_pkt ) |
| 644 | self.dataplane.send( in_port, pkt ) |
| 645 | # we generate the expect pw packet |
| 646 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63) |
| 647 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 648 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 649 | cw = (0, 0, 0, 0) |
| 650 | parsed_pkt = pw_packet( |
| 651 | pktlen=134, |
| 652 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 653 | out_eth_src=port_to_src_mac_str[out_port], |
| 654 | label=[label_2, label_1, label_pw], |
| 655 | cw=cw, |
| 656 | out_dl_vlan_enable=True, |
| 657 | out_vlan_vid=port_to_in_vlan_1[in_port], |
| 658 | ) |
| 659 | pkt = str( parsed_pkt ) |
| 660 | # Assertions |
| 661 | verify_packet( self, pkt, out_port ) |
| 662 | verify_no_packet( self, pkt, in_port ) |
| 663 | verify_no_other_packets( self ) |
| 664 | delete_all_flows( self.controller ) |
| 665 | delete_groups( self.controller, Groups ) |
| 666 | delete_groups( self.controller, Groups2) |
| 667 | delete_all_groups( self.controller ) |
| 668 | |
| 669 | finally: |
| 670 | delete_all_flows( self.controller ) |
| 671 | delete_groups( self.controller, Groups ) |
| 672 | delete_groups( self.controller, Groups2) |
| 673 | delete_all_groups( self.controller ) |
| 674 | |
| 675 | class Tagged2PWInitiation_3_Labels( base_tests.SimpleDataPlane ): |
| 676 | """ |
| 677 | This is meant to test the PW Initiation. The traffic |
| 678 | arrives tagged to the MPLS-TP CE device, it goes out |
| 679 | with a different vlam, with a new ethernet header and 3 mpls labels. |
| 680 | """ |
| 681 | def runTest( self ): |
| 682 | |
| 683 | Groups = Queue.LifoQueue( ) |
| 684 | Groups2 = Queue.LifoQueue( ) |
| 685 | try: |
| 686 | if len( config[ "port_map" ] ) < 1: |
| 687 | logging.info( "Port count less than 1, can't run this case" ) |
| 688 | assert (False) |
| 689 | return |
| 690 | ports = config[ "port_map" ].keys( ) |
| 691 | |
| 692 | for pair in itertools.product(ports, ports): |
| 693 | # we generate all possible products |
| 694 | in_port = pair[0] |
| 695 | out_port = pair[1] |
| 696 | if out_port == in_port: |
| 697 | continue |
| 698 | # we fill the pipeline for the pw initiation |
| 699 | ( |
| 700 | port_to_mpls_label_2, |
| 701 | port_to_mpls_label_1, |
| 702 | port_to_mpls_label_pw, |
| 703 | port_to_in_vlan_3, |
| 704 | port_to_in_vlan_2, |
| 705 | port_to_in_vlan_1, |
| 706 | port_to_src_mac_str, |
| 707 | port_to_dst_mac_str, |
| 708 | Groups ) = fill_pw_initiation_pipeline( |
| 709 | controller=self.controller, |
| 710 | logging=logging, |
| 711 | in_port=in_port, |
| 712 | out_port=out_port, |
| 713 | ingress_tags=1, |
| 714 | egress_tag=EGRESS_TAGGED_TRANS, |
| 715 | mpls_labels=2 |
| 716 | ) |
| 717 | # we fill the pipeline for the pw termination |
| 718 | # on the reverse path |
| 719 | ( |
| 720 | port_to_mpls_label_pw_x, |
| 721 | port_to_vlan_2_x, |
| 722 | port_to_vlan_1_x, |
| 723 | port_to_switch_mac_str_x, |
| 724 | Groups2 ) = fill_pw_termination_pipeline( |
| 725 | controller=self.controller, |
| 726 | logging=logging, |
| 727 | in_port=out_port, |
| 728 | out_port=in_port, |
| 729 | egress_tags=1 |
| 730 | ) |
| 731 | # we generate a simple tcp packet tagged |
| 732 | parsed_pkt = simple_tcp_packet( |
| 733 | pktlen=104, |
| 734 | dl_vlan_enable=True, |
| 735 | vlan_vid=port_to_in_vlan_1[in_port] |
| 736 | ) |
| 737 | pkt = str( parsed_pkt ) |
| 738 | self.dataplane.send( in_port, pkt ) |
| 739 | # we generate the expect pw packet |
| 740 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63) |
| 741 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 742 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 743 | cw = (0, 0, 0, 0) |
| 744 | parsed_pkt = pw_packet( |
| 745 | pktlen=134, |
| 746 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 747 | out_eth_src=port_to_src_mac_str[out_port], |
| 748 | label=[label_2, label_1, label_pw], |
| 749 | cw=cw, |
| 750 | out_dl_vlan_enable=True, |
| 751 | out_vlan_vid=port_to_in_vlan_3[in_port], |
| 752 | ) |
| 753 | pkt = str( parsed_pkt ) |
| 754 | # Assertions |
| 755 | verify_packet( self, pkt, out_port ) |
| 756 | verify_no_packet( self, pkt, in_port ) |
| 757 | verify_no_other_packets( self ) |
| 758 | delete_all_flows( self.controller ) |
| 759 | delete_groups( self.controller, Groups ) |
| 760 | delete_groups( self.controller, Groups2 ) |
| 761 | delete_all_groups( self.controller ) |
| 762 | |
| 763 | finally: |
| 764 | delete_all_flows( self.controller ) |
| 765 | delete_groups( self.controller, Groups ) |
| 766 | delete_groups( self.controller, Groups2 ) |
| 767 | delete_all_groups( self.controller ) |
| 768 | |
| 769 | class DoubleTaggedPWInitiation_2_Labels( base_tests.SimpleDataPlane ): |
| 770 | """ |
| 771 | This is meant to test the PW Initiation. The traffic |
| 772 | arrives double tagged to the MPLS-TP CE device, it goes out |
| 773 | with the same outer vlan, with a new ethernet header and 2 mpls labels. |
| 774 | """ |
| 775 | def runTest( self ): |
| 776 | |
| 777 | Groups = Queue.LifoQueue( ) |
| 778 | Groups2 = Queue.LifoQueue( ) |
| 779 | try: |
| 780 | if len( config[ "port_map" ] ) < 1: |
| 781 | logging.info( "Port count less than 1, can't run this case" ) |
| 782 | assert (False) |
| 783 | return |
| 784 | ports = config[ "port_map" ].keys( ) |
| 785 | |
| 786 | for pair in itertools.product(ports, ports): |
| 787 | # we generate all possible products |
| 788 | in_port = pair[0] |
| 789 | out_port = pair[1] |
| 790 | if out_port == in_port: |
| 791 | continue |
| 792 | # we fill the pipeline for the pw initiation |
| 793 | ( |
| 794 | port_to_mpls_label_2, |
| 795 | port_to_mpls_label_1, |
| 796 | port_to_mpls_label_pw, |
| 797 | port_to_in_vlan_3, |
| 798 | port_to_in_vlan_2, |
| 799 | port_to_in_vlan_1, |
| 800 | port_to_src_mac_str, |
| 801 | port_to_dst_mac_str, |
| 802 | Groups ) = fill_pw_initiation_pipeline( |
| 803 | controller=self.controller, |
| 804 | logging=logging, |
| 805 | in_port=in_port, |
| 806 | out_port=out_port, |
| 807 | ingress_tags=2, |
| 808 | egress_tag=EGRESS_TAGGED, |
| 809 | mpls_labels=1 |
| 810 | ) |
| 811 | # we fill the pipeline for the pw termination |
| 812 | # on the reverse path |
| 813 | ( |
| 814 | port_to_mpls_label_pw_x, |
| 815 | port_to_vlan_2_x, |
| 816 | port_to_vlan_1_x, |
| 817 | port_to_switch_mac_str_x, |
| 818 | Groups2 ) = fill_pw_termination_pipeline( |
| 819 | controller=self.controller, |
| 820 | logging=logging, |
| 821 | in_port=out_port, |
| 822 | out_port=in_port, |
| 823 | egress_tags=2 |
| 824 | ) |
| 825 | # we generate a simple tcp packet with two vlans |
| 826 | parsed_pkt = simple_tcp_packet_two_vlan( |
| 827 | pktlen=108, |
| 828 | out_dl_vlan_enable=True, |
| 829 | out_vlan_vid=port_to_in_vlan_2[in_port], |
| 830 | in_dl_vlan_enable=True, |
| 831 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 832 | ) |
| 833 | pkt = str( parsed_pkt ) |
| 834 | self.dataplane.send( in_port, pkt ) |
| 835 | # we generate the expected pw packet |
| 836 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 837 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 838 | cw = (0, 0, 0, 0) |
| 839 | parsed_pkt = pw_packet( |
| 840 | pktlen=134, |
| 841 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 842 | out_eth_src=port_to_src_mac_str[out_port], |
| 843 | label=[label_1, label_pw], |
| 844 | cw=cw, |
| 845 | out_dl_vlan_enable=True, |
| 846 | out_vlan_vid=port_to_in_vlan_2[in_port], |
| 847 | in_dl_vlan_enable=True, |
| 848 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 849 | ) |
| 850 | pkt = str( parsed_pkt ) |
| 851 | # Assertions |
| 852 | verify_packet( self, pkt, out_port ) |
| 853 | verify_no_packet( self, pkt, in_port ) |
| 854 | verify_no_other_packets( self ) |
| 855 | delete_all_flows( self.controller ) |
| 856 | delete_groups( self.controller, Groups ) |
| 857 | delete_groups( self.controller, Groups2 ) |
| 858 | delete_all_groups( self.controller ) |
| 859 | |
| 860 | finally: |
| 861 | delete_all_flows( self.controller ) |
| 862 | delete_groups( self.controller, Groups ) |
| 863 | delete_groups( self.controller, Groups2 ) |
| 864 | delete_all_groups( self.controller ) |
| 865 | |
| 866 | class DoubleTagged2PWInitiation_2_Labels( base_tests.SimpleDataPlane ): |
| 867 | """ |
| 868 | This is meant to test the PW Initiation. The traffic |
| 869 | arrives double tagged to the MPLS-TP CE device and goes out |
| 870 | with a new ethernet header and 2 mpls labels. |
| 871 | """ |
| 872 | def runTest( self ): |
| 873 | |
| 874 | Groups = Queue.LifoQueue( ) |
| 875 | Groups2 = Queue.LifoQueue( ) |
| 876 | try: |
| 877 | if len( config[ "port_map" ] ) < 1: |
| 878 | logging.info( "Port count less than 1, can't run this case" ) |
| 879 | assert (False) |
| 880 | return |
| 881 | ports = config[ "port_map" ].keys( ) |
| 882 | |
| 883 | for pair in itertools.product(ports, ports): |
| 884 | # we generate all possible products |
| 885 | in_port = pair[0] |
| 886 | out_port = pair[1] |
| 887 | if out_port == in_port: |
| 888 | continue |
| 889 | # we fill the pipeline for the pw initiation |
| 890 | ( |
| 891 | port_to_mpls_label_2, |
| 892 | port_to_mpls_label_1, |
| 893 | port_to_mpls_label_pw, |
| 894 | port_to_in_vlan_3, |
| 895 | port_to_in_vlan_2, |
| 896 | port_to_in_vlan_1, |
| 897 | port_to_src_mac_str, |
| 898 | port_to_dst_mac_str, |
| 899 | Groups ) = fill_pw_initiation_pipeline( |
| 900 | controller=self.controller, |
| 901 | logging=logging, |
| 902 | in_port=in_port, |
| 903 | out_port=out_port, |
| 904 | ingress_tags=2, |
| 905 | egress_tag=EGRESS_TAGGED_TRANS, |
| 906 | mpls_labels=1 |
| 907 | ) |
| 908 | # we fill the pipeline for the pw termination |
| 909 | # on the reverse path |
| 910 | ( |
| 911 | port_to_mpls_label_pw_x, |
| 912 | port_to_vlan_2_x, |
| 913 | port_to_vlan_1_x, |
| 914 | port_to_switch_mac_str_x, |
| 915 | Groups2 ) = fill_pw_termination_pipeline( |
| 916 | controller=self.controller, |
| 917 | logging=logging, |
| 918 | in_port=out_port, |
| 919 | out_port=in_port, |
| 920 | egress_tags=2 |
| 921 | ) |
| 922 | # we generate a simple tcp packet with two vlans |
| 923 | parsed_pkt = simple_tcp_packet_two_vlan( |
| 924 | pktlen=108, |
| 925 | out_dl_vlan_enable=True, |
| 926 | out_vlan_vid=port_to_in_vlan_2[in_port], |
| 927 | in_dl_vlan_enable=True, |
| 928 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 929 | ) |
| 930 | pkt = str( parsed_pkt ) |
| 931 | self.dataplane.send( in_port, pkt ) |
| 932 | # we generate the expected pw packet |
| 933 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 934 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 935 | cw = (0, 0, 0, 0) |
| 936 | parsed_pkt = pw_packet( |
| 937 | pktlen=134, |
| 938 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 939 | out_eth_src=port_to_src_mac_str[out_port], |
| 940 | label=[label_1, label_pw], |
| 941 | cw=cw, |
| 942 | out_dl_vlan_enable=True, |
| 943 | out_vlan_vid=port_to_in_vlan_3[in_port], |
| 944 | in_dl_vlan_enable=True, |
| 945 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 946 | ) |
| 947 | pkt = str( parsed_pkt ) |
| 948 | # Assertions |
| 949 | verify_packet( self, pkt, out_port ) |
| 950 | verify_no_packet( self, pkt, in_port ) |
| 951 | verify_no_other_packets( self ) |
| 952 | delete_all_flows( self.controller ) |
| 953 | delete_groups( self.controller, Groups ) |
| 954 | delete_groups( self.controller, Groups2 ) |
| 955 | delete_all_groups( self.controller ) |
| 956 | |
| 957 | finally: |
| 958 | delete_all_flows( self.controller ) |
| 959 | delete_groups( self.controller, Groups ) |
| 960 | delete_groups( self.controller, Groups2 ) |
| 961 | delete_all_groups( self.controller ) |
| 962 | |
| 963 | class DoubleTaggedPWInitiation_3_Labels( base_tests.SimpleDataPlane ): |
| 964 | """ |
| 965 | This is meant to test the PW Initiation. The traffic |
| 966 | arrives double tagged to the MPLS-TP CE device and goes out |
| 967 | with a new ethernet header and 3 mpls labels. |
| 968 | """ |
| 969 | def runTest( self ): |
| 970 | |
| 971 | Groups = Queue.LifoQueue( ) |
| 972 | Groups2 = Queue.LifoQueue( ) |
| 973 | try: |
| 974 | if len( config[ "port_map" ] ) < 1: |
| 975 | logging.info( "Port count less than 1, can't run this case" ) |
| 976 | assert (False) |
| 977 | return |
| 978 | ports = config[ "port_map" ].keys( ) |
| 979 | |
| 980 | for pair in itertools.product(ports, ports): |
| 981 | # we generate all possible products |
| 982 | in_port = pair[0] |
| 983 | out_port = pair[1] |
| 984 | if out_port == in_port: |
| 985 | continue |
| 986 | # we fill the pipeline for the pw initiation |
| 987 | ( |
| 988 | port_to_mpls_label_2, |
| 989 | port_to_mpls_label_1, |
| 990 | port_to_mpls_label_pw, |
| 991 | port_to_in_vlan_3, |
| 992 | port_to_in_vlan_2, |
| 993 | port_to_in_vlan_1, |
| 994 | port_to_src_mac_str, |
| 995 | port_to_dst_mac_str, |
| 996 | Groups ) = fill_pw_initiation_pipeline( |
| 997 | controller=self.controller, |
| 998 | logging=logging, |
| 999 | in_port=in_port, |
| 1000 | out_port=out_port, |
| 1001 | ingress_tags=2, |
| 1002 | egress_tag=EGRESS_TAGGED, |
| 1003 | mpls_labels=2 |
| 1004 | ) |
| 1005 | # we fill the pipeline for the pw termination |
| 1006 | # on the reverse path |
| 1007 | ( |
| 1008 | port_to_mpls_label_pw_x, |
| 1009 | port_to_vlan_2_x, |
| 1010 | port_to_vlan_1_x, |
| 1011 | port_to_switch_mac_str_x, |
| 1012 | Groups2 ) = fill_pw_termination_pipeline( |
| 1013 | controller=self.controller, |
| 1014 | logging=logging, |
| 1015 | in_port=out_port, |
| 1016 | out_port=in_port, |
| 1017 | egress_tags=2 |
| 1018 | ) |
| 1019 | # we generate a simple tcp packet with two wlan |
| 1020 | parsed_pkt = simple_tcp_packet_two_vlan( |
| 1021 | pktlen=108, |
| 1022 | out_dl_vlan_enable=True, |
| 1023 | out_vlan_vid=port_to_in_vlan_2[in_port], |
| 1024 | in_dl_vlan_enable=True, |
| 1025 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 1026 | ) |
| 1027 | pkt = str( parsed_pkt ) |
| 1028 | self.dataplane.send( in_port, pkt ) |
| 1029 | # we generate the expected pw packet |
| 1030 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63) |
| 1031 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 1032 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 1033 | cw = (0, 0, 0, 0) |
| 1034 | parsed_pkt = pw_packet( |
| 1035 | pktlen=138, |
| 1036 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 1037 | out_eth_src=port_to_src_mac_str[out_port], |
| 1038 | label=[label_2, label_1, label_pw], |
| 1039 | cw=cw, |
| 1040 | out_dl_vlan_enable=True, |
| 1041 | out_vlan_vid=port_to_in_vlan_2[in_port], |
| 1042 | in_dl_vlan_enable=True, |
| 1043 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 1044 | ) |
| 1045 | pkt = str( parsed_pkt ) |
| 1046 | # Assertions |
| 1047 | verify_packet( self, pkt, out_port ) |
| 1048 | verify_no_packet( self, pkt, in_port ) |
| 1049 | verify_no_other_packets( self ) |
| 1050 | delete_all_flows( self.controller ) |
| 1051 | delete_groups( self.controller, Groups ) |
| 1052 | delete_groups( self.controller, Groups2 ) |
| 1053 | delete_all_groups( self.controller ) |
| 1054 | |
| 1055 | finally: |
| 1056 | delete_all_flows( self.controller ) |
| 1057 | delete_groups( self.controller, Groups ) |
| 1058 | delete_groups( self.controller, Groups2 ) |
| 1059 | delete_all_groups( self.controller ) |
| 1060 | |
| 1061 | class DoubleTagged2PWInitiation_3_Labels( base_tests.SimpleDataPlane ): |
| 1062 | """ |
| 1063 | This is meant to test the PW Initiation. The traffic |
| 1064 | arrives double tagged to the MPLS-TP CE device and goes out |
| 1065 | with a new ethernet header and 3 mpls labels. |
| 1066 | """ |
| 1067 | def runTest( self ): |
| 1068 | |
| 1069 | Groups = Queue.LifoQueue( ) |
| 1070 | Groups2 = Queue.LifoQueue( ) |
| 1071 | try: |
| 1072 | if len( config[ "port_map" ] ) < 1: |
| 1073 | logging.info( "Port count less than 1, can't run this case" ) |
| 1074 | assert (False) |
| 1075 | return |
| 1076 | ports = config[ "port_map" ].keys( ) |
| 1077 | |
| 1078 | for pair in itertools.product(ports, ports): |
| 1079 | # we generate all possible products |
| 1080 | in_port = pair[0] |
| 1081 | out_port = pair[1] |
| 1082 | if out_port == in_port: |
| 1083 | continue |
| 1084 | # we fill the pipeline for the pw initiation |
| 1085 | ( |
| 1086 | port_to_mpls_label_2, |
| 1087 | port_to_mpls_label_1, |
| 1088 | port_to_mpls_label_pw, |
| 1089 | port_to_in_vlan_3, |
| 1090 | port_to_in_vlan_2, |
| 1091 | port_to_in_vlan_1, |
| 1092 | port_to_src_mac_str, |
| 1093 | port_to_dst_mac_str, |
| 1094 | Groups ) = fill_pw_initiation_pipeline( |
| 1095 | controller=self.controller, |
| 1096 | logging=logging, |
| 1097 | in_port=in_port, |
| 1098 | out_port=out_port, |
| 1099 | ingress_tags=2, |
| 1100 | egress_tag=EGRESS_TAGGED_TRANS, |
| 1101 | mpls_labels=2 |
| 1102 | ) |
| 1103 | # we fill the pipeline for the pw termination |
| 1104 | # on the reverse path |
| 1105 | ( |
| 1106 | port_to_mpls_label_pw_x, |
| 1107 | port_to_vlan_2_x, |
| 1108 | port_to_vlan_1_x, |
| 1109 | port_to_switch_mac_str_x, |
| 1110 | Groups2 ) = fill_pw_termination_pipeline( |
| 1111 | controller=self.controller, |
| 1112 | logging=logging, |
| 1113 | in_port=out_port, |
| 1114 | out_port=in_port, |
| 1115 | egress_tags=2 |
| 1116 | ) |
| 1117 | # we generate a simple tcp packet with two wlan |
| 1118 | parsed_pkt = simple_tcp_packet_two_vlan( |
| 1119 | pktlen=108, |
| 1120 | out_dl_vlan_enable=True, |
| 1121 | out_vlan_vid=port_to_in_vlan_2[in_port], |
| 1122 | in_dl_vlan_enable=True, |
| 1123 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 1124 | ) |
| 1125 | pkt = str( parsed_pkt ) |
| 1126 | self.dataplane.send( in_port, pkt ) |
| 1127 | # we generate the expected pw packet |
| 1128 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63) |
| 1129 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63) |
| 1130 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63) |
| 1131 | cw = (0, 0, 0, 0) |
| 1132 | parsed_pkt = pw_packet( |
| 1133 | pktlen=138, |
| 1134 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 1135 | out_eth_src=port_to_src_mac_str[out_port], |
| 1136 | label=[label_2, label_1, label_pw], |
| 1137 | cw=cw, |
| 1138 | out_dl_vlan_enable=True, |
| 1139 | out_vlan_vid=port_to_in_vlan_3[in_port], |
| 1140 | in_dl_vlan_enable=True, |
| 1141 | in_vlan_vid=port_to_in_vlan_1[in_port], |
| 1142 | ) |
| 1143 | pkt = str( parsed_pkt ) |
| 1144 | # Assertions |
| 1145 | verify_packet( self, pkt, out_port ) |
| 1146 | verify_no_packet( self, pkt, in_port ) |
| 1147 | verify_no_other_packets( self ) |
| 1148 | delete_all_flows( self.controller ) |
| 1149 | delete_groups( self.controller, Groups ) |
| 1150 | delete_groups( self.controller, Groups2 ) |
| 1151 | delete_all_groups( self.controller ) |
| 1152 | |
| 1153 | finally: |
| 1154 | delete_all_flows( self.controller ) |
| 1155 | delete_groups( self.controller, Groups ) |
| 1156 | delete_groups( self.controller, Groups2 ) |
| 1157 | delete_all_groups( self.controller ) |
| 1158 | |
| 1159 | class IntraCO_2_Labels( base_tests.SimpleDataPlane ): |
| 1160 | """ |
| 1161 | This is meant to test the PW intermediate transport. |
| 1162 | Incoming packet has 2 labels (SR/PW) (intermediate leaf switch). |
| 1163 | There is no VLAN tag in the incoming packet. Pop outer MPLS label |
| 1164 | """ |
| 1165 | def runTest( self ): |
| 1166 | |
| 1167 | Groups = Queue.LifoQueue( ) |
| 1168 | try: |
| 1169 | if len( config[ "port_map" ] ) < 1: |
| 1170 | logging.info( "Port count less than 1, can't run this case" ) |
| 1171 | assert (False) |
| 1172 | return |
| 1173 | ports = config[ "port_map" ].keys( ) |
| 1174 | # we fill the pw pipeline for the intermediate transport |
| 1175 | ( |
| 1176 | port_to_mpls_label_2, |
| 1177 | port_to_mpls_label_1, |
| 1178 | port_to_mpls_label_pw, |
| 1179 | port_to_switch_mac_str, |
| 1180 | port_to_src_mac_str, |
| 1181 | port_to_dst_mac_str, |
| 1182 | Groups |
| 1183 | ) = fill_pw_intermediate_transport_pipeline( |
| 1184 | self.controller, |
| 1185 | logging, |
| 1186 | ports, |
| 1187 | mpls_labels=3 |
| 1188 | ) |
| 1189 | |
| 1190 | for pair in itertools.product(ports, ports): |
| 1191 | # we generate all possible products |
| 1192 | in_port = pair[0] |
| 1193 | out_port = pair[1] |
| 1194 | if out_port == in_port: |
| 1195 | continue |
| 1196 | # we geneate the pw packet |
| 1197 | label_1 = (port_to_mpls_label_2[in_port], 0, 0, 32) |
| 1198 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 32) |
| 1199 | parsed_pkt = mpls_packet( |
| 1200 | pktlen=104, |
| 1201 | ip_ttl=63, |
| 1202 | eth_dst=port_to_switch_mac_str[in_port], |
| 1203 | label=[ label_1, label_pw ] |
| 1204 | ) |
| 1205 | pkt = str( parsed_pkt ) |
| 1206 | self.dataplane.send( in_port, pkt ) |
| 1207 | # we geneate the expected pw packet |
| 1208 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 31) |
| 1209 | parsed_pkt = mpls_packet( |
| 1210 | pktlen=100, |
| 1211 | ip_ttl=63, |
| 1212 | eth_dst=port_to_dst_mac_str[in_port], |
| 1213 | eth_src=port_to_src_mac_str[out_port], |
| 1214 | label=[ label_pw ] |
| 1215 | ) |
| 1216 | pkt = str( parsed_pkt ) |
| 1217 | # Assertions |
| 1218 | verify_packet( self, pkt, out_port ) |
| 1219 | verify_no_packet( self, pkt, in_port ) |
| 1220 | verify_no_other_packets( self ) |
| 1221 | |
| 1222 | finally: |
| 1223 | delete_all_flows( self.controller ) |
| 1224 | delete_groups( self.controller, Groups ) |
| 1225 | delete_all_groups( self.controller ) |
| 1226 | |
| 1227 | class IntraCO_3_Labels( base_tests.SimpleDataPlane ): |
| 1228 | """ |
| 1229 | This is meant to test the PW intermediate transport. |
| 1230 | Incoming packet has 3 labels (SR/SR/PW) (spine switch). |
| 1231 | There is no VLAN tag in the incoming packet. Pop outer MPLS label |
| 1232 | """ |
| 1233 | def runTest( self ): |
| 1234 | |
| 1235 | Groups = Queue.LifoQueue( ) |
| 1236 | try: |
| 1237 | if len( config[ "port_map" ] ) < 1: |
| 1238 | logging.info( "Port count less than 1, can't run this case" ) |
| 1239 | assert (False) |
| 1240 | return |
| 1241 | ports = config[ "port_map" ].keys( ) |
| 1242 | # we fill the pipeline for the intermediate transport |
| 1243 | ( |
| 1244 | port_to_mpls_label_2, |
| 1245 | port_to_mpls_label_1, |
| 1246 | port_to_mpls_label_pw, |
| 1247 | port_to_switch_mac_str, |
| 1248 | port_to_src_mac_str, |
| 1249 | port_to_dst_mac_str, |
| 1250 | Groups |
| 1251 | ) = fill_pw_intermediate_transport_pipeline( |
| 1252 | self.controller, |
| 1253 | logging, |
| 1254 | ports, |
| 1255 | mpls_labels=3 |
| 1256 | ) |
| 1257 | for pair in itertools.product(ports, ports): |
| 1258 | # we generate all possible products |
| 1259 | in_port = pair[0] |
| 1260 | out_port = pair[1] |
| 1261 | if out_port == in_port: |
| 1262 | continue |
| 1263 | # we generate the pw packet |
| 1264 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 32) |
| 1265 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 32) |
| 1266 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 32) |
| 1267 | parsed_pkt = mpls_packet( |
| 1268 | pktlen=104, |
| 1269 | ip_ttl=63, |
| 1270 | eth_dst=port_to_switch_mac_str[in_port], |
| 1271 | label=[ label_2, label_1, label_pw ] |
| 1272 | ) |
| 1273 | pkt = str( parsed_pkt ) |
| 1274 | self.dataplane.send( in_port, pkt ) |
| 1275 | # we generate the expected pw packet |
| 1276 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 31) |
| 1277 | parsed_pkt = mpls_packet( |
| 1278 | pktlen=100, |
| 1279 | ip_ttl=63, |
| 1280 | eth_dst=port_to_dst_mac_str[in_port], |
| 1281 | eth_src=port_to_src_mac_str[out_port], |
| 1282 | label=[ label_1, label_pw ] |
| 1283 | ) |
| 1284 | pkt = str( parsed_pkt ) |
| 1285 | # Assertions |
| 1286 | verify_packet( self, pkt, out_port ) |
| 1287 | verify_no_packet( self, pkt, in_port ) |
| 1288 | verify_no_other_packets( self ) |
| 1289 | |
| 1290 | finally: |
| 1291 | delete_all_flows( self.controller ) |
| 1292 | delete_groups( self.controller, Groups ) |
| 1293 | delete_all_groups( self.controller ) |
| 1294 | |
| 1295 | class InterCO( base_tests.SimpleDataPlane ): |
| 1296 | """ |
| 1297 | This is meant to test the PW intermediate transport. |
| 1298 | Incoming packet has 1 labels (PW) (Intermediate CO leaf switch). |
| 1299 | There is no VLAN tag in the incoming packet. Push up to 2 MPLS labels |
| 1300 | """ |
| 1301 | def runTest( self ): |
| 1302 | |
| 1303 | Groups = Queue.LifoQueue( ) |
| 1304 | try: |
| 1305 | if len( config[ "port_map" ] ) < 1: |
| 1306 | logging.info( "Port count less than 1, can't run this case" ) |
| 1307 | assert (False) |
| 1308 | return |
| 1309 | ports = config[ "port_map" ].keys( ) |
| 1310 | # we fill the pipeline for the intermediate transport |
| 1311 | ( |
| 1312 | port_to_mpls_label_2, |
| 1313 | port_to_mpls_label_1, |
| 1314 | port_to_mpls_label_pw, |
| 1315 | port_to_switch_mac_str, |
| 1316 | port_to_src_mac_str, |
| 1317 | port_to_dst_mac_str, |
| 1318 | Groups |
| 1319 | ) = fill_pw_intermediate_transport_pipeline( |
| 1320 | self.controller, |
| 1321 | logging, |
| 1322 | ports, |
| 1323 | mpls_labels=1 |
| 1324 | ) |
| 1325 | for pair in itertools.product(ports, ports): |
| 1326 | # we generate all possible products |
| 1327 | in_port = pair[0] |
| 1328 | out_port = pair[1] |
| 1329 | if out_port == in_port: |
| 1330 | continue |
| 1331 | # we generate the pw packet |
| 1332 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 32) |
| 1333 | parsed_pkt = mpls_packet( |
| 1334 | pktlen=104, |
| 1335 | ip_ttl=63, |
| 1336 | eth_dst=port_to_switch_mac_str[in_port], |
| 1337 | label=[ label_pw ] |
| 1338 | ) |
| 1339 | pkt = str( parsed_pkt ) |
| 1340 | self.dataplane.send( in_port, pkt ) |
| 1341 | # we generate the expected pw packet |
| 1342 | label_2 = (port_to_mpls_label_2[in_port], 0, 0, 31) |
| 1343 | label_1 = (port_to_mpls_label_1[in_port], 0, 0, 31) |
| 1344 | label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 31) |
| 1345 | parsed_pkt = mpls_packet( |
| 1346 | pktlen=112, |
| 1347 | ip_ttl=63, |
| 1348 | eth_dst=port_to_dst_mac_str[in_port], |
| 1349 | eth_src=port_to_src_mac_str[out_port], |
| 1350 | label=[ label_2, label_1, label_pw ] |
| 1351 | ) |
| 1352 | pkt = str( parsed_pkt ) |
| 1353 | # Assertions |
| 1354 | verify_packet( self, pkt, out_port ) |
| 1355 | verify_no_packet( self, pkt, in_port ) |
| 1356 | verify_no_other_packets( self ) |
| 1357 | |
| 1358 | finally: |
| 1359 | delete_all_flows( self.controller ) |
| 1360 | delete_groups( self.controller, Groups ) |
| 1361 | delete_all_groups( self.controller ) |
| 1362 | |
| 1363 | class UntaggedPWTermination( base_tests.SimpleDataPlane ): |
| 1364 | """ |
| 1365 | This is meant to test the PW Termination. The traffic |
| 1366 | arrives untagged to the MPLS-TP CE device and goes out |
| 1367 | without the outer ethernet header and untagged. |
| 1368 | """ |
| 1369 | def runTest( self ): |
| 1370 | |
| 1371 | Groups = Queue.LifoQueue( ) |
| 1372 | Groups2 = Queue.LifoQueue( ) |
| 1373 | try: |
| 1374 | if len( config[ "port_map" ] ) < 1: |
| 1375 | logging.info( "Port count less than 1, can't run this case" ) |
| 1376 | assert (False) |
| 1377 | return |
| 1378 | ports = config[ "port_map" ].keys( ) |
| 1379 | for pair in itertools.product(ports, ports): |
| 1380 | # we generate all possible products |
| 1381 | in_port = pair[0] |
| 1382 | out_port = pair[1] |
| 1383 | if out_port == in_port: |
| 1384 | continue |
| 1385 | # we fill the pipeline for the pw initiation |
| 1386 | # on the reverse path |
| 1387 | ( |
| 1388 | port_to_mpls_label_2, |
| 1389 | port_to_mpls_label_1, |
| 1390 | port_to_mpls_label_pw, |
| 1391 | port_to_in_vlan_3, |
| 1392 | port_to_in_vlan_2, |
| 1393 | port_to_in_vlan_1, |
| 1394 | port_to_src_mac_str, |
| 1395 | port_to_dst_mac_str, |
| 1396 | Groups ) = fill_pw_initiation_pipeline( |
| 1397 | controller=self.controller, |
| 1398 | logging=logging, |
| 1399 | in_port=out_port, |
| 1400 | out_port=in_port, |
| 1401 | ingress_tags=0, |
| 1402 | egress_tag=EGRESS_UNTAGGED, |
| 1403 | mpls_labels=1 |
| 1404 | ) |
| 1405 | # we fill the pipeline for the pw termination |
| 1406 | ( |
| 1407 | port_to_mpls_label_pw, |
| 1408 | port_to_in_vlan_2, |
| 1409 | port_to_in_vlan_1, |
| 1410 | port_to_dst_mac_str, |
| 1411 | Groups2 ) = fill_pw_termination_pipeline( |
| 1412 | controller=self.controller, |
| 1413 | logging=logging, |
| 1414 | in_port=in_port, |
| 1415 | out_port=out_port, |
| 1416 | egress_tags=0 |
| 1417 | ) |
| 1418 | # we generate the pw packet |
| 1419 | label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63) |
| 1420 | cw = (0, 0, 0, 0) |
| 1421 | parsed_pkt = pw_packet( |
| 1422 | pktlen=104, |
| 1423 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 1424 | label=[label_pw], |
| 1425 | cw=cw |
| 1426 | ) |
| 1427 | pkt = str( parsed_pkt ) |
| 1428 | self.dataplane.send( in_port, pkt ) |
| 1429 | # we generate the expected tcp packet |
| 1430 | parsed_pkt = simple_tcp_packet( |
| 1431 | pktlen=82, |
| 1432 | ) |
| 1433 | pkt = str( parsed_pkt ) |
| 1434 | # Assertions |
| 1435 | verify_packet( self, pkt, out_port ) |
| 1436 | verify_no_packet( self, pkt, in_port ) |
| 1437 | verify_no_other_packets( self ) |
| 1438 | delete_all_flows( self.controller ) |
| 1439 | delete_groups( self.controller, Groups ) |
| 1440 | delete_groups( self.controller, Groups2 ) |
| 1441 | delete_all_groups( self.controller ) |
| 1442 | finally: |
| 1443 | delete_all_flows( self.controller ) |
| 1444 | delete_groups( self.controller, Groups ) |
| 1445 | delete_groups( self.controller, Groups2 ) |
| 1446 | delete_all_groups( self.controller ) |
| 1447 | |
| 1448 | class Untagged2PWTermination( base_tests.SimpleDataPlane ): |
| 1449 | """ |
| 1450 | This is meant to test the PW Termination. The traffic |
| 1451 | arrives untagged to the MPLS-TP CE device and goes out |
| 1452 | without the outer ethernet header and untagged |
| 1453 | but was originally tagged. |
| 1454 | """ |
| 1455 | def runTest( self ): |
| 1456 | |
| 1457 | Groups = Queue.LifoQueue( ) |
| 1458 | Groups2 = Queue.LifoQueue( ) |
| 1459 | try: |
| 1460 | if len( config[ "port_map" ] ) < 1: |
| 1461 | logging.info( "Port count less than 1, can't run this case" ) |
| 1462 | assert (False) |
| 1463 | return |
| 1464 | ports = config[ "port_map" ].keys( ) |
| 1465 | for pair in itertools.product(ports, ports): |
| 1466 | # we generate all possible products |
| 1467 | in_port = pair[0] |
| 1468 | out_port = pair[1] |
| 1469 | if out_port == in_port: |
| 1470 | continue |
| 1471 | # we fill the pipeline for the pw initiation |
| 1472 | # on the reverse path |
| 1473 | ( |
| 1474 | port_to_mpls_label_2, |
| 1475 | port_to_mpls_label_1, |
| 1476 | port_to_mpls_label_pw, |
| 1477 | port_to_in_vlan_3, |
| 1478 | port_to_in_vlan_2, |
| 1479 | port_to_in_vlan_1, |
| 1480 | port_to_src_mac_str, |
| 1481 | port_to_dst_mac_str, |
| 1482 | Groups ) = fill_pw_initiation_pipeline( |
| 1483 | controller=self.controller, |
| 1484 | logging=logging, |
| 1485 | in_port=out_port, |
| 1486 | out_port=in_port, |
| 1487 | ingress_tags=0, |
| 1488 | egress_tag=EGRESS_TAGGED, |
| 1489 | mpls_labels=1 |
| 1490 | ) |
| 1491 | # we fill the pipeline for the pw termination |
| 1492 | ( |
| 1493 | port_to_mpls_label_pw, |
| 1494 | port_to_in_vlan_2, |
| 1495 | port_to_in_vlan_1, |
| 1496 | port_to_dst_mac_str, |
| 1497 | Groups2 ) = fill_pw_termination_pipeline( |
| 1498 | controller=self.controller, |
| 1499 | logging=logging, |
| 1500 | in_port=in_port, |
| 1501 | out_port=out_port, |
| 1502 | egress_tags=0 |
| 1503 | ) |
| 1504 | # we generate the pw packet |
| 1505 | label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63) |
| 1506 | cw = (0, 0, 0, 0) |
| 1507 | parsed_pkt = pw_packet( |
| 1508 | pktlen=104, |
| 1509 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 1510 | label=[label_pw], |
| 1511 | cw=cw, |
| 1512 | out_dl_vlan_enable=True, |
| 1513 | out_vlan_vid=port_to_in_vlan_1[out_port], |
| 1514 | ) |
| 1515 | pkt = str( parsed_pkt ) |
| 1516 | self.dataplane.send( in_port, pkt ) |
| 1517 | # we generate the expected tcp packet |
| 1518 | parsed_pkt = simple_tcp_packet( |
| 1519 | pktlen=78, |
| 1520 | ) |
| 1521 | pkt = str( parsed_pkt ) |
| 1522 | # Assertions |
| 1523 | verify_packet( self, pkt, out_port ) |
| 1524 | verify_no_packet( self, pkt, in_port ) |
| 1525 | verify_no_other_packets( self ) |
| 1526 | delete_all_flows( self.controller ) |
| 1527 | delete_groups( self.controller, Groups ) |
| 1528 | delete_groups( self.controller, Groups2 ) |
| 1529 | delete_all_groups( self.controller ) |
| 1530 | finally: |
| 1531 | delete_all_flows( self.controller ) |
| 1532 | delete_groups( self.controller, Groups ) |
| 1533 | delete_groups( self.controller, Groups2 ) |
| 1534 | delete_all_groups( self.controller ) |
| 1535 | |
| 1536 | class TaggedPWTermination( base_tests.SimpleDataPlane ): |
| 1537 | """ |
| 1538 | This is meant to test the PW Termination. The traffic |
| 1539 | arrives untagged to the MPLS-TP CE device and goes out |
| 1540 | without the outer ethernet header and with a vlan tag. |
| 1541 | """ |
| 1542 | def runTest( self ): |
| 1543 | |
| 1544 | Groups = Queue.LifoQueue( ) |
| 1545 | Groups2 = Queue.LifoQueue( ) |
| 1546 | try: |
| 1547 | if len( config[ "port_map" ] ) < 1: |
| 1548 | logging.info( "Port count less than 1, can't run this case" ) |
| 1549 | assert (False) |
| 1550 | return |
| 1551 | ports = config[ "port_map" ].keys( ) |
| 1552 | for pair in itertools.product(ports, ports): |
| 1553 | # we generate all possible products |
| 1554 | in_port = pair[0] |
| 1555 | out_port = pair[1] |
| 1556 | if out_port == in_port: |
| 1557 | continue |
| 1558 | # we fill the pipeline for the pw initiation |
| 1559 | # on the reverse path |
| 1560 | ( |
| 1561 | port_to_mpls_label_2, |
| 1562 | port_to_mpls_label_1, |
| 1563 | port_to_mpls_label_pw, |
| 1564 | port_to_in_vlan_3, |
| 1565 | port_to_in_vlan_2, |
| 1566 | port_to_in_vlan_1, |
| 1567 | port_to_src_mac_str, |
| 1568 | port_to_dst_mac_str, |
| 1569 | Groups ) = fill_pw_initiation_pipeline( |
| 1570 | controller=self.controller, |
| 1571 | logging=logging, |
| 1572 | in_port=out_port, |
| 1573 | out_port=in_port, |
| 1574 | ingress_tags=1, |
| 1575 | egress_tag=EGRESS_TAGGED, |
| 1576 | mpls_labels=1 |
| 1577 | ) |
| 1578 | # we fill the pipeline for the pw termination |
| 1579 | ( |
| 1580 | port_to_mpls_label_pw, |
| 1581 | port_to_in_vlan_2, |
| 1582 | port_to_in_vlan_1, |
| 1583 | port_to_dst_mac_str, |
| 1584 | Groups2 ) = fill_pw_termination_pipeline( |
| 1585 | controller=self.controller, |
| 1586 | logging=logging, |
| 1587 | in_port=in_port, |
| 1588 | out_port=out_port, |
| 1589 | egress_tags=1 |
| 1590 | ) |
| 1591 | # we generate the pw packet |
| 1592 | label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63) |
| 1593 | cw = (0, 0, 0, 0) |
| 1594 | parsed_pkt = pw_packet( |
| 1595 | pktlen=104, |
| 1596 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 1597 | label=[label_pw], |
| 1598 | cw=cw, |
| 1599 | out_dl_vlan_enable=True, |
| 1600 | out_vlan_vid=port_to_in_vlan_1[out_port], |
| 1601 | ) |
| 1602 | pkt = str( parsed_pkt ) |
| 1603 | self.dataplane.send( in_port, pkt ) |
| 1604 | # we generate the expected tcp packet |
| 1605 | # with a vlan tag |
| 1606 | parsed_pkt = simple_tcp_packet( |
| 1607 | pktlen=82, |
| 1608 | dl_vlan_enable=True, |
| 1609 | vlan_vid=port_to_in_vlan_1[out_port] |
| 1610 | ) |
| 1611 | pkt = str( parsed_pkt ) |
| 1612 | # Assertions |
| 1613 | verify_packet( self, pkt, out_port ) |
| 1614 | verify_no_packet( self, pkt, in_port ) |
| 1615 | verify_no_other_packets( self ) |
| 1616 | delete_all_flows( self.controller ) |
| 1617 | delete_groups( self.controller, Groups ) |
| 1618 | delete_groups( self.controller, Groups2 ) |
| 1619 | delete_all_groups( self.controller ) |
| 1620 | finally: |
| 1621 | delete_all_flows( self.controller ) |
| 1622 | delete_groups( self.controller, Groups ) |
| 1623 | delete_groups( self.controller, Groups2 ) |
| 1624 | delete_all_groups( self.controller ) |
| 1625 | |
| 1626 | class DoubleTaggedPWTermination( base_tests.SimpleDataPlane ): |
| 1627 | """ |
| 1628 | This is meant to test the PW Termination. The traffic |
| 1629 | arrives untagged to the MPLS-TP CE device and goes out |
| 1630 | without the outer ethernet header and 2 vlan tags. |
| 1631 | """ |
| 1632 | def runTest( self ): |
| 1633 | |
| 1634 | Groups = Queue.LifoQueue( ) |
| 1635 | Groups2 = Queue.LifoQueue( ) |
| 1636 | try: |
| 1637 | if len( config[ "port_map" ] ) < 1: |
| 1638 | logging.info( "Port count less than 1, can't run this case" ) |
| 1639 | assert (False) |
| 1640 | return |
| 1641 | ports = config[ "port_map" ].keys( ) |
| 1642 | for pair in itertools.product(ports, ports): |
| 1643 | # we generate all possible products |
| 1644 | in_port = pair[0] |
| 1645 | out_port = pair[1] |
| 1646 | if out_port == in_port: |
| 1647 | continue |
| 1648 | # we fill the pipeline for the pw initiation |
| 1649 | # on the reverse path |
| 1650 | ( |
| 1651 | port_to_mpls_label_2, |
| 1652 | port_to_mpls_label_1, |
| 1653 | port_to_mpls_label_pw, |
| 1654 | port_to_in_vlan_3, |
| 1655 | port_to_in_vlan_2, |
| 1656 | port_to_in_vlan_1, |
| 1657 | port_to_src_mac_str, |
| 1658 | port_to_dst_mac_str, |
| 1659 | Groups ) = fill_pw_initiation_pipeline( |
| 1660 | controller=self.controller, |
| 1661 | logging=logging, |
| 1662 | in_port=out_port, |
| 1663 | out_port=in_port, |
| 1664 | ingress_tags=2, |
| 1665 | egress_tag = EGRESS_TAGGED, |
| 1666 | mpls_labels=1 |
| 1667 | ) |
| 1668 | # we fill the pipeline for the pw termination |
| 1669 | ( |
| 1670 | port_to_mpls_label_pw, |
| 1671 | port_to_in_vlan_2, |
| 1672 | port_to_in_vlan_1, |
| 1673 | port_to_dst_mac_str, |
| 1674 | Groups2 ) = fill_pw_termination_pipeline( |
| 1675 | controller=self.controller, |
| 1676 | logging=logging, |
| 1677 | in_port=in_port, |
| 1678 | out_port=out_port, |
| 1679 | egress_tags=2 |
| 1680 | ) |
| 1681 | # we generate the pw packet |
| 1682 | label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63) |
| 1683 | cw = (0, 0, 0, 0) |
| 1684 | parsed_pkt = pw_packet( |
| 1685 | pktlen=104, |
| 1686 | out_eth_dst=port_to_dst_mac_str[in_port], |
| 1687 | label=[label_pw], |
| 1688 | cw=cw, |
| 1689 | out_dl_vlan_enable=True, |
| 1690 | out_vlan_vid=port_to_in_vlan_2[out_port], |
| 1691 | in_dl_vlan_enable=True, |
| 1692 | in_vlan_vid=port_to_in_vlan_1[out_port] |
| 1693 | ) |
| 1694 | pkt = str( parsed_pkt ) |
| 1695 | self.dataplane.send( in_port, pkt ) |
| 1696 | # we generate the expected tcp |
| 1697 | # packet with two vlan tags |
| 1698 | parsed_pkt = simple_tcp_packet_two_vlan( |
| 1699 | pktlen=82, |
| 1700 | out_dl_vlan_enable=True, |
| 1701 | out_vlan_vid=port_to_in_vlan_2[out_port], |
| 1702 | in_dl_vlan_enable=True, |
| 1703 | in_vlan_vid=port_to_in_vlan_1[out_port] |
| 1704 | ) |
| 1705 | pkt = str( parsed_pkt ) |
| 1706 | # Assertions |
| 1707 | verify_packet( self, pkt, out_port ) |
| 1708 | verify_no_packet( self, pkt, in_port ) |
| 1709 | verify_no_other_packets( self ) |
| 1710 | delete_all_flows( self.controller ) |
| 1711 | delete_groups( self.controller, Groups ) |
| 1712 | delete_groups( self.controller, Groups2 ) |
| 1713 | delete_all_groups( self.controller ) |
| 1714 | finally: |
| 1715 | delete_all_flows( self.controller ) |
| 1716 | delete_groups( self.controller, Groups ) |
| 1717 | delete_groups( self.controller, Groups2 ) |
| 1718 | delete_all_groups( self.controller ) |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1719 | |
| 1720 | class BoSBug( base_tests.SimpleDataPlane ): |
| 1721 | """ |
| 1722 | This test is meant to verify the forwarding of the default traffic |
| 1723 | when the rule for the PW transport (BoS=0) has been installed in the |
| 1724 | switch, together with the rule for the transport of default routing |
| 1725 | traffic. There is a bug in OFDPA 3.0EA4, which requires BOS=0 flow |
| 1726 | to be installed before BOS=1 flow to generate correct packets. Incoming |
| 1727 | packet has 1 label, and there is no VLAN tag in the incoming packet. |
| 1728 | The expected behvior is the Pop of the outer MPLS label and plain IP |
| 1729 | packet should exit from the switch. |
| 1730 | """ |
| 1731 | def runTest( self ): |
| 1732 | Groups = Queue.LifoQueue( ) |
| 1733 | try: |
| 1734 | if len( config[ "port_map" ] ) < 1: |
| 1735 | logging.info( "Port count less than 1, can't run this case" ) |
| 1736 | assert (False) |
| 1737 | return |
| 1738 | ports = config[ "port_map" ].keys( ) |
| 1739 | in_port = ports[0] |
| 1740 | out_port = ports[1] |
| 1741 | out_vlan = 4094 |
| 1742 | src_mac = [ 0x00, 0x00, 0x00, 0x00, 0x11, 0x01 ] |
| 1743 | src_mac_str = ':'.join( [ '%02X' % x for x in src_mac ] ) |
| 1744 | dst_mac = [ 0x00, 0x00, 0x00, 0x11, 0x11, 0x01 ] |
| 1745 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 1746 | mpls_label = 100 |
| 1747 | # Add l2 interface group, we have to pop the VLAN; |
| 1748 | l2_intf_gid, l2_intf_msg = add_one_l2_interface_group( |
| 1749 | ctrl=self.controller, |
| 1750 | port=out_port, |
| 1751 | vlan_id=out_vlan, |
| 1752 | is_tagged=False, |
| 1753 | send_barrier=False |
| 1754 | ) |
| 1755 | Groups._put( l2_intf_gid ) |
| 1756 | # add MPLS interface group |
| 1757 | mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group( |
| 1758 | ctrl=self.controller, |
| 1759 | ref_gid=l2_intf_gid, |
| 1760 | dst_mac=dst_mac, |
| 1761 | src_mac=src_mac, |
| 1762 | vid=out_vlan, |
| 1763 | index=in_port |
| 1764 | ) |
| 1765 | Groups._put( mpls_intf_gid ) |
| 1766 | # Add L3 Unicast group |
| 1767 | l3_msg = add_l3_unicast_group( |
| 1768 | ctrl=self.controller, |
| 1769 | port=out_port, |
| 1770 | vlanid=out_vlan, |
| 1771 | id=in_port, |
| 1772 | src_mac=src_mac, |
| 1773 | dst_mac=dst_mac |
| 1774 | ) |
| 1775 | Groups._put( l3_msg.group_id ) |
| 1776 | # Add L3 ecmp group |
| 1777 | ecmp_msg = add_l3_ecmp_group( |
| 1778 | ctrl=self.controller, |
| 1779 | id=in_port, |
| 1780 | l3_ucast_groups=[ l3_msg.group_id ] |
| 1781 | ) |
| 1782 | Groups._put( ecmp_msg.group_id ) |
| 1783 | # Add MPLS flow with BoS=1 |
| 1784 | add_mpls_flow( |
| 1785 | ctrl=self.controller, |
| 1786 | action_group_id=ecmp_msg.group_id, |
| 1787 | label=mpls_label |
| 1788 | ) |
| 1789 | # add MPLS flow with BoS=0 |
| 1790 | add_mpls_flow_pw( |
| 1791 | ctrl=self.controller, |
| 1792 | action_group_id=mpls_intf_gid, |
| 1793 | label=mpls_label, |
| 1794 | ethertype=0x8847, |
| 1795 | tunnel_index=1, |
| 1796 | bos=0 |
| 1797 | ) |
| 1798 | # add Termination flow |
| 1799 | add_termination_flow( |
| 1800 | ctrl=self.controller, |
| 1801 | in_port=in_port, |
| 1802 | eth_type=0x8847, |
| 1803 | dst_mac=src_mac, |
| 1804 | vlanid=out_vlan, |
| 1805 | goto_table=23 |
| 1806 | ) |
| 1807 | # add VLAN flows |
| 1808 | add_one_vlan_table_flow( |
| 1809 | ctrl=self.controller, |
| 1810 | of_port=in_port, |
| 1811 | vlan_id=out_vlan, |
| 1812 | flag=VLAN_TABLE_FLAG_ONLY_TAG, |
| 1813 | ) |
| 1814 | add_one_vlan_table_flow( |
| 1815 | ctrl=self.controller, |
| 1816 | of_port=in_port, |
| 1817 | vlan_id=out_vlan, |
| 1818 | flag=VLAN_TABLE_FLAG_ONLY_UNTAG |
| 1819 | ) |
| 1820 | # Packet generation with sleep |
| 1821 | time.sleep(2) |
| 1822 | label = (mpls_label, 0, 1, 32) |
| 1823 | parsed_pkt = mpls_packet( |
| 1824 | pktlen=104, |
| 1825 | vlan_vid=out_vlan, |
| 1826 | ip_ttl=63, |
| 1827 | eth_dst=src_mac_str, |
| 1828 | label=[ label] |
| 1829 | ) |
| 1830 | pkt = str( parsed_pkt ) |
| 1831 | self.dataplane.send( in_port, pkt ) |
| 1832 | # we geneate the expected pw packet |
| 1833 | parsed_pkt = simple_tcp_packet( |
| 1834 | pktlen=100, |
| 1835 | vlan_vid=out_vlan, |
| 1836 | ip_ttl=31, |
| 1837 | eth_dst=dst_mac_str, |
| 1838 | eth_src=src_mac_str, |
| 1839 | ) |
| 1840 | pkt = str( parsed_pkt ) |
| 1841 | # Assertions |
| 1842 | verify_packet( self, pkt, out_port ) |
| 1843 | verify_no_packet( self, pkt, in_port ) |
| 1844 | verify_no_other_packets( self ) |
| 1845 | finally: |
| 1846 | delete_all_flows( self.controller ) |
| 1847 | delete_groups( self.controller, Groups ) |
| 1848 | delete_all_groups( self.controller ) |