blob: aa3a5bbd898b0bd14c9f19fd81f717261a02b29d [file] [log] [blame]
Sreeju Sreedhare3fefd92019-04-02 15:57:15 -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
17"""
18Check README file
19"""
20import Queue
21
22from oftest import config
23import inspect
24import logging
25import oftest.base_tests as base_tests
26import ofp
27import time
28from oftest.oft12.testutils import delete_all_flows_one_table
29from oftest.testutils import *
30from accton_util import *
31from oftest.utils import *
32
33
34class FabricSW_OF_PacketInUDP_TC_0010( base_tests.SimpleDataPlane ):
35 """
36 Verify ACL rule for IP_PROTO=2 wont match a UDP packet and a rule for IP_PROTO=17 WILL match a UDP packet.
37 """
38
39 def runTest( self ):
40 try:
41 parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
42 vlan_pkt = str( parsed_vlan_pkt )
43 # create match
44 match = ofp.match( )
45 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
46 match.oxm_list.append( ofp.oxm.ip_proto( 2 ) )
47 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
48 ofp.instruction.apply_actions( actions=[
49 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
50 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
51 logging.info( "Inserting packet in flow to controller" )
52 self.controller.message_send( request )
53
54 for of_port in config[ "port_map" ].keys( ):
55 logging.info( "PacketInMiss test, port %d", of_port )
56 self.dataplane.send( of_port, vlan_pkt )
57
58 verify_no_packet_in( self, vlan_pkt, of_port )
59 delete_all_flows( self.controller )
60 do_barrier( self.controller )
61
62 match = ofp.match( )
63 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
64 match.oxm_list.append( ofp.oxm.ip_proto( 17 ) )
65 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
66 ofp.instruction.apply_actions( actions=[
67 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
68 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
69 logging.info( "Inserting packet in flow to controller" )
70 self.controller.message_send( request )
71 do_barrier( self.controller )
72
73 for of_port in config[ "port_map" ].keys( ):
74 logging.info( "PacketInMiss test, port %d", of_port )
75 self.dataplane.send( of_port, vlan_pkt )
76
77 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION )
78
79 verify_no_other_packets( self )
80 finally:
81 delete_all_flows( self.controller )
82 delete_all_groups( self.controller )
83
84@disabled
85class ArpNL2( base_tests.SimpleDataPlane ):
86 """
87 Needs a description, disabled for now. Also needs try/finally
88 """
89 def runTest( self ):
90 delete_all_flows( self.controller )
91 delete_all_groups( self.controller )
92
93 ports = sorted( config[ "port_map" ].keys( ) )
94 match = ofp.match( )
95 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
96 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
97 ofp.instruction.apply_actions( actions=[
98 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
99 buffer_id=ofp.OFP_NO_BUFFER, priority=40000 )
100 self.controller.message_send( request )
101 for port in ports:
102 add_one_l2_interface_group( self.controller, port, 1, False, False )
103 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
104 group_id = encode_l2_interface_group_id( 1, port )
105 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True )
106 do_barrier( self.controller )
107 parsed_arp_pkt = simple_arp_packet( )
108 arp_pkt = str( parsed_arp_pkt )
109
110 for out_port in ports:
111 self.dataplane.send( out_port, arp_pkt )
112 verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION )
113 # change dest based on port number
114 mac_dst = '00:12:34:56:78:%02X' % out_port
115 for in_port in ports:
116 if in_port == out_port:
117 continue
118 # change source based on port number to avoid packet-ins from learning
119 mac_src = '00:12:34:56:78:%02X' % in_port
120 parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src )
121 pkt = str( parsed_pkt )
122 self.dataplane.send( in_port, pkt )
123
124 for ofport in ports:
125 if ofport in [ out_port ]:
126 verify_packet( self, pkt, ofport )
127 else:
128 verify_no_packet( self, pkt, ofport )
129
130 verify_no_other_packets( self )
131
132class FabricSW_OF_PacketInArp_TC_0005( base_tests.SimpleDataPlane ):
133 """
134 Verify Packet-in message from eth_type 0x806 on ACL table
135 """
136
137 def runTest( self ):
138 try:
139 parsed_arp_pkt = simple_arp_packet( )
140 arp_pkt = str( parsed_arp_pkt )
141 # create match
142 match = ofp.match( )
143 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
144 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
145 ofp.instruction.apply_actions( actions=[
146 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
147 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
148
149 logging.info( "Inserting arp flow " )
150 self.controller.message_send( request )
151 do_barrier( self.controller )
152
153 for of_port in config[ "port_map" ].keys( ):
154 logging.info( "PacketInArp test, sending arp packet to port %d", of_port )
155 self.dataplane.send( of_port, arp_pkt )
156
157 verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION )
158
159 verify_no_other_packets( self )
160 finally:
161 delete_all_flows( self.controller )
162 delete_all_groups( self.controller )
163
164@disabled
165class PacketInIPTable( base_tests.SimpleDataPlane ):
166 """
167 Verify Packet-in message from IP table when controller action is used
168 Send a packet to each dataplane port and verify that a packet
169 in message is received from the controller for each
170 #todo verify you stop receiving after adding rule
171 """
172
173 def runTest( self ):
174 Groups = Queue.LifoQueue( )
175 try:
176 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
177 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
178 dip = 0xc0a80001
179 ports = sorted( config[ "port_map" ].keys( ) )
180
181 for port in ports:
182 # add l2 interface group
183 vlan_id = port
184 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True,
185 send_barrier=False )
186 dst_mac[ 5 ] = vlan_id
187 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
188 src_mac=intf_src_mac, dst_mac=dst_mac )
189 # add vlan flow table
190 add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
191 # add termination flow
192 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
193 # add unicast routing flow
194 dst_ip = dip + (vlan_id << 8)
195 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id,
196 send_ctrl=True )
197 Groups.put( l3_msg.group_id )
198
199 do_barrier( self.controller )
200
201 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
202 for in_port in ports:
203 mac_src = '00:00:00:22:22:%02X' % in_port
204 ip_src = '192.168.%02d.1' % in_port
205 for out_port in ports:
206 if in_port == out_port:
207 continue
208 ip_dst = '192.168.%02d.1' % out_port
209 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
210 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
211 pkt = str( parsed_pkt )
212 self.dataplane.send( in_port, pkt )
213 verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION )
214 # verify_no_other_packets(self)
215 finally:
216 delete_all_flows( self.controller )
217 delete_groups( self.controller, Groups )
218 delete_all_groups( self.controller )
219
220
221class FabricSW_OF_L2FloodQinQ_TC_0015( base_tests.SimpleDataPlane ):
222 """
223 Verify Vlan based flooding of QinQ based on its outer vlan
224 """
225
226 def runTest( self ):
227 Groups = Queue.LifoQueue( )
228 try:
229 ports = sorted( config[ "port_map" ].keys( ) )
230 vlan_id = 100
231
232 for port in ports:
233 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
234 add_one_vlan_table_flow( self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
235 Groups.put( L2gid )
236
237 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
238 Groups.put( msg.group_id )
239 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
240 do_barrier( self.controller )
241
242 # verify flood
243 for ofport in ports:
244 # change dest based on port number
245 mac_src = '00:12:34:56:78:%02X' % ofport
246 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
247 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
248 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
249 pkt = str( parsed_pkt )
250 self.dataplane.send( ofport, pkt )
251 # self won't rx packet
252 verify_no_packet( self, pkt, ofport )
253 # others will rx packet
254 tmp_ports = list( ports )
255 tmp_ports.remove( ofport )
256 verify_packets( self, pkt, tmp_ports )
257
258 verify_no_other_packets( self )
259 finally:
260 delete_all_flows( self.controller )
261 delete_groups( self.controller, Groups )
262 delete_all_groups( self.controller )
263
264
265
266@disabled
267class L2FloodTagged( base_tests.SimpleDataPlane ):
268 """
269 currently disabled; fix with try/finally
270 Test L2 flood to a vlan
271 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
272 """
273
274 def runTest( self ):
275 # Hashes Test Name and uses it as id for installing unique groups
276 vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256)
277 print vlan_id
278
279 ports = sorted( config[ "port_map" ].keys( ) )
280
281 delete_all_flows( self.controller )
282 delete_all_groups( self.controller )
283
284 # Installing flows to avoid packet-in
285 for port in ports:
286 add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
287 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
288 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
289 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
290 do_barrier( self.controller )
291
292 # verify flood
293 for ofport in ports:
294 # change dest based on port number
295 pkt = str(
296 simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) )
297 self.dataplane.send( ofport, pkt )
298 # self won't rx packet
299 verify_no_packet( self, pkt, ofport )
300 # others will rx packet
301 tmp_ports = list( ports )
302 tmp_ports.remove( ofport )
303 verify_packets( self, pkt, tmp_ports )
304 verify_no_other_packets( self )
305
306
307class FabricSW_OF_L2UnicastTagged_TC_0020( base_tests.SimpleDataPlane ):
308 """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """
309
310 def runTest( self ):
311
312 Groups = Queue.LifoQueue( )
313 try:
314 ports = sorted( config[ "port_map" ].keys( ) )
315 vlan_id = 1;
316 for port in ports:
317 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
318 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
319 Groups.put( L2gid )
320 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
321 True )
322 do_barrier( self.controller )
323
324 for out_port in ports:
325 # change dest based on port number
326 mac_dst = '00:12:34:56:78:%02X' % out_port
327 for in_port in ports:
328 if in_port == out_port:
329 continue
330 pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) )
331 self.dataplane.send( in_port, pkt )
332 for ofport in ports:
333 if ofport in [ out_port ]:
334 verify_packet( self, pkt, ofport )
335 else:
336 verify_no_packet( self, pkt, ofport )
337 verify_no_other_packets( self )
338 finally:
339 delete_all_flows( self.controller )
340 delete_groups( self.controller, Groups )
341 delete_all_groups( self.controller )
342
343
344class FabricSW_OF_Bridging_TC_0001( base_tests.SimpleDataPlane ):
345 """
346 Verify bridging works including flooding with different vlans
347 ports[0] has vlan 31 untagged
348 ports[1] has vlan 31 untagged (native) and vlan 41 tagged
349 ARP request should be flooded
350 ARP reply should be forwarded by bridging rule
351 Both arp messages should also be copied to controller
352 """
353
354 def runTest( self ):
355 Groupd = Queue.LifoQueue()
356 try:
357 if len( config[ "port_map" ] ) < 2:
358 logging.info( "Port count less than 2, can't run this case" )
359 return
360 ports = sorted( config[ "port_map" ].keys() )
361 vlan_p0_untagged = 31
362 vlan_p1_tagged = 31
363 vlan_p1_native = 41
364
365 #l2 interface groups and table 10 flows
366 L2p0gid, l2msg0 = add_one_l2_interface_group( self.controller, ports[0], vlan_p0_untagged,
367 is_tagged=False, send_barrier=False )
368 add_one_vlan_table_flow( self.controller, ports[0], vlan_id=vlan_p0_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
369 send_barrier=True)
370 L2p1gid, l2msg1 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_tagged,
371 is_tagged=True, send_barrier=False )
372 add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_tagged, flag=VLAN_TABLE_FLAG_ONLY_TAG,
373 send_barrier=True)
374 L2p1gid2, l2msg3 = add_one_l2_interface_group( self.controller, ports[1], vlan_p1_native,
375 is_tagged=False, send_barrier=False )
376 add_one_vlan_table_flow( self.controller, ports[1], vlan_id=vlan_p1_native, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
377 send_barrier=True)
378 #flooding groups
379 Floodmsg31 = add_l2_flood_group( self.controller, ports, vlan_p0_untagged, id=0 )
380 Floodmsg41 = add_l2_flood_group( self.controller, [ ports[1] ], vlan_p1_native, id=0 )
381
382 #add bridging flows for flooding groups
383 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p0_untagged, group_id=Floodmsg31.group_id )
384 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_p1_native, group_id=Floodmsg41.group_id )
385 do_barrier( self.controller )
386
387 # add bridging flows for dstMac+vlan
388 add_bridge_flow( self.controller, [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ], vlan_p0_untagged, L2p0gid, True )
389 add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_tagged, L2p1gid, True )
390 add_bridge_flow( self.controller, [ 0x00, 0x66, 0x77, 0x88, 0x99, 0xaa ], vlan_p1_native, L2p1gid2, True )
391
392 # add terminationMac flow
393 router_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
394 if config["switch_type"] == "qmx":
395 add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p0_untagged )
396 add_termination_flow( self.controller, 0, 0x0800, router_mac, vlan_p1_native )
397 else:
398 add_termination_flow( self.controller, ports[0], 0x0800, router_mac, vlan_p0_untagged )
399 add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_tagged )
400 add_termination_flow( self.controller, ports[1], 0x0800, router_mac, vlan_p1_native )
401
402 # add acl rule for arp
403 match = ofp.match( )
404 match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) )
405 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
406 ofp.instruction.apply_actions( actions=[
407 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ],
408 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
409 self.controller.message_send( request )
410 do_barrier( self.controller )
411
412 #acl rule for gateway ip
413 match = ofp.match( )
414 match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) )
415 match.oxm_list.append( ofp.oxm.ipv4_dst( 0xc0a80003 ) )
416 request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[
417 ofp.instruction.apply_actions( actions=[
418 ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ),
419 ofp.instruction.clear_actions() ],
420 buffer_id=ofp.OFP_NO_BUFFER, priority=1 )
421 self.controller.message_send( request )
422 do_barrier( self.controller )
423
424 # send ARP request
425 parsed_arp_pkt = simple_arp_packet(pktlen=80,
426 eth_dst='ff:ff:ff:ff:ff:ff',
427 eth_src='00:66:77:88:99:aa',
428 vlan_vid=vlan_p1_tagged,
429 vlan_pcp=0,
430 arp_op=1,
431 ip_snd='192.168.0.2',
432 ip_tgt='192.168.0.1',
433 hw_snd='00:66:77:88:99:aa',
434 hw_tgt='00:00:00:00:00:00')
435 arp_pkt_to_send = str( parsed_arp_pkt )
436 logging.info( "sending arp request to port %d", ports[1] )
437 self.dataplane.send( ports[1], arp_pkt_to_send )
438 verify_packet_in( self, arp_pkt_to_send, ports[1], ofp.OFPR_ACTION )
439 parsed_arp_pkt_untagged = simple_arp_packet(pktlen=76,
440 eth_dst='ff:ff:ff:ff:ff:ff',
441 eth_src='00:66:77:88:99:aa',
442 vlan_vid=0,
443 vlan_pcp=0,
444 arp_op=1,
445 ip_snd='192.168.0.2',
446 ip_tgt='192.168.0.1',
447 hw_snd='00:66:77:88:99:aa',
448 hw_tgt='00:00:00:00:00:00')
449 arp_pkt_dest = str( parsed_arp_pkt_untagged )
450 verify_packet( self, arp_pkt_dest, ports[0] )
451 #verify_no_other_packets( self )
452
453 # send ARP reply
454 parsed_arp_pkt = simple_arp_packet(pktlen=76,
455 eth_dst='00:66:77:88:99:aa',
456 eth_src='00:11:22:33:44:55',
457 vlan_vid=0,
458 vlan_pcp=0,
459 arp_op=2,
460 ip_snd='192.168.0.1',
461 ip_tgt='192.168.0.2',
462 hw_snd='00:11:22:33:44:55',
463 hw_tgt='00:66:77:88:99:aa')
464 arp_pkt_to_send = str( parsed_arp_pkt )
465 logging.info( "sending arp reply to port %d", ports[0] )
466 self.dataplane.send( ports[0], arp_pkt_to_send )
467 verify_packet_in( self, arp_pkt_to_send, ports[0], ofp.OFPR_ACTION )
468 parsed_arp_pkt_tagged = simple_arp_packet(pktlen=80,
469 eth_dst='00:66:77:88:99:aa',
470 eth_src='00:11:22:33:44:55',
471 vlan_vid=vlan_p1_tagged,
472 vlan_pcp=0,
473 arp_op=2,
474 ip_snd='192.168.0.1',
475 ip_tgt='192.168.0.2',
476 hw_snd='00:11:22:33:44:55',
477 hw_tgt='00:66:77:88:99:aa')
478 arp_pkt_dest = str( parsed_arp_pkt_tagged )
479 verify_packet( self, arp_pkt_dest, ports[1] )
480
481 finally:
482 delete_all_flows( self.controller )
483 delete_all_groups( self.controller )
484 #print("done")
485
486
487
488class FabricSW_OF_Mtu1500_TC_0035( base_tests.SimpleDataPlane ):
489 """
490 Verifies basic mtu limits
491 """
492
493 def runTest( self ):
494 Groups = Queue.LifoQueue( )
495 try:
496 ports = sorted( config[ "port_map" ].keys( ) )
497 vlan_id = 18
498 for port in ports:
499 L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
500 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
501 Groups.put( L2gid )
502 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid,
503 True )
504 do_barrier( self.controller )
505
506 for out_port in ports:
507 # change dest based on port number
508 mac_dst = '00:12:34:56:78:%02X' % out_port
509 for in_port in ports:
510 if in_port == out_port:
511 continue
512 pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id,
513 eth_dst=mac_dst ) )
514 self.dataplane.send( in_port, pkt )
515 for ofport in ports:
516 if ofport in [ out_port ]:
517 verify_packet( self, pkt, ofport )
518 else:
519 verify_no_packet( self, pkt, ofport )
520 verify_no_other_packets( self )
521 finally:
522 delete_all_flows( self.controller )
523 delete_groups( self.controller, Groups )
524 delete_all_groups( self.controller )
525
526
527class FabricSW_OF__32UcastTagged_TC_0055( base_tests.SimpleDataPlane ):
528 """ Verify /32 IP forwarding to L3 Unicast-> L2Interface"""
529
530 def runTest( self ):
531 Groups = Queue.LifoQueue( )
532 try:
533 test_id = 26
534 if len( config[ "port_map" ] ) < 2:
535 logging.info( "Port count less than 2, can't run this case" )
536 return
537 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
538 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
539 dip = 0xc0a80001
540 ports = config[ "port_map" ].keys( )
541 for port in ports:
542 vlan_id = port + test_id
543 # add l2 interface group and l3 unicast group
544 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
545 is_tagged=True, send_barrier=False )
546 dst_mac[ 5 ] = vlan_id
547 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
548 src_mac=intf_src_mac, dst_mac=dst_mac )
549 # add vlan flow table
550 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
551 # add termination flow
552 if config["switch_type"] == "qmx":
553 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
554 else:
555 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
556 # add unicast routing flow
557 dst_ip = dip + (vlan_id << 8)
558 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
559 Groups.put( l2gid )
560 Groups.put( l3_msg.group_id )
561 do_barrier( self.controller )
562
563 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
564 for in_port in ports:
565 mac_src = '00:00:00:22:32:%02X' % (test_id + in_port)
566 ip_src = '192.168.%02d.1' % (test_id + in_port)
567 for out_port in ports:
568 if in_port == out_port:
569 continue
570 ip_dst = '192.168.%02d.1' % (test_id + out_port)
571 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
572 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
573 ip_src=ip_src, ip_dst=ip_dst )
574 pkt = str( parsed_pkt )
575 self.dataplane.send( in_port, pkt )
576 # build expected packet
577 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
578 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
579 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
580 ip_src=ip_src, ip_dst=ip_dst )
581 pkt = str( exp_pkt )
582 verify_packet( self, pkt, out_port )
583 verify_no_other_packets( self )
584 finally:
585 delete_all_flows( self.controller )
586 delete_groups( self.controller, Groups )
587 delete_all_groups( self.controller )
588
589@disabled
590class _32VPN( base_tests.SimpleDataPlane ):
591 """
592 Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
593 No ECMP group used
594 """
595
596 def runTest( self ):
597 Groups = Queue.LifoQueue( )
598 try:
599 if len( config[ "port_map" ] ) < 2:
600 logging.info( "Port count less than 2, can't run this case" )
601 return
602
603 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
604 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
605 dip = 0xc0a80001
606 ports = config[ "port_map" ].keys( )
607 for port in ports:
608 # add l2 interface group
609 id = port
610 vlan_id = port
611 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
612 dst_mac[ 5 ] = vlan_id
613 # add MPLS interface group
614 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
615 vlan_id, id )
616 # add MPLS L3 VPN group
617 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
618 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
619 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
620 do_barrier( self.controller )
621 # add vlan flow table
622 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2,
623 flag=VLAN_TABLE_FLAG_ONLY_TAG )
624 # add termination flow
625 if config["switch_type"] == "qmx":
626 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
627 else:
628 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
629 # add routing flow
630 dst_ip = dip + (vlan_id << 8)
631 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 )
632 Groups._put( l2_gid )
633 Groups._put( mpls_gid )
634 Groups._put( mpls_label_gid )
635 do_barrier( self.controller )
636
637 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
638 for in_port in ports:
639 ip_src = '192.168.%02d.1' % (in_port)
640 for out_port in ports:
641 if in_port == out_port:
642 continue
643 ip_dst = '192.168.%02d.1' % (out_port)
644 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
645 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
646 pkt = str( parsed_pkt )
647 self.dataplane.send( in_port, pkt )
648 # build expect packet
649 mac_dst = '00:00:00:22:22:%02X' % (out_port)
650 label = (out_port, 0, 1, 32)
651 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
652 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
653 label=[ label ] )
654 pkt = str( exp_pkt )
655 verify_packet( self, pkt, out_port )
656 verify_no_other_packets( self )
657 finally:
658 delete_all_flows( self.controller )
659 delete_groups( self.controller, Groups )
660 delete_all_groups( self.controller )
661
662@disabled
663class _32EcmpVpn( base_tests.SimpleDataPlane ):
664 """
665 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
666 """
667
668 def runTest( self ):
669 Groups = Queue.LifoQueue( )
670 try:
671 if len( config[ "port_map" ] ) < 2:
672 logging.info( "Port count less than 2, can't run this case" )
673 return
674
675 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
676 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
677 dip = 0xc0a80001
678 ports = config[ "port_map" ].keys( )
679 for port in ports:
680 # add l2 interface group
681 id = port
682 vlan_id = port
683 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
684 dst_mac[ 5 ] = vlan_id
685 # add MPLS interface group
686 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
687 vlan_id, id )
688 # add MPLS L3 VPN group
689 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
690 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
691 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
692 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
693 do_barrier( self.controller )
694 # add vlan flow table
695 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
696 flag=VLAN_TABLE_FLAG_ONLY_TAG )
697 # add termination flow
698 if config["switch_type"] == "qmx":
699 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
700 else:
701 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
702 # add routing flow
703 dst_ip = dip + (vlan_id << 8)
704 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
705 Groups._put( l2_gid )
706 Groups._put( mpls_gid )
707 Groups._put( mpls_label_gid )
708 Groups._put( ecmp_msg.group_id )
709 do_barrier( self.controller )
710
711 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
712 for in_port in ports:
713 ip_src = '192.168.%02d.1' % (in_port)
714 for out_port in ports:
715 if in_port == out_port:
716 continue
717 ip_dst = '192.168.%02d.1' % (out_port)
718 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
719 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
720 pkt = str( parsed_pkt )
721 self.dataplane.send( in_port, pkt )
722 # build expect packet
723 mac_dst = '00:00:00:22:22:%02X' % (out_port)
724 label = (out_port, 0, 1, 32)
725 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
726 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
727 label=[ label ] )
728 pkt = str( exp_pkt )
729 verify_packet( self, pkt, out_port )
730 verify_no_other_packets( self )
731
732 finally:
733 delete_all_flows( self.controller )
734 delete_groups( self.controller, Groups )
735 delete_all_groups( self.controller )
736
737
738@disabled
739class One_32EcmpVpn( base_tests.SimpleDataPlane ):
740 """
741 Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface
742 in only one direction
743 """
744
745 def runTest( self ):
746 Groups = Queue.LifoQueue( )
747 try:
748 if len( config[ "port_map" ] ) < 2:
749 logging.info( "Port count less than 2, can't run this case" )
750 return
751
752 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
753 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
754 dip = 0xc0a80001
755 ports = config[ "port_map" ].keys( )
756 # add l2 interface group
757 id = ports[1]
758 in_offset = 19
759 out_offset = 20
760 vlan_id = ports[1] + out_offset
761 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True )
762 dst_mac[ 5 ] = ports[1]
763 # add MPLS interface group
764 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
765 vlan_id, id )
766 # add MPLS L3 VPN group
767 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
768 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
769 push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 )
770 # add ECMP group
771 ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] )
772 do_barrier( self.controller )
773 # add vlan flow table
774 add_one_vlan_table_flow( self.controller, ports[0], 1, vlan_id=ports[0] + in_offset, vrf=0,
775 flag=VLAN_TABLE_FLAG_ONLY_TAG )
776 # add termination flow
777 if config["switch_type"] == "qmx":
778 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
779 else:
780 add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset )
781 # add routing flow
782 dst_ip = dip + (vlan_id << 8)
783 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
784 Groups._put( l2_gid )
785 Groups._put( mpls_gid )
786 Groups._put( mpls_label_gid )
787 Groups._put( ecmp_msg.group_id )
788
789
790 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
791 in_port = ports[0]
792 out_port = ports[1]
793 ip_src = '192.168.%02d.1' % (in_port)
794 ip_dst = '192.168.%02d.1' % (out_port+out_offset)
795 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset),
796 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
797 pkt = str( parsed_pkt )
798 self.dataplane.send( in_port, pkt )
799 # build expect packet
800 mac_dst = '00:00:00:22:22:%02X' % (out_port)
801 label = (out_port+out_offset, 0, 1, 32)
802 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63,
803 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
804 label=[ label ] )
805 pkt = str( exp_pkt )
806 verify_packet( self, pkt, out_port )
807 #verify_no_other_packets( self )
808
809 finally:
810 delete_all_flows( self.controller )
811 delete_group(self.controller, ecmp_msg.group_id)
812 delete_group(self.controller, mpls_label_gid)
813 delete_group(self.controller, mpls_gid)
814 delete_group(self.controller, l2_gid)
815
816
817class FabricSW_OF__32ECMPL3_TC_0050( base_tests.SimpleDataPlane ):
818 """
819 Verifies /32 IP routing and ECMP with no label push
820 IP -> L3ECMP -> L3Unicast -> L2Interface
821 """
822
823 def runTest( self ):
824 Groups = Queue.LifoQueue( )
825 try:
826 if len( config[ "port_map" ] ) < 2:
827 logging.info( "Port count less than 2, can't run this case" )
828 return
829
830 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
831 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
832 dip = 0xc0a80001
833 # Hashes Test Name and uses it as id for installing unique groups
834 ports = config[ "port_map" ].keys( )
835 for port in ports:
836 vlan_id = port
837 id = port
838 # add l2 interface group
839 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
840 is_tagged=True, send_barrier=False )
841 dst_mac[ 5 ] = vlan_id
842 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
843 src_mac=intf_src_mac, dst_mac=dst_mac )
844 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
845 # add vlan flow table
846 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
847 # add termination flow
848 if config["switch_type"] == "qmx":
849 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
850 else:
851 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
852 # add unicast routing flow
853 dst_ip = dip + (vlan_id << 8)
854 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id )
855 Groups._put( l2_gid )
856 Groups._put( l3_msg.group_id )
857 Groups._put( ecmp_msg.group_id )
858 do_barrier( self.controller )
859
860 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
861 for in_port in ports:
862 mac_src = '00:00:00:22:22:%02X' % in_port
863 ip_src = '192.168.%02d.1' % in_port
864 for out_port in ports:
865 if in_port == out_port:
866 continue
867 ip_dst = '192.168.%02d.1' % out_port
868 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
869 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
870 pkt = str( parsed_pkt )
871 self.dataplane.send( in_port, pkt )
872 # build expected packet
873 mac_dst = '00:00:00:22:22:%02X' % out_port
874 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
875 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
876 pkt = str( exp_pkt )
877 verify_packet( self, pkt, out_port )
878 verify_no_other_packets( self )
879 finally:
880 delete_all_flows( self.controller )
881 delete_groups( self.controller, Groups )
882 delete_all_groups( self.controller )
883
884@disabled
885class One_32ECMPL3( base_tests.SimpleDataPlane ):
886 """
887 Verifies /32 IP routing and ECMP with no label push
888 IP -> L3ECMP -> L3Unicast -> L2Interface
889 in only one direction
890 """
891
892 def runTest( self ):
893 Groups = Queue.LifoQueue( )
894 try:
895 if len( config[ "port_map" ] ) < 2:
896 logging.info( "Port count less than 2, can't run this case" )
897 return
898
899 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
900 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
901 dip = 0xc0a80001
902 # Hashes Test Name and uses it as id for installing unique groups
903 ports = config[ "port_map" ].keys( )
904 inport = ports[0]
905 outport = ports[1]
906 in_offset = 19
907 out_offset = 20
908 vlan_id = outport + out_offset
909 id = outport
910 # add l2 interface group, l3 unicast and ecmp group for outport
911 l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id,
912 is_tagged=True, send_barrier=False )
913 dst_mac[ 5 ] = outport
914 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id,
915 src_mac=intf_src_mac, dst_mac=dst_mac )
916 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
917 # add vlan flow table
918 add_one_vlan_table_flow( self.controller, of_port=inport, vlan_id=inport+in_offset, flag=VLAN_TABLE_FLAG_ONLY_TAG )
919 # add termination flow
920 if config["switch_type"] == "qmx":
921 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlanid=inport+in_offset )
922 else:
923 add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset )
924 # add unicast routing flow
925 dst_ip = dip + (vlan_id << 8)
926 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True )
927 Groups._put( l2_gid )
928 Groups._put( l3_msg.group_id )
929 Groups._put( ecmp_msg.group_id )
930
931 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
932 mac_src = '00:00:00:22:22:%02X' % inport
933 ip_src = '192.168.%02d.1' % inport
934 ip_dst = '192.168.%02d.1' % (outport+out_offset)
935 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset,
936 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
937 pkt = str( parsed_pkt )
938 self.dataplane.send( inport, pkt )
939 # build expected packet
940 mac_dst = '00:00:00:22:22:%02X' % outport
941 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset,
942 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
943 pkt = str( exp_pkt )
944 verify_packet( self, pkt, outport )
945 verify_no_other_packets( self )
946 finally:
947 delete_all_flows( self.controller )
948 delete_groups( self.controller, Groups )
949 delete_all_groups( self.controller )
950
951
952
953
954@disabled
955class _24VPN( base_tests.SimpleDataPlane ):
956 """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """
957
958 def runTest( self ):
959 Groups = Queue.LifoQueue( )
960 try:
961 if len( config[ "port_map" ] ) < 2:
962 logging.info( "Port count less than 2, can't run this case" )
963 return
964
965 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
966 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
967 dip = 0xc0a80001
968 ports = config[ "port_map" ].keys( )
969 for port in ports:
970 # add l2 interface group
971 id = port
972 vlan_id = port
973 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
974 dst_mac[ 5 ] = vlan_id
975 # add MPLS interface group
976 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
977 vlan_id, id )
978 # add MPLS L3 VPN group
979 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
980 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
981 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
982 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
983 do_barrier( self.controller )
984 # add vlan flow table
985 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
986 flag=VLAN_TABLE_FLAG_ONLY_TAG )
987 # add termination flow
988 if config["switch_type"] == "qmx":
989 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
990 else:
991 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
992 # add routing flow
993 dst_ip = dip + (vlan_id << 8)
994 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid )
995 Groups._put( l2_gid )
996 Groups._put( mpls_gid )
997 Groups._put( mpls_label_gid )
998 do_barrier( self.controller )
999
1000 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1001 for in_port in ports:
1002 ip_src = '192.168.%02d.1' % (in_port)
1003 for out_port in ports:
1004 if in_port == out_port:
1005 continue
1006 ip_dst = '192.168.%02d.1' % (out_port)
1007 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1008 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1009 pkt = str( parsed_pkt )
1010 self.dataplane.send( in_port, pkt )
1011 # build expect packet
1012 mac_dst = '00:00:00:22:22:%02X' % (out_port)
1013 label = (out_port, 0, 1, 32)
1014 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
1015 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
1016 label=[ label ] )
1017 pkt = str( exp_pkt )
1018 verify_packet( self, pkt, out_port )
1019 verify_no_other_packets( self )
1020 finally:
1021 delete_all_flows( self.controller )
1022 delete_groups( self.controller, Groups )
1023 delete_all_groups( self.controller )
1024
1025@disabled
1026class _24EcmpVpn( base_tests.SimpleDataPlane ):
1027 """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """
1028
1029 def runTest( self ):
1030 Groups = Queue.LifoQueue( )
1031 try:
1032 if len( config[ "port_map" ] ) < 2:
1033 logging.info( "Port count less than 2, can't run this case" )
1034 return
1035 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1036 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1037 dip = 0xc0a80001
1038 ports = config[ "port_map" ].keys( )
1039 for port in ports:
1040 # add l2 interface group
1041 id = port
1042 vlan_id = id
1043 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True )
1044 dst_mac[ 5 ] = vlan_id
1045 # add MPLS interface group
1046 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1047 vlan_id, id )
1048 # add MPLS L3 VPN group
1049 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1050 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
1051 push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 )
1052 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
1053 do_barrier( self.controller )
1054 # add vlan flow table
1055 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0,
1056 flag=VLAN_TABLE_FLAG_ONLY_TAG )
1057 # add termination flow
1058 if config["switch_type"] == "qmx":
1059 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1060 else:
1061 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
1062 # add routing flow
1063 dst_ip = dip + (vlan_id << 8)
1064 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
1065 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id,
1066 vrf=0 )
1067 Groups._put( l2_gid )
1068 Groups._put( mpls_gid )
1069 Groups._put( mpls_label_gid )
1070 Groups._put( ecmp_msg.group_id )
1071
1072 do_barrier( self.controller )
1073
1074 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1075 for in_port in ports:
1076 mac_src = '00:00:00:22:22:%02X' % (in_port)
1077 ip_src = '192.168.%02d.1' % (in_port)
1078 for out_port in ports:
1079 if in_port == out_port:
1080 continue
1081 ip_dst = '192.168.%02d.1' % (out_port)
1082 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
1083 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1084 pkt = str( parsed_pkt )
1085 self.dataplane.send( in_port, pkt )
1086 # build expect packet
1087 mac_dst = '00:00:00:22:22:%02X' % out_port
1088 label = (out_port, 0, 1, 32)
1089 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63,
1090 ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac,
1091 label=[ label ] )
1092 pkt = str( exp_pkt )
1093 verify_packet( self, pkt, out_port )
1094 verify_no_other_packets( self )
1095 finally:
1096 delete_all_flows( self.controller )
1097 delete_groups( self.controller, Groups )
1098 delete_all_groups( self.controller )
1099
1100
1101class FabricSW_OF_FloodGroupMod_TC_0030( base_tests.SimpleDataPlane ):
1102 """ Modify a referenced flood group """
1103
1104 def runTest( self ):
1105 Groups = Queue.LifoQueue( )
1106 try:
1107 ports = sorted( config[ "port_map" ].keys( ) )
1108 vlan_id = 1
1109
1110 for port in ports:
1111 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1112 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1113 Groups.put( L2gid )
1114
1115 msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id )
1116 Groups.put( msg.group_id )
1117 add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True )
1118 do_barrier( self.controller )
1119 # verify flood
1120 for ofport in ports:
1121 # change dest based on port number
1122 mac_src = '00:12:34:56:78:%02X' % ofport
1123 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
1124 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
1125 eth_dst='00:12:34:56:78:9a', eth_src=mac_src )
1126 pkt = str( parsed_pkt )
1127 self.dataplane.send( ofport, pkt )
1128 # self won't rx packet
1129 verify_no_packet( self, pkt, ofport )
1130 # others will rx packet
1131 tmp_ports = list( ports )
1132 tmp_ports.remove( ofport )
1133 verify_packets( self, pkt, tmp_ports )
1134 verify_no_other_packets( self )
1135 msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id )
1136 mac_src = '00:12:34:56:78:%02X' % ports[ 1 ]
1137 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True,
1138 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a',
1139 eth_src=mac_src )
1140 pkt = str( parsed_pkt )
1141 self.dataplane.send( ports[ 1 ], pkt )
1142 verify_packets( self, pkt, [ ports[ 0 ] ] )
1143 finally:
1144 delete_all_flows( self.controller )
1145 delete_groups( self.controller, Groups )
1146 delete_all_groups( self.controller )
1147
1148
1149class FabricSW_OF__24ECMPL3_TC_0040( base_tests.SimpleDataPlane ):
1150 """ Verifies /24 IP routing using ECMP -> L3U -> L2I """
1151
1152 def runTest( self ):
1153 Groups = Queue.LifoQueue( )
1154 try:
1155 if len( config[ "port_map" ] ) < 2:
1156 logging.info( "Port count less than 2, can't run this case" )
1157 return
1158
1159 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1160 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1161 dip = 0xc0a80001
1162 # Hashes Test Name and uses it as id for installing unique groups
1163 ports = config[ "port_map" ].keys( )
1164 for port in ports:
1165 vlan_id = port
1166 id = port
1167 # add l2 interface group
1168 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
1169 is_tagged=True, send_barrier=False )
1170 dst_mac[ 5 ] = vlan_id
1171 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1172 src_mac=intf_src_mac, dst_mac=dst_mac )
1173 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
1174 # add vlan flow table
1175 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1176 # add termination flow
1177 if config["switch_type"] == "qmx":
1178 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
1179 else:
1180 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
1181 # add unicast routing flow
1182 dst_ip = dip + (vlan_id << 8)
1183 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
1184 Groups._put( l2_gid )
1185 Groups._put( l3_msg.group_id )
1186 Groups._put( ecmp_msg.group_id )
1187 do_barrier( self.controller )
1188
1189 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1190 for in_port in ports:
1191 mac_src = '00:00:00:22:22:%02X' % in_port
1192 ip_src = '192.168.%02d.1' % in_port
1193 for out_port in ports:
1194 if in_port == out_port:
1195 continue
1196 ip_dst = '192.168.%02d.1' % out_port
1197 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1198 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1199 pkt = str( parsed_pkt )
1200 self.dataplane.send( in_port, pkt )
1201 # build expected packet
1202 mac_dst = '00:00:00:22:22:%02X' % out_port
1203 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1204 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1205 pkt = str( exp_pkt )
1206 verify_packet( self, pkt, out_port )
1207 verify_no_other_packets( self )
1208 finally:
1209 delete_all_flows( self.controller )
1210 delete_groups( self.controller, Groups )
1211 delete_all_groups( self.controller )
1212
1213
1214@disabled
1215class MPLSBUG( base_tests.SimpleDataPlane ):
1216 """
1217 Needs a description or needs to be removed
1218 """
1219 def runTest( self ):
1220 if len( config[ "port_map" ] ) < 2:
1221 logging.info( "Port count less than 2, can't run this case" )
1222 return
1223 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1224 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1225 dip = 0xc0a80001
1226 Groups = Queue.LifoQueue( )
1227 ports = config[ "port_map" ].keys( )
1228 for port in ports:
1229 # add l2 interface group
1230 vlan_id = port
1231 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1232 dst_mac[ 5 ] = vlan_id
1233 # add L3 Unicast group
1234 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
1235 src_mac=intf_src_mac, dst_mac=dst_mac )
1236 # add vlan flow table
1237 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH )
1238 # add termination flow
1239 if config["switch_type"] == "qmx":
1240 add_termination_flow( self.controller, 0, 0x08847, intf_src_mac, vlan_id, goto_table=24 )
1241 else:
1242 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1243 # add mpls flow
1244 add_mpls_flow( self.controller, l3_msg.group_id, port )
1245 # add termination flow
1246 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
1247 # add unicast routing flow
1248 dst_ip = dip + (vlan_id << 8)
1249 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id )
1250 Groups._put( l2_gid )
1251 Groups._put( l3_msg.group_id )
1252 do_barrier( self.controller )
1253
1254 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1255 for in_port in ports:
1256 mac_src = '00:00:00:22:22:%02X' % in_port
1257 ip_src = '192.168.%02d.1' % in_port
1258 for out_port in ports:
1259 if in_port == out_port:
1260 continue
1261 ip_dst = '192.168.%02d.1' % out_port
1262 switch_mac = "00:00:00:cc:cc:cc"
1263 label = (out_port, 0, 1, 32)
1264 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
1265 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] )
1266 pkt = str( parsed_pkt )
1267 self.dataplane.send( in_port, pkt )
1268
1269 # build expect packet
1270 mac_dst = '00:00:00:22:22:%02X' % out_port
1271 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1272 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
1273 pkt = str( exp_pkt )
1274 verify_packet( self, pkt, out_port )
1275 verify_no_other_packets( self )
1276
1277 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1278 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
1279 pkt = str( parsed_pkt )
1280 self.dataplane.send( in_port, pkt )
1281 # build expected packet
1282 mac_dst = '00:00:00:22:22:%02X' % out_port
1283 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
1284 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
1285 pkt = str( exp_pkt )
1286 verify_packet( self, pkt, out_port )
1287 verify_no_other_packets( self )
1288 delete_all_flows( self.controller )
1289 delete_groups( self.controller, Groups )
1290
1291class L3McastToL3( base_tests.SimpleDataPlane ):
1292 """
1293 Mcast routing, in this test case the traffic comes in tagged.
1294 port+1 is used as ingress vlan_id. The packet goes out tagged on
1295 different ports. 4094-port is used as egress vlan_id.
1296 """
1297 def runTest( self ):
1298 """
1299 port1 (vlan 300)-> All Ports (vlan 300)
1300 """
1301 Groups = Queue.LifoQueue( )
1302 try:
1303 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
1304 if len( config[ "port_map" ] ) < 1:
1305 logging.info( "Port count less than 1, can't run this case" )
1306 assert (False)
1307 return
1308 ports = config[ "port_map" ].keys( )
1309 dst_ip_str = "224.0.0.1"
1310 (
1311 port_to_in_vlan,
1312 port_to_out_vlan,
1313 port_to_src_mac_str,
1314 port_to_dst_mac_str,
1315 port_to_src_ip,
1316 port_to_src_ip_str,
1317 port_to_intf_src_mac_str,
1318 Groups) = fill_mcast_pipeline_L3toL3(
1319 self.controller,
1320 logging,
1321 ports,
1322 is_ingress_tagged = True,
1323 is_egress_tagged = True,
1324 is_vlan_translated = True,
1325 is_max_vlan = False
1326 )
1327
1328 for in_port in ports:
1329
1330 parsed_pkt = simple_udp_packet(
1331 pktlen = 100,
1332 dl_vlan_enable = True,
1333 vlan_vid = port_to_in_vlan[in_port],
1334 eth_dst = port_to_dst_mac_str[in_port],
1335 eth_src = port_to_src_mac_str[in_port],
1336 ip_ttl = 64,
1337 ip_src = port_to_src_ip_str[in_port],
1338 ip_dst = dst_ip_str
1339 )
1340 pkt = str( parsed_pkt )
1341 self.dataplane.send( in_port, pkt )
1342
1343 for out_port in ports:
1344
1345 parsed_pkt = simple_udp_packet(
1346 pktlen = 100,
1347 dl_vlan_enable = True,
1348 vlan_vid = port_to_out_vlan[out_port],
1349 eth_dst = port_to_dst_mac_str[in_port],
1350 eth_src = port_to_intf_src_mac_str[out_port],
1351 ip_ttl = 63,
1352 ip_src = port_to_src_ip_str[in_port],
1353 ip_dst = dst_ip_str
1354 )
1355 pkt = str( parsed_pkt )
1356 verify_packet( self, pkt, out_port )
1357
1358 verify_no_other_packets( self )
1359
1360 finally:
1361 delete_all_flows( self.controller )
1362 delete_groups( self.controller, Groups )
1363 delete_all_groups( self.controller )
1364
1365@disabled
1366class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ):
1367 """
1368 Fails on alternate runs
1369 Mcast routing, in this test case the traffic is untagged.
1370 4094 is used as internal vlan_id. The packet goes out
1371 untagged.
1372 """
1373 def runTest( self ):
1374 Groups = Queue.LifoQueue( )
1375 try:
1376 if len( config[ "port_map" ] ) < 2:
1377 logging.info( "Port count less than 2, can't run this case" )
1378 assert (False)
1379 return
1380 ports = config[ "port_map" ].keys( )
1381 dst_ip_str = "224.0.0.1"
1382 (
1383 port_to_in_vlan,
1384 port_to_out_vlan,
1385 port_to_src_mac_str,
1386 port_to_dst_mac_str,
1387 port_to_src_ip,
1388 port_to_src_ip_str,
1389 Groups) = fill_mcast_pipeline_L3toL2(
1390 self.controller,
1391 logging,
1392 ports,
1393 is_ingress_tagged = False,
1394 is_egress_tagged = False,
1395 is_vlan_translated = False,
1396 is_max_vlan = True
1397 )
1398
1399 for in_port in ports:
1400
1401 parsed_pkt = simple_udp_packet(
1402 pktlen = 96,
1403 eth_dst = port_to_dst_mac_str[in_port],
1404 eth_src = port_to_src_mac_str[in_port],
1405 ip_ttl = 64,
1406 ip_src = port_to_src_ip_str[in_port],
1407 ip_dst = dst_ip_str
1408 )
1409 pkt = str( parsed_pkt )
1410 self.dataplane.send( in_port, pkt )
1411
1412 for out_port in ports:
1413
1414 parsed_pkt = simple_udp_packet(
1415 pktlen = 96,
1416 eth_dst = port_to_dst_mac_str[in_port],
1417 eth_src = port_to_src_mac_str[in_port],
1418 ip_ttl = 64,
1419 ip_src = port_to_src_ip_str[in_port],
1420 ip_dst = dst_ip_str
1421 )
1422 pkt = str( parsed_pkt )
1423 if out_port == in_port:
1424 verify_no_packet( self, pkt, in_port )
1425 continue
1426 verify_packet( self, pkt, out_port )
1427 verify_no_other_packets( self )
1428 finally:
1429 delete_all_flows( self.controller )
1430 delete_groups( self.controller, Groups )
1431 delete_all_groups( self.controller )
1432
1433class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ):
1434 """
1435 Mcast routing, in this test case the traffic is untagged.
1436 300 is used as vlan_id. The packet goes out
1437 tagged.
1438 """
1439 def runTest( self ):
1440 Groups = Queue.LifoQueue( )
1441 try:
1442 if len( config[ "port_map" ] ) < 2:
1443 logging.info( "Port count less than 2, can't run this case" )
1444 assert (False)
1445 return
1446 ports = config[ "port_map" ].keys( )
1447 dst_ip_str = "224.0.0.1"
1448 (
1449 port_to_in_vlan,
1450 port_to_out_vlan,
1451 port_to_src_mac_str,
1452 port_to_dst_mac_str,
1453 port_to_src_ip,
1454 port_to_src_ip_str,
1455 Groups) = fill_mcast_pipeline_L3toL2(
1456 self.controller,
1457 logging,
1458 ports,
1459 is_ingress_tagged = False,
1460 is_egress_tagged = True,
1461 is_vlan_translated = False,
1462 is_max_vlan = False
1463 )
1464
1465 for in_port in ports:
1466
1467 parsed_pkt = simple_udp_packet(
1468 pktlen = 96,
1469 eth_dst = port_to_dst_mac_str[in_port],
1470 eth_src = port_to_src_mac_str[in_port],
1471 ip_ttl = 64,
1472 ip_src = port_to_src_ip_str[in_port],
1473 ip_dst = dst_ip_str
1474 )
1475 pkt = str( parsed_pkt )
1476 self.dataplane.send( in_port, pkt )
1477
1478 for out_port in ports:
1479
1480 parsed_pkt = simple_udp_packet(
1481 pktlen = 100,
1482 dl_vlan_enable = True,
1483 vlan_vid = port_to_out_vlan[in_port],
1484 eth_dst = port_to_dst_mac_str[in_port],
1485 eth_src = port_to_src_mac_str[in_port],
1486 ip_ttl = 64,
1487 ip_src = port_to_src_ip_str[in_port],
1488 ip_dst = dst_ip_str
1489 )
1490 pkt = str( parsed_pkt )
1491 if out_port == in_port:
1492 verify_no_packet( self, pkt, in_port )
1493 continue
1494 verify_packet( self, pkt, out_port )
1495 verify_no_other_packets( self )
1496 finally:
1497 delete_all_flows( self.controller )
1498 delete_groups( self.controller, Groups )
1499 delete_all_groups( self.controller )
1500
1501
1502class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ):
1503 """
1504 Mcast routing, in this test case the traffic is tagged.
1505 300 is used as vlan_id. The packet goes out
1506 untagged.
1507 """
1508 def runTest( self ):
1509 Groups = Queue.LifoQueue( )
1510 try:
1511 if len( config[ "port_map" ] ) < 2:
1512 logging.info( "Port count less than 2, can't run this case" )
1513 assert (False)
1514 return
1515 ports = config[ "port_map" ].keys( )
1516 dst_ip_str = "224.0.0.1"
1517 (
1518 port_to_in_vlan,
1519 port_to_out_vlan,
1520 port_to_src_mac_str,
1521 port_to_dst_mac_str,
1522 port_to_src_ip,
1523 port_to_src_ip_str,
1524 Groups) = fill_mcast_pipeline_L3toL2(
1525 self.controller,
1526 logging,
1527 ports,
1528 is_ingress_tagged = True,
1529 is_egress_tagged = False,
1530 is_vlan_translated = False,
1531 is_max_vlan = False
1532 )
1533
1534 for in_port in ports:
1535
1536 parsed_pkt = simple_udp_packet(
1537 pktlen = 100,
1538 dl_vlan_enable = True,
1539 vlan_vid = port_to_in_vlan[in_port],
1540 eth_dst = port_to_dst_mac_str[in_port],
1541 eth_src = port_to_src_mac_str[in_port],
1542 ip_ttl = 64,
1543 ip_src = port_to_src_ip_str[in_port],
1544 ip_dst = dst_ip_str
1545 )
1546 pkt = str( parsed_pkt )
1547 self.dataplane.send( in_port, pkt )
1548
1549 for out_port in ports:
1550
1551 parsed_pkt = simple_udp_packet(
1552 pktlen = 96,
1553 eth_dst = port_to_dst_mac_str[in_port],
1554 eth_src = port_to_src_mac_str[in_port],
1555 ip_ttl = 64,
1556 ip_src = port_to_src_ip_str[in_port],
1557 ip_dst = dst_ip_str
1558 )
1559 pkt = str( parsed_pkt )
1560 if out_port == in_port:
1561 verify_no_packet( self, pkt, in_port )
1562 continue
1563 verify_packet( self, pkt, out_port )
1564 verify_no_other_packets( self )
1565 finally:
1566 delete_all_flows( self.controller )
1567 delete_groups( self.controller, Groups )
1568 delete_all_groups( self.controller )
1569
1570class L3McastToL2TagToTag( base_tests.SimpleDataPlane ):
1571 """
1572 Mcast routing, in this test case the traffic is tagged.
1573 300 is used as vlan_id. The packet goes out tagged.
1574 """
1575 def runTest( self ):
1576 Groups = Queue.LifoQueue( )
1577 try:
1578 if len( config[ "port_map" ] ) < 2:
1579 logging.info( "Port count less than 2, can't run this case" )
1580 assert (False)
1581 return
1582 ports = config[ "port_map" ].keys( )
1583 dst_ip_str = "224.0.0.1"
1584 (
1585 port_to_in_vlan,
1586 port_to_out_vlan,
1587 port_to_src_mac_str,
1588 port_to_dst_mac_str,
1589 port_to_src_ip,
1590 port_to_src_ip_str,
1591 Groups) = fill_mcast_pipeline_L3toL2(
1592 self.controller,
1593 logging,
1594 ports,
1595 is_ingress_tagged = True,
1596 is_egress_tagged = True,
1597 is_vlan_translated = False,
1598 is_max_vlan = False
1599 )
1600
1601 for in_port in ports:
1602
1603 parsed_pkt = simple_udp_packet(
1604 pktlen = 100,
1605 dl_vlan_enable = True,
1606 vlan_vid = port_to_in_vlan[in_port],
1607 eth_dst = port_to_dst_mac_str[in_port],
1608 eth_src = port_to_src_mac_str[in_port],
1609 ip_ttl = 64,
1610 ip_src = port_to_src_ip_str[in_port],
1611 ip_dst = dst_ip_str
1612 )
1613 pkt = str( parsed_pkt )
1614 self.dataplane.send( in_port, pkt )
1615
1616 for out_port in ports:
1617
1618 parsed_pkt = simple_udp_packet(
1619 pktlen = 100,
1620 dl_vlan_enable = True,
1621 vlan_vid = port_to_in_vlan[in_port],
1622 eth_dst = port_to_dst_mac_str[in_port],
1623 eth_src = port_to_src_mac_str[in_port],
1624 ip_ttl = 64,
1625 ip_src = port_to_src_ip_str[in_port],
1626 ip_dst = dst_ip_str
1627 )
1628 pkt = str( parsed_pkt )
1629 if out_port == in_port:
1630 verify_no_packet( self, pkt, in_port )
1631 continue
1632 verify_packet( self, pkt, out_port )
1633 verify_no_other_packets( self )
1634 finally:
1635 delete_all_flows( self.controller )
1636 delete_groups( self.controller, Groups )
1637 delete_all_groups( self.controller )
1638
1639class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ):
1640 """
1641 Mcast routing, in this test case the traffic is tagged.
1642 port+1 is used as ingress vlan_id. The packet goes out
1643 tagged. 4094-port is used as egress vlan_id
1644 """
1645 def runTest( self ):
1646 Groups = Queue.LifoQueue( )
1647 try:
1648 if len( config[ "port_map" ] ) < 2:
1649 logging.info( "Port count less than 2, can't run this case" )
1650 assert (False)
1651 return
1652 ports = config[ "port_map" ].keys( )
1653 dst_ip_str = "224.0.0.1"
1654 (
1655 port_to_in_vlan,
1656 port_to_out_vlan,
1657 port_to_src_mac_str,
1658 port_to_dst_mac_str,
1659 port_to_src_ip,
1660 port_to_src_ip_str,
1661 Groups) = fill_mcast_pipeline_L3toL2(
1662 self.controller,
1663 logging,
1664 ports,
1665 is_ingress_tagged = True,
1666 is_egress_tagged = True,
1667 is_vlan_translated = True,
1668 is_max_vlan = False
1669 )
1670
1671 for in_port in ports:
1672
1673 parsed_pkt = simple_udp_packet(
1674 pktlen = 100,
1675 dl_vlan_enable = True,
1676 vlan_vid = port_to_in_vlan[in_port],
1677 eth_dst = port_to_dst_mac_str[in_port],
1678 eth_src = port_to_src_mac_str[in_port],
1679 ip_ttl = 64,
1680 ip_src = port_to_src_ip_str[in_port],
1681 ip_dst = dst_ip_str
1682 )
1683 pkt = str( parsed_pkt )
1684 self.dataplane.send( in_port, pkt )
1685
1686 for out_port in ports:
1687
1688 parsed_pkt = simple_udp_packet(
1689 pktlen = 100,
1690 dl_vlan_enable = True,
1691 vlan_vid = port_to_out_vlan[in_port],
1692 eth_dst = port_to_dst_mac_str[in_port],
1693 eth_src = port_to_src_mac_str[in_port],
1694 ip_ttl = 64,
1695 ip_src = port_to_src_ip_str[in_port],
1696 ip_dst = dst_ip_str
1697 )
1698 pkt = str( parsed_pkt )
1699 if out_port == in_port:
1700 verify_no_packet( self, pkt, in_port )
1701 continue
1702 verify_packet( self, pkt, out_port )
1703 verify_no_other_packets( self )
1704 finally:
1705 delete_all_flows( self.controller )
1706 delete_groups( self.controller, Groups )
1707 delete_all_groups( self.controller )
1708
1709@disabled
1710class L3McastTrafficThenDrop( base_tests.SimpleDataPlane ):
1711 # fails on alternate repeated runs
1712 """
1713 Mcast routing, in this test case the traffic is untagged.
1714 4094 is used as internal vlan_id. We first install aa full pipeline,
1715 test that it forwards properly then remove all rules on table 40 and
1716 mcast groups and ensure traffic is dropped. Blackhole of mcast traffic
1717 if no tree is programmed on the switch.
1718 """
1719 def runTest( self ):
1720 Groups = Queue.LifoQueue( )
1721 try:
1722 if len( config[ "port_map" ] ) < 2:
1723 logging.info( "Port count less than 2, can't run this case" )
1724 assert (False)
1725 return
1726 ports = config[ "port_map" ].keys( )
1727 dst_ip_str = "224.0.0.1"
1728 (
1729 port_to_in_vlan,
1730 port_to_out_vlan,
1731 port_to_src_mac_str,
1732 port_to_dst_mac_str,
1733 port_to_src_ip,
1734 port_to_src_ip_str,
1735 Groups) = fill_mcast_pipeline_L3toL2(
1736 self.controller,
1737 logging,
1738 ports,
1739 is_ingress_tagged = False,
1740 is_egress_tagged = False,
1741 is_vlan_translated = False,
1742 is_max_vlan = True
1743 )
1744
1745 for in_port in ports:
1746
1747 parsed_pkt = simple_udp_packet(
1748 pktlen = 96,
1749 eth_dst = port_to_dst_mac_str[in_port],
1750 eth_src = port_to_src_mac_str[in_port],
1751 ip_ttl = 64,
1752 ip_src = port_to_src_ip_str[in_port],
1753 ip_dst = dst_ip_str
1754 )
1755 pkt = str( parsed_pkt )
1756 self.dataplane.send( in_port, pkt )
1757
1758 for out_port in ports:
1759
1760 parsed_pkt = simple_udp_packet(
1761 pktlen = 96,
1762 eth_dst = port_to_dst_mac_str[in_port],
1763 eth_src = port_to_src_mac_str[in_port],
1764 ip_ttl = 64,
1765 ip_src = port_to_src_ip_str[in_port],
1766 ip_dst = dst_ip_str
1767 )
1768 pkt = str( parsed_pkt )
1769 if out_port == in_port:
1770 verify_no_packet( self, pkt, in_port )
1771 continue
1772 verify_packet( self, pkt, out_port )
1773 verify_no_other_packets( self )
1774
1775 delete_all_flows_one_table(ctrl=self.controller, logger=logging, table_id=40);
1776 delete_all_groups(self.controller)
1777
1778 for in_port in ports:
1779
1780 parsed_pkt = simple_udp_packet(
1781 pktlen = 96,
1782 eth_dst = port_to_dst_mac_str[in_port],
1783 eth_src = port_to_src_mac_str[in_port],
1784 ip_ttl = 64,
1785 ip_src = port_to_src_ip_str[in_port],
1786 ip_dst = dst_ip_str
1787 )
1788 pkt = str( parsed_pkt )
1789 self.dataplane.send( in_port, pkt )
1790
1791 for out_port in ports:
1792
1793 parsed_pkt = simple_udp_packet(
1794 pktlen = 96,
1795 eth_dst = port_to_dst_mac_str[in_port],
1796 eth_src = port_to_src_mac_str[in_port],
1797 ip_ttl = 64,
1798 ip_src = port_to_src_ip_str[in_port],
1799 ip_dst = dst_ip_str
1800 )
1801 pkt = str( parsed_pkt )
1802 if out_port == in_port:
1803 verify_no_packet( self, pkt, in_port )
1804 continue
1805 verify_no_packet( self, pkt, out_port )
1806 verify_no_other_packets( self )
1807 finally:
1808 delete_all_flows( self.controller )
1809 delete_groups( self.controller, Groups )
1810 delete_all_groups( self.controller )
1811
1812@disabled
1813class _MplsFwd( base_tests.SimpleDataPlane ):
1814 """ Verify basic MPLS forwarding: Label switch router """
1815
1816 def runTest( self ):
1817 Groups = Queue.LifoQueue( )
1818 try:
1819 if len( config[ "port_map" ] ) < 2:
1820 logging.info( "Port count less than 2, can't run this case" )
1821 return
1822 dip = 0xc0a80001
1823 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1824 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1825 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1826 ports = config[ "port_map" ].keys( )
1827 for port in ports:
1828 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1829 vlan_id = port + 16
1830 mpls_label = port + 16
1831
1832 # add l2 interface group
1833 id = port
1834 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1835 dst_mac[ 5 ] = port
1836 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
1837 vlan_id, id )
1838 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
1839 subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid,
1840 push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 )
1841 #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller,
1842 # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] )
1843 # add vlan flow table
1844 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1845 # add termination flow
1846 if config["switch_type"] == "qmx":
1847 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1848 else:
1849 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1850 #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 )
1851 if config["switch_type"] != 'xpliant':
1852 add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
1853 else:
1854 xpliant_add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 )
1855 dst_ip = dip + (vlan_id << 8)
1856 Groups._put( l2_gid )
1857 Groups._put( mpls_gid )
1858 Groups._put( mpls_label_gid )
1859 #Groups._put( ecmp_gid )
1860 do_barrier( self.controller )
1861
1862 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1863 for in_port in ports:
1864 ip_src = '192.168.%02d.1' % (in_port)
1865 for out_port in ports:
1866 if in_port == out_port:
1867 continue
1868
1869 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1870 out_mpls_label = out_port + 16
1871 in_vlan_vid = in_port + 16
1872 out_vlan_vid = out_port + 16
1873
1874 ip_dst = '192.168.%02d.1' % (out_port)
1875 label = (out_mpls_label, 0, 1, 32)
1876 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
1877 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1878 pkt = str( parsed_pkt )
1879 self.dataplane.send( in_port, pkt )
1880
1881 # build expect packet
1882 mac_dst = '00:00:00:22:22:%02X' % (out_port)
1883 label = (out_mpls_label, 0, 1, 31)
1884 exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
1885 ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst,
1886 label=[ label ] )
1887 pkt = str( exp_pkt )
1888 verify_packet( self, pkt, out_port )
1889 verify_no_other_packets( self )
1890 finally:
1891 delete_all_flows( self.controller )
1892 delete_groups( self.controller, Groups )
1893 delete_all_groups( self.controller )
1894
1895@disabled
1896class _MplsTermination( base_tests.SimpleDataPlane ):
1897 """ Verify MPLS VPN Termination at penultimate hop """
1898
1899 def runTest( self ):
1900 Groups = Queue.LifoQueue( )
1901 try:
1902 if len( config[ "port_map" ] ) < 2:
1903 logging.info( "Port count less than 2, can't run this case" )
1904 return
1905 dip = 0xc0a80001
1906 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1907 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1908 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1909 ports = config[ "port_map" ].keys( )
1910 for port in ports:
1911 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1912 vlan_id = port + 16
1913 mpls_label = port + 16
1914
1915 # add l2 interface group
1916 id, dst_mac[ 5 ] = port, port
1917 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False )
1918 # add L3 Unicast group
1919 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
1920 src_mac=intf_src_mac, dst_mac=dst_mac )
1921 # add L3 ecmp group
1922 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
1923 # add vlan flow table
1924 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1925 # add termination flow
1926 if config["switch_type"] == "qmx":
1927 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1928 else:
1929 add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 )
1930
1931 if config["switch_type"] != 'xpliant':
1932 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
1933 else:
1934 xpliant_add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label )
1935
1936 # add_mpls_flow(self.controller, label=port)
1937 dst_ip = dip + (vlan_id << 8)
1938 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00,
1939 # ecmp_msg.group_id, 1)
1940 Groups._put( l2_gid )
1941 Groups._put( l3_msg.group_id )
1942 Groups._put( ecmp_msg.group_id )
1943 do_barrier( self.controller )
1944
1945 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
1946 for in_port in ports:
1947 ip_src = '192.168.%02d.1' % (in_port)
1948 for out_port in ports:
1949 if in_port == out_port:
1950 continue
1951
1952 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1953 out_mpls_label = out_port + 16
1954 in_vlan_vid = in_port + 16
1955 out_vlan_vid = out_port + 16
1956
1957 ip_dst = '192.168.%02d.1' % (out_port)
1958 label = (out_mpls_label, 0, 1, 32)
1959 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
1960 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
1961 pkt = str( parsed_pkt )
1962 self.dataplane.send( in_port, pkt )
1963 # build expect packet
1964 mac_dst = '00:00:00:22:22:%02X' % (out_port)
1965 if config["switch_type"] != 'xpliant':
1966 ip_ttl=31
1967 else:
1968 ip_ttl=64
1969 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
1970 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=ip_ttl, ip_src=ip_src, ip_dst=ip_dst )
1971 pkt = str( exp_pkt )
1972 verify_packet( self, pkt, out_port )
1973 verify_no_other_packets( self )
1974 finally:
1975 delete_all_flows( self.controller )
1976 delete_groups( self.controller, Groups )
1977 delete_all_groups( self.controller )
1978
1979
1980@disabled
1981class One_MplsTermination( base_tests.SimpleDataPlane ):
1982 """
1983 Verify MPLS VPN Termination at penultimate hop in only one direction
1984 """
1985
1986 def runTest( self ):
1987 Groups = Queue.LifoQueue( )
1988 try:
1989 if len( config[ "port_map" ] ) < 2:
1990 logging.info( "Port count less than 2, can't run this case" )
1991 return
1992 dip = 0xc0a80001
1993 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
1994 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
1995 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
1996 ports = config[ "port_map" ].keys( )
1997 inport = ports[0]
1998 outport = ports[1]
1999
2000 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
2001 invlan_id = inport + 16
2002 outvlan_id = outport + 16
2003 mpls_label = outport + 16
2004
2005 # add l2 interface group
2006 id, dst_mac[ 5 ] = inport, outport
2007 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False )
2008 # add L3 Unicast group
2009 l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id,
2010 src_mac=intf_src_mac, dst_mac=dst_mac )
2011 # add L3 ecmp group
2012 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] )
2013 # add vlan flow table
2014 add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2015 # add tmac flow
2016 if config["switch_type"] == "qmx":
2017 add_termination_flow( self.controller, 0, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
2018 else:
2019 add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 )
2020 # add mpls termination flow
2021 add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True )
2022 Groups._put( l2_gid )
2023 Groups._put( l3_msg.group_id )
2024 Groups._put( ecmp_msg.group_id )
2025
2026 time.sleep(0.1)
2027 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2028 ip_src = '192.168.%02d.1' % (inport)
2029 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
2030 out_mpls_label = outport + 16
2031 in_vlan_vid = inport + 16
2032 out_vlan_vid = outport + 16
2033
2034 ip_dst = '192.168.%02d.1' % (outport)
2035 label = (out_mpls_label, 0, 1, 32)
2036 parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid),
2037 ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] )
2038 pkt = str( parsed_pkt )
2039 self.dataplane.send( inport, pkt )
2040 # build expect packet
2041 mac_dst = '00:00:00:22:22:%02X' % (outport)
2042 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid),
2043 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst )
2044 pkt = str( exp_pkt )
2045 verify_packet( self, pkt, outport )
2046 verify_no_other_packets( self )
2047 finally:
2048 delete_all_flows( self.controller )
2049 delete_groups( self.controller, Groups )
2050 delete_all_groups( self.controller )
2051
2052
2053class FabricSW_OF__24UcastTagged_TC_0045( base_tests.SimpleDataPlane ):
2054 """ Verify /24 IP forwarding to L3 Interface """
2055
2056 def runTest( self ):
2057 Groups = Queue.LifoQueue( )
2058 try:
2059 test_id = 26
2060 if len( config[ "port_map" ] ) < 2:
2061 logging.info( "Port count less than 2, can't run this case" )
2062 return
2063 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2064 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2065 dip = 0xc0a80001
2066 ports = config[ "port_map" ].keys( )
2067 for port in ports:
2068 # add l2 interface group
2069 vlan_id = port + test_id
2070 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2071 is_tagged=True, send_barrier=False )
2072 dst_mac[ 5 ] = vlan_id
2073 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id,
2074 src_mac=intf_src_mac, dst_mac=dst_mac )
2075 # add vlan flow table
2076 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2077 # add termination flow
2078 if config["switch_type"] == "qmx":
2079 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2080 else:
2081 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
2082 # add unicast routing flow
2083 dst_ip = dip + (vlan_id << 8)
2084 # def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False, priority = 1):
2085 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
2086 Groups.put( l2gid )
2087 Groups.put( l3_msg.group_id )
2088 do_barrier( self.controller )
2089
2090 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2091 for in_port in ports:
2092 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
2093 ip_src = '192.168.%02d.1' % (test_id + in_port)
2094 for out_port in ports:
2095 if in_port == out_port:
2096 continue
2097 ip_dst = '192.168.%02d.1' % (test_id + out_port)
2098 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2099 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
2100 ip_src=ip_src, ip_dst=ip_dst )
2101 pkt = str( parsed_pkt )
2102 self.dataplane.send( in_port, pkt )
2103 # build expected packet
2104 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
2105 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2106 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
2107 ip_src=ip_src, ip_dst=ip_dst )
2108 pkt = str( exp_pkt )
2109 verify_packet( self, pkt, out_port )
2110 verify_no_other_packets( self )
2111 finally:
2112 delete_all_flows( self.controller )
2113 delete_groups( self.controller, Groups )
2114 delete_all_groups( self.controller )
2115
2116class _24UcastRouteBlackHole( base_tests.SimpleDataPlane ):
2117 """ Verify black-holing of unicast routes, feature present only from OFDPA Premium 1.1.3.0"""
2118
2119 def runTest( self ):
2120 Groups = Queue.LifoQueue( )
2121 try:
2122 test_id = 27
2123 if len( config[ "port_map" ] ) < 2:
2124 logging.info( "Port count less than 2, can't run this case" )
2125 return
2126 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2127 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2128 dip = 0xc0a80001
2129 ports = config[ "port_map" ].keys( )
2130 for port in ports:
2131 # add l2 interface group
2132 vlan_id = port + test_id
2133 # add vlan flow table
2134 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2135 # add termination flow
2136 if config["switch_type"] == "qmx":
2137 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2138 else:
2139 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
2140 # add unicast routing flow
2141 #dst ip = 10.0.0.0/8
2142 dst_ip = 0x0a000000
2143 add_unicast_blackhole_flow(self.controller, 0x0800, dst_ip, 0xffffff00 )
2144 do_barrier( self.controller )
2145
2146 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2147 for in_port in ports:
2148 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
2149 ip_src = '192.168.%02d.1' % (test_id + in_port)
2150 for out_port in ports:
2151 if in_port == out_port:
2152 continue
2153 ip_dst = '192.168.%02d.1' % (test_id + out_port)
2154 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2155 vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
2156 ip_src=ip_src, ip_dst=ip_dst )
2157 pkt = str( parsed_pkt )
2158 self.dataplane.send( in_port, pkt )
2159 # build expected packet
2160 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
2161 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
2162 vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
2163 ip_src=ip_src, ip_dst=ip_dst )
2164 pkt = str( exp_pkt )
2165 verify_no_packet( self, pkt, out_port )
2166 verify_no_other_packets( self )
2167 finally:
2168 delete_all_flows( self.controller )
2169 delete_groups( self.controller, Groups )
2170 delete_all_groups( self.controller )
2171
2172
2173class _0Ucast( base_tests.SimpleDataPlane ):
2174 """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """
2175
2176 def runTest( self ):
2177 Groups = Queue.LifoQueue( )
2178 try:
2179 if len( config[ "port_map" ] ) < 2:
2180 logging.info( "Port count less than 2, can't run this case" )
2181 return
2182
2183 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2184 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2185 dip = 0xc0a80001
2186 ports = config[ "port_map" ].keys( )
2187 for port in ports:
2188 # add l2 interface group
2189 vlan_id = port
2190 l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1,
2191 is_tagged=True, send_barrier=False )
2192 dst_mac[ 5 ] = vlan_id
2193 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id,
2194 src_mac=intf_src_mac, dst_mac=dst_mac )
2195 # add vlan flow table
2196 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2197 # add termination flow
2198 if config["switch_type"] == "qmx":
2199 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2200 else:
2201 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
2202 # add unicast routing flow
2203 dst_ip = dip + (vlan_id << 8)
2204 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id, priority=2 )
2205 Groups.put( l2gid )
2206 Groups.put( l3_msg.group_id )
2207 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2208 dst_ip = 0x0
2209 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid )
2210 do_barrier( self.controller )
2211
2212 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2213 for in_port in ports:
2214 mac_src = '00:00:00:22:22:%02X' % (in_port)
2215 ip_src = '192.168.%02d.1' % (in_port)
2216 for out_port in ports:
2217 if in_port == out_port:
2218 continue
2219 ip_dst = '192.168.%02d.1' % (out_port)
2220 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port),
2221 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2222 pkt = str( parsed_pkt )
2223 self.dataplane.send( in_port, pkt )
2224 # build expected packet
2225 mac_dst = '00:00:00:22:22:%02X' % (out_port)
2226 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1),
2227 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2228 pkt = str( exp_pkt )
2229 verify_packet( self, pkt, out_port )
2230 verify_no_other_packets( self )
2231 ip_dst = '1.168.%02d.1' % ports[ 0 ]
2232 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
2233 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2234 pkt = str( parsed_pkt )
2235 self.dataplane.send( in_port, pkt )
2236 # build expect packet
2237 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2238 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1,
2239 ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac )
2240 pkt = str( exp_pkt )
2241 verify_packet( self, pkt, ports[ 0 ] )
2242 verify_no_other_packets( self )
2243 finally:
2244 delete_all_flows( self.controller )
2245 delete_groups( self.controller, Groups )
2246 delete_all_groups( self.controller )
2247
2248
2249class Unfiltered( base_tests.SimpleDataPlane ):
2250 """
2251 Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition
2252 """
2253
2254 def runTest( self ):
2255 try:
2256 ports = sorted( config[ "port_map" ].keys( ) )
2257 vlan_id = 1;
2258 for port in ports:
2259 add_l2_unfiltered_group( self.controller, [ port ], False )
2260 do_barrier( self.controller )
2261 finally:
2262 delete_all_flows( self.controller )
2263 delete_all_groups( self.controller )
2264
2265@disabled
2266class L3McastToVPN( base_tests.SimpleDataPlane ):
2267 """
2268 Mcast routing and VPN initiation
2269 """
2270
2271 def runTest( self ):
2272 """
2273 port1 (vlan 1)-> port 2 (vlan 2)
2274 """
2275 try:
2276 delete_all_flows( self.controller )
2277 delete_all_groups( self.controller )
2278
2279 if len( config[ "port_map" ] ) < 3:
2280 logging.info( "Port count less than 3, can't run this case" )
2281 assert (False)
2282 return
2283
2284 vlan_id = 1
2285 port2_out_vlan = 2
2286 port3_out_vlan = 3
2287 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
2288 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2289 intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2290 dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
2291 dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
2292 port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
2293 port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
2294 src_ip = 0xc0a80101
2295 src_ip_str = "192.168.1.1"
2296 dst_ip = 0xe0010101
2297 dst_ip_str = "224.1.1.1"
2298
2299 port1 = config[ "port_map" ].keys( )[ 0 ]
2300 port2 = config[ "port_map" ].keys( )[ 1 ]
2301 # port3=config["port_map"].keys()[2]
2302
2303 # add l2 interface group
2304 for port in config[ "port_map" ].keys( ):
2305 add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False,
2306 send_barrier=False )
2307 # add vlan flow table
2308 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2309 vlan_id += 1
2310
2311 # add termination flow
2312 add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
2313 vlan_id )
2314
2315 # add MPLS interface group
2316 l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 )
2317 mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac,
2318 port2_out_vlan, port2 )
2319 # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
2320 # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
2321 # add L3VPN groups
2322 mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller,
2323 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2,
2324 push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True )
2325 # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
2326 # index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
2327
2328 mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] )
2329 add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id )
2330
2331 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
2332 eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
2333 pkt = str( parsed_pkt )
2334 self.dataplane.send( port1, pkt )
2335 label = (12, 0, 1, 63)
2336 exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64,
2337 ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str )
2338 pkt = str( exp_pkt )
2339 verify_packet( self, pkt, port2 )
2340 # verify_packet(self, pkt, port3)
2341 verify_no_other_packets( self )
2342 delete_all_groups( self.controller )
2343 finally:
2344 delete_all_flows( self.controller )
2345 delete_all_groups( self.controller )
2346
2347@disabled
2348class PacketInSrcMacMiss( base_tests.SimpleDataPlane ):
2349 """
2350 Test packet in function on a src-mac miss
2351 Send a packet to each dataplane port and verify that a packet
2352 in message is received from the controller for each
2353 #todo verify you stop receiving after adding rule
2354 """
2355
2356 def runTest( self ):
2357 Groups = Queue.LifoQueue( )
2358 try:
2359 ports = sorted( config[ "port_map" ].keys( ) )
2360
2361 Groups = Queue.LifoQueue( )
2362 for port in ports:
2363 L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False )
2364 add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2365 Groups.put( L2gid )
2366 parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True )
2367 vlan_pkt = str( parsed_vlan_pkt )
2368 for of_port in config[ "port_map" ].keys( ):
2369 logging.info( "PacketInMiss test, port %d", of_port )
2370 self.dataplane.send( of_port, vlan_pkt )
2371 verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH )
2372 verify_no_other_packets( self )
2373 finally:
2374 delete_all_flows( self.controller )
2375 delete_all_groups( self.controller )
2376
2377
2378class FabricSW_OF_EcmpGroupMod_TC_0025( base_tests.SimpleDataPlane ):
2379 """
2380 Verify referenced group can be modified by adding or removing buckets
2381 """
2382
2383 def runTest( self ):
2384 Groups = Queue.LifoQueue( )
2385 try:
2386 if len( config[ "port_map" ] ) < 2:
2387 logging.info( "Port count less than 2, can't run this case" )
2388 return
2389
2390 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2391 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2392 dip = 0xc0a80001
2393 # Hashes Test Name and uses it as id for installing unique groups
2394 ports = config[ "port_map" ].keys( )
2395 ecmp = [ ]
2396 dst_ips = []
2397 # add flows for all ports but include only the egress switchport (connected to ports[1])
2398 # in the ecmp group
2399 for port in ports:
2400 vlan_id = port
2401 id = port
2402 # add l2 interface group
2403 l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
2404 is_tagged=True, send_barrier=False )
2405 dst_mac[ 5 ] = vlan_id
2406 l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id,
2407 src_mac=intf_src_mac, dst_mac=dst_mac )
2408 if port == ports[1]:
2409 ecmp += [ l3_msg.group_id ]
2410 Groups._put( l2_gid )
2411 Groups._put( l3_msg.group_id )
2412 ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] )
2413 # add vlan flow table
2414 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2415 # add termination flow
2416 if config["switch_type"] == "qmx":
2417 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
2418 else:
2419 add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
2420 # add unicast routing flow
2421 dst_ip = dip + (vlan_id << 8)
2422 dst_ips += [dst_ip]
2423 Groups._put( ecmp_msg.group_id )
2424 mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp )
2425 for dst_ip in dst_ips:
2426 add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id )
2427 do_barrier(self.controller)
2428 time.sleep(0.1)
2429 # first part of the test: send packet from ingress switchport and expect it at egress switchport
2430 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
2431 parsed_pkt = exp_pkt = 0
2432 in_port = ports[0]
2433 out_port = ports[1]
2434 logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2435 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2436 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2437 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2438 tcp = out_port if out_port == 24 else 25
2439 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2440 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2441 ip_dst=ip_dst, tcp_dport=tcp )
2442 pkt = str( parsed_pkt )
2443 self.dataplane.send( ports[ 0 ], pkt )
2444 # build expected packet at egress switchport
2445 mac_dst = '00:00:00:22:22:%02X' % out_port
2446 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2447 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2448 ip_dst=ip_dst, tcp_dport=tcp )
2449 pkt = str( exp_pkt )
2450 verify_packet( self, pkt, out_port )
2451 verify_no_other_packets( self )
2452
2453 # second part of the test - edit the ecmp group to remove the orginal egress switchport
2454 # and instead add the ingress switchport. Send packet from ingress switchport, and expect
2455 # it back on the ingress switchport
2456 l3_gid = encode_l3_unicast_group_id( ports[ 0 ] )
2457 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
2458 time.sleep(0.1)
2459 logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0]))
2460 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2461 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2462 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2463 tcp = port if port == 24 else 25
2464 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2465 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2466 ip_dst=ip_dst,tcp_dport=tcp )
2467 pkt = str( parsed_pkt )
2468 self.dataplane.send( ports[ 0 ], pkt )
2469 # build expected packet
2470 mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ]
2471 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2472 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2473 ip_dst=ip_dst,tcp_dport=tcp )
2474 # Expects packet on the input port
2475 if config["switch_type"] != 'xpliant':
2476 pkt = str( exp_pkt )
2477 verify_packet( self, pkt, ports[ 0 ] )
2478 verify_no_other_packets( self )
2479
2480 # third part of the test - edit the group to completely remove bucket. Packet sent
2481 # should be dropped by the switch
2482 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] )
2483 time.sleep(0.1)
2484 logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop")
2485 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2486 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2487 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2488 tcp = port if port == 24 else 25
2489 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2490 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2491 ip_dst=ip_dst,tcp_dport=tcp )
2492 pkt = str( parsed_pkt )
2493 self.dataplane.send( ports[ 0 ], pkt )
2494 verify_no_other_packets( self )
2495
2496 # final part of the test - edit the empty group to add back the bucket for the
2497 # original egress port, and verify packet is received on egress switch port
2498 l3_gid = encode_l3_unicast_group_id( ports[ 1 ] )
2499 mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] )
2500 do_barrier(self.controller)
2501 in_port = ports[0]
2502 out_port = ports[1]
2503 logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port))
2504 mac_src = '00:00:00:22:22:%02X' % ports[ 0 ]
2505 ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1)
2506 ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1)
2507 tcp = out_port if out_port == 24 else 25
2508 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ],
2509 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
2510 ip_dst=ip_dst, tcp_dport=tcp )
2511 pkt = str( parsed_pkt )
2512 self.dataplane.send( ports[ 0 ], pkt )
2513 # build expected packet at egress switchport
2514 mac_dst = '00:00:00:22:22:%02X' % out_port
2515 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
2516 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src,
2517 ip_dst=ip_dst, tcp_dport=tcp )
2518 pkt = str( exp_pkt )
2519 verify_packet( self, pkt, out_port )
2520 verify_no_other_packets( self )
2521
2522 finally:
2523 delete_all_flows( self.controller )
2524 delete_groups( self.controller, Groups )
2525 delete_all_groups( self.controller )
2526
2527
2528class Untagged( base_tests.SimpleDataPlane ):
2529 """
2530 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
2531 This should be fixed in OFDPA 2.0 GA and above, the test fails with
2532 previous versions of the OFDPA.
2533
2534 Two rules are necessary in VLAN table (10):
2535 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
2536 2) Filtering: match 0x100A/0x1FFF, goto 20
2537
2538 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
2539 The remaining part of the test is based on the use of the bridging table
2540 """
2541
2542 MAX_INTERNAL_VLAN = 4094
2543
2544 def runTest( self ):
2545 groups = Queue.LifoQueue( )
2546 try:
2547 if len( config[ "port_map" ] ) < 2:
2548 logging.info( "Port count less than 2, can't run this case" )
2549 return
2550
2551 ports = sorted( config[ "port_map" ].keys( ) )
2552 for port in ports:
2553 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
2554 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2555 add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2556 for other_port in ports:
2557 if other_port == port:
2558 continue
2559 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
2560 groups.put( L2gid )
2561 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
2562
2563 do_barrier( self.controller )
2564
2565 for out_port in ports:
2566 # change dest based on port number
2567 mac_dst = '00:12:34:56:78:%02X' % out_port
2568 for in_port in ports:
2569 if in_port == out_port:
2570 continue
2571 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
2572 self.dataplane.send( in_port, pkt )
2573 for ofport in ports:
2574 if ofport in [ out_port ]:
2575 verify_packet( self, pkt, ofport )
2576 else:
2577 verify_no_packet( self, pkt, ofport )
2578 verify_no_other_packets( self )
2579 finally:
2580 delete_all_flows( self.controller )
2581 delete_groups( self.controller, groups )
2582 delete_all_groups( self.controller )
2583
2584class MPLSSwapTest( base_tests.SimpleDataPlane ):
2585 """
2586 MPLS switching with the same label used.
2587 Used for interconnecting spines between different fabrics where
2588 the label should not be popped, but swapepd with the same label.
2589 """
2590
2591 def runTest( self ):
2592 try:
2593 delete_all_flows( self.controller )
2594 delete_all_groups( self.controller )
2595
2596 if len( config[ "port_map" ] ) < 2:
2597 logging.info( "Port count less than 3, can't run this case" )
2598 assert (False)
2599 return
2600
2601 input_src_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
2602 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2603
2604 input_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x02 ]
2605 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2606
2607 output_dst_mac = [ 0x00, 0x00, 0x5e, 0x01, 0x01, 0x03 ]
2608 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2609
2610 mpls_label = 1000
2611
2612 src_ip = 0xc0a80101
2613 src_ip_str = "192.168.1.1"
2614 dst_ip = 0xe0010101
2615 dst_ip_str = "224.1.1.1"
2616
2617 src_port = config[ "port_map" ].keys( )[ 0 ]
2618 dst_port = config[ "port_map" ].keys( )[ 1 ]
2619
2620 out_vlan = 4094
2621
2622 add_one_l2_interface_group( self.controller, dst_port, vlan_id=out_vlan, is_tagged=False,
2623 send_barrier=True )
2624
2625 # add vlan flow table
2626 add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_TAG )
2627 add_one_vlan_table_flow( self.controller, src_port, out_vlan_id=out_vlan, vlan_id=out_vlan, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2628
2629 # add termination flow
2630
2631 if config["switch_type"] == "qmx":
2632 logging.debug("MPLSSwitching : Adding flow for qmx, without input port")
2633 add_termination_flow( self.controller, 0, eth_type=0x08847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23)
2634 else:
2635 add_termination_flow( self.controller, in_port=src_port,
2636 eth_type=0x8847, dst_mac=input_dst_mac, vlanid=out_vlan, goto_table=23)
2637
2638 # add groups that will be used now
2639 l2_gid = encode_l2_interface_group_id( out_vlan, dst_port)
2640 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid,
2641 output_dst_mac, input_dst_mac,
2642 out_vlan, dst_port, send_barrier=True)
2643 index = 60
2644 mpls_swap_gid, mpls_swap_msg = add_mpls_swap_label_group( self.controller, mpls_gid,
2645 5, index, mpls_label)
2646
2647 # add flow to mpls table
2648 add_mpls_flow_swap( self.controller, mpls_swap_gid, mpls_label, 0x8847, 1, send_barrier=True)
2649
2650 # we generate the packet which carries a single label
2651 label = (mpls_label, 0, 1, 63)
2652 parsed_pkt = mpls_packet(
2653 pktlen=104,
2654 label=[label],
2655 eth_src=input_src_mac_str,
2656 eth_dst=input_dst_mac_str,
2657 )
2658 pkt = str( parsed_pkt )
2659
2660 self.dataplane.send( src_port, pkt )
2661
2662 label = (mpls_label, 0, 1, 62)
2663 parsed_pkt = mpls_packet(
2664 pktlen=104,
2665 label=[label],
2666 eth_src=input_dst_mac_str,
2667 eth_dst=output_dst_mac_str,
2668 )
2669 pkt = str( parsed_pkt )
2670
2671 verify_packet( self, pkt, dst_port )
2672 verify_no_packet( self, pkt, src_port )
2673 verify_no_other_packets( self )
2674
2675 delete_all_flows( self.controller )
2676 delete_all_groups( self.controller )
2677
2678 finally:
2679 delete_all_flows( self.controller )
2680 delete_all_groups( self.controller )
2681
2682@disabled
2683class DoubleToUntagged( base_tests.SimpleDataPlane ):
2684 """
2685 Verify MPLS IP VPN Initiation from /24 rule using ECMP
2686 where we receive double tagged packets and output untagged
2687 packets.
2688
2689 Each double tagged packet represents a subscriber where Outer tag is pon
2690 and inner tag is the subrscriber tag.
2691 """
2692
2693 def runTest( self ):
2694 Groups = Queue.LifoQueue( )
2695 try:
2696 if len( config[ "port_map" ] ) < 2:
2697 logging.info( "Port count less than 2, can't run this case" )
2698 return
2699
2700 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2701 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2702
2703 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2704 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2705
2706 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2707 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2708
2709 dip = 0xc0a80001
2710 ports = config[ "port_map" ].keys( )
2711
2712 inner_vlan = 66
2713 outer_vlan = 77
2714 id = 10
2715 mpls_label = 152
2716
2717 port = ports[0]
2718 out_port = ports[1]
2719
2720 # add l2 interface group
2721 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True )
2722
2723 # add MPLS interface group
2724 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac,
2725 inner_vlan, id )
2726
2727 # add MPLS L3 VPN group
2728 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
2729 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
2730 push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 )
2731 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
2732
2733 do_barrier( self.controller )
2734
2735 # add vlan flow table
2736 add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0,
2737 flag=VLAN_TABLE_FLAG_ONLY_STACKED )
2738
2739 add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan,
2740 flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2741
2742 # add termination flow
2743 if config["switch_type"] == "qmx":
2744 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan )
2745 else:
2746 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan )
2747
2748 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
2749 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id,
2750 vrf=0 )
2751 Groups._put( l2_gid )
2752 Groups._put( mpls_gid )
2753 Groups._put( mpls_label_gid )
2754 Groups._put( ecmp_msg.group_id )
2755
2756 do_barrier( self.controller )
2757
2758 ip_src = '192.168.5.5'
2759 ip_dst = '192.168.0.5'
2760 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2761 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2762 pkt = str( parsed_pkt )
2763
2764 # print("Expected %s" % format_packet(pkt))
2765
2766 self.dataplane.send( port, pkt )
2767
2768 # build expect packet
2769 label = (mpls_label, 0, 1, 32)
2770 exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63,
2771 ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str,
2772 label=[ label ] )
2773 pkt = str( exp_pkt )
2774 verify_packet( self, pkt, out_port )
2775 verify_no_other_packets( self )
2776
2777 finally:
2778 delete_all_flows( self.controller )
2779 delete_groups( self.controller, Groups )
2780 delete_all_groups( self.controller )
2781
2782@disabled
2783class DoubleToUntaggedMultipleSubscribers( base_tests.SimpleDataPlane ):
2784 """
2785 Verify MPLS IP VPN Initiation from /24 rule using ECMP
2786 where we receive double tagged packets and output untagged
2787 packets.
2788
2789 Each double tagged packet represents a subscriber where Outer tag is pon
2790 and inner tag is the subrscriber tag.
2791 """
2792
2793 def runTest( self ):
2794 Groups = Queue.LifoQueue( )
2795 try:
2796 if len( config[ "port_map" ] ) < 2:
2797 logging.info( "Port count less than 2, can't run this case" )
2798 return
2799
2800 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form]
2801 subscriber_info = [ [10, 0xc0a80001, 10, 100, "192.168.0.1"],
2802 [20, 0xc0a80002, 10, 101, "192.168.0.2"],
2803 [30, 0xc0a80003, 11, 100, "192.168.0.3"],
2804 [40, 0xc0a80004, 11, 101, "192.168.0.4"]]
2805
2806 print("")
2807
2808 for sub_info in subscriber_info:
2809
2810 print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
2811
2812 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2813 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2814
2815 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2816 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2817
2818 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2819 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2820
2821 dip = sub_info[1]
2822 ports = config[ "port_map" ].keys( )
2823
2824 inner_vlan = sub_info[2]
2825 outer_vlan = sub_info[3]
2826 id = 10
2827 mpls_label = 152
2828
2829 port = ports[0]
2830 out_port = ports[1]
2831
2832 # add l2 interface group
2833 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, inner_vlan, False, True )
2834
2835 # add MPLS interface group
2836 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, output_dst_mac, input_dst_mac,
2837 inner_vlan, id )
2838
2839 # add MPLS L3 VPN group
2840 mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller,
2841 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid,
2842 push_mpls_header=True, set_mpls_label=mpls_label, set_bos=1, set_ttl=32 )
2843 ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] )
2844
2845 do_barrier( self.controller )
2846
2847 # add vlan flow table
2848 add_one_vlan_table_flow( self.controller, port, 1, outer_vlan, vrf=0,
2849 flag=VLAN_TABLE_FLAG_ONLY_STACKED )
2850
2851 add_one_vlan_1_table_flow( self.controller, port, outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan,
2852 flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
2853
2854 # add termination flow
2855 if config["switch_type"] == "qmx":
2856 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, inner_vlan )
2857 else:
2858 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, inner_vlan )
2859
2860 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
2861 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffff00, ecmp_msg.group_id,
2862 vrf=0 )
2863 Groups._put( l2_gid )
2864 Groups._put( mpls_gid )
2865 Groups._put( mpls_label_gid )
2866 Groups._put( ecmp_msg.group_id )
2867
2868 do_barrier( self.controller )
2869
2870 for sub_info in subscriber_info:
2871
2872 print("Sending packet for subscriber with id {0}".format(sub_info[0]))
2873
2874 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
2875 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2876
2877 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2878 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2879
2880 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2881 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2882
2883 dip = sub_info[1]
2884 ports = config[ "port_map" ].keys( )
2885
2886 inner_vlan = sub_info[2]
2887 outer_vlan = sub_info[3]
2888 id = 10
2889 mpls_label = 152
2890
2891 port = ports[0]
2892 out_port = ports[1]
2893
2894 ip_src = sub_info[4]
2895 ip_dst = '192.168.0.{}'.format(sub_info[0])
2896 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2897 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2898 pkt = str( parsed_pkt )
2899
2900 # print("Sent %s" % format_packet(pkt))
2901
2902 self.dataplane.send( port, pkt )
2903
2904 # build expect packet
2905 label = (mpls_label, 0, 1, 32)
2906 exp_pkt = mpls_packet( pktlen=96, dl_vlan_enable=False, ip_ttl=63,
2907 ip_src=ip_src, ip_dst=ip_dst, eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str,
2908 label=[ label ] )
2909 pkt = str( exp_pkt )
2910 verify_packet( self, pkt, out_port )
2911 verify_no_other_packets( self )
2912
2913 finally:
2914 delete_all_flows( self.controller )
2915 delete_groups( self.controller, Groups )
2916 delete_all_groups( self.controller )
2917
2918
2919@disabled
2920class UntaggedToDouble ( base_tests.SimpleDataPlane ):
2921 """
2922 Verify google senario where we need to go from
2923 an untagged packet to a double tagged packet.
2924
2925 This is used for a single subscriber.
2926 """
2927
2928 def runTest( self ):
2929 Groups = Queue.LifoQueue( )
2930 try:
2931 if len( config[ "port_map" ] ) < 2:
2932 logging.info( "Port count less than 2, can't run this case" )
2933 return
2934
2935 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
2936 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
2937
2938 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
2939 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
2940
2941 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
2942 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
2943
2944 dip = 0xc0a80001
2945 ports = config[ "port_map" ].keys( )
2946
2947 inner_vlan = 66
2948 outer_vlan = 77
2949 id = 10
2950 mpls_label = 152
2951
2952 port = ports[0]
2953 out_port = ports[1]
2954
2955 # add l2 unfiltered interface group
2956 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
2957
2958 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id,
2959 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
2960
2961 do_barrier( self.controller )
2962
2963 # add vlan flow table
2964 add_one_vlan_table_flow( self.controller, port, 1, 4094,
2965 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
2966
2967 # add termination flow
2968 if config["switch_type"] == "qmx":
2969 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
2970 else:
2971 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
2972
2973 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
2974 vrf=0 )
2975
2976 add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan)
2977
2978 Groups._put( l2_gid )
2979 Groups._put( l3_msg.group_id )
2980
2981 do_barrier( self.controller )
2982
2983 ip_src = '192.168.5.5'
2984 ip_dst = '192.168.0.1'
2985 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False,
2986 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
2987 pkt = str( parsed_pkt )
2988
2989 # print("Input Packet %s" % format_packet(pkt))
2990
2991 self.dataplane.send( port, pkt )
2992
2993 # build expect packet
2994 exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
2995 eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
2996 pkt = str( exp_pkt )
2997
2998 # print("Expected Packet %s" % format_packet(pkt))
2999
3000 verify_packet( self, pkt, out_port )
3001 verify_no_other_packets( self )
3002 finally:
3003 delete_all_flows( self.controller )
3004 delete_groups( self.controller, Groups )
3005 delete_all_groups( self.controller )
3006
3007@disabled
3008class UntaggedToDoubleMultipleSubscribers ( base_tests.SimpleDataPlane ):
3009 """
3010 Verify google senario where we need to go from
3011 an untagged packet to a double tagged packet.
3012
3013 This is used for multiple subscribers.
3014
3015 However, this solution does not scale, since we assign an internal vlan to each subscriber
3016 used in L3 Unicast Group in order to differentiate between them in the Egress Vlan Table.
3017 """
3018
3019 def runTest( self ):
3020 Groups = Queue.LifoQueue( )
3021 try:
3022 if len( config[ "port_map" ] ) < 2:
3023 logging.info( "Port count less than 2, can't run this case" )
3024 return
3025
3026 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form, internal vlan]
3027 subscriber_info = [[1, 0xc0a80001, 10, 100, "192.168.0.1", 4000],
3028 [2, 0xc0a80002, 10, 101, "192.168.0.2", 4001],
3029 [3, 0xc0a80003, 11, 100, "192.168.0.3", 4002],
3030 [4, 0xc0a80004, 11, 101, "192.168.0.4", 4003]]
3031
3032 print("")
3033
3034 for sub_info in subscriber_info:
3035
3036 print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
3037
3038 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3039 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3040
3041 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3042 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3043
3044 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3045 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3046
3047 dip = sub_info[1]
3048 ports = config[ "port_map" ].keys( )
3049
3050 inner_vlan = sub_info[2]
3051 outer_vlan = sub_info[3]
3052 internal_vlan = sub_info[5]
3053 id = sub_info[0] + 10
3054
3055 port = ports[0]
3056 out_port = ports[1]
3057
3058 # add l2 unfiltered interface group
3059 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3060
3061 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=internal_vlan, id=id,
3062 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
3063
3064 do_barrier( self.controller )
3065
3066 # add vlan flow table
3067 add_one_vlan_table_flow( self.controller, port, 1, 4094,
3068 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
3069
3070 # add termination flow
3071 if config["switch_type"] == "qmx":
3072 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
3073 else:
3074 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
3075
3076 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
3077 vrf=0 )
3078
3079 add_one_egress_vlan_table_flow( self.controller, out_port, internal_vlan, inner_vlan, outer_vlan)
3080
3081 Groups._put( l2_gid )
3082 Groups._put( l3_msg.group_id )
3083 do_barrier( self.controller )
3084
3085 for sub_info in subscriber_info:
3086
3087 print("Sending packet for subscriber with id {0}".format(sub_info[0]))
3088
3089 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3090 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3091
3092 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3093 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3094
3095 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3096 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3097
3098 dip = sub_info[1]
3099 ports = config[ "port_map" ].keys( )
3100
3101 inner_vlan = sub_info[2]
3102 outer_vlan = sub_info[3]
3103 internal_vlan = sub_info[5]
3104
3105 id = sub_info[0] + 10
3106 ip_src = '192.168.5.5'
3107 ip_dst = '192.168.0.{}'.format(sub_info[0])
3108 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=False,
3109 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3110 pkt = str( parsed_pkt )
3111
3112 # print("Input Packet %s" % format_packet(pkt))
3113
3114 self.dataplane.send( port, pkt )
3115
3116 # build expect packet
3117 exp_pkt = simple_tcp_packet( pktlen=108, dl_vlan_enable=True, vlan_vid=inner_vlan, outer_vlan=outer_vlan,
3118 eth_dst=output_dst_mac_str, eth_src=input_dst_mac_str, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst )
3119 pkt = str( exp_pkt )
3120
3121 # print("Expected Packet %s" % format_packet(pkt))
3122
3123 verify_packet( self, pkt, out_port )
3124 verify_no_other_packets( self )
3125 finally:
3126 delete_all_flows( self.controller )
3127 delete_groups( self.controller, Groups )
3128 delete_all_groups( self.controller )
3129
3130@disabled
3131class UntaggedToDoubleChangeEthertype ( base_tests.SimpleDataPlane ):
3132
3133 def runTest( self ):
3134 Groups = Queue.LifoQueue()
3135
3136 try:
3137 if len( config[ "port_map" ] ) < 2:
3138 logging.info( "port count less than 2, can't run this case" )
3139 return
3140
3141 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
3142 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3143
3144 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3145 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3146
3147 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3148 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3149
3150 dip = 0xc0a80001
3151 ports = config[ "port_map" ].keys( )
3152
3153 inner_vlan = 66
3154 outer_vlan = 77
3155 id = 10
3156
3157 port = ports[0]
3158 out_port = ports[1]
3159
3160 # add l2 unfiltered interface group
3161 l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3162
3163 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=4094, id=id,
3164 src_mac=input_dst_mac, dst_mac=output_dst_mac, gid=l2_gid)
3165
3166 do_barrier( self.controller )
3167
3168 # add vlan flow table
3169 add_one_vlan_table_flow( self.controller, port, 1, 4094,
3170 flag=VLAN_TABLE_FLAG_ONLY_BOTH )
3171
3172 # add termination flow
3173 if config["switch_type"] == "qmx":
3174 add_termination_flow( self.controller, 0, 0x0800, input_dst_mac, 4094 )
3175 else:
3176 add_termination_flow( self.controller, port, 0x0800, input_dst_mac, 4094 )
3177
3178 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id,
3179 vrf=0 )
3180
3181 add_one_egress_vlan_table_flow( self.controller, out_port, 4094 , inner_vlan, outer_vlan)
3182
3183 Groups._put( l2_gid )
3184 Groups._put( l3_msg.group_id )
3185
3186 # add vlan flow table
3187 add_one_egress_vlan_tpid_table_flow( self.controller, out_port, outer_vlan+0x1000 )
3188 do_barrier( self.controller )
3189
3190 ip_src = '192.168.5.5'
3191 ip_dst = '192.168.0.1'
3192 parsed_pkt = simple_tcp_packet( pktlen=100,
3193 dl_vlan_enable=False,
3194 eth_dst=input_dst_mac_str,
3195 eth_src=input_src_mac_str,
3196 ip_ttl=64,
3197 ip_src=ip_src,
3198 ip_dst=ip_dst )
3199 pkt = str( parsed_pkt )
3200
3201 print("Input Packet %s" % format_packet(pkt))
3202
3203 self.dataplane.send( port, pkt )
3204
3205 # build expect packet
3206 exp_pkt = simple_tcp_packet_two_vlan( pktlen=108,
3207 out_dl_vlan_enable=True,
3208 out_vlan_vid=outer_vlan,
3209 out_vlan_tpid=0x88a8,
3210 in_dl_vlan_enable=True,
3211 in_vlan_vid=inner_vlan,
3212 eth_dst=output_dst_mac_str,
3213 eth_src=input_dst_mac_str,
3214 ip_ttl=63,
3215 ip_src=ip_src,
3216 ip_dst=ip_dst )
3217 pkt = str( exp_pkt )
3218
3219 print("Expected Packet %s" % format_packet(pkt))
3220
3221 verify_packet( self, pkt, out_port )
3222 verify_no_other_packets( self )
3223 finally:
3224 delete_all_flows( self.controller )
3225 delete_groups( self.controller, Groups )
3226 delete_all_groups( self.controller )
3227
3228@disabled
3229class _MplsFwdInterfaceProblem_PW( base_tests.SimpleDataPlane ):
3230 """
3231 Reproduces the pseudowire bug with the wrongly set destination mac address.
3232 """
3233 def runTest( self ):
3234 Groups = Queue.LifoQueue( )
3235 try:
3236 if len( config[ "port_map" ] ) < 1:
3237 logging.info( "Port count less than 1, can't run this case" )
3238 assert (False)
3239 return
3240
3241 macs_to_test = [( [ 0x00, 0x00, 0x00, 0x11, 0x11, 0x00 ], [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ], '00:00:00:11:11:00', '00:00:00:22:22:00'),
3242 ( [ 0x00, 0x00, 0x00, 0x11, 0x22, 0x00 ], [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ], '00:00:00:11:22:00', '00:00:00:33:33:00'),
3243 ( [ 0x00, 0x00, 0x00, 0x11, 0x33, 0x00 ], [ 0x00, 0x00, 0x00, 0x44, 0x44, 0x00 ], '00:00:00:11:33:00', '00:00:00:44:44:00'),
3244 ( [ 0x00, 0x00, 0x00, 0x11, 0x44, 0x00 ], [ 0x00, 0x00, 0x00, 0x55, 0x55, 0x00 ], '00:00:00:11:44:00', '00:00:00:55:55:00'),
3245 ( [ 0x00, 0x00, 0x00, 0x11, 0x55, 0x00 ], [ 0x00, 0x00, 0x00, 0x66, 0x66, 0x00 ], '00:00:00:11:55:00', '00:00:00:66:66:00')]
3246
3247 for dummy_dst_mac, dst_mac, mac_dst_dummy, mac_dst in macs_to_test:
3248
3249 dip = 0xc0a80001
3250 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
3251
3252 out_port = 12
3253 port = 24
3254 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
3255 vlan_id = port + 16
3256 mpls_label = port + 16
3257
3258 in_port = 24
3259 ip_src = '192.168.%02d.1' % (in_port)
3260
3261 # create dummy groups
3262 id = port
3263 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, vlan_id, False, False)
3264 mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dummy_dst_mac, intf_src_mac,
3265 vlan_id, id, send_barrier=True)
3266 do_barrier( self.controller )
3267
3268 # PW Case.
3269 raw_input("Press anything to move on with pseudowire rules, after that you should see the updated groups in the switch.")
3270 logging.info("Installing entries for pseudowire!")
3271 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
3272 mpls_label = 100
3273 mpls_label_SR2 = 100 + 10
3274 mpls_label_PW = 100 + 15
3275
3276 print("Install MPLS intf group for dst mac {0}", dst_mac)
3277 # add MPLS interface group
3278 mpls_intf_gid, mpls_intf_msg = add_mpls_intf_group(
3279 ctrl=self.controller,
3280 ref_gid=l2_gid,
3281 dst_mac=dst_mac,
3282 src_mac=intf_src_mac,
3283 vid=vlan_id,
3284 index=id,
3285 add=False,
3286 send_barrier=True
3287 )
3288
3289 # add MPLS flow with BoS=0
3290 add_mpls_flow_pw(
3291 ctrl=self.controller,
3292 action_group_id=mpls_intf_gid,
3293 label=mpls_label_SR2,
3294 ethertype=0x8847,
3295 tunnel_index=1,
3296 bos=0
3297 )
3298
3299 # add Termination flow
3300 add_termination_flow(
3301 ctrl=self.controller,
3302 in_port=in_port,
3303 eth_type=0x8847,
3304 dst_mac=intf_src_mac,
3305 vlanid=vlan_id,
3306 goto_table=23
3307 )
3308
3309 # add VLAN flows
3310 add_one_vlan_table_flow(
3311 ctrl=self.controller,
3312 of_port=in_port,
3313 vlan_id=vlan_id,
3314 flag=VLAN_TABLE_FLAG_ONLY_TAG,
3315 )
3316 add_one_vlan_table_flow(
3317 ctrl=self.controller,
3318 of_port=in_port,
3319 vlan_id=vlan_id,
3320 flag=VLAN_TABLE_FLAG_ONLY_UNTAG
3321 )
3322 # Packet generation with sleep
3323 time.sleep(2)
3324 label_SR2 = (mpls_label_SR2, 0, 0, 32)
3325 label_2 = (mpls_label_PW, 0, 1, 32)
3326
3327 # set to false to test if routing traffic
3328 # comes through
3329 raw_input("Press enter to send the packet, inspect the groups in the switch!")
3330 print("Sending packet with dst mac {0} and labels {1}".format(switch_mac, [label_SR2, label_2]))
3331 parsed_pkt = mpls_packet(
3332 pktlen=104,
3333 ip_ttl=63,
3334 label=[label_SR2, label_2],
3335 encapsulated_ethernet = True,
3336 eth_dst=switch_mac
3337 )
3338
3339 pkt = str( parsed_pkt )
3340 self.dataplane.send( in_port, pkt )
3341
3342 expected_label = (mpls_label_PW, 0, 1, 31)
3343 print("Expecting packet with dst mac {0} and labels {1}".format(mac_dst, [label_2]))
3344 parsed_pkt = mpls_packet(
3345 pktlen=100,
3346 ip_ttl=63,
3347 eth_dst=mac_dst,
3348 eth_src=switch_mac,
3349 label=[ expected_label ],
3350 encapsulated_ethernet = True
3351 )
3352
3353 pkt = str( parsed_pkt )
3354 verify_packet( self, pkt, out_port )
3355 verify_no_packet( self, pkt, in_port )
3356
3357 delete_all_flows( self.controller )
3358 delete_groups( self.controller, Groups )
3359 delete_all_groups( self.controller )
3360
3361 finally:
3362 delete_all_flows( self.controller )
3363 delete_groups( self.controller, Groups )
3364 delete_all_groups( self.controller )
3365
3366
3367class VlanCrossConnect ( base_tests.SimpleDataPlane ):
3368 """
3369 Tries the cross connect functionality of the ofdpa switches.
3370 """
3371 def runTest( self ):
3372 Groups = Queue.LifoQueue( )
3373 try:
3374 if len( config[ "port_map" ] ) < 2:
3375 logging.info( "Port count less than 2, can't run this case" )
3376 return
3377
3378 # each entry represents a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form]
3379 subscriber_info = [ [10, 0xc0a80001, 12, 11, "192.168.0.1"] ]
3380
3381 index = 5
3382 for sub_info in subscriber_info:
3383
3384 #print("Initializing rules for subscriber with id {0}".format(sub_info[0]))
3385
3386 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3387 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3388
3389 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3390 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3391
3392 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3393 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3394
3395 dip = sub_info[1]
3396 ports = config[ "port_map" ].keys( )
3397
3398 inner_vlan = sub_info[2]
3399 outer_vlan = sub_info[3]
3400
3401 index = inner_vlan
3402
3403 port = ports[0]
3404 out_port = ports[1]
3405
3406 # add l2 interface group, uncomment for unfiltered
3407 l2_gid, l2_msg = add_one_l2_interface_group( self.controller, out_port, outer_vlan, True, True)
3408 #i l2_gid, l2_msg = add_one_l2_unfiltered_group( self.controller, out_port, 1, True)
3409
3410 # add vlan flow table
3411 add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED )
3412 add_one_vlan_1_table_flow_pw( self.controller, port, index, new_outer_vlan_id=outer_vlan ,outer_vlan_id=outer_vlan, inner_vlan_id=inner_vlan, cross_connect=True, send_barrier=True)
3413 add_mpls_l2_port_flow(ctrl=self.controller, of_port=port, mpls_l2_port=port, tunnel_index=index, ref_gid=l2_gid, qos_index=0, goto=ACL_FLOW_TABLE)
3414 index += 1
3415
3416 Groups._put( l2_gid )
3417 do_barrier( self.controller )
3418
3419 for sub_info in subscriber_info:
3420 #print("Sending packet for subscriber with id {0}".format(sub_info[0]))
3421 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3422 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3423
3424 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3425 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3426
3427 dip = sub_info[1]
3428 ports = config[ "port_map" ].keys( )
3429
3430 inner_vlan = sub_info[2]
3431 outer_vlan = sub_info[3]
3432
3433 port = ports[0]
3434 out_port = ports[1]
3435
3436 ip_src = sub_info[4]
3437 ip_dst = '192.168.0.{}'.format(sub_info[0])
3438 parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan,
3439 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3440 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=120, out_dl_vlan_enable=True, in_dl_vlan_enable=True, in_vlan_vid=inner_vlan, out_vlan_vid=outer_vlan,
3441 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3442
3443 pkt = str( parsed_pkt )
3444
3445 self.dataplane.send( port, pkt )
3446 verify_packet( self, pkt, out_port )
3447 verify_no_other_packets( self )
3448
3449 finally:
3450 delete_all_flows( self.controller )
3451 delete_groups( self.controller, Groups )
3452 delete_all_groups( self.controller )
3453
3454
3455@disabled
3456class Lag( base_tests.SimpleDataPlane ):
3457 """
3458 Checks the L2 load balancing (LAG) functionality of the ofdpa switches.
3459 """
3460 def runTest( self ):
3461 Groups = Queue.LifoQueue( )
3462 try:
3463 if len( config[ "port_map" ] ) < 2:
3464 logging.info( "Port count less than 2, can't run this case" )
3465 return
3466
3467 ports = sorted(config[ "port_map" ].keys( ))
3468 in_port = ports[0]
3469 out_port = ports[1]
3470
3471 # add l2 interface unfiltered group
3472 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3473
3474 # create l2 load-balance group
3475 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3476 Groups.put(l2_o_gid, lag_gid)
3477
3478 # --- TEST 1: bridging with load-bal----
3479 vlan_in_port_untagged = 31
3480 # table 10 flows and bridging flows for dstMac+vlan -> l2-load-bal group
3481 add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3482 send_barrier=True)
3483 mac_dst = [ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 ]
3484 mac_dst_str = '00:11:22:33:44:55'
3485 add_bridge_flow( self.controller, mac_dst, vlan_in_port_untagged, lag_gid, True )
3486 # untagged packet input becomes tagged packet at output
3487 time.sleep(0.1)
3488 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=mac_dst_str ) )
3489 exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=mac_dst_str ) )
3490 self.dataplane.send( in_port, pkt )
3491 verify_packet( self, exp_pkt, out_port )
3492 verify_no_other_packets( self )
3493
3494 # --- TEST 2: flooding with load-bal ----
3495 # flooding group --> load-bal group --> l2 unfiltered interface
3496 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 )
3497 Groups.put( floodmsg.group_id )
3498 # add bridging flows for flooding groups
3499 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id )
3500 # unknown dstmac packet input to hit flood group
3501 un_mac_dst_str = '00:11:22:ff:ff:ff'
3502 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3503 exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) )
3504 time.sleep(0.1)
3505 self.dataplane.send( in_port, pkt )
3506 verify_packet( self, exp_pkt, out_port )
3507 verify_no_other_packets( self )
3508
3509 # --- TEST 3: editing load-bal ----
3510 # create and add another l2 unfiltered interface group to the load-balancing group
3511 l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True)
3512 msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True)
3513 self.dataplane.send( in_port, pkt )
3514 verify_packet( self, exp_pkt, out_port )
3515
3516 # delete all buckets in loadbal group
3517 msg = mod_l2_loadbal_group(self.controller, 1, [], True)
3518 time.sleep(0.1)
3519 self.dataplane.send( in_port, pkt )
3520 verify_no_other_packets( self ) # no buckets
3521
3522 # only input port in load balancing group
3523 msg = mod_l2_loadbal_group(self.controller, 1, [l2_i_gid], True)
3524 self.dataplane.send( in_port, pkt )
3525 verify_no_other_packets( self ) # packet should not be sent out of in port
3526
3527 # remove input port and add output port in lag group
3528 msg = mod_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3529 time.sleep(0.1)
3530 self.dataplane.send( in_port, pkt )
3531 verify_packet( self, exp_pkt, out_port )
3532 verify_no_other_packets( self )
3533
3534 finally:
3535 #print("done")
3536 delete_all_flows( self.controller )
3537 delete_groups( self.controller, Groups )
3538 delete_all_groups( self.controller )
3539
3540@disabled
3541class FloodLb( base_tests.SimpleDataPlane ):
3542 """
3543 Checks L2 flood group pointing to L2 load balance group with 2 buckets (unfiltered).
3544 The packet from in_port should not be seen on the out_port
3545 """
3546 def runTest( self ):
3547 Groups = Queue.LifoQueue( )
3548 try:
3549 if len( config[ "port_map" ] ) < 2:
3550 logging.info( "Port count less than 2, can't run this case" )
3551 return
3552
3553 ports = sorted(config[ "port_map" ].keys( ))
3554 in_port = ports[0]
3555 out_port = ports[1]
3556 vlan_in_port_untagged = 31
3557
3558 # add l2 unfiltered interface group for outport
3559 l2_i_gid, l2_i_msg = add_one_l2_unfiltered_group( self.controller, in_port, True)
3560 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3561
3562 # create l2 load-balance group
3563 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_i_gid, l2_o_gid], True)
3564
3565 # create l2 flood group with mix of l2i and l2-loadbal
3566 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0, send_barrier=True )
3567 Groups.put( l2_i_gid )
3568 Groups.put( l2_o_gid )
3569 Groups.put( lag_gid )
3570 Groups.put( floodmsg.group_id )
3571
3572 # table 10 flows for untagged input
3573 add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3574 send_barrier=True)
3575 add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3576 send_barrier=True)
3577
3578 # add bridging flows for flooding groups
3579 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id )
3580 # unknown dstmac packet will hit flood group
3581 un_mac_dst_str = '00:11:22:ff:ff:ff'
3582
3583 # check one direction -> packet enters through inport should not be seen on the outport
3584 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3585 self.dataplane.send( in_port, pkt )
3586 verify_no_other_packets( self )
3587
3588 # check other direction -> packet enters through outport should not be seen on the inport
3589 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3590 self.dataplane.send( out_port, pkt )
3591 verify_no_other_packets( self )
3592
3593 finally:
3594 #print("done")
3595 delete_all_flows( self.controller )
3596 delete_groups( self.controller, Groups )
3597 delete_all_groups( self.controller )
3598
3599@disabled
3600class FloodMixUntagged( base_tests.SimpleDataPlane ):
3601 """
3602 Checks the combination of L2 filtered and L2 load balancing (LAG) groups
3603 in a flooding group
3604 """
3605 def runTest( self ):
3606 Groups = Queue.LifoQueue( )
3607 try:
3608 if len( config[ "port_map" ] ) < 2:
3609 logging.info( "Port count less than 2, can't run this case" )
3610 return
3611
3612 ports = sorted(config[ "port_map" ].keys( ))
3613 in_port = ports[0]
3614 out_port = ports[1]
3615 vlan_in_port_untagged = 31
3616
3617 # add l2 unfiltered interface group for outport
3618 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3619
3620 # create l2 load-balance group
3621 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3622
3623 # create l2 interface (filtered) group for inport
3624 l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged,
3625 is_tagged=False, send_barrier=True)
3626
3627 # create l2 flood group with mix of l2i and l2-loadbal
3628 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid, l2_i_gid] , vlan_in_port_untagged, id=0 )
3629 Groups.put( l2_o_gid )
3630 Groups.put( lag_gid )
3631 Groups.put( l2_i_gid )
3632 Groups.put( floodmsg.group_id )
3633
3634 # table 10 flows for untagged input
3635 add_one_vlan_table_flow( self.controller, in_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3636 send_barrier=True)
3637
3638 # add bridging flows for flooding groups
3639 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id )
3640 # unknown dstmac packet will hit flood group
3641 un_mac_dst_str = '00:11:22:ff:ff:ff'
3642
3643 # check one direction -> packet enters through filtered port (inport) and exits through
3644 # unfiltered port (outport) via the flood and lag groups
3645 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3646 exp_pkt = str( simple_tcp_packet( pktlen=84, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) )
3647 self.dataplane.send( in_port, pkt )
3648 verify_packet( self, exp_pkt, out_port )
3649 verify_no_other_packets( self )
3650
3651 # check other direction -> packet enters through unfiltered port (outport) and exits through
3652 # filtered port (inport) via the flood group
3653 add_one_vlan_table_flow( self.controller, out_port, vlan_id=vlan_in_port_untagged, flag=VLAN_TABLE_FLAG_ONLY_BOTH,
3654 send_barrier=True)
3655 pkt = str( simple_tcp_packet( pktlen=80, eth_dst=un_mac_dst_str ) )
3656 exp_pkt = pkt # ingress packet gets internal vlan 31 which gets popped at l2 interface group before egress
3657 self.dataplane.send( out_port, pkt )
3658 verify_packet( self, exp_pkt, in_port )
3659 verify_no_other_packets( self )
3660
3661 finally:
3662 print("done")
3663 delete_all_flows( self.controller )
3664 delete_groups( self.controller, Groups )
3665 delete_all_groups( self.controller )
3666
3667@disabled
3668class FloodMixTagged( base_tests.SimpleDataPlane ):
3669 """
3670 Checks the combination of L2 filtered and L2 load balancing (LAG) groups
3671 in a flooding group
3672 """
3673 def runTest( self ):
3674 Groups = Queue.LifoQueue( )
3675 try:
3676 if len( config[ "port_map" ] ) < 2:
3677 logging.info( "Port count less than 2, can't run this case" )
3678 return
3679
3680 ports = sorted(config[ "port_map" ].keys( ))
3681 in_port = ports[0]
3682 out_port = ports[1]
3683 vlan_in_port_untagged = 31
3684
3685 # add l2 unfiltered interface group for outport
3686 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3687
3688 # create l2 load-balance group
3689 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3690
3691 # create l2 interface (filtered) group for inport
3692 l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged,
3693 is_tagged=True, send_barrier=True)
3694
3695 # create l2 flood group with mix of l2i and l2-loadbal
3696 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid, l2_i_gid] , vlan_in_port_untagged, id=0 )
3697 Groups.put( l2_o_gid )
3698 Groups.put( lag_gid )
3699 Groups.put( l2_i_gid )
3700 Groups.put( floodmsg.group_id )
3701
3702 # table 10 flows for tagged in_port. Note: VLAN in table 10 must be wildcarded for an unfiltered port
3703 add_vlan_table_flow_allow_all_vlan(self.controller, in_port, send_barrier=True)
3704
3705 # add bridging flows for flooding groups
3706 add_bridge_flow( self.controller, dst_mac=None, vlanid=vlan_in_port_untagged, group_id=floodmsg.group_id )
3707 # unknown dstmac packet will hit flood group
3708 un_mac_dst_str = '00:11:22:ff:ff:ff'
3709
3710 # check one direction -> packet enters through unfiltered port (inport) and exits through
3711 # unfiltered port (outport) via the flood and lag groups
3712 pkt = str( simple_tcp_packet( pktlen=80, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) )
3713 exp_pkt = pkt
3714 self.dataplane.send( in_port, pkt )
3715 verify_packet( self, exp_pkt, out_port )
3716 verify_no_other_packets( self )
3717
3718 # check other direction -> packet enters through unfiltered port (outport) and exits through
3719 # unfiltered port (inport) via the flood group
3720
3721 # table 10 flows for tagged out_port. Note: VLAN must be wildcarded for an unfiltered port
3722 add_vlan_table_flow_allow_all_vlan(self.controller, out_port, send_barrier=True)
3723 pkt = str( simple_tcp_packet( pktlen=80, dl_vlan_enable=True, vlan_vid=vlan_in_port_untagged, eth_dst=un_mac_dst_str ) )
3724 exp_pkt = pkt
3725 self.dataplane.send( out_port, pkt )
3726 verify_packet( self, exp_pkt, in_port )
3727 verify_no_other_packets( self )
3728
3729 finally:
3730 print("done")
3731 delete_all_flows( self.controller )
3732 delete_groups( self.controller, Groups )
3733 delete_all_groups( self.controller )
3734
3735@disabled
3736class LagMix( base_tests.SimpleDataPlane ):
3737 """
3738 Checks the combination of L2 filtered and unfiltered interface groups
3739 in a L2 load balancing (LAG) group - this should not work according to spec
3740 """
3741 def runTest( self ):
3742 Groups = Queue.LifoQueue( )
3743 try:
3744 if len( config[ "port_map" ] ) < 2:
3745 logging.info( "Port count less than 2, can't run this case" )
3746 return
3747
3748 ports = sorted(config[ "port_map" ].keys( ))
3749 in_port = ports[0]
3750 out_port = ports[1]
3751 vlan_in_port_untagged = 31
3752
3753 # add l2 unfiltered interface group
3754 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3755
3756 # create l2 interface (filtered) group
3757 l2_i_gid, l2_i_msg = add_one_l2_interface_group( self.controller, in_port, vlan_in_port_untagged,
3758 is_tagged=False, send_barrier=True)
3759
3760 # create l2 load-balance group with a mix of filtered and unfiltered groups
3761 """
3762 XXX the following does not work - the group does not get created but curiously we don't get an openflow
3763 error message. The ofdpa logs show
3764 ofdbGroupBucketValidate: Referenced Group Id 0x1f000c not of type L2 Unfiltered Interface.
3765 We do get an openflow error message for the flood group that follows because it cannot
3766 find the lag group it points to (because it did not get created).
3767 """
3768 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid, l2_i_gid], True)
3769
3770 # create l2 flood group to point to lag group
3771 floodmsg = add_l2_flood_group_with_gids( self.controller, [lag_gid] , vlan_in_port_untagged, id=0 )
3772 Groups.put( floodmsg.group_id, l2_i_gid, lag_gid )
3773 Groups.put( l2_o_gid )
3774
3775 finally:
3776 #print("done")
3777 delete_all_flows( self.controller )
3778 delete_groups( self.controller, Groups )
3779 delete_all_groups( self.controller )
3780
3781
3782@disabled
3783class LagXconn( base_tests.SimpleDataPlane ):
3784 """
3785 Checks the L2 load balancing (LAG) with vlan crossconnects.
3786 Note that for this to work, basic VlanCrossConnect test above (without LAG) should work first
3787 Note: this doesn't work on XGS or QMX yet with premium 1.1.7
3788 """
3789 def runTest( self ):
3790 Groups = Queue.LifoQueue( )
3791 try:
3792 if len( config[ "port_map" ] ) < 2:
3793 logging.info( "Port count less than 2, can't run this case" )
3794 return
3795
3796 ports = sorted(config[ "port_map" ].keys( ))
3797 in_port = ports[0]
3798 out_port = ports[1]
3799
3800 # add l2 interface unfiltered group
3801 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3802
3803 # create l2 load-balance group
3804 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3805 Groups.put(l2_o_gid, lag_gid)
3806
3807 # a subscriber [id, ip in hex, inner_vlan, outer_vlan, ip in dot form]
3808 sub_info = [10, 0xc0a80001, 12, 11, "192.168.0.1"]
3809
3810 input_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, sub_info[0] ]
3811 input_src_mac_str = ':'.join( [ '%02X' % x for x in input_src_mac ] )
3812 input_dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3813 input_dst_mac_str = ':'.join( [ '%02X' % x for x in input_dst_mac ] )
3814 output_dst_mac = [ 0x00, 0x00, 0x00, 0x33, 0x33, 0x00 ]
3815 output_dst_mac_str = ':'.join( [ '%02X' % x for x in output_dst_mac ] )
3816
3817 dip = sub_info[1]
3818 ports = config[ "port_map" ].keys( )
3819 inner_vlan = sub_info[2]
3820 outer_vlan = sub_info[3]
3821 index = inner_vlan
3822 port = ports[0]
3823 out_port = ports[1]
3824
3825 # add vlan flow table
3826 add_one_vlan_table_flow( self.controller, port, inner_vlan, outer_vlan, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_STACKED )
3827 add_one_vlan_1_table_flow_pw( self.controller, port, index, new_outer_vlan_id=outer_vlan, outer_vlan_id=outer_vlan,
3828 inner_vlan_id=inner_vlan, cross_connect=True, send_barrier=True)
3829 """
3830 XXX The following flow in table 13 is rejected by the switch (qmx) probably due to the reference to lag group
3831 ofdpa logs say: 08-22 00:43:10.344338 [ofstatemanager] Error from Forwarding while inserting flow: Unknown error
3832 """
3833 add_mpls_l2_port_flow(ctrl=self.controller, of_port=port, mpls_l2_port=port, tunnel_index=index, ref_gid=lag_gid,
3834 qos_index=0, goto=ACL_FLOW_TABLE)
3835 do_barrier( self.controller )
3836
3837 ip_src = sub_info[4]
3838 ip_dst = '192.168.0.{}'.format(sub_info[0])
3839 parsed_pkt = qinq_tcp_packet( pktlen=120, vlan_vid=inner_vlan, dl_vlan_outer=outer_vlan,
3840 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3841 parsed_pkt = simple_tcp_packet_two_vlan( pktlen=120, out_dl_vlan_enable=True, in_dl_vlan_enable=True,
3842 in_vlan_vid=inner_vlan, out_vlan_vid=outer_vlan,
3843 eth_dst=input_dst_mac_str, eth_src=input_src_mac_str,
3844 ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst )
3845
3846 pkt = str( parsed_pkt )
3847 self.dataplane.send( port, pkt )
3848 verify_packet( self, pkt, out_port )
3849 verify_no_other_packets( self )
3850
3851 finally:
3852 #print("done")
3853 delete_all_flows( self.controller )
3854 delete_groups( self.controller, Groups )
3855 delete_all_groups( self.controller )
3856
3857@disabled
3858class LagRouting( base_tests.SimpleDataPlane ):
3859 """
3860 Checks the L2 load balancing (LAG) with routing flows.
3861 Specifically route -> L3Unicast -> Lag -> L2 Unfiltered interface
3862 """
3863 def runTest( self ):
3864 Groups = Queue.LifoQueue( )
3865 try:
3866 if len( config[ "port_map" ] ) < 2:
3867 logging.info( "Port count less than 2, can't run this case" )
3868 return
3869
3870 ports = sorted(config[ "port_map" ].keys( ))
3871 in_port = ports[0]
3872 out_port = ports[1]
3873
3874 # add l2 interface unfiltered group
3875 l2_o_gid, l2_o_msg = add_one_l2_unfiltered_group( self.controller, out_port, True)
3876
3877 # create l2 load-balance group
3878 lag_gid, lag_msg = add_l2_loadbal_group(self.controller, 1, [l2_o_gid], True)
3879 Groups.put(l2_o_gid, lag_gid)
3880
3881 intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
3882 dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
3883 dip = 0xc0a80001
3884 vlan_id = 31
3885
3886 # create L3 Unicast group to point to Lag group
3887 l3_msg = add_l3_unicast_group( self.controller, out_port, vlanid=vlan_id, id=vlan_id,
3888 src_mac=intf_src_mac, dst_mac=dst_mac, gid=lag_gid )
3889 # add vlan flow table
3890 add_one_vlan_table_flow( self.controller, in_port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
3891 # add termination flow
3892 if config["switch_type"] == "qmx":
3893 add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
3894 else:
3895 add_termination_flow( self.controller, in_port, 0x0800, intf_src_mac, vlan_id )
3896 # add unicast routing flow
3897 add_unicast_routing_flow( self.controller, 0x0800, dip, 0xffffffff, l3_msg.group_id )
3898
3899 Groups.put( l3_msg.group_id )
3900 do_barrier( self.controller )
3901
3902 switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
3903 mac_src = '00:00:00:22:22:%02X' % (in_port)
3904 ip_src = '192.168.0.2'
3905 ip_dst = '192.168.0.1'
3906 parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
3907 vlan_vid=vlan_id, eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
3908 ip_src=ip_src, ip_dst=ip_dst )
3909 pkt = str( parsed_pkt )
3910 self.dataplane.send( in_port, pkt )
3911 # build expected packet
3912 mac_dst = '00:00:00:22:22:00'
3913 exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
3914 vlan_vid=vlan_id, eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
3915 ip_src=ip_src, ip_dst=ip_dst )
3916 pkt = str( exp_pkt )
3917 verify_packet( self, pkt, out_port )
3918 verify_no_other_packets( self )
3919
3920 finally:
3921 #print("done")
3922 delete_all_flows( self.controller )
3923 delete_groups( self.controller, Groups )
3924 delete_all_groups( self.controller )
3925
3926class FabricSW_OF_EAPOL_TC_0060(base_tests.SimpleDataPlane):
3927 """
3928 To verify double VLAN tagged EAPOL packets can be matched and sent to controller.
3929 """
3930
3931 def runTest(self):
3932 try:
3933 eth_type_eapol = 0x888e
3934 eth_type_non_eapol = 0x88ee
3935 eth_type = 0x8100
3936 vlan_id100 = 100
3937 vlanid200 = 200
3938
3939 logging.info("Step 1")
3940 logging.info("Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.")
3941
3942 ports = sorted(config["port_map"].keys())
3943 for port in ports:
3944 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
3945
3946 add_acl_rule(self.controller, eth_type=eth_type_eapol)
3947
3948 match = ofp.match()
3949 match.oxm_list.append(ofp.oxm.eth_type(eth_type_eapol))
3950
3951 logging.info("Step 2")
3952 logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_eapol)))
3953 parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True,
3954 in_dl_vlan_enable=True,
3955 out_vlan_tpid=eth_type,
3956 in_vlan_tpid=eth_type_eapol,
3957 out_vlan_vid=vlan_id100,
3958 in_vlan_vid=vlanid200)
3959 vlan_pkt = str(parsed_pkt)
3960
3961 logging.info("Step 3")
3962 logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_non_eapol)))
3963 parsed_pkt_non_eapol = simple_ether_packet_two_vlan(out_dl_vlan_enable=True,
3964 in_dl_vlan_enable=True,
3965 out_vlan_tpid=eth_type,
3966 in_vlan_tpid=eth_type_non_eapol,
3967 out_vlan_vid=vlan_id100,
3968 in_vlan_vid=vlanid200)
3969 vlan_pkt_non_eapol = str(parsed_pkt_non_eapol)
3970
3971 logging.info("Step 4")
3972 logging.info(
3973 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_eapol), ports[0]))
3974 self.dataplane.send(ports[0], vlan_pkt)
3975 verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION)
3976
3977 logging.info("Step 5")
3978 logging.info(
3979 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_non_eapol), ports[0]))
3980 self.dataplane.send(ports[0], vlan_pkt_non_eapol)
3981 verify_no_packet_in(self, vlan_pkt_non_eapol, ports[0])
3982
3983 logging.info("Step 6 Cleanup flows")
3984 delete_all_flows(self.controller)
3985 time.sleep(1)
3986
3987 logging.info("Step 7")
3988 logging.info("Add flows again ID=10 and ID=60")
3989 for port in ports:
3990 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
3991
3992 add_acl_rule(self.controller, eth_type=eth_type_eapol)
3993
3994 match = ofp.match()
3995 match.oxm_list.append(ofp.oxm.eth_type(eth_type_eapol))
3996 time.sleep(1)
3997
3998 logging.info("Step 8")
3999 logging.info(
4000 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_eapol), ports[0]))
4001 self.dataplane.send(ports[0], vlan_pkt)
4002 verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION)
4003
4004
4005 finally:
4006 delete_all_flows( self.controller )
4007 delete_all_groups( self.controller )
4008 logging.info("End of Test")
4009
4010
4011
4012class FabricSW_OF_ARP_TC_0065(base_tests.SimpleDataPlane):
4013 """
4014 To verify double VLAN tagged ARP packets can be matched and sent to controller.
4015 """
4016
4017 def runTest(self):
4018 try:
4019 eth_type_arp = 0x806
4020 eth_type_non_arp = 0x888e
4021 eth_type = 0x8100
4022 vlan_id100 = 100
4023 vlanid200 = 200
4024
4025 logging.info("Step 1")
4026 logging.info("Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.")
4027
4028 ports = sorted(config["port_map"].keys())
4029 for port in ports:
4030 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4031
4032 add_acl_rule(self.controller, eth_type=eth_type_arp)
4033
4034 match = ofp.match()
4035 match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp))
4036
4037 logging.info("Step 2")
4038 logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_arp)))
4039 parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True,
4040 in_dl_vlan_enable=True,
4041 out_vlan_tpid=eth_type,
4042 in_vlan_tpid=eth_type_arp,
4043 out_vlan_vid=vlan_id100,
4044 in_vlan_vid=vlanid200)
4045 vlan_pkt = str(parsed_pkt)
4046
4047 logging.info("Step 3")
4048 logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_non_arp)))
4049 parsed_pkt_non_arp = simple_ether_packet_two_vlan(out_dl_vlan_enable=True,
4050 in_dl_vlan_enable=True,
4051 out_vlan_tpid=eth_type,
4052 in_vlan_tpid=eth_type_non_arp,
4053 out_vlan_vid=vlan_id100,
4054 in_vlan_vid=vlanid200)
4055 vlan_pkt_non_arp = str(parsed_pkt_non_arp)
4056
4057 logging.info("Step 4")
4058 logging.info(
4059 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), ports[0]))
4060 self.dataplane.send(ports[0], vlan_pkt)
4061 verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION)
4062
4063 logging.info("Step 5")
4064 logging.info(
4065 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_non_arp), ports[0]))
4066 self.dataplane.send(ports[0], vlan_pkt_non_arp)
4067 verify_no_packet_in(self, vlan_pkt_non_arp, ports[0])
4068
4069 logging.info("Step 6 Cleanup flows")
4070 delete_all_flows(self.controller)
4071 time.sleep(1)
4072
4073 logging.info("Step 7")
4074 logging.info("Add flows again ID=10 and ID=60")
4075 for port in ports:
4076 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4077
4078 add_acl_rule(self.controller, eth_type=eth_type_arp)
4079
4080 match = ofp.match()
4081 match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp))
4082 time.sleep(1)
4083
4084 logging.info("Step 8")
4085 logging.info(
4086 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), ports[0]))
4087 self.dataplane.send(ports[0], vlan_pkt)
4088 verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION)
4089
4090
4091 finally:
4092 delete_all_flows(self.controller)
4093 delete_all_groups(self.controller)
4094 logging.info("End of Test")
4095
4096@disabled
4097class FabricSW_OF_ARP_LAG_TC(base_tests.SimpleDataPlane):
4098 """
4099 To verify double VLAN tagged ARP packets received over a LAG interface can be matched and sent to controller.
4100
4101 TODO: Need to add step: Create a logical port (LAG) and bind data ports 1 and 2 to the logical port.
4102 """
4103
4104 def runTest(self):
4105 try:
4106 eth_type_arp = 0x806
4107 eth_type_non_arp = 0x888e
4108 eth_type = 0x8100
4109 vlan_id100 = 100
4110 vlanid200 = 200
4111
4112 logging.info("Step 1")
4113 logging.info(
4114 "Create a logical port (LAG) and bind data ports 1 and 2 to the logical port.")
4115
4116 # TODO: add LAG here:
4117
4118 logging.info("Step 2")
4119 logging.info("Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.")
4120
4121 ports = sorted(config["port_map"].keys())
4122 for port in ports:
4123 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4124
4125 add_acl_rule(self.controller, eth_type=eth_type_arp)
4126
4127 match = ofp.match()
4128 match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp))
4129
4130 logging.info("Step 3")
4131 logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_arp)))
4132 parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True,
4133 in_dl_vlan_enable=True,
4134 out_vlan_tpid=eth_type,
4135 in_vlan_tpid=eth_type_arp,
4136 out_vlan_vid=vlan_id100,
4137 in_vlan_vid=vlanid200)
4138 vlan_pkt = str(parsed_pkt)
4139
4140 logging.info("Step 4")
4141 logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_non_arp)))
4142 parsed_pkt_non_eapol = simple_ether_packet_two_vlan(out_dl_vlan_enable=True,
4143 in_dl_vlan_enable=True,
4144 out_vlan_tpid=eth_type,
4145 in_vlan_tpid=eth_type_non_arp,
4146 out_vlan_vid=vlan_id100,
4147 in_vlan_vid=vlanid200)
4148 vlan_pkt_non_eapol = str(parsed_pkt_non_eapol)
4149
4150 logging.info("Step 5")
4151 for port in ports:
4152 logging.info(
4153 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), port))
4154 self.dataplane.send(port, vlan_pkt)
4155 verify_packet_in(self, vlan_pkt, port, ofp.OFPR_ACTION)
4156
4157 logging.info("Step 7")
4158 logging.info(
4159 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_non_arp), ports[0]))
4160 self.dataplane.send(ports[0], vlan_pkt_non_eapol)
4161 verify_no_packet_in(self, vlan_pkt_non_eapol, ports[0])
4162
4163 logging.info("Step 8 Cleanup flows")
4164 delete_all_flows(self.controller)
4165
4166 match = ofp.match()
4167 match.oxm_list.append(ofp.oxm.eth_type(eth_type_arp))
4168
4169 logging.info("Step 9")
4170 logging.info(
4171 "Send double tagged vlan packet with ethernet type {} to port {}".format(hex(eth_type_arp), ports[0]))
4172 self.dataplane.send(ports[0], vlan_pkt)
4173 verify_no_packet_in(self, vlan_pkt, ports[0])
4174
4175
4176 finally:
4177 delete_all_flows( self.controller )
4178 delete_all_groups( self.controller )
4179 logging.info("End of Test")
4180
4181
4182class FabricSW_OF_VLANPUSH_TC_0070(base_tests.SimpleDataPlane):
4183 """
4184 To verify a VLAN tag can be pushed into an untagged packet received on a physical interface.
4185 """
4186
4187 def runTest(self):
4188 try:
4189 vlan_id100 = 100
4190 ports = sorted(config["port_map"].keys())
4191
4192 logging.info("Step 1")
4193 logging.info("Add a flow to TABLE-10 to match untagged packets received in Data Port 1 and immediate "
4194 "action to insert VLAN tag {} and transition to TABLE-20.".format(vlan_id100))
4195 add_one_vlan_table_flow(ctrl=self.controller, of_port=ports[0], vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4196 add_one_vlan_table_flow(ctrl=self.controller, of_port=ports[0], vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_UNTAG)
4197
4198 logging.info("Step 2")
4199 logging.info("Add a flow to TABLE-60 to match VLAN tag {} and action Send to Controller".format(vlan_id100))
4200 add_acl_rule(ctrl=self.controller, vlan_id=vlan_id100)
4201
4202 match = ofp.match()
4203 match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id100))
4204
4205 logging.info("Step 3")
4206 logging.info("Creating an untagged vlan packet")
4207 parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=False,
4208 in_dl_vlan_enable=False)
4209 vlan_pkt = str(parsed_pkt)
4210
4211 logging.info("Step 4")
4212 logging.info("Send untagged packet to port {}".format(ports[0]))
4213 self.dataplane.send(ports[0], vlan_pkt)
4214 verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION)
4215
4216 logging.info("Step 6 Cleanup flows")
4217 delete_all_flows(self.controller)
4218
4219 logging.info("Step 5")
4220 logging.info("Send untagged packet to port {}".format(ports[0]))
4221 self.dataplane.send(ports[0], vlan_pkt)
4222 verify_no_packet_in(self, vlan_pkt, ports[0])
4223
4224
4225 finally:
4226 delete_all_flows(self.controller)
4227 delete_all_groups(self.controller)
4228 logging.info("End of Test")
4229
4230
4231class FabricSW_OF_LLDP_TC_0075(base_tests.SimpleDataPlane):
4232 """
4233 To verify LLDP packets received on a physical interface can be matched and sent to Controller.
4234 """
4235
4236 def runTest(self):
4237 try:
4238 eth_type_lldp = 0x88cc
4239 eth_type_non_lldp = 0x88ee
4240
4241 similar_steps(eth_type_lldp, eth_type_non_lldp, self)
4242
4243 finally:
4244 delete_all_flows(self.controller)
4245 delete_all_groups(self.controller)
4246 logging.info("End of Test")
4247
4248
4249class FabricSW_OF_BDDP_TC_0080(base_tests.SimpleDataPlane):
4250 """
4251 To verify BDDP packets received on a physical interface can be matched and sent to Controller.
4252 """
4253
4254 def runTest(self):
4255 try:
4256 eth_type_bddp = 0x8942
4257 eth_type_non_bddp = 0x888e
4258
4259 similar_steps(eth_type_bddp, eth_type_non_bddp, self)
4260
4261 finally:
4262 delete_all_flows(self.controller)
4263 delete_all_groups(self.controller)
4264 logging.info("End of Test")
4265
4266
4267class FabricSW_OF_VLANXConnect_Single_TC_0085(base_tests.SimpleDataPlane):
4268 """
4269 Verify QnQ traffic flooding between 2 cross (one-to-one) connected physical interfaces.
4270 """
4271
4272 def runTest(self):
4273 groups = Queue.LifoQueue()
4274 try:
4275 ports = sorted(config["port_map"].keys())
4276 vlan_id = 100
4277 vlan_id101 = 101
4278
4279 for port in ports:
4280 L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
4281 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4282 groups.put(L2gid)
4283
4284 msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
4285 groups.put(msg.group_id)
4286 add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
4287
4288 #do_barrier(self.controller)
4289
4290 logging.info(
4291 "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id))
4292 add_acl_rule(self.controller, vlan_id=vlan_id)
4293
4294 match = ofp.match()
4295 match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id))
4296
4297 # verify flood
4298 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id))
4299 for ofport in ports:
4300 # change dest based on port number
4301 mac_src = '00:12:34:56:78:%02X' % ofport
4302 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4303 out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10,
4304 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4305
4306 pkt = str(parsed_pkt)
4307 self.dataplane.send(ofport, pkt)
4308 # self won't rx packet
4309 verify_no_packet(self, pkt, ofport)
4310 # others will rx packet
4311 tmp_ports = list(ports)
4312 tmp_ports.remove(ofport)
4313 verify_packets(self, pkt, tmp_ports)
4314
4315 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101))
4316 mac_src = '00:12:34:56:78:%02X' % ports[0]
4317 parsed_pkt_101 = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4318 out_vlan_vid=vlan_id101, in_dl_vlan_enable=True, in_vlan_vid=10,
4319 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4320
4321 pkt_101 = str(parsed_pkt_101)
4322 logging.info("Send double tugged packet to port {}".format(ports[0]))
4323 self.dataplane.send(ports[0], pkt_101)
4324
4325 logging.info("Verify the packet is not flooded to data port2 with outer vlan id {}".format(vlan_id101))
4326 verify_no_packet(self, pkt_101, ports[1])
4327
4328 logging.info("Cleanup flows")
4329 delete_all_flows(self.controller)
4330
4331 logging.info("Send double tugged packet to port {}".format(ports[1]))
4332 self.dataplane.send(ports[1], pkt)
4333
4334 logging.info("Verify the packet is not flooded to data port1 with outer vlan id {}".format(vlan_id))
4335 verify_no_packet(self, pkt, ports[0])
4336
4337 finally:
4338 delete_all_flows(self.controller)
4339 delete_groups(self.controller, groups)
4340 delete_all_groups(self.controller)
4341 logging.info("End of Test")
4342
4343
4344class FabricSW_OF_VLANXConnect_Multi_TC_0090(base_tests.SimpleDataPlane):
4345 """
4346 Verify QnQ traffic flooding between Many-to-One (multiple S tags to single BNG) and One-Many (Single BNG to
4347 multiple S tags) cross connected physical interfaces.
4348 """
4349
4350 def runTest(self):
4351 groups = Queue.LifoQueue()
4352 try:
4353 ports = sorted(config["port_map"].keys())
4354 vlan_id100 = 100
4355 vlan_id101 = 101
4356 vlan_id102 = 102
4357
4358 # Create VLAN100 flow and tables for port1 and port4
4359 tmp_ports = list(ports)
4360 tmp_ports.remove(ports[1])
4361 tmp_ports.remove(ports[2])
4362
4363 for port in tmp_ports:
4364 L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id100, True, False)
4365 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4366 groups.put(L2gid)
4367
4368 msg = add_l2_flood_group(self.controller, tmp_ports, vlan_id100, vlan_id100)
4369 groups.put(msg.group_id)
4370 add_bridge_flow(self.controller, None, vlan_id100, msg.group_id, True)
4371
4372 # do_barrier(self.controller)
4373
4374 logging.info(
4375 "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id100))
4376 add_acl_rule(self.controller, vlan_id=vlan_id100)
4377
4378 match = ofp.match()
4379 match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id100))
4380
4381 # Create VLAN101 flow and tables for port2 and port4
4382 tmp_ports1 = list(ports)
4383 tmp_ports1.remove(ports[0])
4384 tmp_ports1.remove(ports[2])
4385
4386 for port in tmp_ports1:
4387 L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id101, True, False)
4388 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id101, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4389 groups.put(L2gid)
4390
4391 msg = add_l2_flood_group(self.controller, tmp_ports1, vlan_id101, vlan_id101)
4392 groups.put(msg.group_id)
4393 add_bridge_flow(self.controller, None, vlan_id101, msg.group_id, True)
4394
4395 # do_barrier(self.controller)
4396
4397 logging.info(
4398 "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id101))
4399 add_acl_rule(self.controller, vlan_id=vlan_id101)
4400
4401 match = ofp.match()
4402 match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id101))
4403
4404 # Create VLAN102 flow and tables for port3 and port4
4405 tmp_ports2 = list(ports)
4406 tmp_ports2.remove(ports[0])
4407 tmp_ports2.remove(ports[1])
4408
4409 for port in tmp_ports2:
4410 L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id102, True, False)
4411 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id102, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4412 groups.put(L2gid)
4413
4414 msg = add_l2_flood_group(self.controller, tmp_ports2, vlan_id102, vlan_id102)
4415 groups.put(msg.group_id)
4416 add_bridge_flow(self.controller, None, vlan_id102, msg.group_id, True)
4417
4418 # do_barrier(self.controller)
4419
4420 logging.info(
4421 "Add a flow to TABLE-60 to match vlan {} and action Send to Controller".format(vlan_id102))
4422 add_acl_rule(self.controller, vlan_id=vlan_id102)
4423
4424 match = ofp.match()
4425 match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id102))
4426
4427
4428 # verify flood VLAN100 from port1 to port4
4429 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100))
4430 for ofport in tmp_ports:
4431 # change dest based on port number
4432 mac_src = '00:12:34:56:78:%02X' % ofport
4433 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4434 out_vlan_vid=vlan_id100, in_dl_vlan_enable=True, in_vlan_vid=10,
4435 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4436
4437 pkt = str(parsed_pkt)
4438 self.dataplane.send(ofport, pkt)
4439 # self won't rx packet
4440 verify_no_packet(self, pkt, ofport)
4441 # others will rx packet
4442 tmp_ports.remove(ofport)
4443 verify_packets(self, pkt, tmp_ports)
4444
4445 # verify flood VLAN101 from port2 to port4
4446 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101))
4447 for ofport in tmp_ports1:
4448 # change dest based on port number
4449 mac_src = '00:12:34:56:78:%02X' % ofport
4450 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4451 out_vlan_vid=vlan_id101, in_dl_vlan_enable=True,
4452 in_vlan_vid=10,
4453 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4454
4455 pkt = str(parsed_pkt)
4456 self.dataplane.send(ofport, pkt)
4457 # self won't rx packet
4458 verify_no_packet(self, pkt, ofport)
4459 # others will rx packet
4460 tmp_ports1.remove(ofport)
4461 verify_packets(self, pkt, tmp_ports1)
4462
4463 # verify flood VLAN102 from port3 to port4
4464 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id102))
4465 for ofport in tmp_ports2:
4466 # change dest based on port number
4467 mac_src = '00:12:34:56:78:%02X' % ofport
4468 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4469 out_vlan_vid=vlan_id102, in_dl_vlan_enable=True,
4470 in_vlan_vid=10,
4471 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4472
4473 pkt = str(parsed_pkt)
4474 self.dataplane.send(ofport, pkt)
4475 # self won't rx packet
4476 verify_no_packet(self, pkt, ofport)
4477 # others will rx packet
4478 tmp_ports2.remove(ofport)
4479 verify_packets(self, pkt, tmp_ports2)
4480
4481 # verify flood VLAN101 to port1 - no receive on other ports
4482 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101))
4483 mac_src = '00:12:34:56:78:01'
4484 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4485 out_vlan_vid=vlan_id101, in_dl_vlan_enable=True,
4486 in_vlan_vid=10,
4487 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4488
4489 pkt = str(parsed_pkt)
4490 self.dataplane.send(ports[0], pkt)
4491 # won't rx packet
4492 verify_no_packet(self, pkt, ports[1])
4493 verify_no_packet(self, pkt, ports[2])
4494 verify_no_packet(self, pkt, ports[3])
4495
4496 # verify flood VLAN100 to port4 - receive on port1
4497 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100))
4498 mac_src = '00:12:34:56:78:04'
4499 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4500 out_vlan_vid=vlan_id100, in_dl_vlan_enable=True,
4501 in_vlan_vid=10,
4502 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4503
4504 pkt = str(parsed_pkt)
4505 self.dataplane.send(ports[3], pkt)
4506 tmp_ports = list(ports)
4507 tmp_ports.remove(ports[1])
4508 tmp_ports.remove(ports[2])
4509 tmp_ports.remove(ports[3])
4510 # rx packet on port1
4511 verify_packets(self, pkt, tmp_ports)
4512
4513 # verify flood VLAN101 to port4 - receive on port2
4514 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id101))
4515 mac_src = '00:12:34:56:78:04'
4516 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4517 out_vlan_vid=vlan_id101, in_dl_vlan_enable=True,
4518 in_vlan_vid=10,
4519 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4520
4521 pkt = str(parsed_pkt)
4522 self.dataplane.send(ports[3], pkt)
4523 tmp_ports = list(ports)
4524 tmp_ports.remove(ports[0])
4525 tmp_ports.remove(ports[2])
4526 tmp_ports.remove(ports[3])
4527 # rx packet on port1
4528 verify_packets(self, pkt, tmp_ports)
4529
4530 # verify flood VLAN102 to port4 - receive on port3
4531 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id102))
4532 mac_src = '00:12:34:56:78:04'
4533 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4534 out_vlan_vid=vlan_id102, in_dl_vlan_enable=True,
4535 in_vlan_vid=10,
4536 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4537
4538 pkt = str(parsed_pkt)
4539 self.dataplane.send(ports[3], pkt)
4540 tmp_ports = list(ports)
4541 tmp_ports.remove(ports[0])
4542 tmp_ports.remove(ports[1])
4543 tmp_ports.remove(ports[3])
4544 # rx packet on port1
4545 verify_packets(self, pkt, tmp_ports)
4546
4547 logging.info("Cleanup flows")
4548 delete_all_flows(self.controller)
4549
4550 # verify flood VLAN101 to port1 and port4 - no receive on any ports
4551 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100))
4552 mac_src = '00:12:34:56:78:01'
4553 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4554 out_vlan_vid=vlan_id100, in_dl_vlan_enable=True,
4555 in_vlan_vid=10,
4556 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4557
4558 pkt = str(parsed_pkt)
4559 self.dataplane.send(ports[0], pkt)
4560 tmp_ports = list(ports)
4561 tmp_ports.remove(ports[0])
4562 # won't rx packet
4563 verify_no_packet(self, pkt, ports[1])
4564 verify_no_packet(self, pkt, ports[2])
4565 verify_no_packet(self, pkt, ports[3])
4566
4567 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id100))
4568 mac_src = '00:12:34:56:78:04'
4569 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True,
4570 out_vlan_vid=vlan_id100, in_dl_vlan_enable=True,
4571 in_vlan_vid=10,
4572 eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
4573
4574 pkt = str(parsed_pkt)
4575 self.dataplane.send(ports[3], pkt)
4576 tmp_ports = list(ports)
4577 tmp_ports.remove(ports[3])
4578 # won't rx packet
4579 verify_no_packet(self, pkt, ports[0])
4580 verify_no_packet(self, pkt, ports[1])
4581 verify_no_packet(self, pkt, ports[2])
4582
4583 finally:
4584 delete_all_flows(self.controller)
4585 delete_groups(self.controller, groups)
4586 delete_all_groups(self.controller)
4587 logging.info("End of Test")
4588
4589
4590class FabricSW_OF_Counters_TC_0095(base_tests.SimpleDataPlane):
4591 """
4592 To verify the following port counters can be retrieved successfully from Open Flow switch:
4593 rx_bytes_total, tx_bytes_total, rx_packets_total, tx_packets_total, rx_drop_packets_total, tx_drop_packets_total.
4594 """
4595
4596 def runTest(self):
4597 groups = Queue.LifoQueue()
4598 try:
4599 ports = sorted(config["port_map"].keys())
4600 vlan_id = 100
4601 vlan_len = 4
4602 num_pkts = 5
4603 pktlen = 108
4604 rx_bytes_expected = (pktlen + vlan_len) * num_pkts
4605 rx_dropped_expected = 0
4606 tx_pkt_expected = num_pkts
4607 tx_bytes_expected = rx_bytes_expected
4608 tx_dropped_expected = 0
4609
4610 for port in ports:
4611 L2gid, l2msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
4612 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4613 groups.put(L2gid)
4614
4615 msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
4616 groups.put(msg.group_id)
4617 add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
4618
4619 # do_barrier(self.controller)
4620
4621 logging.info("Add a flow to TABLE-60 to match vlan {}".format(vlan_id))
4622 add_acl_rule(self.controller, vlan_id=vlan_id)
4623
4624 match = ofp.match()
4625 match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id))
4626
4627 # Send Port_Stats request for the ingress port (retrieve old counter state)
4628 initial_stats_rx = get_port_stats(self, ports[0])
4629 initial_stats_tx = get_port_stats(self, ports[1])
4630
4631 logging.info("Get required counter values from port".format(ports[0]))
4632 rx_bytes_before = get_required_statistic_from_port(self, ports[0], "rx_bytes")
4633 rx_pkts_before = get_required_statistic_from_port(self, ports[0], "rx_packets")
4634 rx_dropped_before = get_required_statistic_from_port(self, ports[0], "rx_dropped")
4635 tx_bytes_before = get_required_statistic_from_port(self, ports[1], "tx_bytes")
4636 tx_packets_before = get_required_statistic_from_port(self, ports[1], "tx_packets")
4637 tx_dropped_before = get_required_statistic_from_port(self, ports[1], "tx_dropped")
4638
4639 logging.info("Creating a double tagged vlan packet with outer vlan id {}".format(vlan_id))
4640 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=pktlen,
4641 out_dl_vlan_enable=True,
4642 out_vlan_vid=vlan_id,
4643 in_dl_vlan_enable=True,
4644 in_vlan_vid=10,
4645 eth_dst='00:12:34:56:78:9a')
4646 pkt = str(parsed_pkt)
4647
4648 logging.info("Send double tugged packets to port {}".format(ports[0]))
4649 for pkt_cnt in range(num_pkts):
4650 self.dataplane.send(ports[0], pkt)
4651
4652 logging.info("Verify transmitted_packet counters")
4653 verify_port_stats(self, ports[0], initial=initial_stats_rx, rx_pkts=num_pkts)
4654 verify_port_stats(self, ports[1], initial=initial_stats_tx, tx_pkts=num_pkts)
4655
4656 logging.info("Get required counter values from port after sending packets".format(ports[0]))
4657 rx_bytes_after = get_required_statistic_from_port(self, ports[0], "rx_bytes")
4658 rx_pkts_after = get_required_statistic_from_port(self, ports[0], "rx_packets")
4659 rx_dropped_after = get_required_statistic_from_port(self, ports[0], "rx_dropped")
4660 tx_bytes_after = get_required_statistic_from_port(self, ports[1], "tx_bytes")
4661 tx_packets_after = get_required_statistic_from_port(self, ports[1], "tx_packets")
4662 tx_dropped_after = get_required_statistic_from_port(self, ports[1], "tx_dropped")
4663
4664 logging.info("Verify values incremented as expected on port".format(ports[0]))
4665 self.assertGreaterEqual(rx_pkts_after - rx_pkts_before, num_pkts,
4666 "Port RX packet counter is not updated as expected: {}, current value: {}".format(num_pkts, rx_pkts_after - rx_pkts_before))
4667 self.assertGreaterEqual(rx_bytes_after - rx_bytes_before, rx_bytes_expected,
4668 "Port RX bytes counter is not updated as expected: {}, current value: {}".format(rx_bytes_expected, rx_bytes_after - rx_bytes_before))
4669 self.assertGreaterEqual(rx_dropped_after - rx_dropped_before, rx_dropped_expected,
4670 "Port RX dropped counter is not updated as expected: {}, current value: {}".format(rx_dropped_expected, rx_dropped_after - rx_dropped_before))
4671
4672 self.assertEqual(tx_packets_after - tx_packets_before, tx_pkt_expected,
4673 "Port TX packet counter is not updated as expected: {}, current value: {}".format(tx_pkt_expected, tx_packets_after - tx_packets_before))
4674 self.assertEqual(tx_bytes_after - tx_bytes_before, tx_bytes_expected,
4675 "Port TX bytes counter is not updated as expected: {}, current value: {}".format(tx_bytes_expected, tx_bytes_after - tx_bytes_before))
4676 self.assertEqual(tx_dropped_after - tx_dropped_before, tx_dropped_expected,
4677 "Port TX dropped counter is not updated as expected: {}, current value: {}".format(tx_dropped_expected, tx_dropped_after - tx_dropped_before))
4678
4679 finally:
4680 delete_all_flows(self.controller)
4681 delete_groups(self.controller, groups)
4682 delete_all_groups(self.controller)
4683 logging.info("End of Test")
4684
4685
4686def similar_steps(eth_type, not_expected_eth_type, self):
4687 """
4688 Similar steps for tests: FabricSW_OF_BDDP_TC_0020 and FabricSW_OF_LLDP_TC_0015
4689 parameters:
4690 @param eth_type matched ethernet type
4691 @param not_expected_eth_type not matched ethernet type
4692 @param self class instance
4693 """
4694
4695 ports = sorted(config["port_map"].keys())
4696
4697 logging.info("Step 1")
4698 logging.info(
4699 "Add a flow to TABLE-60 to match Ethernet Type to {} and action Send to Controller".format(eth_type))
4700 add_acl_rule(self.controller, eth_type=eth_type)
4701
4702 match = ofp.match()
4703 match.oxm_list.append(ofp.oxm.eth_type(eth_type))
4704
4705 logging.info("Step 2")
4706 logging.info("Creating an untagged packet with ethernet type {}".format(hex(eth_type)))
4707 parsed_pkt = simple_eth_packet(eth_type=eth_type)
4708 eth_pkt = str(parsed_pkt)
4709
4710 logging.info("Step 3")
4711 logging.info("Creating an untagged packet with ethernet type {}".format(hex(not_expected_eth_type)))
4712 parsed_pkt_not_expected = simple_eth_packet(eth_type=not_expected_eth_type)
4713 eth_pkt_non_lldp = str(parsed_pkt_not_expected)
4714
4715 logging.info("Step 4")
4716 logging.info(
4717 "Send untagged packet with ethernet type {} to port {}".format(hex(eth_type), ports[0]))
4718 self.dataplane.send(ports[0], eth_pkt)
4719 verify_packet_in(self, eth_pkt, ports[0], ofp.OFPR_ACTION)
4720
4721 logging.info("Step 5")
4722 logging.info(
4723 "Send untagged packet with ethernet type {} to port {}".format(hex(not_expected_eth_type), ports[0]))
4724 self.dataplane.send(ports[0], eth_pkt_non_lldp)
4725 verify_no_packet_in(self, eth_pkt_non_lldp, ports[0])
4726
4727 logging.info("Step 6 Cleanup flows")
4728 delete_all_flows(self.controller)
4729 time.sleep(1)
4730
4731 logging.info("Step 7")
4732 logging.info(
4733 "Send untagged packet with ethernet type {} to port {}".format(hex(eth_type), ports[0]))
4734 self.dataplane.send(ports[0], eth_pkt)
4735 verify_no_packet_in(self, eth_pkt, ports[0])
4736
4737
4738@disabled
4739class test_interface_flap(base_tests.SimpleDataPlane):
4740 """
4741 This is pilot test case to verify interface flap
4742 """
4743
4744 def runTest(self):
4745 try:
4746 eth_type_eapol = 0x888e
4747 eth_type = 0x8100
4748 vlan_id100 = 100
4749 vlanid200 = 200
4750
4751 logging.info("Step 1")
4752 logging.info(
4753 "Add a flow to TABLE-10 to match VLAN ID '100' for packets received at Data Port 1 and action transition to TABLE-20.")
4754
4755 ports = sorted(config["port_map"].keys())
4756 for port in ports:
4757 add_one_vlan_table_flow(self.controller, port, vlan_id=vlan_id100, flag=VLAN_TABLE_FLAG_ONLY_TAG)
4758
4759 add_acl_rule(self.controller, eth_type=eth_type_eapol)
4760
4761 match = ofp.match()
4762 match.oxm_list.append(ofp.oxm.eth_type(eth_type_eapol))
4763
4764 logging.info("Step 2")
4765 logging.info("Creating a double tagged vlan packet with ethernet type {}".format(hex(eth_type_eapol)))
4766 parsed_pkt = simple_ether_packet_two_vlan(out_dl_vlan_enable=True,
4767 in_dl_vlan_enable=True,
4768 out_vlan_tpid=eth_type,
4769 in_vlan_tpid=eth_type_eapol,
4770 out_vlan_vid=vlan_id100,
4771 in_vlan_vid=vlanid200)
4772 vlan_pkt = str(parsed_pkt)
4773
4774 logging.info("Step 4")
4775 logging.info("Send untagged packet to port {}".format(ports[0]))
4776
4777 self.dataplane.send(ports[0], vlan_pkt)
4778 verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION)
4779
4780 print("")
4781 print("flapping interface")
4782 self.dataplane.port_down(ports[0])
4783
4784 time.sleep(2)
4785
4786 print("bring up interface")
4787 self.dataplane.port_up(ports[0])
4788
4789 self.dataplane.send(ports[0], vlan_pkt)
4790 verify_packet_in(self, vlan_pkt, ports[0], ofp.OFPR_ACTION)
4791
4792
4793 finally:
4794 delete_all_flows(self.controller)
4795 delete_all_groups(self.controller)
4796 logging.info("End of Test")