blob: 2e679e08a504d2b57bb066cd3bc870e792b73a79 [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
Piere1308762016-09-12 15:29:56 -070017"""
18Check README file
19"""
20import Queue
21
22from oftest import config
23import inspect
24import logging
25import oftest.base_tests as base_tests
26import ofp
27from oftest.testutils import *
28from accton_util import *
29from utils import *
30
31MAX_INTERNAL_VLAN = 4094
32
33class L2ForwardingStackedVLAN( base_tests.SimpleDataPlane ):
34 """
35 Verify the proper operation of the pipeline part which includes VLAN table
36 and VLAN 1 table. This is necessary for classify packets in VPWS
37
38 One rules is necessary in VLAN table (10):
39 1) inPort = 12 (Physical) vlanId:mask = 0x1ff2:0x1fff (VLAN 4082) |
40 GoTo = 11 (VLAN 1) popVlanAction ovid = 8178 |
41 priority = 0 hard_time = 0 idle_time = 0 cookie = 1
42
43 One rules is necessary in VLAN 1 table (11):
44 2) inPort = 12 (Physical) vlanId = 0x1f8e (VLAN 3982) ovid = 0x1ff2 (VLAN 4082) |
45 GoTo = 20 (Termination MAC) newTpid2 = 0x8100 newVlanId2 = 0x1ff2 (VLAN 4082) |
46 priority = 0 hard_time = 0 idle_time = 0 cookie = 2
47
48 In this test case outer_vlan_id = (MAX_INTERNAL_VLAN - port_no) and
49 inner_vlan_id = (MAX_INTERNAL_VLAN - 100 - port_no)
50 The remaining part of the test is based on the use of the bridging table
51 """
52
53 def runTest( self ):
54 groups = Queue.LifoQueue( )
55 try:
56 if len( config[ "port_map" ] ) < 2:
57 logging.info( "Port count less than 2, can't run this case" )
58 return
59
60 ports = sorted( config[ "port_map" ].keys( ) )
61 for in_port in ports:
62 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
63 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
64 add_one_vlan_table_flow(
65 self.controller,
66 in_port,
67 vlan_id=outer_vlan_id,
68 flag=VLAN_TABLE_FLAG_ONLY_STACKED
69 )
70 add_one_vlan_1_table_flow(
71 self.controller,
72 in_port,
73 new_outer_vlan_id=-1,
74 outer_vlan_id=outer_vlan_id,
75 inner_vlan_id=inner_vlan_id,
76 flag=VLAN_TABLE_FLAG_ONLY_TAG
77 )
78 for out_port in ports:
79 if out_port == in_port:
80 continue
81 L2gid, l2msg = add_one_l2_interface_group(
82 self.controller,
83 out_port,
84 outer_vlan_id,
85 True,
86 False
87 )
88 groups.put( L2gid )
89 add_bridge_flow(
90 self.controller,
91 [ 0x00, 0x12, 0x34, 0x56, 0x78, in_port ],
92 outer_vlan_id,
93 L2gid,
94 True
95 )
96
97 do_barrier( self.controller )
98
99 for in_port in ports:
100 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
101 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
102 mac_dst = '00:12:34:56:78:%02X' % in_port
103
104 parsed_pkt = simple_tcp_packet_two_vlan(
105 pktlen=108,
106 out_dl_vlan_enable=True,
107 out_vlan_vid=outer_vlan_id,
108 in_dl_vlan_enable=True,
109 in_vlan_vid=inner_vlan_id,
110 eth_dst=mac_dst,
111 )
112 pkt = str( parsed_pkt )
113 self.dataplane.send( in_port, pkt )
114
115 # change dest based on port number
116 for out_port in ports:
117 if out_port == in_port:
118 verify_no_packet( self, pkt, in_port )
119 continue
120 verify_packet( self, pkt, out_port )
121 verify_no_other_packets( self )
122
123 finally:
124 delete_all_flows( self.controller )
125 delete_groups( self.controller, groups )
126 delete_all_groups( self.controller )
127
128class L2ForwardingStackedVLAN2( base_tests.SimpleDataPlane ):
129 """
130 Verify the proper operation of the pipeline part which includes VLAN table
131 and VLAN 1 table. This is necessary for classify packets in VPWS. In this test
132 case we verify the change of outer vlan VLAN 1 table.
133
134 One rules is necessary in VLAN table (10):
135 1) inPort = 12 (Physical) vlanId:mask = 0x1ff2:0x1fff (VLAN 4082) |
136 GoTo = 11 (VLAN 1) popVlanAction ovid = 8178 |
137 priority = 0 hard_time = 0 idle_time = 0 cookie = 1
138
139 One rules is necessary in VLAN 1 table (11):
140 2) inPort = 12 (Physical) vlanId = 0x1f8e (VLAN 3982) ovid = 0x1ff2 (VLAN 4082) |
141 GoTo = 20 (Termination MAC) newTpid2 = 0x8100 newVlanId2 = 0x1f2a (VLAN 3882) |
142 priority = 0 hard_time = 0 idle_time = 0 cookie = 2
143
144 In this test case:
145 1) outer_vlan_id = (MAX_INTERNAL_VLAN - port_no)
146 2) inner_vlan_id = (MAX_INTERNAL_VLAN - 100 - port_no)
147 3) new_outer_vlan_id = (MAX_INTERNAL_VLAN - 200 - port_no)
148
149 The remaining part of the test is based on the use of the bridging table
150 """
151
152 MAX_INTERNAL_VLAN = 4094
153
154 def runTest( self ):
155 groups = Queue.LifoQueue( )
156 try:
157 if len( config[ "port_map" ] ) < 2:
158 logging.info( "Port count less than 2, can't run this case" )
159 return
160
161 ports = sorted( config[ "port_map" ].keys( ) )
162 for in_port in ports:
163 new_outer_vlan_id = MAX_INTERNAL_VLAN - 200 - in_port
164 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
165 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
166 add_one_vlan_table_flow(
167 self.controller,
168 in_port,
169 vlan_id=outer_vlan_id,
170 flag=VLAN_TABLE_FLAG_ONLY_STACKED
171 )
172 add_one_vlan_1_table_flow(
173 self.controller,
174 in_port,
175 new_outer_vlan_id=new_outer_vlan_id,
176 outer_vlan_id=outer_vlan_id,
177 inner_vlan_id=inner_vlan_id,
178 flag=VLAN_TABLE_FLAG_ONLY_TAG
179 )
180 for out_port in ports:
181 if out_port == in_port:
182 continue
183 L2gid, l2msg = add_one_l2_interface_group(
184 self.controller,
185 out_port,
186 new_outer_vlan_id,
187 True,
188 False
189 )
190 groups.put( L2gid )
191 add_bridge_flow(
192 self.controller,
193 [ 0x00, 0x12, 0x34, 0x56, 0x78, in_port ],
194 new_outer_vlan_id,
195 L2gid,
196 True
197 )
198
199 do_barrier( self.controller )
200
201 for in_port in ports:
202 new_outer_vlan_id = MAX_INTERNAL_VLAN - 200 - in_port
203 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
204 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
205 mac_dst = '00:12:34:56:78:%02X' % in_port
206
207 parsed_pkt = simple_tcp_packet_two_vlan(
208 pktlen=108,
209 out_dl_vlan_enable=True,
210 out_vlan_vid=outer_vlan_id,
211 in_dl_vlan_enable=True,
212 in_vlan_vid=inner_vlan_id,
213 eth_dst=mac_dst,
214 )
215 pkt = str( parsed_pkt )
216 self.dataplane.send( in_port, pkt )
217
218 # change dest based on port number
219 for out_port in ports:
220 parsed_pkt = simple_tcp_packet_two_vlan(
221 pktlen=108,
222 out_dl_vlan_enable=True,
223 out_vlan_vid=new_outer_vlan_id,
224 in_dl_vlan_enable=True,
225 in_vlan_vid=inner_vlan_id,
226 eth_dst=mac_dst,
227 )
228 pkt = str( parsed_pkt )
229 if out_port == in_port:
230 verify_no_packet( self, pkt, in_port )
231 continue
232 verify_packet( self, pkt, out_port )
233 verify_no_other_packets( self )
234
235 finally:
236 delete_all_flows( self.controller )
237 delete_groups( self.controller, groups )
238 delete_all_groups( self.controller )
239
240class L2ForwardingStackedVLAN3( base_tests.SimpleDataPlane ):
241 """
242 Verify the proper operation of the pipeline part which includes VLAN table.
243 This is necessary for classify packets in VPWS. In this test
244 case we verify the change of outer vlan pushing another vlan in VLAN table.
245
246 One rules is necessary in VLAN table (10):
247 1) inPort = 12 (Physical) vlanId:mask = 0x1f8e:0x1fff (VLAN 3982) |
248 GoTo = 20 (Termination MAC) newTpid2 = 0x8100 newVlanId2 = 0x1ff2 (VLAN 4082) |
249 priority = 0 hard_time = 0 idle_time = 0 cookie = 1
250
251 In this test case:
252 1) outer_vlan_id = (MAX_INTERNAL_VLAN - port_no)
253 2) inner_vlan_id = (MAX_INTERNAL_VLAN - 100 - port_no)
254
255 The remaining part of the test is based on the use of the bridging table
256 """
257
258 MAX_INTERNAL_VLAN = 4094
259
260 def runTest( self ):
261 groups = Queue.LifoQueue( )
262 try:
263 if len( config[ "port_map" ] ) < 2:
264 logging.info( "Port count less than 2, can't run this case" )
265 return
266
267 ports = sorted( config[ "port_map" ].keys( ) )
268 for in_port in ports:
269 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
270 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
271 add_vlan_table_flow_pvid(
272 self.controller,
273 in_port,
274 match_vid=inner_vlan_id,
275 pvid=outer_vlan_id,
276 send_barrier=True
277 )
278 for out_port in ports:
279 if out_port == in_port:
280 continue
281 L2gid, l2msg = add_one_l2_interface_group(
282 self.controller,
283 out_port,
284 outer_vlan_id,
285 True,
286 False
287 )
288 groups.put( L2gid )
289 add_bridge_flow(
290 self.controller,
291 [ 0x00, 0x12, 0x34, 0x56, 0x78, in_port ],
292 outer_vlan_id,
293 L2gid,
294 True
295 )
296
297 do_barrier( self.controller )
298
299 for in_port in ports:
300 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
301 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
302 mac_dst = '00:12:34:56:78:%02X' % in_port
303
304 parsed_pkt = simple_tcp_packet(
305 pktlen=108,
306 dl_vlan_enable=True,
307 vlan_vid=inner_vlan_id,
308 eth_dst=mac_dst,
309 )
310 pkt = str( parsed_pkt )
311 self.dataplane.send( in_port, pkt )
312
313 # change dest based on port number
314 for out_port in ports:
315 parsed_pkt = simple_tcp_packet_two_vlan(
316 pktlen=112,
317 out_dl_vlan_enable=True,
318 out_vlan_vid=outer_vlan_id,
319 in_dl_vlan_enable=True,
320 in_vlan_vid=inner_vlan_id,
321 eth_dst=mac_dst,
322 )
323 pkt = str( parsed_pkt )
324 if out_port == in_port:
325 verify_no_packet( self, pkt, in_port )
326 continue
327 verify_packet( self, pkt, out_port )
328 verify_no_other_packets( self )
329
330 finally:
331 delete_all_flows( self.controller )
332 delete_groups( self.controller, groups )
333 delete_all_groups( self.controller )
334
335class L2ForwardingStackedVLAN4( base_tests.SimpleDataPlane ):
336 """
337 Verify the proper operation of the pipeline part which includes VLAN table
338 and VLAN 1 table. This is necessary for classify packets in VPWS. In this test
339 case we verify the change of outer vlan popping the tag in VLAN 1 table.
340
341 One rules is necessary in VLAN table (10):
342 1) inPort = 12 (Physical) vlanId:mask = 0x1ff2:0x1fff (VLAN 4082) |
343 GoTo = 11 (VLAN 1) popVlanAction ovid = 8178 |
344 priority = 0 hard_time = 0 idle_time = 0 cookie = 1
345
346 One rules is necessary in VLAN table (11):
347 1) inPort = 12 (Physical) vlanId = 0x1f8e (VLAN 3982) ovid = 0x1ff2 (VLAN 4082) |
348 GoTo = 20 (Termination MAC) |
349 priority = 0 hard_time = 0 idle_time = 0 cookie = 2
350
351 In this test case:
352 1) outer_vlan_id = (MAX_INTERNAL_VLAN - port_no)
353 2) inner_vlan_id = (MAX_INTERNAL_VLAN - 100 - port_no)
354
355 The remaining part of the test is based on the use of the bridging table
356 """
357
358 MAX_INTERNAL_VLAN = 4094
359
360 def runTest( self ):
361 groups = Queue.LifoQueue( )
362 try:
363 if len( config[ "port_map" ] ) < 2:
364 logging.info( "Port count less than 2, can't run this case" )
365 return
366
367 ports = sorted( config[ "port_map" ].keys( ) )
368 for in_port in ports:
369 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
370 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
371 add_one_vlan_table_flow(
372 self.controller,
373 in_port,
374 vlan_id=outer_vlan_id,
375 flag=VLAN_TABLE_FLAG_ONLY_STACKED
376 )
377 add_one_vlan_1_table_flow(
378 self.controller,
379 in_port,
380 new_outer_vlan_id=-1,
381 outer_vlan_id=outer_vlan_id,
382 inner_vlan_id=inner_vlan_id,
383 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
384 )
385 for out_port in ports:
386 if out_port == in_port:
387 continue
388 L2gid, l2msg = add_one_l2_interface_group(
389 self.controller,
390 out_port,
391 inner_vlan_id,
392 True,
393 False
394 )
395 groups.put( L2gid )
396 add_bridge_flow(
397 self.controller,
398 [ 0x00, 0x12, 0x34, 0x56, 0x78, in_port ],
399 inner_vlan_id,
400 L2gid,
401 True
402 )
403
404 do_barrier( self.controller )
405
406 for in_port in ports:
407 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
408 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
409 mac_dst = '00:12:34:56:78:%02X' % in_port
410
411 parsed_pkt = simple_tcp_packet_two_vlan(
412 pktlen=112,
413 out_dl_vlan_enable=True,
414 out_vlan_vid=outer_vlan_id,
415 in_dl_vlan_enable=True,
416 in_vlan_vid=inner_vlan_id,
417 eth_dst=mac_dst,
418 )
419 pkt = str( parsed_pkt )
420 self.dataplane.send( in_port, pkt )
421
422 # change dest based on port number
423 for out_port in ports:
424 parsed_pkt = simple_tcp_packet(
425 pktlen=108,
426 dl_vlan_enable=True,
427 vlan_vid=inner_vlan_id,
428 eth_dst=mac_dst,
429 )
430 pkt = str( parsed_pkt )
431 if out_port == in_port:
432 verify_no_packet( self, pkt, in_port )
433 continue
434 verify_packet( self, pkt, out_port )
435 verify_no_other_packets( self )
436
437 finally:
438 delete_all_flows( self.controller )
439 delete_groups( self.controller, groups )
440 delete_all_groups( self.controller )
441
442class L2ForwardingStackedVLAN5( base_tests.SimpleDataPlane ):
443 """
444 Verify the proper operation of the pipeline part which includes VLAN table
445 and VLAN 1 table. This is necessary for classify packets in VPWS. In this test
446 case we verify the change of outer vlan in VLAN table.
447
448 One rules is necessary in VLAN table (10):
449 1) inPort = 12 (Physical) vlanId:mask = 0x1ff2:0x1fff (VLAN 4082) |
450 GoTo = 20 (VLAN 1) newVlanId = 0x1f2a (VLAN 3882) |
451 priority = 0 hard_time = 0 idle_time = 0 cookie = 1
452
453 In this test case:
454 1) outer_vlan_id = (MAX_INTERNAL_VLAN - port_no)
455 3) new_outer_vlan_id = (MAX_INTERNAL_VLAN - 200 - port_no)
456
457 The remaining part of the test is based on the use of the bridging table
458 """
459
460 MAX_INTERNAL_VLAN = 4094
461
462 def runTest( self ):
463 groups = Queue.LifoQueue( )
464 try:
465 if len( config[ "port_map" ] ) < 2:
466 logging.info( "Port count less than 2, can't run this case" )
467 return
468
469 ports = sorted( config[ "port_map" ].keys( ) )
470 for in_port in ports:
471 new_outer_vlan_id = MAX_INTERNAL_VLAN - 200 - in_port
472 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
473 add_one_vlan_table_flow_translation(
474 self.controller,
475 in_port,
476 vlan_id=outer_vlan_id,
477 new_vlan_id=new_outer_vlan_id,
478 vrf=0,
479 flag=VLAN_TABLE_FLAG_ONLY_TAG,
480 send_barrier=False
481 )
482 for out_port in ports:
483 if out_port == in_port:
484 continue
485 L2gid, l2msg = add_one_l2_interface_group(
486 self.controller,
487 out_port,
488 new_outer_vlan_id,
489 True,
490 False
491 )
492 groups.put( L2gid )
493 add_bridge_flow(
494 self.controller,
495 [ 0x00, 0x12, 0x34, 0x56, 0x78, in_port ],
496 new_outer_vlan_id,
497 L2gid,
498 True
499 )
500
501 do_barrier( self.controller )
502
503 for in_port in ports:
504 new_outer_vlan_id = MAX_INTERNAL_VLAN - 200 - in_port
505 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
506 inner_vlan_id =MAX_INTERNAL_VLAN - 100 - in_port
507 mac_dst = '00:12:34:56:78:%02X' % in_port
508
509 parsed_pkt = simple_tcp_packet_two_vlan(
510 pktlen=112,
511 out_dl_vlan_enable=True,
512 out_vlan_vid=outer_vlan_id,
513 in_dl_vlan_enable=True,
514 in_vlan_vid=inner_vlan_id,
515 eth_dst=mac_dst,
516 )
517 pkt = str( parsed_pkt )
518 self.dataplane.send( in_port, pkt )
519
520 # change dest based on port number
521 for out_port in ports:
522 parsed_pkt = simple_tcp_packet_two_vlan(
523 pktlen=112,
524 out_dl_vlan_enable=True,
525 out_vlan_vid=new_outer_vlan_id,
526 in_dl_vlan_enable=True,
527 in_vlan_vid=inner_vlan_id,
528 eth_dst=mac_dst,
529 )
530 pkt = str( parsed_pkt )
531 if out_port == in_port:
532 verify_no_packet( self, pkt, in_port )
533 continue
534 verify_packet( self, pkt, out_port )
535 verify_no_other_packets( self )
536
537 finally:
538 delete_all_flows( self.controller )
539 delete_groups( self.controller, groups )
540 delete_all_groups( self.controller )
541
542class L2ForwardingStackedVLAN6( base_tests.SimpleDataPlane ):
543 """
544 Verify the proper operation of the pipeline part which includes VLAN table.
545 This is necessary for classify packets priority tagged. In this test
546 case we verify the change of outer vlan in VLAN table.
547
548 Two rules are necessary in VLAN table (10):
549 1) inPort = 12 (Physical) vlanId:mask = 0x1000:0x1fff (VLAN 0) |
550 GoTo = 20 (Termination MAC) newVlanId = 0x1f8e (VLAN 3982) newTpid2 = 0x8100 newVlanId2 = 0x1ff2 (VLAN 4082) |
551 priority = 0 hard_time = 0 idle_time = 0 cookie = 3
552 2) inPort = 12 (Physical) vlanId:mask = 0x1ff2:0x1fff (VLAN 4082) |
553 GoTo = 20 (Termination MAC) |
554 priority = 0 hard_time = 0 idle_time = 0 cookie = 1
555
556
557 In this test case:
558 1) outer_vlan_id = (MAX_INTERNAL_VLAN - port_no)
559 3) inner_vlan_id = (MAX_INTERNAL_VLAN - 100 - port_no)
560
561 The remaining part of the test is based on the use of the bridging table
562 """
563
564 MAX_INTERNAL_VLAN = 4094
565
566 def runTest( self ):
567 groups = Queue.LifoQueue( )
568 try:
569 if len( config[ "port_map" ] ) < 2:
570 logging.info( "Port count less than 2, can't run this case" )
571 return
572
573 ports = sorted( config[ "port_map" ].keys( ) )
574 for in_port in ports:
575 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
576 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
577 add_one_vlan_table_flow(
578 ctrl=self.controller,
579 of_port=in_port,
580 vlan_id=outer_vlan_id,
581 vrf=0,
582 flag=VLAN_TABLE_FLAG_ONLY_BOTH,
583 send_barrier=False
584 )
585 add_one_vlan_table_flow(
586 ctrl=self.controller,
587 of_port=in_port,
588 out_vlan_id=outer_vlan_id,
589 vlan_id=inner_vlan_id,
590 vrf=0,
591 flag=VLAN_TABLE_FLAG_PRIORITY,
592 send_barrier=False
593 )
594 for out_port in ports:
595 if out_port == in_port:
596 continue
597 L2gid, l2msg = add_one_l2_interface_group(
598 self.controller,
599 out_port,
600 outer_vlan_id,
601 True,
602 False
603 )
604 groups.put( L2gid )
605 add_bridge_flow(
606 self.controller,
607 [ 0x00, 0x12, 0x34, 0x56, 0x78, in_port ],
608 outer_vlan_id,
609 L2gid,
610 True
611 )
612
613 do_barrier( self.controller )
614
615 for in_port in ports:
616 outer_vlan_id = MAX_INTERNAL_VLAN - in_port
617 inner_vlan_id = MAX_INTERNAL_VLAN - 100 - in_port
618 mac_dst = '00:12:34:56:78:%02X' % in_port
619
620 parsed_pkt = simple_tcp_packet(
621 pktlen=112,
622 dl_vlan_enable=True,
623 vlan_vid=0,
624 eth_dst=mac_dst,
625 )
626 pkt = str( parsed_pkt )
627 self.dataplane.send( in_port, pkt )
628
629 # change dest based on port number
630 for out_port in ports:
631 parsed_pkt = simple_tcp_packet_two_vlan(
632 pktlen=116,
633 out_dl_vlan_enable=True,
634 out_vlan_vid=outer_vlan_id,
635 in_dl_vlan_enable=True,
636 in_vlan_vid=inner_vlan_id,
637 eth_dst=mac_dst,
638 )
639 pkt = str( parsed_pkt )
640 if out_port == in_port:
641 verify_no_packet( self, pkt, in_port )
642 continue
643 verify_packet( self, pkt, out_port )
644 verify_no_other_packets( self )
645
646 finally:
647 delete_all_flows( self.controller )
648 delete_groups( self.controller, groups )
649 delete_all_groups( self.controller )