blob: e7f61c1251f20b5d329032a6cc82955c3dca3a8a [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
Pier1e4e98e2016-10-26 14:36:05 -070017"""
18Check README file
19"""
20import Queue
21
22import itertools
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 *
31import time
32
33class PacketInICMPv6( base_tests.SimpleDataPlane ):
34 """
35 Verify ACL rule for ICMPv6 packet. The expected behavior is
36 Packet-In message in the control plane.
37 """
38
39 def runTest( self ):
40 try:
41 # We insert an ACL rule for ICMPv6
42 add_acl_rule(
43 self.controller,
44 eth_type=0x86dd,
45 ip_proto=0x3A,
Tony Choud6195802018-06-01 11:52:26 +080046 send_barrier=True
Pier1e4e98e2016-10-26 14:36:05 -070047 )
48
49 ports = config[ "port_map" ].keys( )
50 for in_port in ports:
51 # Neighbor solicitation
52 parsed_icmpv6_pkt = simple_icmpv6_packet(icmp_type=135)
53 icmpv6_pkt = str( parsed_icmpv6_pkt )
54 self.dataplane.send(in_port, icmpv6_pkt)
55 verify_packet_in(self, icmpv6_pkt, in_port, ofp.OFPR_ACTION)
56 verify_no_other_packets( self )
57 # Neighbor advertisement
58 parsed_icmpv6_pkt = simple_icmpv6_packet(icmp_type=136)
59 icmpv6_pkt = str( parsed_icmpv6_pkt )
60 self.dataplane.send(in_port, icmpv6_pkt)
61 verify_packet_in(self, icmpv6_pkt, in_port, ofp.OFPR_ACTION)
62 verify_no_other_packets( self )
63
64 finally:
65 delete_all_flows( self.controller )
66 delete_all_groups( self.controller )
67
68class PacketInIPv6Table( base_tests.SimpleDataPlane ):
69 """
70 Verify Packet-in message from IP table when controller action is used
71 Send a packet to each dataplane port and verify that a packet
72 in message is received from the controller for each
73 #todo verify you stop receiving after adding rule
74 """
75
76 def runTest( self ):
77 try:
78
79 if len( config[ "port_map" ] ) < 2:
80 logging.info( "Port count less than 2, can't run this case" )
81 return
82
83 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
84 # We are assuming that the port number are xx"
85 dip = "2000::%s"
86 sip = "2000::1"
87 ports = config[ "port_map" ].keys( )
88
89 for pair in itertools.product(ports, ports):
90 # we generate all possible products
91 in_port = pair[0]
92 out_port = pair[1]
93 vlan_id = in_port
94 dst_mac[ 5 ] = vlan_id
95 dst_ip = dip % in_port
96 # We fill the unicast_table
97 add_unicast_v6_routing_flow(
98 ctrl=self.controller,
99 eth_type=0x86dd,
100 dst_ip=dst_ip,
101 mask="ffff:ffff:ffff:ffff::",
102 action_group_id=None,
103 vrf=0,
104 send_ctrl=True,
105 send_barrier=False
106 )
107 # add termination flow
108 add_termination_flow(
109 ctrl=self.controller,
110 in_port=in_port,
111 eth_type=0x86dd,
112 dst_mac=dst_mac,
113 vlanid=vlan_id
114 )
115 # add vlan table flow
116 add_one_vlan_table_flow(
117 ctrl=self.controller,
118 of_port=in_port,
Pier265ad5f2017-02-28 17:46:28 +0100119 out_vlan_id=1,
Pier1e4e98e2016-10-26 14:36:05 -0700120 vlan_id=vlan_id,
121 flag=VLAN_TABLE_FLAG_ONLY_TAG
122 )
123
124 for port in ports:
125 vlan_id = port
126 dst_mac[ 5 ] = vlan_id
127 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
128 dip_str = dip % port
129 parsed_tcpv6_pkt = simple_tcpv6_packet(
130 pktlen=100,
131 eth_dst=dst_mac_str,
132 dl_vlan_enable=True,
133 vlan_vid=vlan_id,
134 ipv6_dst=dip_str,
135 ipv6_src=sip
136 )
137 tcpv6_pkt = str( parsed_tcpv6_pkt )
138 self.dataplane.send(port, tcpv6_pkt)
139 verify_packet_in(self, tcpv6_pkt, port, ofp.OFPR_ACTION)
140 verify_no_other_packets( self )
141
142 finally:
143 delete_all_flows( self.controller )
144 delete_all_groups( self.controller )
145
146class _128UcastUnTagged( base_tests.SimpleDataPlane ):
147 """ Verify /128 IP forwarding to L3 Interface"""
148
149 def runTest( self ):
150 try:
151
152 if len( config[ "port_map" ] ) < 2:
153 logging.info( "Port count less than 2, can't run this case" )
154 return
155
156 Groups = Queue.LifoQueue( )
157 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
158 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
159 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
160 # We are assuming that the port number are xx"
161 dip = "2000::%s"
162 sip = "2000::1"
163 ports = config[ "port_map" ].keys( )
164 vlan_id = 4094
165
166 in_port = ports[0]
167 out_port = ports[1]
168 r_dst_mac[5] = in_port
169 intf_src_mac[5] = out_port
170 dst_mac[5] = out_port
171 dst_ip = dip % in_port
172 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
173 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
174 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
175 # We create the L2 group
176 l2gid, msg = add_one_l2_interface_group(
177 ctrl=self.controller,
178 port=out_port,
179 vlan_id=vlan_id,
180 is_tagged=False,
181 send_barrier=True
182 )
183 Groups._put(l2gid)
184 # We create the L3 group
185 l3_msg = add_l3_unicast_group(
186 ctrl=self.controller,
187 port=out_port,
188 vlanid=vlan_id,
189 id=vlan_id,
190 src_mac=intf_src_mac,
191 dst_mac=dst_mac,
192 send_barrier=True
193 )
194 Groups._put( l3_msg.group_id )
195 # We fill the unicast_table
196 add_unicast_v6_routing_flow(
197 ctrl=self.controller,
198 eth_type=0x86dd,
199 dst_ip=dst_ip,
200 mask="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
201 action_group_id=l3_msg.group_id,
202 vrf=0,
203 send_ctrl=False,
204 send_barrier=True
205 )
206 # add termination flow
207 add_termination_flow(
208 ctrl=self.controller,
209 in_port=in_port,
210 eth_type=0x86dd,
211 dst_mac=r_dst_mac,
212 vlanid=vlan_id,
213 )
214 # add filtering flow
215 add_one_vlan_table_flow(
216 ctrl=self.controller,
217 of_port=in_port,
218 vlan_id=vlan_id,
219 flag=VLAN_TABLE_FLAG_ONLY_TAG
220 )
221 # add assignment flow
222 add_one_vlan_table_flow(
223 ctrl=self.controller,
224 of_port=in_port,
225 vlan_id=vlan_id,
226 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
227 )
228
229 parsed_tcpv6_pkt = simple_tcpv6_packet(
230 pktlen=100,
231 eth_dst=r_dst_mac_str,
232 ipv6_dst=dst_ip,
233 ipv6_src=sip
234 )
235 tcpv6_pkt = str( parsed_tcpv6_pkt )
236 self.dataplane.send(in_port, tcpv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -0700237 parsed_tcpv6_pkt = simple_tcpv6_packet(
238 pktlen=100,
239 eth_dst=dst_mac_str,
240 eth_src=intf_src_mac_str,
241 ipv6_dst=dst_ip,
242 ipv6_src=sip,
243 ipv6_hlim=63
244 )
Pier1e4e98e2016-10-26 14:36:05 -0700245 tcpv6_pkt = str( parsed_tcpv6_pkt )
246 verify_packet(self, tcpv6_pkt, out_port )
247 verify_no_packet(self, tcpv6_pkt, in_port )
248 verify_no_other_packets(self)
249
250
251 finally:
252 delete_all_flows( self.controller )
253 delete_groups( self.controller, Groups )
254 delete_all_groups( self.controller )
255
256class _128ECMPVpn( base_tests.SimpleDataPlane ):
257 """ Verify MPLS IP VPN Initiation from /128 rule using ECMP """
258
259 def runTest( self ):
260 try:
261
262 if len( config[ "port_map" ] ) < 2:
263 logging.info( "Port count less than 2, can't run this case" )
264 return
265
266 Groups = Queue.LifoQueue( )
267 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
268 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
269 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
270 # We are assuming that the port number are xx"
271 dip = "2000::%s"
272 sip = "2000::1"
273 ports = config[ "port_map" ].keys( )
274 vlan_id = 4094
275 mpls_label = 255
276 label = (mpls_label, 0, 1, 63)
277
278 in_port = ports[0]
279 out_port = ports[1]
280 r_dst_mac[5] = in_port
281 intf_src_mac[5] = out_port
282 dst_mac[5] = out_port
283 dst_ip = dip % in_port
284 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
285 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
286 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
287 # We create the L2 group
288 l2gid, msg = add_one_l2_interface_group(
289 ctrl=self.controller,
290 port=out_port,
291 vlan_id=vlan_id,
292 is_tagged=False,
293 send_barrier=True
294 )
295 Groups.put(l2gid)
296 mpls_gid, mpls_msg = add_mpls_intf_group(
297 ctrl=self.controller,
298 ref_gid=l2gid,
299 dst_mac=dst_mac,
300 src_mac=intf_src_mac,
301 vid=vlan_id,
302 index=out_port,
303 send_barrier=True
304 )
305 Groups.put( mpls_gid )
306 # add MPLS L3 VPN group
307 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
308 ctrl=self.controller,
309 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
310 index=out_port,
311 ref_gid=mpls_gid,
312 push_mpls_header=True,
313 set_mpls_label=mpls_label,
314 set_bos=1,
315 cpy_ttl_outward=True,
316 send_barrier=True
317 )
318 Groups.put( mpls_label_gid )
319 # Add ECMP group
320 ecmp_msg = add_l3_ecmp_group(
321 ctrl=self.controller,
322 id=vlan_id,
323 l3_ucast_groups=[ mpls_label_gid ],
324 send_barrier=True
325 )
326 Groups.put( ecmp_msg.group_id )
327 # We fill the unicast_table
328 add_unicast_v6_routing_flow(
329 ctrl=self.controller,
330 eth_type=0x86dd,
331 dst_ip=dst_ip,
332 mask="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
333 action_group_id=ecmp_msg.group_id,
334 vrf=0,
335 send_ctrl=False,
336 send_barrier=True
337 )
338 # add termination flow
339 add_termination_flow(
340 ctrl=self.controller,
341 in_port=in_port,
342 eth_type=0x86dd,
343 dst_mac=r_dst_mac,
344 vlanid=vlan_id
345 )
346 # add filtering flow
347 add_one_vlan_table_flow(
348 ctrl=self.controller,
349 of_port=in_port,
350 vlan_id=vlan_id,
351 flag=VLAN_TABLE_FLAG_ONLY_TAG
352 )
353 # add assignment flow
354 add_one_vlan_table_flow(
355 ctrl=self.controller,
356 of_port=in_port,
357 vlan_id=vlan_id,
358 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
359 )
360
361 parsed_tcpv6_pkt = simple_tcpv6_packet(
362 pktlen=100,
363 eth_dst=r_dst_mac_str,
364 ipv6_dst=dst_ip,
365 ipv6_src=sip
366 )
367 tcpv6_pkt = str( parsed_tcpv6_pkt )
368 self.dataplane.send(in_port, tcpv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -0700369 parsed_mplsv6_pkt = mplsv6_packet(
370 pktlen=104,
371 eth_dst=dst_mac_str,
372 eth_src=intf_src_mac_str,
373 ipv6_dst=dst_ip,
374 ipv6_src=sip,
375 ipv6_hlim=63,
376 label=[ label ]
377 )
378 mplsv6_pkt = str( parsed_mplsv6_pkt )
Pier1e4e98e2016-10-26 14:36:05 -0700379 verify_packet(self, mplsv6_pkt, out_port )
380 verify_no_packet(self, mplsv6_pkt, in_port )
381 verify_no_other_packets(self)
382
383 finally:
384 delete_all_flows( self.controller )
385 delete_groups( self.controller, Groups )
386 delete_all_groups( self.controller )
387
388class _128ECMPL3( base_tests.SimpleDataPlane ):
389 """ Verifies /128 IP routing and ECMP """
390
Pier1e4e98e2016-10-26 14:36:05 -0700391 def runTest( self ):
392 try:
393
394 if len( config[ "port_map" ] ) < 2:
395 logging.info( "Port count less than 2, can't run this case" )
396 return
397
398 Groups = Queue.LifoQueue( )
399 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
400 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
401 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
402 # We are assuming that the port number are xx"
403 dip = "2000::%s"
404 sip = "2000::1"
405 ports = config[ "port_map" ].keys( )
406 vlan_id = 4094
407
408 in_port = ports[0]
409 out_port = ports[1]
410 r_dst_mac[5] = in_port
411 intf_src_mac[5] = out_port
412 dst_mac[5] = out_port
413 dst_ip = dip % in_port
414 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
415 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
416 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
417 # We create the L2 group
418 l2gid, msg = add_one_l2_interface_group(
419 ctrl=self.controller,
420 port=out_port,
421 vlan_id=vlan_id,
422 is_tagged=False,
423 send_barrier=True
424 )
425 Groups.put(l2gid)
426 # We create the L3 group
427 l3_msg = add_l3_unicast_group(
428 ctrl=self.controller,
429 port=out_port,
430 vlanid=vlan_id,
431 id=vlan_id,
432 src_mac=intf_src_mac,
433 dst_mac=dst_mac,
434 send_barrier=True
435 )
436 Groups.put( l3_msg.group_id )
437 # Add ECMP group
438 ecmp_msg = add_l3_ecmp_group(
439 ctrl=self.controller,
440 id=vlan_id,
441 l3_ucast_groups=[ l3_msg.group_id ],
442 send_barrier=True
443 )
444 Groups.put( ecmp_msg.group_id )
445 # We fill the unicast_table
446 add_unicast_v6_routing_flow(
447 ctrl=self.controller,
448 eth_type=0x86dd,
449 dst_ip=dst_ip,
450 mask="ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff",
451 action_group_id=ecmp_msg.group_id,
452 vrf=0,
453 send_ctrl=False,
454 send_barrier=True
455 )
456 # add termination flow
457 add_termination_flow(
458 ctrl=self.controller,
459 in_port=in_port,
460 eth_type=0x86dd,
461 dst_mac=r_dst_mac,
462 vlanid=vlan_id
463 )
464 # add filtering flow
465 add_one_vlan_table_flow(
466 ctrl=self.controller,
467 of_port=in_port,
468 vlan_id=vlan_id,
469 flag=VLAN_TABLE_FLAG_ONLY_TAG
470 )
471 # add assignment flow
472 add_one_vlan_table_flow(
473 ctrl=self.controller,
474 of_port=in_port,
475 vlan_id=vlan_id,
476 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
477 )
478
479 parsed_tcpv6_pkt = simple_tcpv6_packet(
480 pktlen=100,
481 eth_dst=r_dst_mac_str,
482 ipv6_dst=dst_ip,
483 ipv6_src=sip
484 )
485 tcpv6_pkt = str( parsed_tcpv6_pkt )
486 self.dataplane.send(in_port, tcpv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -0700487 parsed_tcpv6_pkt = simple_tcpv6_packet(
488 pktlen=100,
489 eth_dst=dst_mac_str,
490 eth_src=intf_src_mac_str,
491 ipv6_dst=dst_ip,
492 ipv6_src=sip,
493 ipv6_hlim=63
494 )
495 tcpv6_pkt = str( parsed_tcpv6_pkt )
Pier1e4e98e2016-10-26 14:36:05 -0700496 verify_packet(self, tcpv6_pkt, out_port )
497 verify_no_packet(self, tcpv6_pkt, in_port )
498 verify_no_other_packets(self)
499
500 finally:
501 print "END"
502 #delete_all_flows( self.controller )
503 #delete_groups( self.controller, Groups )
504 #delete_all_groups( self.controller )
505
506class _64UcastUntagged( base_tests.SimpleDataPlane ):
507 """ Verify /64 IP forwarding to L3 Interface"""
508
509 def runTest( self ):
510 try:
511
512 if len( config[ "port_map" ] ) < 2:
513 logging.info( "Port count less than 2, can't run this case" )
514 return
515
516 Groups = Queue.LifoQueue( )
517 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
518 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
519 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
520 # We are assuming that the port number are xx"
521 dip = "2000::%s"
522 sip = "2000::1"
523 ports = config[ "port_map" ].keys( )
524 vlan_id = 4094
525
526 in_port = ports[0]
527 out_port = ports[1]
528 r_dst_mac[5] = in_port
529 intf_src_mac[5] = out_port
530 dst_mac[5] = out_port
531 dst_ip = dip % in_port
532 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
533 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
534 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
535 # We create the L2 group
536 l2gid, msg = add_one_l2_interface_group(
537 ctrl=self.controller,
538 port=out_port,
539 vlan_id=vlan_id,
540 is_tagged=False,
541 send_barrier=True
542 )
543 Groups._put(l2gid)
544 # We create the L3 group
545 l3_msg = add_l3_unicast_group(
546 ctrl=self.controller,
547 port=out_port,
548 vlanid=vlan_id,
549 id=vlan_id,
550 src_mac=intf_src_mac,
551 dst_mac=dst_mac,
552 send_barrier=True
553 )
554 Groups._put( l3_msg.group_id )
555 # We fill the unicast_table
556 add_unicast_v6_routing_flow(
557 ctrl=self.controller,
558 eth_type=0x86dd,
559 dst_ip=dst_ip,
560 mask="ffff:ffff:ffff:ffff::",
561 action_group_id=l3_msg.group_id,
562 vrf=0,
563 send_ctrl=False,
564 send_barrier=True
565 )
566 # add termination flow
567 add_termination_flow(
568 ctrl=self.controller,
569 in_port=in_port,
570 eth_type=0x86dd,
571 dst_mac=r_dst_mac,
572 vlanid=vlan_id,
573 )
574 # add filtering flow
575 add_one_vlan_table_flow(
576 ctrl=self.controller,
577 of_port=in_port,
578 vlan_id=vlan_id,
579 flag=VLAN_TABLE_FLAG_ONLY_TAG
580 )
581 # add assignment flow
582 add_one_vlan_table_flow(
583 ctrl=self.controller,
584 of_port=in_port,
585 vlan_id=vlan_id,
586 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
587 )
588
589 parsed_tcpv6_pkt = simple_tcpv6_packet(
590 pktlen=100,
591 eth_dst=r_dst_mac_str,
592 ipv6_dst=dst_ip,
593 ipv6_src=sip
594 )
595 tcpv6_pkt = str( parsed_tcpv6_pkt )
596 self.dataplane.send(in_port, tcpv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -0700597 parsed_tcpv6_pkt = simple_tcpv6_packet(
598 pktlen=100,
599 eth_dst=dst_mac_str,
600 eth_src=intf_src_mac_str,
601 ipv6_dst=dst_ip,
602 ipv6_src=sip,
603 ipv6_hlim=63
604 )
Pier1e4e98e2016-10-26 14:36:05 -0700605 tcpv6_pkt = str( parsed_tcpv6_pkt )
606 verify_packet(self, tcpv6_pkt, out_port )
607 verify_no_packet(self, tcpv6_pkt, in_port )
608 verify_no_other_packets(self)
609
610 finally:
611 delete_all_flows( self.controller )
612 delete_groups( self.controller, Groups )
613 delete_all_groups( self.controller )
614
615class _64ECMPVpn( base_tests.SimpleDataPlane ):
616 """ Verify MPLS IP VPN Initiation from /64 rule using ECMP """
617
618 def runTest( self ):
619 try:
620
621 if len( config[ "port_map" ] ) < 2:
622 logging.info( "Port count less than 2, can't run this case" )
623 return
624
625 Groups = Queue.LifoQueue( )
626 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
627 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
628 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
629 # We are assuming that the port number are xx"
630 dip = "2000::%s"
631 sip = "2000::1"
632 ports = config[ "port_map" ].keys( )
633 vlan_id = 4094
634 mpls_label = 255
635 label = (mpls_label, 0, 1, 63)
636
637 in_port = ports[0]
638 out_port = ports[1]
639 r_dst_mac[5] = in_port
640 intf_src_mac[5] = out_port
641 dst_mac[5] = out_port
642 dst_ip = dip % in_port
643 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
644 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
645 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
646 # We create the L2 group
647 l2gid, msg = add_one_l2_interface_group(
648 ctrl=self.controller,
649 port=out_port,
650 vlan_id=vlan_id,
651 is_tagged=False,
652 send_barrier=True
653 )
654 Groups.put(l2gid)
655 mpls_gid, mpls_msg = add_mpls_intf_group(
656 ctrl=self.controller,
657 ref_gid=l2gid,
658 dst_mac=dst_mac,
659 src_mac=intf_src_mac,
660 vid=vlan_id,
661 index=out_port,
662 send_barrier=True
663 )
664 Groups.put( mpls_gid )
665 # add MPLS L3 VPN group
666 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
667 ctrl=self.controller,
668 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
669 index=out_port,
670 ref_gid=mpls_gid,
671 push_mpls_header=True,
672 set_mpls_label=mpls_label,
673 set_bos=1,
674 cpy_ttl_outward=True,
675 send_barrier=True
676 )
677 Groups.put( mpls_label_gid )
678 # Add ECMP group
679 ecmp_msg = add_l3_ecmp_group(
680 ctrl=self.controller,
681 id=vlan_id,
682 l3_ucast_groups=[ mpls_label_gid ],
683 send_barrier=True
684 )
685 Groups.put( ecmp_msg.group_id )
686 # We fill the unicast_table
687 add_unicast_v6_routing_flow(
688 ctrl=self.controller,
689 eth_type=0x86dd,
690 dst_ip=dst_ip,
691 mask="ffff:ffff:ffff:ffff::",
692 action_group_id=ecmp_msg.group_id,
693 vrf=0,
694 send_ctrl=False,
695 send_barrier=True
696 )
697 # add termination flow
698 add_termination_flow(
699 ctrl=self.controller,
700 in_port=in_port,
701 eth_type=0x86dd,
702 dst_mac=r_dst_mac,
703 vlanid=vlan_id
704 )
705 # add filtering flow
706 add_one_vlan_table_flow(
707 ctrl=self.controller,
708 of_port=in_port,
709 vlan_id=vlan_id,
710 flag=VLAN_TABLE_FLAG_ONLY_TAG
711 )
712 # add assignment flow
713 add_one_vlan_table_flow(
714 ctrl=self.controller,
715 of_port=in_port,
716 vlan_id=vlan_id,
717 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
718 )
719
720 parsed_tcpv6_pkt = simple_tcpv6_packet(
721 pktlen=100,
722 eth_dst=r_dst_mac_str,
723 ipv6_dst=dst_ip,
724 ipv6_src=sip
725 )
726 tcpv6_pkt = str( parsed_tcpv6_pkt )
727 self.dataplane.send(in_port, tcpv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -0700728 parsed_mplsv6_pkt = mplsv6_packet(
729 pktlen=104,
730 eth_dst=dst_mac_str,
731 eth_src=intf_src_mac_str,
732 ipv6_dst=dst_ip,
733 ipv6_src=sip,
734 ipv6_hlim=63,
735 label=[ label ]
736 )
737 mplsv6_pkt = str( parsed_mplsv6_pkt )
Pier1e4e98e2016-10-26 14:36:05 -0700738 verify_packet(self, mplsv6_pkt, out_port )
739 verify_no_packet(self, mplsv6_pkt, in_port )
740 verify_no_other_packets(self)
741
742 finally:
743 delete_all_flows( self.controller )
744 delete_groups( self.controller, Groups )
745 delete_all_groups( self.controller )
746
747class _64ECMPL3( base_tests.SimpleDataPlane ):
748 """ Verifies /64 IP routing and ECMP """
749
750
751 def runTest( self ):
752 try:
753
754 if len( config[ "port_map" ] ) < 2:
755 logging.info( "Port count less than 2, can't run this case" )
756 return
757
758 Groups = Queue.LifoQueue( )
759 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
760 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
761 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
762 # We are assuming that the port number are xx"
763 dip = "2000::%s"
764 sip = "2000::1"
765 ports = config[ "port_map" ].keys( )
766 vlan_id = 4094
767
768 in_port = ports[0]
769 out_port = ports[1]
770 r_dst_mac[5] = in_port
771 intf_src_mac[5] = out_port
772 dst_mac[5] = out_port
773 dst_ip = dip % in_port
774 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
775 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
776 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
777 # We create the L2 group
778 l2gid, msg = add_one_l2_interface_group(
779 ctrl=self.controller,
780 port=out_port,
781 vlan_id=vlan_id,
782 is_tagged=False,
783 send_barrier=True
784 )
785 Groups.put(l2gid)
786 # We create the L3 group
787 l3_msg = add_l3_unicast_group(
788 ctrl=self.controller,
789 port=out_port,
790 vlanid=vlan_id,
791 id=vlan_id,
792 src_mac=intf_src_mac,
793 dst_mac=dst_mac,
794 send_barrier=True
795 )
796 Groups.put( l3_msg.group_id )
797 # Add ECMP group
798 ecmp_msg = add_l3_ecmp_group(
799 ctrl=self.controller,
800 id=vlan_id,
801 l3_ucast_groups=[ l3_msg.group_id ],
802 send_barrier=True
803 )
804 Groups.put( ecmp_msg.group_id )
805 # We fill the unicast_table
806 add_unicast_v6_routing_flow(
807 ctrl=self.controller,
808 eth_type=0x86dd,
809 dst_ip=dst_ip,
810 mask="ffff:ffff:ffff:ffff::",
811 action_group_id=ecmp_msg.group_id,
812 vrf=0,
813 send_ctrl=False,
814 send_barrier=True
815 )
816 # add termination flow
817 add_termination_flow(
818 ctrl=self.controller,
819 in_port=in_port,
820 eth_type=0x86dd,
821 dst_mac=r_dst_mac,
822 vlanid=vlan_id
823 )
824 # add filtering flow
825 add_one_vlan_table_flow(
826 ctrl=self.controller,
827 of_port=in_port,
Pier265ad5f2017-02-28 17:46:28 +0100828 out_vlan_id=1,
Pier1e4e98e2016-10-26 14:36:05 -0700829 vlan_id=vlan_id,
830 flag=VLAN_TABLE_FLAG_ONLY_TAG
831 )
832 # add assignment flow
833 add_one_vlan_table_flow(
834 ctrl=self.controller,
835 of_port=in_port,
Pier265ad5f2017-02-28 17:46:28 +0100836 out_vlan_id=1,
Pier1e4e98e2016-10-26 14:36:05 -0700837 vlan_id=vlan_id,
838 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
839 )
840
841 parsed_tcpv6_pkt = simple_tcpv6_packet(
842 pktlen=100,
843 eth_dst=r_dst_mac_str,
844 ipv6_dst=dst_ip,
845 ipv6_src=sip
846 )
847 tcpv6_pkt = str( parsed_tcpv6_pkt )
848 self.dataplane.send(in_port, tcpv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -0700849 parsed_tcpv6_pkt = simple_tcpv6_packet(
850 pktlen=100,
851 eth_dst=dst_mac_str,
852 eth_src=intf_src_mac_str,
853 ipv6_dst=dst_ip,
854 ipv6_src=sip,
855 ipv6_hlim=63
856 )
857 tcpv6_pkt = str( parsed_tcpv6_pkt )
Pier1e4e98e2016-10-26 14:36:05 -0700858 verify_packet(self, tcpv6_pkt, out_port )
859 verify_no_packet(self, tcpv6_pkt, in_port )
860 verify_no_other_packets(self)
861
862 finally:
863 delete_all_flows( self.controller )
864 delete_groups( self.controller, Groups )
865 delete_all_groups( self.controller )
866
867class _0UcastV6( base_tests.SimpleDataPlane ):
868 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
869
870 def runTest( self ):
871 try:
872
873 if len( config[ "port_map" ] ) < 2:
874 logging.info( "Port count less than 2, can't run this case" )
875 return
876
877 Groups = Queue.LifoQueue( )
878 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
879 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
880 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
881 # We are assuming that the port number are xx"
882 dip = "2000::%s"
883 sip = "2000::1"
884 ports = config[ "port_map" ].keys( )
885 vlan_id = 4094
886
887 in_port = ports[0]
888 out_port = ports[1]
889 r_dst_mac[5] = in_port
890 intf_src_mac[5] = out_port
891 dst_mac[5] = out_port
892 dst_ip = dip % in_port
893 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
894 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
895 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
896 # We create the L2 group
897 l2gid, msg = add_one_l2_interface_group(
898 ctrl=self.controller,
899 port=out_port,
900 vlan_id=vlan_id,
901 is_tagged=False,
902 send_barrier=True
903 )
904 Groups._put(l2gid)
905 # We create the L3 group
906 l3_msg = add_l3_unicast_group(
907 ctrl=self.controller,
908 port=out_port,
909 vlanid=vlan_id,
910 id=vlan_id,
911 src_mac=intf_src_mac,
912 dst_mac=dst_mac,
913 send_barrier=True
914 )
915 Groups._put( l3_msg.group_id )
916 # We fill the unicast_table
917 add_unicast_v6_routing_flow(
918 ctrl=self.controller,
919 eth_type=0x86dd,
920 dst_ip="::",
921 mask="::",
922 action_group_id=l3_msg.group_id,
923 vrf=0,
924 send_ctrl=False,
925 send_barrier=True
926 )
927 # add termination flow
928 add_termination_flow(
929 ctrl=self.controller,
930 in_port=in_port,
931 eth_type=0x86dd,
932 dst_mac=r_dst_mac,
933 vlanid=vlan_id,
934 )
935 # add filtering flow
936 add_one_vlan_table_flow(
937 ctrl=self.controller,
938 of_port=in_port,
939 vlan_id=vlan_id,
940 flag=VLAN_TABLE_FLAG_ONLY_TAG
941 )
942 # add assignment flow
943 add_one_vlan_table_flow(
944 ctrl=self.controller,
945 of_port=in_port,
946 vlan_id=vlan_id,
947 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
948 )
949
950 parsed_tcpv6_pkt = simple_tcpv6_packet(
951 pktlen=100,
952 eth_dst=r_dst_mac_str,
953 ipv6_dst=dst_ip,
954 ipv6_src=sip
955 )
956 tcpv6_pkt = str( parsed_tcpv6_pkt )
957 self.dataplane.send(in_port, tcpv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -0700958 parsed_tcpv6_pkt = simple_tcpv6_packet(
959 pktlen=100,
960 eth_dst=dst_mac_str,
961 eth_src=intf_src_mac_str,
962 ipv6_dst=dst_ip,
963 ipv6_src=sip,
964 ipv6_hlim=63
965 )
Pier1e4e98e2016-10-26 14:36:05 -0700966 tcpv6_pkt = str( parsed_tcpv6_pkt )
967 verify_packet(self, tcpv6_pkt, out_port )
968 verify_no_packet(self, tcpv6_pkt, in_port )
969 verify_no_other_packets(self)
970
971 finally:
972 delete_all_flows( self.controller )
973 delete_groups( self.controller, Groups )
974 delete_all_groups( self.controller )
975
976class _MPLSTerminationV6( base_tests.SimpleDataPlane ):
977 """ Verify MPLS termination with IPv6 traffic """
978
979 def runTest( self ):
980 try:
981
982 if len( config[ "port_map" ] ) < 2:
983 logging.info( "Port count less than 2, can't run this case" )
984 return
985
986 Groups = Queue.LifoQueue( )
987 r_dst_mac = [ 0x00, 0x00, 0x00, 0xa2, 0x22, 0x00 ]
988 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0xa2, 0x00 ]
989 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0x00 ]
990 # We are assuming that the port number are xx"
991 dip = "2000::%s"
992 sip = "2000::1"
993 ports = config[ "port_map" ].keys( )
994 vlan_id = 4094
995 mpls_label = 255
996 label = (mpls_label, 0, 1, 64)
997
998 in_port = ports[0]
999 out_port = ports[1]
1000 r_dst_mac[5] = in_port
1001 intf_src_mac[5] = out_port
1002 dst_mac[5] = out_port
1003 dst_ip = dip % in_port
1004 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
1005 r_dst_mac_str = ':'.join( [ '%02X' % x for x in r_dst_mac ] )
1006 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1007 # We create the L2 group
1008 l2gid, msg = add_one_l2_interface_group(
1009 ctrl=self.controller,
1010 port=out_port,
1011 vlan_id=vlan_id,
1012 is_tagged=False,
1013 send_barrier=True
1014 )
1015 Groups.put(l2gid)
1016 # We create the L3 group
1017 l3_msg = add_l3_unicast_group(
1018 ctrl=self.controller,
1019 port=out_port,
1020 vlanid=vlan_id,
1021 id=vlan_id,
1022 src_mac=intf_src_mac,
1023 dst_mac=dst_mac,
1024 send_barrier=True
1025 )
1026 Groups.put( l3_msg.group_id )
1027 # Add ECMP group
1028 ecmp_msg = add_l3_ecmp_group(
1029 ctrl=self.controller,
1030 id=vlan_id,
1031 l3_ucast_groups=[ l3_msg.group_id ],
1032 send_barrier=True
1033 )
1034 Groups.put( ecmp_msg.group_id )
1035 # add filtering flow
1036 add_one_vlan_table_flow(
1037 ctrl=self.controller,
1038 of_port=in_port,
1039 vlan_id=vlan_id,
1040 flag=VLAN_TABLE_FLAG_ONLY_TAG
1041 )
1042 # add assignment flow
1043 add_one_vlan_table_flow(
1044 ctrl=self.controller,
1045 of_port=in_port,
1046 vlan_id=vlan_id,
1047 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
1048 )
1049 # add termination flow
1050 add_termination_flow(
1051 ctrl=self.controller,
1052 in_port=in_port,
1053 eth_type=0x8847,
1054 dst_mac=r_dst_mac,
1055 vlanid=vlan_id,
1056 goto_table=24
1057 )
1058 # We fill the mpls flow table 1
1059 add_mpls_flow(
1060 ctrl=self.controller,
1061 action_group_id=ecmp_msg.group_id,
1062 label=mpls_label,
1063 send_barrier=True
1064 )
1065
1066 parsed_mplsv6_pkt = mplsv6_packet(
1067 pktlen=104,
1068 eth_dst=r_dst_mac_str,
1069 ipv6_dst=dst_ip,
1070 ipv6_src=sip,
1071 label=[ label ]
1072 )
1073 mplsv6_pkt = str( parsed_mplsv6_pkt )
1074 self.dataplane.send(in_port, mplsv6_pkt)
Pier1e4e98e2016-10-26 14:36:05 -07001075 parsed_tcpv6_pkt = simple_tcpv6_packet(
1076 pktlen=100,
1077 eth_dst=dst_mac_str,
1078 eth_src=intf_src_mac_str,
1079 ipv6_dst=dst_ip,
1080 ipv6_src=sip,
1081 ipv6_hlim=63
1082 )
1083 tcpv6_pkt = str( parsed_tcpv6_pkt )
Pier1e4e98e2016-10-26 14:36:05 -07001084 verify_packet(self, tcpv6_pkt, out_port )
1085 verify_no_packet(self, tcpv6_pkt, in_port )
1086 verify_no_other_packets(self)
1087
1088 finally:
1089 delete_all_flows( self.controller )
1090 delete_groups( self.controller, Groups )
Tony Choud6195802018-06-01 11:52:26 +08001091 delete_all_groups( self.controller )