blob: 5713a9451f697c7b54d5b980695a573eb4894647 [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
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
Pier23784aa2016-09-19 20:08:21 -070017"""
18Check README file
19"""
20import Queue
Pier265ad5f2017-02-28 17:46:28 +010021import time
Pier23784aa2016-09-19 20:08:21 -070022
23from oftest import config
24import inspect
25import logging
26import oftest.base_tests as base_tests
27import ofp
28from oftest.testutils import *
29from accton_util import *
30from utils import *
31
32class 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
122class 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 )
Charles Chanc85f1562018-01-18 15:44:29 -0800202
Pier23784aa2016-09-19 20:08:21 -0700203 # Flush all the rules for the next couple
204 delete_all_flows( self.controller )
205 delete_groups( self.controller, Groups )
206 delete_groups( self.controller, Groups2 )
207 delete_all_groups( self.controller )
208
209 finally:
210 delete_all_flows( self.controller )
211 delete_groups( self.controller, Groups )
212 delete_groups( self.controller, Groups2 )
213 delete_all_groups( self.controller )
214
215class UntaggedPWInitiation_3_Labels( base_tests.SimpleDataPlane ):
216 """
217 This is meant to test the PW Initiation. The traffic
218 arrives untagged to the MPLS-TP CE device, it goes out
219 untagged, with a new ethernet header and 3 mpls labels.
220 """
221 def runTest( self ):
222
223 Groups = Queue.LifoQueue( )
224 Groups2 = Queue.LifoQueue( )
225 try:
226 if len( config[ "port_map" ] ) < 1:
227 logging.info( "Port count less than 1, can't run this case" )
228 assert (False)
229 return
230 ports = config[ "port_map" ].keys( )
231
232 for pair in itertools.product(ports, ports):
233 # we generate all possible products
234 in_port = pair[0]
235 out_port = pair[1]
236 if out_port == in_port:
237 continue
238 # we fill the pipeline for the pw initiation
239 (
240 port_to_mpls_label_2,
241 port_to_mpls_label_1,
242 port_to_mpls_label_pw,
243 port_to_in_vlan_3,
244 port_to_in_vlan_2,
245 port_to_in_vlan_1,
246 port_to_src_mac_str,
247 port_to_dst_mac_str,
248 Groups ) = fill_pw_initiation_pipeline(
249 controller=self.controller,
250 logging=logging,
251 in_port=in_port,
252 out_port=out_port,
253 ingress_tags=0,
254 egress_tag=EGRESS_UNTAGGED,
255 mpls_labels=2
256 )
257 # we fill the pipeline for the pw termination
258 # on the reverse path
259 (
260 port_to_mpls_label_pw_x,
261 port_to_vlan_2_x,
262 port_to_vlan_1_x,
263 port_to_switch_mac_str_x,
264 Groups2 ) = fill_pw_termination_pipeline(
265 controller=self.controller,
266 logging=logging,
267 in_port=out_port,
268 out_port=in_port,
269 egress_tags=0
270 )
271 # we generate a simple tcp packet
272 parsed_pkt = simple_tcp_packet(
273 pktlen=104,
274 )
275 pkt = str( parsed_pkt )
276 self.dataplane.send( in_port, pkt )
277 # we generate the pw packet we expect on the out port
278 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63)
279 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
280 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
281 cw = (0, 0, 0, 0)
282 parsed_pkt = pw_packet(
283 pktlen=134,
284 out_eth_dst=port_to_dst_mac_str[in_port],
285 out_eth_src=port_to_src_mac_str[out_port],
286 label=[label_2, label_1, label_pw],
287 cw=cw
288 )
289 pkt = str( parsed_pkt )
290 # Assertions
291 verify_packet( self, pkt, out_port )
292 verify_no_packet( self, pkt, in_port )
293 verify_no_other_packets( self )
294 delete_all_flows( self.controller )
295 delete_groups( self.controller, Groups )
296 delete_groups( self.controller, Groups2 )
297 delete_all_groups( self.controller )
298
299 finally:
300 delete_all_flows( self.controller )
301 delete_groups( self.controller, Groups )
302 delete_groups( self.controller, Groups2 )
303 delete_all_groups( self.controller )
304
305class Untagged2PWInitiation_3_Labels( base_tests.SimpleDataPlane ):
306 """
307 This is meant to test the PW Initiation. The traffic
308 arrives untagged to the MPLS-TP CE device, it goes out
309 tagged with a new ethernet header and 3 mpls labels.
310 """
311 def runTest( self ):
312
313 Groups = Queue.LifoQueue( )
314 Groups2 = Queue.LifoQueue( )
315 try:
316 if len( config[ "port_map" ] ) < 1:
317 logging.info( "Port count less than 1, can't run this case" )
318 assert (False)
319 return
320 ports = config[ "port_map" ].keys( )
321
322 for pair in itertools.product(ports, ports):
323 # we generate all possible products
324 in_port = pair[0]
325 out_port = pair[1]
326 if out_port == in_port:
327 continue
328 # we fill the pipeline for the pw initiation
329 (
330 port_to_mpls_label_2,
331 port_to_mpls_label_1,
332 port_to_mpls_label_pw,
333 port_to_in_vlan_3,
334 port_to_in_vlan_2,
335 port_to_in_vlan_1,
336 port_to_src_mac_str,
337 port_to_dst_mac_str,
338 Groups ) = fill_pw_initiation_pipeline(
339 controller=self.controller,
340 logging=logging,
341 in_port=in_port,
342 out_port=out_port,
343 ingress_tags=0,
344 egress_tag=EGRESS_TAGGED,
345 mpls_labels=2
346 )
347 # we fill the pipeline for the pw termination
348 # on the reverse path
349 (
350 port_to_mpls_label_pw_x,
351 port_to_vlan_2_x,
352 port_to_vlan_1_x,
353 port_to_switch_mac_str_x,
354 Groups2 ) = fill_pw_termination_pipeline(
355 controller=self.controller,
356 logging=logging,
357 in_port=out_port,
358 out_port=in_port,
359 egress_tags=0
360 )
361 # we generate a simple tcp packet
362 parsed_pkt = simple_tcp_packet(
363 pktlen=104,
364 )
365 pkt = str( parsed_pkt )
366 self.dataplane.send( in_port, pkt )
367 # we generate the pw packet we expect on the out port
368 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63)
369 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
370 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
371 cw = (0, 0, 0, 0)
372 parsed_pkt = pw_packet(
373 pktlen=138,
374 out_eth_dst=port_to_dst_mac_str[in_port],
375 out_eth_src=port_to_src_mac_str[out_port],
376 label=[label_2, label_1, label_pw],
377 cw=cw,
378 out_dl_vlan_enable=True,
379 out_vlan_vid=port_to_in_vlan_1[in_port],
380 )
381 pkt = str( parsed_pkt )
382 # Asserions
383 verify_packet( self, pkt, out_port )
384 verify_no_packet( self, pkt, in_port )
385 verify_no_other_packets( self )
386 delete_all_flows( self.controller )
387 delete_groups( self.controller, Groups )
388 delete_groups( self.controller, Groups2 )
389 delete_all_groups( self.controller )
390
391 finally:
392 delete_all_flows( self.controller )
393 delete_groups( self.controller, Groups )
394 delete_groups( self.controller, Groups2 )
395 delete_all_groups( self.controller )
396
397class TaggedPWInitiation_2_Labels( base_tests.SimpleDataPlane ):
398 """
399 This is meant to test the PW Initiation. The traffic
400 arrives tagged to the MPLS-TP CE device, it goes out
401 with the same tag, a new ethernet header and 2 mpls labels.
402 """
403 def runTest( self ):
404
405 Groups = Queue.LifoQueue( )
406 Groups2 = Queue.LifoQueue( )
407 try:
408 if len( config[ "port_map" ] ) < 1:
409 logging.info( "Port count less than 1, can't run this case" )
410 assert (False)
411 return
412 ports = config[ "port_map" ].keys( )
413 for pair in itertools.product(ports, ports):
414 # we generate all possible products
415 in_port = pair[0]
416 out_port = pair[1]
417 if out_port == in_port:
418 continue
419 # we fill the pipeline for the pw initiation
420 (
421 port_to_mpls_label_2,
422 port_to_mpls_label_1,
423 port_to_mpls_label_pw,
424 port_to_in_vlan_3,
425 port_to_in_vlan_2,
426 port_to_in_vlan_1,
427 port_to_src_mac_str,
428 port_to_dst_mac_str,
429 Groups ) = fill_pw_initiation_pipeline(
430 controller=self.controller,
431 logging=logging,
432 in_port=in_port,
433 out_port=out_port,
434 ingress_tags=1,
435 egress_tag=EGRESS_TAGGED,
436 mpls_labels=1
437 )
438 # we fill the pipeline for the pw termination
439 # on the reverse path
440 (
441 port_to_mpls_label_pw_x,
442 port_to_vlan_2_x,
443 port_to_vlan_1_x,
444 port_to_switch_mac_str_x,
445 Groups2 ) = fill_pw_termination_pipeline(
446 controller=self.controller,
447 logging=logging,
448 in_port=out_port,
449 out_port=in_port,
450 egress_tags=1
451 )
452 # we generate a simple tcp packet tagged
453 parsed_pkt = simple_tcp_packet(
454 pktlen=104,
455 dl_vlan_enable=True,
456 vlan_vid=port_to_in_vlan_1[in_port]
457 )
458 pkt = str( parsed_pkt )
459 self.dataplane.send( in_port, pkt )
460 # we generate the expected pw packet
461 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
462 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
463 cw = (0, 0, 0, 0)
464 parsed_pkt = pw_packet(
465 pktlen=130,
466 out_eth_dst=port_to_dst_mac_str[in_port],
467 out_eth_src=port_to_src_mac_str[out_port],
468 label=[label_1, label_pw],
469 cw=cw,
470 out_dl_vlan_enable=True,
471 out_vlan_vid=port_to_in_vlan_1[in_port],
472 )
473 pkt = str( parsed_pkt )
474 # Assertions
475 verify_packet( self, pkt, out_port )
476 verify_no_packet( self, pkt, in_port )
477 verify_no_other_packets( self )
Charles Chanc85f1562018-01-18 15:44:29 -0800478
Pier23784aa2016-09-19 20:08:21 -0700479 delete_all_flows( self.controller )
480 delete_groups( self.controller, Groups )
481 delete_groups( self.controller, Groups2 )
482 delete_all_groups( self.controller )
483
484 finally:
485 delete_all_flows( self.controller )
486 delete_groups( self.controller, Groups )
487 delete_groups( self.controller, Groups2 )
488 delete_all_groups( self.controller )
489
490class Tagged2PWInitiation_2_Labels( base_tests.SimpleDataPlane ):
491 """
492 This is meant to test the PW Initiation. The traffic
493 arrives tagged to the MPLS-TP CE device, it goes out
494 with a different vlan, with a new ethernet header and 2 mpls labels.
495 """
496 def runTest( self ):
497
498 Groups = Queue.LifoQueue( )
499 Groups2 = Queue.LifoQueue( )
500 try:
501 if len( config[ "port_map" ] ) < 1:
502 logging.info( "Port count less than 1, can't run this case" )
503 assert (False)
504 return
505 ports = config[ "port_map" ].keys( )
506
507 for pair in itertools.product(ports, ports):
508 # we generate all possible products
509 in_port = pair[0]
510 out_port = pair[1]
511 if out_port == in_port:
512 continue
513 # we fill the pipeline for the pw initiation
514 (
515 port_to_mpls_label_2,
516 port_to_mpls_label_1,
517 port_to_mpls_label_pw,
518 port_to_in_vlan_3,
519 port_to_in_vlan_2,
520 port_to_in_vlan_1,
521 port_to_src_mac_str,
522 port_to_dst_mac_str,
523 Groups ) = fill_pw_initiation_pipeline(
524 controller=self.controller,
525 logging=logging,
526 in_port=in_port,
527 out_port=out_port,
528 ingress_tags=1,
529 egress_tag=EGRESS_TAGGED_TRANS,
530 mpls_labels=1
531 )
532 # we fill the pipeline for the pw termination
533 # on the reverse path
534 (
535 port_to_mpls_label_pw_x,
536 port_to_vlan_2_x,
537 port_to_vlan_1_x,
538 port_to_switch_mac_str_x,
539 Groups2 ) = fill_pw_termination_pipeline(
540 controller=self.controller,
541 logging=logging,
542 in_port=out_port,
543 out_port=in_port,
544 egress_tags=1
545 )
546 # we generate a simple tcp packet tagged
547 parsed_pkt = simple_tcp_packet(
548 pktlen=104,
549 dl_vlan_enable=True,
550 vlan_vid=port_to_in_vlan_1[in_port]
551 )
552 pkt = str( parsed_pkt )
553 self.dataplane.send( in_port, pkt )
554 # we generate the expected pw packet
555 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
556 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
557 cw = (0, 0, 0, 0)
558 parsed_pkt = pw_packet(
559 pktlen=130,
560 out_eth_dst=port_to_dst_mac_str[in_port],
561 out_eth_src=port_to_src_mac_str[out_port],
562 label=[label_1, label_pw],
563 cw=cw,
564 out_dl_vlan_enable=True,
565 out_vlan_vid=port_to_in_vlan_3[in_port],
566 )
567 pkt = str( parsed_pkt )
568 # Assertions
569 verify_packet( self, pkt, out_port )
570 verify_no_packet( self, pkt, in_port )
571 verify_no_other_packets( self )
Charles Chanc85f1562018-01-18 15:44:29 -0800572
Pier23784aa2016-09-19 20:08:21 -0700573 delete_all_flows( self.controller )
574 delete_groups( self.controller, Groups )
575 delete_groups( self.controller, Groups2 )
576 delete_all_groups( self.controller )
577
578 finally:
579 delete_all_flows( self.controller )
580 delete_groups( self.controller, Groups )
581 delete_groups( self.controller, Groups2 )
582 delete_all_groups( self.controller )
583
584class TaggedPWInitiation_3_Labels( base_tests.SimpleDataPlane ):
585 """
586 This is meant to test the PW Initiation. The traffic
587 arrives tagged to the MPLS-TP CE device, it goes out
588 with the same vlan, with a new ethernet header and 3 mpls labels.
589 """
590 def runTest( self ):
591
592 Groups = Queue.LifoQueue( )
593 Groups2 = Queue.LifoQueue( )
594 try:
595 if len( config[ "port_map" ] ) < 1:
596 logging.info( "Port count less than 1, can't run this case" )
597 assert (False)
598 return
599 ports = config[ "port_map" ].keys( )
600
601 for pair in itertools.product(ports, ports):
602 # we generate all possible products
603 in_port = pair[0]
604 out_port = pair[1]
605 if out_port == in_port:
606 continue
607 # we fill the pipeline for the pw initiation
608 (
609 port_to_mpls_label_2,
610 port_to_mpls_label_1,
611 port_to_mpls_label_pw,
612 port_to_in_vlan_3,
613 port_to_in_vlan_2,
614 port_to_in_vlan_1,
615 port_to_src_mac_str,
616 port_to_dst_mac_str,
617 Groups ) = fill_pw_initiation_pipeline(
618 controller=self.controller,
619 logging=logging,
620 in_port=in_port,
621 out_port=out_port,
622 ingress_tags=1,
623 egress_tag=EGRESS_TAGGED,
624 mpls_labels=2
625 )
626 # we fill the pipeline for the pw termination
627 # on the reverse path
628 (
629 port_to_mpls_label_pw_x,
630 port_to_vlan_2_x,
631 port_to_vlan_1_x,
632 port_to_switch_mac_str_x,
633 Groups2 ) = fill_pw_termination_pipeline(
634 controller=self.controller,
635 logging=logging,
636 in_port=out_port,
637 out_port=in_port,
638 egress_tags=1
639 )
640 # we generate a simple tcp packet tagged
641 parsed_pkt = simple_tcp_packet(
642 pktlen=104,
643 dl_vlan_enable=True,
644 vlan_vid=port_to_in_vlan_1[in_port]
645 )
646 pkt = str( parsed_pkt )
647 self.dataplane.send( in_port, pkt )
648 # we generate the expect pw packet
649 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63)
650 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
651 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
652 cw = (0, 0, 0, 0)
653 parsed_pkt = pw_packet(
654 pktlen=134,
655 out_eth_dst=port_to_dst_mac_str[in_port],
656 out_eth_src=port_to_src_mac_str[out_port],
657 label=[label_2, label_1, label_pw],
658 cw=cw,
659 out_dl_vlan_enable=True,
660 out_vlan_vid=port_to_in_vlan_1[in_port],
661 )
662 pkt = str( parsed_pkt )
663 # Assertions
664 verify_packet( self, pkt, out_port )
665 verify_no_packet( self, pkt, in_port )
666 verify_no_other_packets( self )
667 delete_all_flows( self.controller )
668 delete_groups( self.controller, Groups )
669 delete_groups( self.controller, Groups2)
670 delete_all_groups( self.controller )
671
672 finally:
673 delete_all_flows( self.controller )
674 delete_groups( self.controller, Groups )
675 delete_groups( self.controller, Groups2)
676 delete_all_groups( self.controller )
677
678class Tagged2PWInitiation_3_Labels( base_tests.SimpleDataPlane ):
679 """
680 This is meant to test the PW Initiation. The traffic
681 arrives tagged to the MPLS-TP CE device, it goes out
682 with a different vlam, with a new ethernet header and 3 mpls labels.
683 """
684 def runTest( self ):
685
686 Groups = Queue.LifoQueue( )
687 Groups2 = Queue.LifoQueue( )
688 try:
689 if len( config[ "port_map" ] ) < 1:
690 logging.info( "Port count less than 1, can't run this case" )
691 assert (False)
692 return
693 ports = config[ "port_map" ].keys( )
694
695 for pair in itertools.product(ports, ports):
696 # we generate all possible products
697 in_port = pair[0]
698 out_port = pair[1]
699 if out_port == in_port:
700 continue
701 # we fill the pipeline for the pw initiation
702 (
703 port_to_mpls_label_2,
704 port_to_mpls_label_1,
705 port_to_mpls_label_pw,
706 port_to_in_vlan_3,
707 port_to_in_vlan_2,
708 port_to_in_vlan_1,
709 port_to_src_mac_str,
710 port_to_dst_mac_str,
711 Groups ) = fill_pw_initiation_pipeline(
712 controller=self.controller,
713 logging=logging,
714 in_port=in_port,
715 out_port=out_port,
716 ingress_tags=1,
717 egress_tag=EGRESS_TAGGED_TRANS,
718 mpls_labels=2
719 )
720 # we fill the pipeline for the pw termination
721 # on the reverse path
722 (
723 port_to_mpls_label_pw_x,
724 port_to_vlan_2_x,
725 port_to_vlan_1_x,
726 port_to_switch_mac_str_x,
727 Groups2 ) = fill_pw_termination_pipeline(
728 controller=self.controller,
729 logging=logging,
730 in_port=out_port,
731 out_port=in_port,
732 egress_tags=1
733 )
734 # we generate a simple tcp packet tagged
735 parsed_pkt = simple_tcp_packet(
736 pktlen=104,
737 dl_vlan_enable=True,
738 vlan_vid=port_to_in_vlan_1[in_port]
739 )
740 pkt = str( parsed_pkt )
741 self.dataplane.send( in_port, pkt )
742 # we generate the expect pw packet
743 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63)
744 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
745 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
746 cw = (0, 0, 0, 0)
747 parsed_pkt = pw_packet(
748 pktlen=134,
749 out_eth_dst=port_to_dst_mac_str[in_port],
750 out_eth_src=port_to_src_mac_str[out_port],
751 label=[label_2, label_1, label_pw],
752 cw=cw,
753 out_dl_vlan_enable=True,
754 out_vlan_vid=port_to_in_vlan_3[in_port],
755 )
756 pkt = str( parsed_pkt )
757 # Assertions
758 verify_packet( self, pkt, out_port )
759 verify_no_packet( self, pkt, in_port )
760 verify_no_other_packets( self )
761 delete_all_flows( self.controller )
762 delete_groups( self.controller, Groups )
763 delete_groups( self.controller, Groups2 )
764 delete_all_groups( self.controller )
765
766 finally:
767 delete_all_flows( self.controller )
768 delete_groups( self.controller, Groups )
769 delete_groups( self.controller, Groups2 )
770 delete_all_groups( self.controller )
771
772class DoubleTaggedPWInitiation_2_Labels( base_tests.SimpleDataPlane ):
773 """
774 This is meant to test the PW Initiation. The traffic
775 arrives double tagged to the MPLS-TP CE device, it goes out
776 with the same outer vlan, with a new ethernet header and 2 mpls labels.
777 """
778 def runTest( self ):
779
780 Groups = Queue.LifoQueue( )
781 Groups2 = Queue.LifoQueue( )
782 try:
783 if len( config[ "port_map" ] ) < 1:
784 logging.info( "Port count less than 1, can't run this case" )
785 assert (False)
786 return
787 ports = config[ "port_map" ].keys( )
788
789 for pair in itertools.product(ports, ports):
790 # we generate all possible products
791 in_port = pair[0]
792 out_port = pair[1]
793 if out_port == in_port:
794 continue
795 # we fill the pipeline for the pw initiation
796 (
797 port_to_mpls_label_2,
798 port_to_mpls_label_1,
799 port_to_mpls_label_pw,
800 port_to_in_vlan_3,
801 port_to_in_vlan_2,
802 port_to_in_vlan_1,
803 port_to_src_mac_str,
804 port_to_dst_mac_str,
805 Groups ) = fill_pw_initiation_pipeline(
806 controller=self.controller,
807 logging=logging,
808 in_port=in_port,
809 out_port=out_port,
810 ingress_tags=2,
811 egress_tag=EGRESS_TAGGED,
812 mpls_labels=1
813 )
814 # we fill the pipeline for the pw termination
815 # on the reverse path
816 (
817 port_to_mpls_label_pw_x,
818 port_to_vlan_2_x,
819 port_to_vlan_1_x,
820 port_to_switch_mac_str_x,
821 Groups2 ) = fill_pw_termination_pipeline(
822 controller=self.controller,
823 logging=logging,
824 in_port=out_port,
825 out_port=in_port,
826 egress_tags=2
827 )
828 # we generate a simple tcp packet with two vlans
829 parsed_pkt = simple_tcp_packet_two_vlan(
830 pktlen=108,
831 out_dl_vlan_enable=True,
832 out_vlan_vid=port_to_in_vlan_2[in_port],
833 in_dl_vlan_enable=True,
834 in_vlan_vid=port_to_in_vlan_1[in_port],
835 )
836 pkt = str( parsed_pkt )
837 self.dataplane.send( in_port, pkt )
838 # we generate the expected pw packet
839 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
840 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
841 cw = (0, 0, 0, 0)
842 parsed_pkt = pw_packet(
843 pktlen=134,
844 out_eth_dst=port_to_dst_mac_str[in_port],
845 out_eth_src=port_to_src_mac_str[out_port],
846 label=[label_1, label_pw],
847 cw=cw,
848 out_dl_vlan_enable=True,
849 out_vlan_vid=port_to_in_vlan_2[in_port],
850 in_dl_vlan_enable=True,
851 in_vlan_vid=port_to_in_vlan_1[in_port],
852 )
853 pkt = str( parsed_pkt )
854 # Assertions
855 verify_packet( self, pkt, out_port )
856 verify_no_packet( self, pkt, in_port )
857 verify_no_other_packets( self )
858 delete_all_flows( self.controller )
859 delete_groups( self.controller, Groups )
860 delete_groups( self.controller, Groups2 )
861 delete_all_groups( self.controller )
862
863 finally:
864 delete_all_flows( self.controller )
865 delete_groups( self.controller, Groups )
866 delete_groups( self.controller, Groups2 )
867 delete_all_groups( self.controller )
868
869class DoubleTagged2PWInitiation_2_Labels( base_tests.SimpleDataPlane ):
870 """
871 This is meant to test the PW Initiation. The traffic
872 arrives double tagged to the MPLS-TP CE device and goes out
873 with a new ethernet header and 2 mpls labels.
874 """
875 def runTest( self ):
876
877 Groups = Queue.LifoQueue( )
878 Groups2 = Queue.LifoQueue( )
879 try:
880 if len( config[ "port_map" ] ) < 1:
881 logging.info( "Port count less than 1, can't run this case" )
882 assert (False)
883 return
884 ports = config[ "port_map" ].keys( )
885
886 for pair in itertools.product(ports, ports):
887 # we generate all possible products
888 in_port = pair[0]
889 out_port = pair[1]
890 if out_port == in_port:
891 continue
892 # we fill the pipeline for the pw initiation
893 (
894 port_to_mpls_label_2,
895 port_to_mpls_label_1,
896 port_to_mpls_label_pw,
897 port_to_in_vlan_3,
898 port_to_in_vlan_2,
899 port_to_in_vlan_1,
900 port_to_src_mac_str,
901 port_to_dst_mac_str,
902 Groups ) = fill_pw_initiation_pipeline(
903 controller=self.controller,
904 logging=logging,
905 in_port=in_port,
906 out_port=out_port,
907 ingress_tags=2,
908 egress_tag=EGRESS_TAGGED_TRANS,
909 mpls_labels=1
910 )
911 # we fill the pipeline for the pw termination
912 # on the reverse path
913 (
914 port_to_mpls_label_pw_x,
915 port_to_vlan_2_x,
916 port_to_vlan_1_x,
917 port_to_switch_mac_str_x,
918 Groups2 ) = fill_pw_termination_pipeline(
919 controller=self.controller,
920 logging=logging,
921 in_port=out_port,
922 out_port=in_port,
923 egress_tags=2
924 )
925 # we generate a simple tcp packet with two vlans
926 parsed_pkt = simple_tcp_packet_two_vlan(
927 pktlen=108,
928 out_dl_vlan_enable=True,
929 out_vlan_vid=port_to_in_vlan_2[in_port],
930 in_dl_vlan_enable=True,
931 in_vlan_vid=port_to_in_vlan_1[in_port],
932 )
933 pkt = str( parsed_pkt )
934 self.dataplane.send( in_port, pkt )
935 # we generate the expected pw packet
936 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
937 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
938 cw = (0, 0, 0, 0)
939 parsed_pkt = pw_packet(
940 pktlen=134,
941 out_eth_dst=port_to_dst_mac_str[in_port],
942 out_eth_src=port_to_src_mac_str[out_port],
943 label=[label_1, label_pw],
944 cw=cw,
945 out_dl_vlan_enable=True,
946 out_vlan_vid=port_to_in_vlan_3[in_port],
947 in_dl_vlan_enable=True,
948 in_vlan_vid=port_to_in_vlan_1[in_port],
949 )
950 pkt = str( parsed_pkt )
951 # Assertions
952 verify_packet( self, pkt, out_port )
953 verify_no_packet( self, pkt, in_port )
954 verify_no_other_packets( self )
955 delete_all_flows( self.controller )
956 delete_groups( self.controller, Groups )
957 delete_groups( self.controller, Groups2 )
958 delete_all_groups( self.controller )
959
960 finally:
961 delete_all_flows( self.controller )
962 delete_groups( self.controller, Groups )
963 delete_groups( self.controller, Groups2 )
964 delete_all_groups( self.controller )
965
966class DoubleTaggedPWInitiation_3_Labels( base_tests.SimpleDataPlane ):
967 """
968 This is meant to test the PW Initiation. The traffic
969 arrives double tagged to the MPLS-TP CE device and goes out
970 with a new ethernet header and 3 mpls labels.
971 """
972 def runTest( self ):
973
974 Groups = Queue.LifoQueue( )
975 Groups2 = Queue.LifoQueue( )
976 try:
977 if len( config[ "port_map" ] ) < 1:
978 logging.info( "Port count less than 1, can't run this case" )
979 assert (False)
980 return
981 ports = config[ "port_map" ].keys( )
982
983 for pair in itertools.product(ports, ports):
984 # we generate all possible products
985 in_port = pair[0]
986 out_port = pair[1]
987 if out_port == in_port:
988 continue
989 # we fill the pipeline for the pw initiation
990 (
991 port_to_mpls_label_2,
992 port_to_mpls_label_1,
993 port_to_mpls_label_pw,
994 port_to_in_vlan_3,
995 port_to_in_vlan_2,
996 port_to_in_vlan_1,
997 port_to_src_mac_str,
998 port_to_dst_mac_str,
999 Groups ) = fill_pw_initiation_pipeline(
1000 controller=self.controller,
1001 logging=logging,
1002 in_port=in_port,
1003 out_port=out_port,
1004 ingress_tags=2,
1005 egress_tag=EGRESS_TAGGED,
1006 mpls_labels=2
1007 )
1008 # we fill the pipeline for the pw termination
1009 # on the reverse path
1010 (
1011 port_to_mpls_label_pw_x,
1012 port_to_vlan_2_x,
1013 port_to_vlan_1_x,
1014 port_to_switch_mac_str_x,
1015 Groups2 ) = fill_pw_termination_pipeline(
1016 controller=self.controller,
1017 logging=logging,
1018 in_port=out_port,
1019 out_port=in_port,
1020 egress_tags=2
1021 )
1022 # we generate a simple tcp packet with two wlan
1023 parsed_pkt = simple_tcp_packet_two_vlan(
1024 pktlen=108,
1025 out_dl_vlan_enable=True,
1026 out_vlan_vid=port_to_in_vlan_2[in_port],
1027 in_dl_vlan_enable=True,
1028 in_vlan_vid=port_to_in_vlan_1[in_port],
1029 )
1030 pkt = str( parsed_pkt )
1031 self.dataplane.send( in_port, pkt )
1032 # we generate the expected pw packet
1033 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63)
1034 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
1035 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
1036 cw = (0, 0, 0, 0)
1037 parsed_pkt = pw_packet(
1038 pktlen=138,
1039 out_eth_dst=port_to_dst_mac_str[in_port],
1040 out_eth_src=port_to_src_mac_str[out_port],
1041 label=[label_2, label_1, label_pw],
1042 cw=cw,
1043 out_dl_vlan_enable=True,
1044 out_vlan_vid=port_to_in_vlan_2[in_port],
1045 in_dl_vlan_enable=True,
1046 in_vlan_vid=port_to_in_vlan_1[in_port],
1047 )
1048 pkt = str( parsed_pkt )
1049 # Assertions
1050 verify_packet( self, pkt, out_port )
1051 verify_no_packet( self, pkt, in_port )
1052 verify_no_other_packets( self )
1053 delete_all_flows( self.controller )
1054 delete_groups( self.controller, Groups )
1055 delete_groups( self.controller, Groups2 )
1056 delete_all_groups( self.controller )
1057
1058 finally:
1059 delete_all_flows( self.controller )
1060 delete_groups( self.controller, Groups )
1061 delete_groups( self.controller, Groups2 )
1062 delete_all_groups( self.controller )
1063
1064class DoubleTagged2PWInitiation_3_Labels( base_tests.SimpleDataPlane ):
1065 """
1066 This is meant to test the PW Initiation. The traffic
1067 arrives double tagged to the MPLS-TP CE device and goes out
1068 with a new ethernet header and 3 mpls labels.
1069 """
1070 def runTest( self ):
1071
1072 Groups = Queue.LifoQueue( )
1073 Groups2 = Queue.LifoQueue( )
1074 try:
1075 if len( config[ "port_map" ] ) < 1:
1076 logging.info( "Port count less than 1, can't run this case" )
1077 assert (False)
1078 return
1079 ports = config[ "port_map" ].keys( )
1080
1081 for pair in itertools.product(ports, ports):
1082 # we generate all possible products
1083 in_port = pair[0]
1084 out_port = pair[1]
1085 if out_port == in_port:
1086 continue
1087 # we fill the pipeline for the pw initiation
1088 (
1089 port_to_mpls_label_2,
1090 port_to_mpls_label_1,
1091 port_to_mpls_label_pw,
1092 port_to_in_vlan_3,
1093 port_to_in_vlan_2,
1094 port_to_in_vlan_1,
1095 port_to_src_mac_str,
1096 port_to_dst_mac_str,
1097 Groups ) = fill_pw_initiation_pipeline(
1098 controller=self.controller,
1099 logging=logging,
1100 in_port=in_port,
1101 out_port=out_port,
1102 ingress_tags=2,
1103 egress_tag=EGRESS_TAGGED_TRANS,
1104 mpls_labels=2
1105 )
1106 # we fill the pipeline for the pw termination
1107 # on the reverse path
1108 (
1109 port_to_mpls_label_pw_x,
1110 port_to_vlan_2_x,
1111 port_to_vlan_1_x,
1112 port_to_switch_mac_str_x,
1113 Groups2 ) = fill_pw_termination_pipeline(
1114 controller=self.controller,
1115 logging=logging,
1116 in_port=out_port,
1117 out_port=in_port,
1118 egress_tags=2
1119 )
1120 # we generate a simple tcp packet with two wlan
1121 parsed_pkt = simple_tcp_packet_two_vlan(
1122 pktlen=108,
1123 out_dl_vlan_enable=True,
1124 out_vlan_vid=port_to_in_vlan_2[in_port],
1125 in_dl_vlan_enable=True,
1126 in_vlan_vid=port_to_in_vlan_1[in_port],
1127 )
1128 pkt = str( parsed_pkt )
1129 self.dataplane.send( in_port, pkt )
1130 # we generate the expected pw packet
1131 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 63)
1132 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 63)
1133 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 63)
1134 cw = (0, 0, 0, 0)
1135 parsed_pkt = pw_packet(
1136 pktlen=138,
1137 out_eth_dst=port_to_dst_mac_str[in_port],
1138 out_eth_src=port_to_src_mac_str[out_port],
1139 label=[label_2, label_1, label_pw],
1140 cw=cw,
1141 out_dl_vlan_enable=True,
1142 out_vlan_vid=port_to_in_vlan_3[in_port],
1143 in_dl_vlan_enable=True,
1144 in_vlan_vid=port_to_in_vlan_1[in_port],
1145 )
1146 pkt = str( parsed_pkt )
1147 # Assertions
1148 verify_packet( self, pkt, out_port )
1149 verify_no_packet( self, pkt, in_port )
1150 verify_no_other_packets( self )
1151 delete_all_flows( self.controller )
1152 delete_groups( self.controller, Groups )
1153 delete_groups( self.controller, Groups2 )
1154 delete_all_groups( self.controller )
1155
1156 finally:
1157 delete_all_flows( self.controller )
1158 delete_groups( self.controller, Groups )
1159 delete_groups( self.controller, Groups2 )
1160 delete_all_groups( self.controller )
1161
Charles Chanc85f1562018-01-18 15:44:29 -08001162
Pier23784aa2016-09-19 20:08:21 -07001163class IntraCO_2_Labels( base_tests.SimpleDataPlane ):
1164 """
1165 This is meant to test the PW intermediate transport.
1166 Incoming packet has 2 labels (SR/PW) (intermediate leaf switch).
1167 There is no VLAN tag in the incoming packet. Pop outer MPLS label
1168 """
1169 def runTest( self ):
1170
1171 Groups = Queue.LifoQueue( )
1172 try:
1173 if len( config[ "port_map" ] ) < 1:
1174 logging.info( "Port count less than 1, can't run this case" )
1175 assert (False)
1176 return
1177 ports = config[ "port_map" ].keys( )
1178 # we fill the pw pipeline for the intermediate transport
1179 (
1180 port_to_mpls_label_2,
1181 port_to_mpls_label_1,
1182 port_to_mpls_label_pw,
1183 port_to_switch_mac_str,
1184 port_to_src_mac_str,
1185 port_to_dst_mac_str,
1186 Groups
1187 ) = fill_pw_intermediate_transport_pipeline(
1188 self.controller,
1189 logging,
1190 ports,
1191 mpls_labels=3
1192 )
1193
1194 for pair in itertools.product(ports, ports):
1195 # we generate all possible products
1196 in_port = pair[0]
1197 out_port = pair[1]
1198 if out_port == in_port:
1199 continue
1200 # we geneate the pw packet
1201 label_1 = (port_to_mpls_label_2[in_port], 0, 0, 32)
1202 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 32)
1203 parsed_pkt = mpls_packet(
1204 pktlen=104,
1205 ip_ttl=63,
1206 eth_dst=port_to_switch_mac_str[in_port],
1207 label=[ label_1, label_pw ]
1208 )
1209 pkt = str( parsed_pkt )
1210 self.dataplane.send( in_port, pkt )
1211 # we geneate the expected pw packet
1212 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 31)
1213 parsed_pkt = mpls_packet(
1214 pktlen=100,
1215 ip_ttl=63,
1216 eth_dst=port_to_dst_mac_str[in_port],
1217 eth_src=port_to_src_mac_str[out_port],
1218 label=[ label_pw ]
1219 )
1220 pkt = str( parsed_pkt )
1221 # Assertions
1222 verify_packet( self, pkt, out_port )
1223 verify_no_packet( self, pkt, in_port )
1224 verify_no_other_packets( self )
1225
1226 finally:
1227 delete_all_flows( self.controller )
1228 delete_groups( self.controller, Groups )
1229 delete_all_groups( self.controller )
1230
1231class IntraCO_3_Labels( base_tests.SimpleDataPlane ):
1232 """
1233 This is meant to test the PW intermediate transport.
1234 Incoming packet has 3 labels (SR/SR/PW) (spine switch).
1235 There is no VLAN tag in the incoming packet. Pop outer MPLS label
1236 """
1237 def runTest( self ):
1238
1239 Groups = Queue.LifoQueue( )
1240 try:
1241 if len( config[ "port_map" ] ) < 1:
1242 logging.info( "Port count less than 1, can't run this case" )
1243 assert (False)
1244 return
1245 ports = config[ "port_map" ].keys( )
1246 # we fill the pipeline for the intermediate transport
1247 (
1248 port_to_mpls_label_2,
1249 port_to_mpls_label_1,
1250 port_to_mpls_label_pw,
1251 port_to_switch_mac_str,
1252 port_to_src_mac_str,
1253 port_to_dst_mac_str,
1254 Groups
1255 ) = fill_pw_intermediate_transport_pipeline(
1256 self.controller,
1257 logging,
1258 ports,
1259 mpls_labels=3
1260 )
1261 for pair in itertools.product(ports, ports):
1262 # we generate all possible products
1263 in_port = pair[0]
1264 out_port = pair[1]
1265 if out_port == in_port:
1266 continue
1267 # we generate the pw packet
1268 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 32)
1269 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 32)
1270 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 32)
1271 parsed_pkt = mpls_packet(
1272 pktlen=104,
1273 ip_ttl=63,
1274 eth_dst=port_to_switch_mac_str[in_port],
1275 label=[ label_2, label_1, label_pw ]
1276 )
1277 pkt = str( parsed_pkt )
1278 self.dataplane.send( in_port, pkt )
1279 # we generate the expected pw packet
1280 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 31)
1281 parsed_pkt = mpls_packet(
1282 pktlen=100,
1283 ip_ttl=63,
1284 eth_dst=port_to_dst_mac_str[in_port],
1285 eth_src=port_to_src_mac_str[out_port],
1286 label=[ label_1, label_pw ]
1287 )
1288 pkt = str( parsed_pkt )
1289 # Assertions
1290 verify_packet( self, pkt, out_port )
1291 verify_no_packet( self, pkt, in_port )
1292 verify_no_other_packets( self )
1293
1294 finally:
1295 delete_all_flows( self.controller )
1296 delete_groups( self.controller, Groups )
1297 delete_all_groups( self.controller )
1298
1299class InterCO( base_tests.SimpleDataPlane ):
1300 """
1301 This is meant to test the PW intermediate transport.
1302 Incoming packet has 1 labels (PW) (Intermediate CO leaf switch).
1303 There is no VLAN tag in the incoming packet. Push up to 2 MPLS labels
1304 """
1305 def runTest( self ):
1306
1307 Groups = Queue.LifoQueue( )
1308 try:
1309 if len( config[ "port_map" ] ) < 1:
1310 logging.info( "Port count less than 1, can't run this case" )
1311 assert (False)
1312 return
1313 ports = config[ "port_map" ].keys( )
1314 # we fill the pipeline for the intermediate transport
1315 (
1316 port_to_mpls_label_2,
1317 port_to_mpls_label_1,
1318 port_to_mpls_label_pw,
1319 port_to_switch_mac_str,
1320 port_to_src_mac_str,
1321 port_to_dst_mac_str,
1322 Groups
1323 ) = fill_pw_intermediate_transport_pipeline(
1324 self.controller,
1325 logging,
1326 ports,
1327 mpls_labels=1
1328 )
1329 for pair in itertools.product(ports, ports):
1330 # we generate all possible products
1331 in_port = pair[0]
1332 out_port = pair[1]
1333 if out_port == in_port:
1334 continue
1335 # we generate the pw packet
1336 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 32)
1337 parsed_pkt = mpls_packet(
1338 pktlen=104,
1339 ip_ttl=63,
1340 eth_dst=port_to_switch_mac_str[in_port],
1341 label=[ label_pw ]
1342 )
1343 pkt = str( parsed_pkt )
1344 self.dataplane.send( in_port, pkt )
1345 # we generate the expected pw packet
1346 label_2 = (port_to_mpls_label_2[in_port], 0, 0, 31)
1347 label_1 = (port_to_mpls_label_1[in_port], 0, 0, 31)
1348 label_pw = (port_to_mpls_label_pw[in_port], 0, 1, 31)
1349 parsed_pkt = mpls_packet(
1350 pktlen=112,
1351 ip_ttl=63,
1352 eth_dst=port_to_dst_mac_str[in_port],
1353 eth_src=port_to_src_mac_str[out_port],
1354 label=[ label_2, label_1, label_pw ]
1355 )
1356 pkt = str( parsed_pkt )
1357 # Assertions
1358 verify_packet( self, pkt, out_port )
1359 verify_no_packet( self, pkt, in_port )
1360 verify_no_other_packets( self )
1361
1362 finally:
1363 delete_all_flows( self.controller )
1364 delete_groups( self.controller, Groups )
1365 delete_all_groups( self.controller )
1366
1367class UntaggedPWTermination( base_tests.SimpleDataPlane ):
1368 """
1369 This is meant to test the PW Termination. The traffic
1370 arrives untagged to the MPLS-TP CE device and goes out
1371 without the outer ethernet header and untagged.
1372 """
1373 def runTest( self ):
1374
1375 Groups = Queue.LifoQueue( )
1376 Groups2 = Queue.LifoQueue( )
1377 try:
1378 if len( config[ "port_map" ] ) < 1:
1379 logging.info( "Port count less than 1, can't run this case" )
1380 assert (False)
1381 return
1382 ports = config[ "port_map" ].keys( )
1383 for pair in itertools.product(ports, ports):
1384 # we generate all possible products
1385 in_port = pair[0]
1386 out_port = pair[1]
1387 if out_port == in_port:
1388 continue
1389 # we fill the pipeline for the pw initiation
1390 # on the reverse path
1391 (
1392 port_to_mpls_label_2,
1393 port_to_mpls_label_1,
1394 port_to_mpls_label_pw,
1395 port_to_in_vlan_3,
1396 port_to_in_vlan_2,
1397 port_to_in_vlan_1,
1398 port_to_src_mac_str,
1399 port_to_dst_mac_str,
1400 Groups ) = fill_pw_initiation_pipeline(
1401 controller=self.controller,
1402 logging=logging,
1403 in_port=out_port,
1404 out_port=in_port,
1405 ingress_tags=0,
1406 egress_tag=EGRESS_UNTAGGED,
1407 mpls_labels=1
1408 )
1409 # we fill the pipeline for the pw termination
1410 (
1411 port_to_mpls_label_pw,
1412 port_to_in_vlan_2,
1413 port_to_in_vlan_1,
1414 port_to_dst_mac_str,
1415 Groups2 ) = fill_pw_termination_pipeline(
1416 controller=self.controller,
1417 logging=logging,
1418 in_port=in_port,
1419 out_port=out_port,
1420 egress_tags=0
1421 )
1422 # we generate the pw packet
1423 label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63)
1424 cw = (0, 0, 0, 0)
1425 parsed_pkt = pw_packet(
1426 pktlen=104,
1427 out_eth_dst=port_to_dst_mac_str[in_port],
1428 label=[label_pw],
1429 cw=cw
1430 )
1431 pkt = str( parsed_pkt )
1432 self.dataplane.send( in_port, pkt )
1433 # we generate the expected tcp packet
1434 parsed_pkt = simple_tcp_packet(
1435 pktlen=82,
1436 )
1437 pkt = str( parsed_pkt )
1438 # Assertions
1439 verify_packet( self, pkt, out_port )
1440 verify_no_packet( self, pkt, in_port )
1441 verify_no_other_packets( self )
1442 delete_all_flows( self.controller )
1443 delete_groups( self.controller, Groups )
1444 delete_groups( self.controller, Groups2 )
1445 delete_all_groups( self.controller )
1446 finally:
1447 delete_all_flows( self.controller )
1448 delete_groups( self.controller, Groups )
1449 delete_groups( self.controller, Groups2 )
1450 delete_all_groups( self.controller )
1451
1452class Untagged2PWTermination( base_tests.SimpleDataPlane ):
1453 """
1454 This is meant to test the PW Termination. The traffic
1455 arrives untagged to the MPLS-TP CE device and goes out
1456 without the outer ethernet header and untagged
1457 but was originally tagged.
1458 """
1459 def runTest( self ):
1460
1461 Groups = Queue.LifoQueue( )
1462 Groups2 = Queue.LifoQueue( )
1463 try:
1464 if len( config[ "port_map" ] ) < 1:
1465 logging.info( "Port count less than 1, can't run this case" )
1466 assert (False)
1467 return
1468 ports = config[ "port_map" ].keys( )
1469 for pair in itertools.product(ports, ports):
Charles Chanc85f1562018-01-18 15:44:29 -08001470
Pier23784aa2016-09-19 20:08:21 -07001471 # we generate all possible products
1472 in_port = pair[0]
1473 out_port = pair[1]
1474 if out_port == in_port:
1475 continue
Charles Chanc85f1562018-01-18 15:44:29 -08001476
Pier23784aa2016-09-19 20:08:21 -07001477 # we fill the pipeline for the pw initiation
1478 # on the reverse path
Charles Chanc85f1562018-01-18 15:44:29 -08001479
Pier23784aa2016-09-19 20:08:21 -07001480 (
1481 port_to_mpls_label_2,
1482 port_to_mpls_label_1,
1483 port_to_mpls_label_pw,
1484 port_to_in_vlan_3,
1485 port_to_in_vlan_2,
1486 port_to_in_vlan_1,
1487 port_to_src_mac_str,
1488 port_to_dst_mac_str,
1489 Groups ) = fill_pw_initiation_pipeline(
1490 controller=self.controller,
1491 logging=logging,
1492 in_port=out_port,
1493 out_port=in_port,
1494 ingress_tags=0,
1495 egress_tag=EGRESS_TAGGED,
1496 mpls_labels=1
1497 )
Charles Chanc85f1562018-01-18 15:44:29 -08001498 # we fill the pipeline for the pw termination
Pier23784aa2016-09-19 20:08:21 -07001499 (
1500 port_to_mpls_label_pw,
1501 port_to_in_vlan_2,
1502 port_to_in_vlan_1,
1503 port_to_dst_mac_str,
1504 Groups2 ) = fill_pw_termination_pipeline(
1505 controller=self.controller,
1506 logging=logging,
1507 in_port=in_port,
1508 out_port=out_port,
1509 egress_tags=0
1510 )
1511 # we generate the pw packet
1512 label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63)
1513 cw = (0, 0, 0, 0)
1514 parsed_pkt = pw_packet(
1515 pktlen=104,
1516 out_eth_dst=port_to_dst_mac_str[in_port],
1517 label=[label_pw],
1518 cw=cw,
1519 out_dl_vlan_enable=True,
1520 out_vlan_vid=port_to_in_vlan_1[out_port],
1521 )
1522 pkt = str( parsed_pkt )
1523 self.dataplane.send( in_port, pkt )
1524 # we generate the expected tcp packet
1525 parsed_pkt = simple_tcp_packet(
1526 pktlen=78,
1527 )
1528 pkt = str( parsed_pkt )
1529 # Assertions
1530 verify_packet( self, pkt, out_port )
1531 verify_no_packet( self, pkt, in_port )
1532 verify_no_other_packets( self )
Charles Chanc85f1562018-01-18 15:44:29 -08001533
1534 delete_all_flows( self.controller )
Pier23784aa2016-09-19 20:08:21 -07001535 delete_groups( self.controller, Groups )
1536 delete_groups( self.controller, Groups2 )
1537 delete_all_groups( self.controller )
1538 finally:
Charles Chanc85f1562018-01-18 15:44:29 -08001539 delete_all_flows( self.controller )
Pier23784aa2016-09-19 20:08:21 -07001540 delete_groups( self.controller, Groups )
1541 delete_groups( self.controller, Groups2 )
1542 delete_all_groups( self.controller )
1543
1544class TaggedPWTermination( base_tests.SimpleDataPlane ):
1545 """
1546 This is meant to test the PW Termination. The traffic
1547 arrives untagged to the MPLS-TP CE device and goes out
1548 without the outer ethernet header and with a vlan tag.
1549 """
1550 def runTest( self ):
1551
1552 Groups = Queue.LifoQueue( )
1553 Groups2 = Queue.LifoQueue( )
1554 try:
1555 if len( config[ "port_map" ] ) < 1:
1556 logging.info( "Port count less than 1, can't run this case" )
1557 assert (False)
1558 return
1559 ports = config[ "port_map" ].keys( )
1560 for pair in itertools.product(ports, ports):
1561 # we generate all possible products
1562 in_port = pair[0]
1563 out_port = pair[1]
1564 if out_port == in_port:
1565 continue
1566 # we fill the pipeline for the pw initiation
1567 # on the reverse path
1568 (
1569 port_to_mpls_label_2,
1570 port_to_mpls_label_1,
1571 port_to_mpls_label_pw,
1572 port_to_in_vlan_3,
1573 port_to_in_vlan_2,
1574 port_to_in_vlan_1,
1575 port_to_src_mac_str,
1576 port_to_dst_mac_str,
1577 Groups ) = fill_pw_initiation_pipeline(
1578 controller=self.controller,
1579 logging=logging,
1580 in_port=out_port,
1581 out_port=in_port,
1582 ingress_tags=1,
1583 egress_tag=EGRESS_TAGGED,
1584 mpls_labels=1
1585 )
1586 # we fill the pipeline for the pw termination
1587 (
1588 port_to_mpls_label_pw,
1589 port_to_in_vlan_2,
1590 port_to_in_vlan_1,
1591 port_to_dst_mac_str,
1592 Groups2 ) = fill_pw_termination_pipeline(
1593 controller=self.controller,
1594 logging=logging,
1595 in_port=in_port,
1596 out_port=out_port,
1597 egress_tags=1
1598 )
1599 # we generate the pw packet
1600 label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63)
1601 cw = (0, 0, 0, 0)
1602 parsed_pkt = pw_packet(
1603 pktlen=104,
1604 out_eth_dst=port_to_dst_mac_str[in_port],
1605 label=[label_pw],
1606 cw=cw,
1607 out_dl_vlan_enable=True,
1608 out_vlan_vid=port_to_in_vlan_1[out_port],
1609 )
1610 pkt = str( parsed_pkt )
1611 self.dataplane.send( in_port, pkt )
1612 # we generate the expected tcp packet
1613 # with a vlan tag
1614 parsed_pkt = simple_tcp_packet(
1615 pktlen=82,
1616 dl_vlan_enable=True,
1617 vlan_vid=port_to_in_vlan_1[out_port]
1618 )
1619 pkt = str( parsed_pkt )
1620 # Assertions
1621 verify_packet( self, pkt, out_port )
1622 verify_no_packet( self, pkt, in_port )
1623 verify_no_other_packets( self )
Charles Chanc85f1562018-01-18 15:44:29 -08001624
Pier23784aa2016-09-19 20:08:21 -07001625 delete_all_flows( self.controller )
1626 delete_groups( self.controller, Groups )
1627 delete_groups( self.controller, Groups2 )
1628 delete_all_groups( self.controller )
1629 finally:
1630 delete_all_flows( self.controller )
1631 delete_groups( self.controller, Groups )
1632 delete_groups( self.controller, Groups2 )
1633 delete_all_groups( self.controller )
1634
1635class DoubleTaggedPWTermination( base_tests.SimpleDataPlane ):
1636 """
1637 This is meant to test the PW Termination. The traffic
1638 arrives untagged to the MPLS-TP CE device and goes out
1639 without the outer ethernet header and 2 vlan tags.
1640 """
1641 def runTest( self ):
1642
1643 Groups = Queue.LifoQueue( )
1644 Groups2 = Queue.LifoQueue( )
1645 try:
1646 if len( config[ "port_map" ] ) < 1:
1647 logging.info( "Port count less than 1, can't run this case" )
1648 assert (False)
1649 return
1650 ports = config[ "port_map" ].keys( )
1651 for pair in itertools.product(ports, ports):
1652 # we generate all possible products
1653 in_port = pair[0]
1654 out_port = pair[1]
1655 if out_port == in_port:
1656 continue
1657 # we fill the pipeline for the pw initiation
1658 # on the reverse path
1659 (
1660 port_to_mpls_label_2,
1661 port_to_mpls_label_1,
1662 port_to_mpls_label_pw,
1663 port_to_in_vlan_3,
1664 port_to_in_vlan_2,
1665 port_to_in_vlan_1,
1666 port_to_src_mac_str,
1667 port_to_dst_mac_str,
1668 Groups ) = fill_pw_initiation_pipeline(
1669 controller=self.controller,
1670 logging=logging,
1671 in_port=out_port,
1672 out_port=in_port,
1673 ingress_tags=2,
1674 egress_tag = EGRESS_TAGGED,
1675 mpls_labels=1
1676 )
1677 # we fill the pipeline for the pw termination
1678 (
1679 port_to_mpls_label_pw,
1680 port_to_in_vlan_2,
1681 port_to_in_vlan_1,
1682 port_to_dst_mac_str,
1683 Groups2 ) = fill_pw_termination_pipeline(
1684 controller=self.controller,
1685 logging=logging,
1686 in_port=in_port,
1687 out_port=out_port,
1688 egress_tags=2
1689 )
1690 # we generate the pw packet
1691 label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63)
1692 cw = (0, 0, 0, 0)
1693 parsed_pkt = pw_packet(
1694 pktlen=104,
1695 out_eth_dst=port_to_dst_mac_str[in_port],
1696 label=[label_pw],
1697 cw=cw,
1698 out_dl_vlan_enable=True,
1699 out_vlan_vid=port_to_in_vlan_2[out_port],
1700 in_dl_vlan_enable=True,
1701 in_vlan_vid=port_to_in_vlan_1[out_port]
1702 )
1703 pkt = str( parsed_pkt )
1704 self.dataplane.send( in_port, pkt )
1705 # we generate the expected tcp
1706 # packet with two vlan tags
1707 parsed_pkt = simple_tcp_packet_two_vlan(
1708 pktlen=82,
1709 out_dl_vlan_enable=True,
1710 out_vlan_vid=port_to_in_vlan_2[out_port],
1711 in_dl_vlan_enable=True,
1712 in_vlan_vid=port_to_in_vlan_1[out_port]
1713 )
1714 pkt = str( parsed_pkt )
1715 # Assertions
1716 verify_packet( self, pkt, out_port )
1717 verify_no_packet( self, pkt, in_port )
1718 verify_no_other_packets( self )
1719 delete_all_flows( self.controller )
1720 delete_groups( self.controller, Groups )
1721 delete_groups( self.controller, Groups2 )
1722 delete_all_groups( self.controller )
1723 finally:
1724 delete_all_flows( self.controller )
1725 delete_groups( self.controller, Groups )
1726 delete_groups( self.controller, Groups2 )
1727 delete_all_groups( self.controller )
Pier265ad5f2017-02-28 17:46:28 +01001728
Charles Chanc85f1562018-01-18 15:44:29 -08001729class IntermediateTransport( base_tests.SimpleDataPlane ):
1730 """
1731 This test is meant to verify that the alternative approach for handling
1732 pseudowires in spine switches. Specifically, in the mpls table we install
1733 2 rules , the match(SR1, BoS=1) and match(SR2, BoS=0). The match(SR2, BoS=0)
1734 should match and the packet should be forwarded through the port and the label
1735 for SR2 should be removed.
1736 """
1737 def runTest( self ):
1738 Groups = Queue.LifoQueue( )
1739 try:
1740 if len( config[ "port_map" ] ) < 1:
1741 logging.info( "Port count less than 1, can't run this case" )
1742 assert (False)
1743 return
1744 ports = config[ "port_map" ].keys( )
1745 in_port = ports[0]
1746 out_port = ports[1]
1747 out_vlan = 4094
1748 src_mac = [ 0x00, 0x00, 0x00, 0x00, 0x11, 0x01 ]
1749 src_mac_str = ':'.join( [ '%02X' % x for x in src_mac ] )
1750 dst_mac = [ 0x00, 0x00, 0x00, 0x11, 0x11, 0x01 ]
1751 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
1752 mpls_label = 100
1753 mpls_label_SR1 = 100 + 5
1754 mpls_label_SR2 = 100 + 10
1755 mpls_label_PW = 100 + 15
1756
1757 # Add l2 interface group, we have to pop the VLAN;
1758 l2_intf_gid, l2_intf_msg = add_one_l2_interface_group(
1759 ctrl=self.controller,
1760 port=out_port,
1761 vlan_id=out_vlan,
1762 is_tagged=False,
1763 send_barrier=False
1764 )
1765 Groups._put( l2_intf_gid )
1766
1767 # add MPLS interface group
1768 mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group(
1769 ctrl=self.controller,
1770 ref_gid=l2_intf_gid,
1771 dst_mac=dst_mac,
1772 src_mac=src_mac,
1773 vid=out_vlan,
1774 index=in_port
1775 )
1776 Groups._put( mpls_intf_gid )
1777
1778 # Add L3 Unicast group
1779 l3_msg = add_l3_unicast_group(
1780 ctrl=self.controller,
1781 port=out_port,
1782 vlanid=out_vlan,
1783 id=in_port,
1784 src_mac=src_mac,
1785 dst_mac=dst_mac
1786 )
1787 Groups._put( l3_msg.group_id )
1788
1789 # Add L3 ecmp group
1790 ecmp_msg = add_l3_ecmp_group(
1791 ctrl=self.controller,
1792 id=in_port,
1793 l3_ucast_groups=[ l3_msg.group_id ]
1794 )
1795 Groups._put( ecmp_msg.group_id )
1796
1797 # Add MPLS flow with BoS=1
1798 add_mpls_flow(
1799 ctrl=self.controller,
1800 action_group_id=ecmp_msg.group_id,
1801 label=mpls_label_SR1
1802 )
1803
1804 # add MPLS flow with BoS=0
1805 add_mpls_flow_pw(
1806 ctrl=self.controller,
1807 action_group_id=mpls_intf_gid,
1808 label=mpls_label_SR2,
1809 ethertype=0x8847,
1810 tunnel_index=1,
1811 bos=0
1812 )
1813
1814 # add Termination flow
1815 add_termination_flow(
1816 ctrl=self.controller,
1817 in_port=in_port,
1818 eth_type=0x8847,
1819 dst_mac=src_mac,
1820 vlanid=out_vlan,
1821 goto_table=23
1822 )
1823 # add VLAN flows
1824 add_one_vlan_table_flow(
1825 ctrl=self.controller,
1826 of_port=in_port,
1827 vlan_id=out_vlan,
1828 flag=VLAN_TABLE_FLAG_ONLY_TAG,
1829 )
1830 add_one_vlan_table_flow(
1831 ctrl=self.controller,
1832 of_port=in_port,
1833 vlan_id=out_vlan,
1834 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
1835 )
1836 # Packet generation with sleep
1837 time.sleep(2)
1838 label_SR1 = (mpls_label_SR1, 0, 1, 32)
1839 label_SR2 = (mpls_label_SR2, 0, 0, 32)
1840 label_2 = (mpls_label_PW, 0, 1, 32)
1841
1842 # set to false to test if routing traffic
1843 # comes through
1844
1845 pw = True
1846 if pw:
1847 parsed_pkt = mpls_packet(
1848 pktlen=104,
1849 ip_ttl=63,
1850 eth_dst=src_mac_str,
1851 label=[label_SR2, label_2],
1852 encapsulated_ethernet = True
1853 )
1854 pkt = str( parsed_pkt )
1855 self.dataplane.send( in_port, pkt )
1856
1857
1858 expected_label = (mpls_label_PW, 0, 1, 31)
1859 # we geneate the expected pw packet
1860 parsed_pkt = mpls_packet(
1861 pktlen=100,
1862 ip_ttl=63,
1863 eth_dst=dst_mac_str,
1864 eth_src=src_mac_str,
1865 label=[ expected_label ],
1866 encapsulated_ethernet = True
1867 )
1868
1869 pkt = str( parsed_pkt )
1870 verify_packet( self, pkt, out_port )
1871 verify_no_packet( self, pkt, in_port )
1872 else:
1873 # packet for routing traffic
1874 parsed_pkt_2 = mpls_packet(
1875 pktlen=104,
1876 ip_ttl=63,
1877 eth_dst=src_mac_str,
1878 label=[ label_SR1 ]
1879 )
1880 pkt_2 = str(parsed_pkt_2)
1881 self.dataplane.send( in_port, pkt_2 )
1882
1883 # we geneate the expected routed packet
1884 parsed_pkt_2 = simple_tcp_packet(
1885 pktlen=100,
1886 ip_ttl=31,
1887 eth_dst=dst_mac_str,
1888 eth_src=src_mac_str,
1889 )
1890 pkt_2 = str(parsed_pkt_2)
1891
1892 verify_packet( self, pkt_2, out_port)
1893 verify_no_packet( self, pkt_2, in_port )
1894
1895 verify_no_other_packets( self )
1896 finally:
1897
1898 delete_all_flows( self.controller )
1899 delete_groups( self.controller, Groups )
1900 delete_all_groups( self.controller )
1901
1902class PseudowireSpineTerminationBug( base_tests.SimpleDataPlane ):
1903 """
1904 This is meant to demonstrate a bug observed in the termination of
1905 Leaf-Spine pseudowires, where the termination point at the spine
1906 is a port connecting to another leaf switch.
1907 In this case, there exist two L2 interface groups in the device for the
1908 same port :
1909
1910 L2 interface for routing : POP_VLAN, output to port
1911 L2 interface for pseudowire : outpute to port
1912
1913 The choice of the l2 interface group is associated with the vlan id of the packet.
1914 In both cases, packets arrive with untagged vlan and are associated with vlan-id 4094.
1915 However, in pw case the outer l2 is popped, and the vlan-id changes (that of the original
1916 traffic) which matches the L2 interface group for the pw.
1917
1918 The bug is that still the group that is chossen is that for routing, which pops the vlan,
1919 and thus the pseudowire results with untagged traffic.
1920 """
1921 def runTest( self ):
1922
1923 Groups = Queue.LifoQueue( )
1924 Groups2 = Queue.LifoQueue( )
1925 try:
1926 if len( config[ "port_map" ] ) < 1:
1927 logging.info( "Port count less than 1, can't run this case" )
1928 assert (False)
1929 return
1930 ports = config[ "port_map" ].keys( )
1931 for pair in itertools.product(ports, ports):
1932 # we generate all possible products
1933 in_port = pair[0]
1934 out_port = pair[1]
1935 if out_port == in_port:
1936 continue
1937 # we fill the pipeline for the pw initiation
1938 # on the reverse path
1939 (
1940 port_to_mpls_label_2,
1941 port_to_mpls_label_1,
1942 port_to_mpls_label_pw,
1943 port_to_in_vlan_3,
1944 port_to_in_vlan_2,
1945 port_to_in_vlan_1,
1946 port_to_src_mac_str,
1947 port_to_dst_mac_str,
1948 Groups ) = fill_pw_initiation_pipeline(
1949 controller=self.controller,
1950 logging=logging,
1951 in_port=out_port,
1952 out_port=in_port,
1953 ingress_tags=1,
1954 egress_tag=EGRESS_TAGGED,
1955 mpls_labels=1
1956 )
1957 # we fill the pipeline for the pw termination
1958 (
1959 port_to_mpls_label_pw,
1960 port_to_in_vlan_2,
1961 port_to_in_vlan_1,
1962 port_to_dst_mac_str,
1963 Groups2 ) = fill_pw_termination_pipeline(
1964 controller=self.controller,
1965 logging=logging,
1966 in_port=in_port,
1967 out_port=out_port,
1968 egress_tags=1
1969 )
1970
1971 print('''\nBefore adding the l2 interface group that pops the vlan we expect to see tagged packets at the output. ''')
1972
1973 # we generate the pw packet
1974 label_pw = (port_to_mpls_label_pw[out_port], 0, 1, 63)
1975 cw = (0, 0, 0, 0)
1976 parsed_pkt = pw_packet(
1977 pktlen=104,
1978 out_eth_dst=port_to_dst_mac_str[in_port],
1979 label=[label_pw],
1980 cw=cw,
1981 out_dl_vlan_enable=True,
1982 out_vlan_vid=port_to_in_vlan_1[out_port],
1983 )
1984 pkt = str( parsed_pkt )
1985 self.dataplane.send( in_port, pkt )
1986 # we generate the expected tcp packet
1987 # with a vlan tag
1988 parsed_pkt = simple_tcp_packet(
1989 pktlen=82,
1990 dl_vlan_enable=True,
1991 vlan_vid=port_to_in_vlan_1[out_port]
1992 )
1993 pkt = str( parsed_pkt )
1994
1995 # Assertions
1996 verify_packet( self, pkt, out_port )
1997 verify_no_packet( self, pkt, in_port )
1998 verify_no_other_packets( self )
1999
2000 print('''After adding the l2 interface group that pops the vlan, packets will come out UNTAGGED and test will fail. Check logs for details.''')
2001 # we create an l2 interface group for routing that
2002 # pops the vlan tags
2003 l2_intf_gid, l2_intf_msg = add_one_l2_interface_group(
2004 ctrl=self.controller,
2005 port=out_port,
2006 vlan_id=4094,
2007 is_tagged=False,
2008 send_barrier=False
2009 )
2010 Groups._put( l2_intf_gid )
2011
2012 parsed_pkt = pw_packet(
2013 pktlen=104,
2014 out_eth_dst=port_to_dst_mac_str[in_port],
2015 label=[label_pw],
2016 cw=cw,
2017 out_dl_vlan_enable=True,
2018 out_vlan_vid=port_to_in_vlan_1[out_port],
2019 )
2020 pkt = str( parsed_pkt )
2021 self.dataplane.send( in_port, pkt )
2022
2023 parsed_pkt = simple_tcp_packet(
2024 pktlen=82,
2025 dl_vlan_enable=True,
2026 vlan_vid=port_to_in_vlan_1[out_port]
2027 )
2028 pkt = str( parsed_pkt )
2029
2030 # send the packet, test should fail now
2031 verify_packet( self, pkt, out_port )
2032 verify_no_packet( self, pkt, in_port )
2033 verify_no_other_packets( self )
2034
2035 delete_all_flows( self.controller )
2036 delete_groups( self.controller, Groups )
2037 delete_groups( self.controller, Groups2 )
2038 delete_all_groups( self.controller )
2039 finally:
2040 delete_all_flows( self.controller )
2041 delete_groups( self.controller, Groups )
2042 delete_groups( self.controller, Groups2 )
2043 delete_all_groups( self.controller )
2044
2045
Pier265ad5f2017-02-28 17:46:28 +01002046class BoSBug( base_tests.SimpleDataPlane ):
2047 """
2048 This test is meant to verify the forwarding of the default traffic
2049 when the rule for the PW transport (BoS=0) has been installed in the
2050 switch, together with the rule for the transport of default routing
2051 traffic. There is a bug in OFDPA 3.0EA4, which requires BOS=0 flow
2052 to be installed before BOS=1 flow to generate correct packets. Incoming
2053 packet has 1 label, and there is no VLAN tag in the incoming packet.
2054 The expected behvior is the Pop of the outer MPLS label and plain IP
2055 packet should exit from the switch.
2056 """
2057 def runTest( self ):
2058 Groups = Queue.LifoQueue( )
2059 try:
2060 if len( config[ "port_map" ] ) < 1:
2061 logging.info( "Port count less than 1, can't run this case" )
2062 assert (False)
2063 return
2064 ports = config[ "port_map" ].keys( )
2065 in_port = ports[0]
2066 out_port = ports[1]
2067 out_vlan = 4094
2068 src_mac = [ 0x00, 0x00, 0x00, 0x00, 0x11, 0x01 ]
2069 src_mac_str = ':'.join( [ '%02X' % x for x in src_mac ] )
2070 dst_mac = [ 0x00, 0x00, 0x00, 0x11, 0x11, 0x01 ]
2071 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
2072 mpls_label = 100
2073 # Add l2 interface group, we have to pop the VLAN;
2074 l2_intf_gid, l2_intf_msg = add_one_l2_interface_group(
2075 ctrl=self.controller,
2076 port=out_port,
2077 vlan_id=out_vlan,
2078 is_tagged=False,
2079 send_barrier=False
2080 )
2081 Groups._put( l2_intf_gid )
2082 # add MPLS interface group
2083 mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group(
2084 ctrl=self.controller,
2085 ref_gid=l2_intf_gid,
2086 dst_mac=dst_mac,
2087 src_mac=src_mac,
2088 vid=out_vlan,
2089 index=in_port
2090 )
2091 Groups._put( mpls_intf_gid )
2092 # Add L3 Unicast group
2093 l3_msg = add_l3_unicast_group(
2094 ctrl=self.controller,
2095 port=out_port,
2096 vlanid=out_vlan,
2097 id=in_port,
2098 src_mac=src_mac,
2099 dst_mac=dst_mac
2100 )
2101 Groups._put( l3_msg.group_id )
2102 # Add L3 ecmp group
2103 ecmp_msg = add_l3_ecmp_group(
2104 ctrl=self.controller,
2105 id=in_port,
2106 l3_ucast_groups=[ l3_msg.group_id ]
2107 )
2108 Groups._put( ecmp_msg.group_id )
2109 # Add MPLS flow with BoS=1
2110 add_mpls_flow(
2111 ctrl=self.controller,
2112 action_group_id=ecmp_msg.group_id,
2113 label=mpls_label
2114 )
2115 # add MPLS flow with BoS=0
2116 add_mpls_flow_pw(
2117 ctrl=self.controller,
2118 action_group_id=mpls_intf_gid,
2119 label=mpls_label,
2120 ethertype=0x8847,
2121 tunnel_index=1,
2122 bos=0
2123 )
2124 # add Termination flow
2125 add_termination_flow(
2126 ctrl=self.controller,
2127 in_port=in_port,
2128 eth_type=0x8847,
2129 dst_mac=src_mac,
2130 vlanid=out_vlan,
2131 goto_table=23
2132 )
2133 # add VLAN flows
2134 add_one_vlan_table_flow(
2135 ctrl=self.controller,
2136 of_port=in_port,
2137 vlan_id=out_vlan,
2138 flag=VLAN_TABLE_FLAG_ONLY_TAG,
2139 )
2140 add_one_vlan_table_flow(
2141 ctrl=self.controller,
2142 of_port=in_port,
2143 vlan_id=out_vlan,
2144 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
2145 )
2146 # Packet generation with sleep
2147 time.sleep(2)
Charles Chanc85f1562018-01-18 15:44:29 -08002148 label = (mpls_label, 0, 0, 32)
Pier265ad5f2017-02-28 17:46:28 +01002149 parsed_pkt = mpls_packet(
2150 pktlen=104,
2151 vlan_vid=out_vlan,
2152 ip_ttl=63,
2153 eth_dst=src_mac_str,
Charles Chanc85f1562018-01-18 15:44:29 -08002154 label=[ label ]
Pier265ad5f2017-02-28 17:46:28 +01002155 )
2156 pkt = str( parsed_pkt )
2157 self.dataplane.send( in_port, pkt )
2158 # we geneate the expected pw packet
2159 parsed_pkt = simple_tcp_packet(
2160 pktlen=100,
2161 vlan_vid=out_vlan,
2162 ip_ttl=31,
2163 eth_dst=dst_mac_str,
2164 eth_src=src_mac_str,
2165 )
2166 pkt = str( parsed_pkt )
2167 # Assertions
2168 verify_packet( self, pkt, out_port )
2169 verify_no_packet( self, pkt, in_port )
2170 verify_no_other_packets( self )
2171 finally:
Charles Chanc85f1562018-01-18 15:44:29 -08002172 print("SHOULD CLEAR STATE HERE")
2173 # delete_all_flows( self.controller )
2174 # delete_groups( self.controller, Groups )
2175 # delete_all_groups( self.controller )
2176
2177class ClearAll( base_tests.SimpleDataPlane ):
2178
2179 def runTest( self ):
2180 delete_all_flows( self.controller )
2181 delete_all_groups( self.controller )
2182
2183
2184
2185