blob: c3c3ee720f3ffa30ba225eb1bc1ecdfe38189cdb [file] [log] [blame]
Flavio Castro05d20bc2015-11-16 15:06:14 -05001"""
Flavio Castroc36621e2015-12-08 12:57:07 -05002The following tests are being done here
Flavio Castro3aec8902015-11-20 10:51:38 -050031) PacketInSrcMacMiss
castroflavio9e715f32015-12-08 14:04:12 -050042) VlanSupport
53) L2FloodQinQ
64) L2FloodTagged
75) L2Flood Tagged Unknown Src
86) L2 Unicast Tagged
97) MTU 1500
108) MTU 4100
119) MTU 4500
1210) L3UnicastTagged
1311) L3VPNMPLS
1412) MPLS Termination
Flavio Castro05d20bc2015-11-16 15:06:14 -050015"""
16
Flavio Castro05d20bc2015-11-16 15:06:14 -050017from oftest import config
Flavio Castro167f5bd2015-12-02 19:33:53 -050018import logging
19import oftest.base_tests as base_tests
Flavio Castro05d20bc2015-11-16 15:06:14 -050020import ofp
21from oftest.testutils import *
22from accton_util import *
Flavio Castrod8f8af22015-12-02 18:19:26 -050023
Flavio Castroa8a767b2016-02-02 17:41:32 -050024@disabled
Flavio Castroaabb5792015-11-18 19:03:50 -050025class PacketInSrcMacMiss(base_tests.SimpleDataPlane):
26 """
27 Test packet in function on a src-mac miss
28 Send a packet to each dataplane port and verify that a packet
29 in message is received from the controller for each
30 #todo verify you stop receiving after adding rule
31 """
32
Flavio Castro6efe1862015-11-18 16:28:06 -050033 def runTest(self):
34 delete_all_flows(self.controller)
35 delete_all_groups(self.controller)
36
Flavio Castro34352e72015-12-07 20:01:51 -050037 ports = sorted(config["port_map"].keys())
38 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -050039 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -050040 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
41
Flavio Castroaabb5792015-11-18 19:03:50 -050042 parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
43 vlan_vid=0x1001, dl_vlan_enable=True)
44 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6efe1862015-11-18 16:28:06 -050045
Flavio Castroaabb5792015-11-18 19:03:50 -050046 for of_port in config["port_map"].keys():
47 logging.info("PacketInMiss test, port %d", of_port)
48 self.dataplane.send(of_port, vlan_pkt)
49
50 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
51
52 verify_no_other_packets(self)
53
Flavio Castro7fb6ca92015-12-16 15:50:14 -050054class PacketInUDP(base_tests.SimpleDataPlane):
Flavio Castro6d498522015-12-15 14:05:04 -050055 """
56 Test packet in function for a table-miss flow
57 Send a packet to each dataplane port and verify that a packet
58 in message is received from the controller for each
59
60 NOTE: Verify This case the oft option shall not use --switch-ip
61 """
62
63 def runTest(self):
64 delete_all_flows(self.controller)
65 delete_all_groups(self.controller)
66
67 parsed_vlan_pkt = simple_udp_packet(pktlen=104,
68 vlan_vid=0x1001, dl_vlan_enable=True)
69 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6d498522015-12-15 14:05:04 -050070 # create match
71 match = ofp.match()
72 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
castroflavio4a09c962016-01-05 13:13:41 -080073 match.oxm_list.append(ofp.oxm.ip_proto(17))
Flavio Castro6d498522015-12-15 14:05:04 -050074 request = ofp.message.flow_add(
75 table_id=60,
76 cookie=42,
77 match=match,
78 instructions=[
79 ofp.instruction.apply_actions(
80 actions=[
81 ofp.action.output(
82 port=ofp.OFPP_CONTROLLER,
83 max_len=ofp.OFPCML_NO_BUFFER)]),
84 ],
85 buffer_id=ofp.OFP_NO_BUFFER,
86 priority=1)
87
88 logging.info("Inserting packet in flow to controller")
89 self.controller.message_send(request)
90 do_barrier(self.controller)
91
92 for of_port in config["port_map"].keys():
93 logging.info("PacketInMiss test, port %d", of_port)
94 self.dataplane.send(of_port, vlan_pkt)
95
96 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
97
98 verify_no_other_packets(self)
99
Flavio Castroa8a767b2016-02-02 17:41:32 -0500100@disabled
101class PacketInIPTable(base_tests.SimpleDataPlane):
102 """
103 Test packet in function on IPTABLE
104 Send a packet to each dataplane port and verify that a packet
105 in message is received from the controller for each
106 #todo verify you stop receiving after adding rule
107 """
108
109 def runTest(self):
110 delete_all_flows(self.controller)
111 delete_all_groups(self.controller)
112
113 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
114 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
115 dip=0xc0a80001
116 ports = sorted(config["port_map"].keys())
117 for port in ports:
118 #add l2 interface group
119 vlan_id=port
120 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False)
121 dst_mac[5]=vlan_id
122 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
123 #add vlan flow table
124 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
125 #add termination flow
126 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
127 #add unicast routing flow
128 dst_ip = dip + (vlan_id<<8)
129 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xfffffff0, l3_msg.group_id, send_ctrl=True)
130
131 do_barrier(self.controller)
132
133 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
134 for in_port in ports:
135 mac_src='00:00:00:22:22:%02X' % in_port
136 ip_src='192.168.%02d.1' % in_port
137 for out_port in ports:
138 if in_port == out_port:
139 continue
140 ip_dst='192.168.%02d.1' % out_port
141 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
142 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
143 ip_dst=ip_dst)
144 pkt=str(parsed_pkt)
145 self.dataplane.send(in_port, pkt)
146 verify_packet_in(self, pkt, in_port, ofp.OFPR_ACTION)
147 #verify_no_other_packets(self)
148
149
150@disabled
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500151class ArpNL2(base_tests.SimpleDataPlane):
152 def runTest(self):
153 delete_all_flows(self.controller)
154 delete_all_groups(self.controller)
155
156 ports = sorted(config["port_map"].keys())
157 match = ofp.match()
158 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
159 request = ofp.message.flow_add(
160 table_id=60,
161 cookie=42,
162 match=match,
163 instructions=[
164 ofp.instruction.apply_actions(
165 actions=[
166 ofp.action.output(
167 port=ofp.OFPP_CONTROLLER,
168 max_len=ofp.OFPCML_NO_BUFFER)]),
169 ],
170 buffer_id=ofp.OFP_NO_BUFFER,
171 priority=40000)
172 self.controller.message_send(request)
173 for port in ports:
Flavio Castro932014b2016-01-05 18:29:15 -0500174 add_one_l2_interface_group(self.controller, port, 1, False, False)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500175 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
176 group_id = encode_l2_interface_group_id(1, port)
177 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
178 do_barrier(self.controller)
179 parsed_arp_pkt = simple_arp_packet()
180 arp_pkt = str(parsed_arp_pkt)
181
182 for out_port in ports:
183 self.dataplane.send(out_port, arp_pkt)
184 verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION)
185 # change dest based on port number
186 mac_dst= '00:12:34:56:78:%02X' % out_port
187 for in_port in ports:
188 if in_port == out_port:
189 continue
190 # change source based on port number to avoid packet-ins from learning
191 mac_src= '00:12:34:56:78:%02X' % in_port
192 parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src)
193 pkt = str(parsed_pkt)
194 self.dataplane.send(in_port, pkt)
195
196 for ofport in ports:
197 if ofport in [out_port]:
198 verify_packet(self, pkt, ofport)
199 else:
200 verify_no_packet(self, pkt, ofport)
201
202 verify_no_other_packets(self)
203
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500204class PacketInArp(base_tests.SimpleDataPlane):
205 """
206 Test packet in function for a table-miss flow
207 Send a packet to each dataplane port and verify that a packet
208 in message is received from the controller for each
209
210 NOTE: Verify This case the oft option shall not use --switch-ip
211 """
212
213 def runTest(self):
214 delete_all_flows(self.controller)
215 delete_all_groups(self.controller)
216
217 parsed_arp_pkt = simple_arp_packet()
218 arp_pkt = str(parsed_arp_pkt)
219 ports = sorted(config["port_map"].keys())
220 #for port in ports:
221 # add_one_l2_interface_group(self.controller, port, 1, True, False)
222 # add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
223
224 # create match
225 match = ofp.match()
226 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
227 request = ofp.message.flow_add(
228 table_id=60,
229 cookie=42,
230 match=match,
231 instructions=[
232 ofp.instruction.apply_actions(
233 actions=[
234 ofp.action.output(
235 port=ofp.OFPP_CONTROLLER,
236 max_len=ofp.OFPCML_NO_BUFFER)]),
237 ],
238 buffer_id=ofp.OFP_NO_BUFFER,
239 priority=1)
240
241 logging.info("Inserting packet in flow to controller")
242 self.controller.message_send(request)
243 do_barrier(self.controller)
244
245 for of_port in config["port_map"].keys():
246 logging.info("PacketInMiss test, port %d", of_port)
247 self.dataplane.send(of_port, arp_pkt)
248
249 verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION)
250
251 verify_no_other_packets(self)
252
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500253class L2FloodQinQ(base_tests.SimpleDataPlane):
254 """
Flavio Castroc36621e2015-12-08 12:57:07 -0500255 Test L2 flood of double tagged vlan packets (802.1Q)
256 Sends a double tagged packet and verifies flooding behavior according to outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500257 """
258 def runTest(self):
259 ports = sorted(config["port_map"].keys())
260
261 delete_all_flows(self.controller)
262 delete_all_groups(self.controller)
263
264 # Installing flows to avoid packet-in
265 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500266 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500267 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
268
269 group_id = encode_l2_interface_group_id(1, port)
270 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
271 msg=add_l2_flood_group(self.controller, ports, 1, 1)
272 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
273 do_barrier(self.controller)
274
275 #verify flood
276 for ofport in ports:
277 # change dest based on port number
278 mac_src= '00:12:34:56:78:%02X' % ofport
279 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=1,
280 in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
281 pkt = str(parsed_pkt)
282 self.dataplane.send(ofport, pkt)
283 #self won't rx packet
284 verify_no_packet(self, pkt, ofport)
285 #others will rx packet
286 tmp_ports=list(ports)
287 tmp_ports.remove(ofport)
288 verify_packets(self, pkt, tmp_ports)
289
290 verify_no_other_packets(self)
291
Flavio Castro184cefe2015-11-19 20:52:49 -0500292class L2FloodTagged(base_tests.SimpleDataPlane):
293 """
294 Test L2 flood to a vlan
295 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
296 #todo take in account unknown src
297 """
298 def runTest(self):
299 ports = sorted(config["port_map"].keys())
Flavio Castro34352e72015-12-07 20:01:51 -0500300
Flavio Castro184cefe2015-11-19 20:52:49 -0500301 delete_all_flows(self.controller)
302 delete_all_groups(self.controller)
303
Flavio Castro184cefe2015-11-19 20:52:49 -0500304 # Installing flows to avoid packet-in
305 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500306 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500307 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
308
Flavio Castro184cefe2015-11-19 20:52:49 -0500309 group_id = encode_l2_interface_group_id(1, port)
310 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro34352e72015-12-07 20:01:51 -0500311 msg=add_l2_flood_group(self.controller, ports, 1, 1)
312 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
Flavio Castro184cefe2015-11-19 20:52:49 -0500313 do_barrier(self.controller)
314
315 #verify flood
316 for ofport in ports:
317 # change dest based on port number
318 mac_src= '00:12:34:56:78:%02X' % ofport
319 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
320 pkt = str(parsed_pkt)
321 self.dataplane.send(ofport, pkt)
322 #self won't rx packet
323 verify_no_packet(self, pkt, ofport)
324 #others will rx packet
325 tmp_ports=list(ports)
326 tmp_ports.remove(ofport)
327 verify_packets(self, pkt, tmp_ports)
328
329 verify_no_other_packets(self)
330
Flavio Castroaabb5792015-11-18 19:03:50 -0500331class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane):
332 """
333 Test L2 flood to a vlan
334 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
335 #todo take in account unknown src
336 """
337 def runTest(self):
Flavio Castroaabb5792015-11-18 19:03:50 -0500338 delete_all_flows(self.controller)
339 delete_all_groups(self.controller)
340
Flavio Castro34352e72015-12-07 20:01:51 -0500341 ports = sorted(config["port_map"].keys())
342 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500343 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500344 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500345
346 msg=add_l2_flood_group(self.controller, ports, 1, 1)
347 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
348
349 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a')
350 pkt = str(parsed_pkt)
351 #verify flood
352 for ofport in ports:
353 self.dataplane.send(ofport, pkt)
354 #self won't rx packet
355 verify_no_packet(self, pkt, ofport)
356 #others will rx packet
357 tmp_ports=list(ports)
358 tmp_ports.remove(ofport)
359 verify_packets(self, pkt, tmp_ports)
360
361 verify_no_other_packets(self)
362
Flavio Castroaabb5792015-11-18 19:03:50 -0500363class L2UnicastTagged(base_tests.SimpleDataPlane):
364 """
365 Test output function for an exact-match flow
366
367 For each port A, adds a flow directing matching packets to that port.
368 Then, for all other ports B != A, verifies that sending a matching packet
369 to B results in an output to A.
370 """
371 def runTest(self):
372 ports = sorted(config["port_map"].keys())
373
374 delete_all_flows(self.controller)
375 delete_all_groups(self.controller)
376
Flavio Castroaabb5792015-11-18 19:03:50 -0500377 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500378 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500379 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500380 group_id = encode_l2_interface_group_id(1, port)
381 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro6efe1862015-11-18 16:28:06 -0500382 do_barrier(self.controller)
383
Flavio Castroaabb5792015-11-18 19:03:50 -0500384 for out_port in ports:
385 # change dest based on port number
386 mac_dst= '00:12:34:56:78:%02X' % out_port
387 for in_port in ports:
388 if in_port == out_port:
389 continue
390 # change source based on port number to avoid packet-ins from learning
391 mac_src= '00:12:34:56:78:%02X' % in_port
392 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
393 pkt = str(parsed_pkt)
394 self.dataplane.send(in_port, pkt)
395
396 for ofport in ports:
397 if ofport in [out_port]:
398 verify_packet(self, pkt, ofport)
399 else:
400 verify_no_packet(self, pkt, ofport)
401
402 verify_no_other_packets(self)
Flavio Castro6efe1862015-11-18 16:28:06 -0500403
Flavio Castrob6773032015-11-19 22:49:24 -0500404class Mtu1500(base_tests.SimpleDataPlane):
405
406 def runTest(self):
407 ports = sorted(config["port_map"].keys())
408
409 delete_all_flows(self.controller)
410 delete_all_groups(self.controller)
411
Flavio Castro34352e72015-12-07 20:01:51 -0500412 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500413 add_l2_interface_group(self.controller, ports, 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500414
Flavio Castro34352e72015-12-07 20:01:51 -0500415 add_vlan_table_flow(self.controller, ports)
Flavio Castrob6773032015-11-19 22:49:24 -0500416
417 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500418 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500419 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500420 group_id = encode_l2_interface_group_id(1, port)
421 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
422 do_barrier(self.controller)
423
424 for out_port in ports:
425 # change dest based on port number
426 mac_dst= '00:12:34:56:78:%02X' % out_port
427 for in_port in ports:
428 if in_port == out_port:
429 continue
430 # change source based on port number to avoid packet-ins from learning
431 mac_src= '00:12:34:56:78:%02X' % in_port
432 parsed_pkt = simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
433 pkt = str(parsed_pkt)
434 self.dataplane.send(in_port, pkt)
435
436 for ofport in ports:
437 if ofport in [out_port]:
438 verify_packet(self, pkt, ofport)
439 else:
440 verify_no_packet(self, pkt, ofport)
441
442 verify_no_other_packets(self)
443
Flavio Castroa8a767b2016-02-02 17:41:32 -0500444@disabled
Flavio Castrob6773032015-11-19 22:49:24 -0500445class Mtu4000(base_tests.SimpleDataPlane):
446 """
447 Test output function for an exact-match flow
448 For each port A, adds a flow directing matching packets to that port.
449 Then, for all other ports B != A, verifies that sending a matching packet
450 to B results in an output to A.
451 """
452 def runTest(self):
453 ports = sorted(config["port_map"].keys())
454
455 delete_all_flows(self.controller)
456 delete_all_groups(self.controller)
457
458 add_vlan_table_flow(self.controller, config["port_map"].keys())
459
460 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500461 add_l2_interface_group(self.controller, config["port_map"].keys(), 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500462
463 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500464 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500465 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500466 group_id = encode_l2_interface_group_id(1, port)
467 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
468 do_barrier(self.controller)
469
470 for out_port in ports:
471 # change dest based on port number
472 mac_dst= '00:12:34:56:78:%02X' % out_port
473 for in_port in ports:
474 if in_port == out_port:
475 continue
476 # change source based on port number to avoid packet-ins from learning
477 mac_src= '00:12:34:56:78:%02X' % in_port
478 parsed_pkt = simple_tcp_packet(pktlen=4000,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
479 pkt = str(parsed_pkt)
480 self.dataplane.send(in_port, pkt)
481
482 for ofport in ports:
483 if ofport in [out_port]:
484 verify_packet(self, pkt, ofport)
485 else:
486 verify_no_packet(self, pkt, ofport)
487
488 verify_no_other_packets(self)
Flavio Castroaabb5792015-11-18 19:03:50 -0500489
490class L3UcastTagged(base_tests.SimpleDataPlane):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500491 """
Flavio Castro35e64392015-12-02 16:53:14 -0500492 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
493 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500494 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500495 def runTest(self):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500496 delete_all_flows(self.controller)
497 delete_all_groups(self.controller)
498
499 if len(config["port_map"]) <2:
500 logging.info("Port count less than 2, can't run this case")
501 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500502
Flavio Castro05d20bc2015-11-16 15:06:14 -0500503 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
504 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
505 dip=0xc0a80001
Flavio Castroa8233862015-12-02 14:41:11 -0500506 ports = config["port_map"].keys()
507 for port in ports:
Flavio Castro05d20bc2015-11-16 15:06:14 -0500508 #add l2 interface group
Flavio Castroa8233862015-12-02 14:41:11 -0500509 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500510 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500511 dst_mac[5]=vlan_id
512 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
513 #add vlan flow table
Flavio Castro34352e72015-12-07 20:01:51 -0500514 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500515 #add termination flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500516 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500517 #add unicast routing flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500518 dst_ip = dip + (vlan_id<<8)
Flavio Castroa8a767b2016-02-02 17:41:32 -0500519 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id)
Flavio Castro6efe1862015-11-18 16:28:06 -0500520 #add entries in the Bridging table to avoid packet-in from mac learning
521 group_id = encode_l2_interface_group_id(vlan_id, port)
522 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500523
524 do_barrier(self.controller)
525
Flavio Castro05d20bc2015-11-16 15:06:14 -0500526 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
Flavio Castroa8233862015-12-02 14:41:11 -0500527 for in_port in ports:
528 mac_src='00:00:00:22:22:%02X' % in_port
529 ip_src='192.168.%02d.1' % in_port
530 for out_port in ports:
531 if in_port == out_port:
532 continue
533 ip_dst='192.168.%02d.1' % out_port
534 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
535 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
Flavio Castrod8f8af22015-12-02 18:19:26 -0500536 ip_dst=ip_dst)
Flavio Castroa8233862015-12-02 14:41:11 -0500537 pkt=str(parsed_pkt)
538 self.dataplane.send(in_port, pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500539 #build expected packet
Flavio Castroa8233862015-12-02 14:41:11 -0500540 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castrod8f8af22015-12-02 18:19:26 -0500541 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castroa8233862015-12-02 14:41:11 -0500542 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
543 ip_src=ip_src, ip_dst=ip_dst)
544 pkt=str(exp_pkt)
545 verify_packet(self, pkt, out_port)
546 verify_no_other_packets(self)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500547
Flavio Castrod8f8af22015-12-02 18:19:26 -0500548class L3VPNMPLS(base_tests.SimpleDataPlane):
549 """
550 Insert IP packet
551 Receive MPLS packet
552 """
Flavio Castro72a45d52015-12-02 16:37:05 -0500553 def runTest(self):
554 delete_all_flows(self.controller)
555 delete_all_groups(self.controller)
556
557 if len(config["port_map"]) <2:
558 logging.info("Port count less than 2, can't run this case")
559 return
560
561 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
562 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
563 dip=0xc0a80001
564 index=1
565 ports = config["port_map"].keys()
566 for port in ports:
567 #add l2 interface group
568 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500569 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
Flavio Castro72a45d52015-12-02 16:37:05 -0500570 dst_mac[5]=vlan_id
Flavio Castro35e64392015-12-02 16:53:14 -0500571 #add MPLS interface group
Flavio Castro72a45d52015-12-02 16:37:05 -0500572 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
Flavio Castro35e64392015-12-02 16:53:14 -0500573 #add MPLS L3 VPN group
Flavio Castrod8f8af22015-12-02 18:19:26 -0500574 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
Flavio Castro72a45d52015-12-02 16:37:05 -0500575 index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
Flavio Castro5edf3132016-01-27 15:45:08 -0500576 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castro80730822015-12-11 15:38:47 -0500577 do_barrier(self.controller)
Flavio Castro72a45d52015-12-02 16:37:05 -0500578 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500579 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castro72a45d52015-12-02 16:37:05 -0500580 #add termination flow
581 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro35e64392015-12-02 16:53:14 -0500582 #add routing flow
Flavio Castroa8a767b2016-02-02 17:41:32 -0500583 dst_ip = dip + (vlan_id<<8)
Flavio Castro5edf3132016-01-27 15:45:08 -0500584 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
585 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, vrf=2)
Flavio Castro80730822015-12-11 15:38:47 -0500586 #add entries in the Bridging table to avoid packet-in from mac learning
587 group_id = encode_l2_interface_group_id(vlan_id, port)
588 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
589
590 do_barrier(self.controller)
591
592 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
593 for in_port in ports:
594 mac_src='00:00:00:22:22:%02X' % in_port
595 ip_src='192.168.%02d.1' % in_port
596 for out_port in ports:
597 if in_port == out_port:
598 continue
599 ip_dst='192.168.%02d.1' % out_port
600 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
601 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
602 ip_dst=ip_dst)
603 pkt=str(parsed_pkt)
604 self.dataplane.send(in_port, pkt)
605 #build expect packet
606 mac_dst='00:00:00:22:22:%02X' % out_port
607 label = (out_port, 0, 1, 32)
608 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
609 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
610 pkt=str(exp_pkt)
611 verify_packet(self, pkt, out_port)
612 verify_no_other_packets(self)
castroflavioee294842016-01-06 15:54:28 -0800613
Flavio Castroa8a767b2016-02-02 17:41:32 -0500614@disabled
Flavio Castro80730822015-12-11 15:38:47 -0500615class L3VPN_32(base_tests.SimpleDataPlane):
616 """
617 Insert IP packet
618 Receive MPLS packet
619 """
620 def runTest(self):
621 delete_all_flows(self.controller)
622 delete_all_groups(self.controller)
623
624 if len(config["port_map"]) <2:
625 logging.info("Port count less than 2, can't run this case")
626 return
627
628 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
629 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
630 dip=0xc0a80001
631 index=1
632 ports = config["port_map"].keys()
633 for port in ports:
634 #add l2 interface group
635 vlan_id=port
636 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
637 dst_mac[5]=vlan_id
638 #add MPLS interface group
639 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
640 #add MPLS L3 VPN group
641 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
642 index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
643 #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
644 do_barrier(self.controller)
645 #add vlan flow table
646 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, flag=VLAN_TABLE_FLAG_ONLY_TAG)
647 #add termination flow
648 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
649 #add routing flow
650 dst_ip = dip + (vlan_id<<8)
Flavio Castroa8a767b2016-02-02 17:41:32 -0500651 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, mpls_gid, vrf=2)
Flavio Castro80730822015-12-11 15:38:47 -0500652 #ecmp_msg.group_id, vrf=2)
Flavio Castro72a45d52015-12-02 16:37:05 -0500653 #add entries in the Bridging table to avoid packet-in from mac learning
654 group_id = encode_l2_interface_group_id(vlan_id, port)
655 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
656
657 do_barrier(self.controller)
658
659 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
660 for in_port in ports:
661 mac_src='00:00:00:22:22:%02X' % in_port
662 ip_src='192.168.%02d.1' % in_port
663 for out_port in ports:
664 if in_port == out_port:
665 continue
666 ip_dst='192.168.%02d.1' % out_port
667 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
668 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
669 ip_dst=ip_dst)
670 pkt=str(parsed_pkt)
671 self.dataplane.send(in_port, pkt)
672 #build expect packet
673 mac_dst='00:00:00:22:22:%02X' % out_port
674 label = (out_port, 0, 1, 32)
Flavio Castro34352e72015-12-07 20:01:51 -0500675 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
Flavio Castro72a45d52015-12-02 16:37:05 -0500676 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
677 pkt=str(exp_pkt)
678 verify_packet(self, pkt, out_port)
679 verify_no_other_packets(self)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500680
Flavio Castroa8a767b2016-02-02 17:41:32 -0500681@disabled
Flavio Castrod8f8af22015-12-02 18:19:26 -0500682class MplsTermination(base_tests.SimpleDataPlane):
Flavio Castro34352e72015-12-07 20:01:51 -0500683 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500684 Insert IP packet
685 Receive MPLS packet
Flavio Castro34352e72015-12-07 20:01:51 -0500686 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500687 def runTest(self):
688 delete_all_flows(self.controller)
689 delete_all_groups(self.controller)
690
691 if len(config["port_map"]) <2:
692 logging.info("Port count less than 2, can't run this case")
693 return
694
695 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
696 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500697 mcast_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x01]
698
Flavio Castrod8f8af22015-12-02 18:19:26 -0500699 dip=0xc0a80001
700 index=1
701 ports = config["port_map"].keys()
702 for port in ports:
703 #add l2 interface group
704 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500705 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500706 dst_mac[5]=vlan_id
707 #add L3 Unicast group
Flavio Castro932014b2016-01-05 18:29:15 -0500708 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500709 #add L3 ecmp group
710 ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500711 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500712 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500713 #add termination flow
Flavio Castro167f5bd2015-12-02 19:33:53 -0500714 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500715 #add routing flow
716 dst_ip = dip + (vlan_id<<8)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500717 add_mpls_flow(self.controller, ecmp_msg.group_id, port)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500718 #add entries in the Bridging table to avoid packet-in from mac learning
719 group_id = encode_l2_interface_group_id(vlan_id, port)
720 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
721
722 do_barrier(self.controller)
723
724 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
725 for in_port in ports:
726 mac_src='00:00:00:22:22:%02X' % in_port
727 ip_src='192.168.%02d.1' % in_port
728 for out_port in ports:
729 if in_port == out_port:
730 continue
731 ip_dst='192.168.%02d.1' % out_port
Flavio Castro167f5bd2015-12-02 19:33:53 -0500732
733 label = (out_port, 0, 1, 32)
734 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
735 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500736 pkt=str(parsed_pkt)
737 self.dataplane.send(in_port, pkt)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500738
Flavio Castrod8f8af22015-12-02 18:19:26 -0500739 #build expect packet
740 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500741 mcast='01:00:5e:00:00:01'
Flavio Castro167f5bd2015-12-02 19:33:53 -0500742 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castro932014b2016-01-05 18:29:15 -0500743 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500744 pkt=str(exp_pkt)
745 verify_packet(self, pkt, out_port)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500746 verify_no_other_packets(self)
747
Flavio Castroa8a767b2016-02-02 17:41:32 -0500748@disabled
Flavio Castro80730822015-12-11 15:38:47 -0500749class MPLSBUG(base_tests.SimpleDataPlane):
750
751 def runTest(self):
752 delete_all_flows(self.controller)
753 delete_all_groups(self.controller)
754
755 if len(config["port_map"]) <2:
756 logging.info("Port count less than 2, can't run this case")
757 return
758
759 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
760 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
761 dip=0xc0a80001
762 index=1
763 ports = config["port_map"].keys()
764 for port in ports:
765 #add l2 interface group
766 vlan_id=port
767 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
768 dst_mac[5]=vlan_id
769 #add L3 Unicast group
770 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
771 #add vlan flow table
772 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
773 #add termination flow
774 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
775 #add mpls flow
776 add_mpls_flow(self.controller, l3_msg.group_id, port)
777 #add termination flow
778 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
779 #add unicast routing flow
780 dst_ip = dip + (vlan_id<<8)
Flavio Castroa8a767b2016-02-02 17:41:32 -0500781 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id)
Flavio Castro80730822015-12-11 15:38:47 -0500782
783 #add entries in the Bridging table to avoid packet-in from mac learning
784 group_id = encode_l2_interface_group_id(vlan_id, port)
785 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
786
787 do_barrier(self.controller)
788
789 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
790 for in_port in ports:
791 mac_src='00:00:00:22:22:%02X' % in_port
792 ip_src='192.168.%02d.1' % in_port
793 for out_port in ports:
794 if in_port == out_port:
795 continue
796 ip_dst='192.168.%02d.1' % out_port
797 switch_mac = "00:00:00:cc:cc:cc"
798 label = (out_port, 0, 1, 32)
799 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
800 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
801 pkt=str(parsed_pkt)
802 self.dataplane.send(in_port, pkt)
803
804 #build expect packet
805 mac_dst='00:00:00:22:22:%02X' % out_port
806 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
807 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst)
808 pkt=str(exp_pkt)
809 verify_packet(self, pkt, out_port)
810 verify_no_other_packets(self)
811
812 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
813 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
814 ip_dst=ip_dst)
815 pkt=str(parsed_pkt)
816 self.dataplane.send(in_port, pkt)
817 #build expected packet
818 mac_dst='00:00:00:22:22:%02X' % out_port
819 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
820 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
821 ip_src=ip_src, ip_dst=ip_dst)
822 pkt=str(exp_pkt)
823 verify_packet(self, pkt, out_port)
824 verify_no_other_packets(self)
825
Flavio Castroa8a767b2016-02-02 17:41:32 -0500826@disabled
Flavio Castro12296312015-12-15 17:48:26 -0500827class L3McastToL2(base_tests.SimpleDataPlane):
castroflaviocc403a92015-12-15 14:04:19 -0500828 """
Flavio Castro12296312015-12-15 17:48:26 -0500829 Mcast routing to L2
castroflaviocc403a92015-12-15 14:04:19 -0500830 """
831 def runTest(self):
832 """
833 port1 (vlan 300)-> All Ports (vlan 300)
834 """
Flavio Castro932014b2016-01-05 18:29:15 -0500835 #delete_all_flows(self.controller)
836 #delete_all_groups(self.controller)
castroflaviocc403a92015-12-15 14:04:19 -0500837
castroflavio4a09c962016-01-05 13:13:41 -0800838 if len(config["port_map"]) <3:
839 logging.info("Port count less than 3, can't run this case")
840 assert(False)
castroflaviocc403a92015-12-15 14:04:19 -0500841 return
842
843 vlan_id =300
844 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
845 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
846 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
847 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
848 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
849 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
850 src_ip=0xc0a80101
851 src_ip_str="192.168.1.1"
852 dst_ip=0xe0010101
853 dst_ip_str="224.1.1.1"
854
855 port1=config["port_map"].keys()[0]
856 port2=config["port_map"].keys()[1]
857
858 switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]
859
860
861 #add l2 interface group
862 l2_intf_group_list=[]
863 for port in config["port_map"].keys():
Flavio Castro932014b2016-01-05 18:29:15 -0500864 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=4)
castroflaviocc403a92015-12-15 14:04:19 -0500865 if port == port2:
866 continue
Flavio Castro12296312015-12-15 17:48:26 -0500867 l2_intf_gid, msg=add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False)
castroflaviocc403a92015-12-15 14:04:19 -0500868 l2_intf_group_list.append(l2_intf_gid)
castroflaviocc403a92015-12-15 14:04:19 -0500869
870 #add termination flow
871 add_termination_flow(self.controller, port1, 0x0800, switch_mac, vlan_id)
872
873 #add l3 interface group
874 mcat_group_msg=add_l3_mcast_group(self.controller, vlan_id, 2, l2_intf_group_list)
875 add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id)
876
Flavio Castro932014b2016-01-05 18:29:15 -0500877 parsed_pkt = simple_udp_packet(pktlen=100,
878 dl_vlan_enable=True,
castroflaviocc403a92015-12-15 14:04:19 -0500879 eth_dst=dst_mac_str,
880 eth_src=port1_mac_str,
881 ip_ttl=64,
882 ip_src=src_ip_str,
883 ip_dst=dst_ip_str)
884 pkt=str(parsed_pkt)
885 self.dataplane.send(port1, pkt)
886 for port in config["port_map"].keys():
Flavio Castro12296312015-12-15 17:48:26 -0500887 if port == port2 or port == port1:
castroflaviocc403a92015-12-15 14:04:19 -0500888 verify_no_packet(self, pkt, port)
Flavio Castro12296312015-12-15 17:48:26 -0500889 continue
castroflaviocc403a92015-12-15 14:04:19 -0500890 verify_packet(self, pkt, port)
891 verify_no_other_packets(self)
892
Flavio Castroa8a767b2016-02-02 17:41:32 -0500893@disabled
Flavio Castro12296312015-12-15 17:48:26 -0500894class L3McastToL3(base_tests.SimpleDataPlane):
895 """
896 Mcast routing
897 """
898 def runTest(self):
899 """
900 port1 (vlan 1)-> port 2 (vlan 2)
901 """
902 delete_all_flows(self.controller)
903 delete_all_groups(self.controller)
904
905 if len(config["port_map"]) <3:
castroflavio4a09c962016-01-05 13:13:41 -0800906 logging.info("Port count less than 3, can't run this case")
907 assert(False)
Flavio Castro12296312015-12-15 17:48:26 -0500908 return
909
910 vlan_id =1
911 port2_out_vlan=2
912 port3_out_vlan=3
913 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
914 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
915 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
916 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
917 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
918 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
919 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
920 src_ip=0xc0a80101
921 src_ip_str="192.168.1.1"
922 dst_ip=0xe0010101
923 dst_ip_str="224.1.1.1"
924
925 port1=config["port_map"].keys()[0]
926 port2=config["port_map"].keys()[1]
927 port3=config["port_map"].keys()[2]
928
929 #add l2 interface group
930 for port in config["port_map"].keys():
931 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
932 #add vlan flow table
933 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
934 vlan_id +=1
935
936 #add termination flow
937 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
938
939 #add l3 interface group
940 port2_ucast_msg=add_l3_interface_group(self.controller, port2, port2_out_vlan, 2, intf_src_mac)
941 port3_ucast_msg=add_l3_interface_group(self.controller, port3, port3_out_vlan, 3, intf_src_mac)
942 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [port2_ucast_msg.group_id, port3_ucast_msg.group_id])
943 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
944
945 parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
946 eth_dst=dst_mac_str,
947 eth_src=port1_mac_str,
948 ip_ttl=64,
949 ip_src=src_ip_str,
950 ip_dst=dst_ip_str)
951 pkt=str(parsed_pkt)
952 self.dataplane.send(port1, pkt)
953 parsed_pkt = simple_udp_packet(pktlen=96,
954 eth_dst=dst_mac_str,
955 eth_src=intf_src_mac_str,
956 ip_ttl=63,
957 ip_src=src_ip_str,
958 ip_dst=dst_ip_str)
959 pkt=str(parsed_pkt)
960 verify_packet(self, pkt, port2)
961 verify_packet(self, pkt, port3)
962 verify_no_other_packets(self)
963
Flavio Castroa8a767b2016-02-02 17:41:32 -0500964@disabled
Flavio Castro12296312015-12-15 17:48:26 -0500965class L3McastToVPN(base_tests.SimpleDataPlane):
966 """
967 Mcast routing
968 """
969 def runTest(self):
970 """
971 port1 (vlan 1)-> port 2 (vlan 2)
972 """
973 #delete_all_flows(self.controller)
974 #delete_all_groups(self.controller)
975
976 if len(config["port_map"]) <3:
castroflavio4a09c962016-01-05 13:13:41 -0800977 logging.info("Port count less than 3, can't run this case")
978 assert(False)
Flavio Castro12296312015-12-15 17:48:26 -0500979 return
980
981 vlan_id =1
982 port2_out_vlan=2
983 port3_out_vlan=3
984 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
985 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
986 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
987 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
988 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
989 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
990 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
991 src_ip=0xc0a80101
992 src_ip_str="192.168.1.1"
993 dst_ip=0xe0010101
994 dst_ip_str="224.1.1.1"
995
996 port1=config["port_map"].keys()[0]
997 port2=config["port_map"].keys()[1]
998 port3=config["port_map"].keys()[2]
999
1000 #add l2 interface group
1001 for port in config["port_map"].keys():
1002 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
1003 #add vlan flow table
1004 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
1005 vlan_id +=1
1006
1007 #add termination flow
1008 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
1009
1010 #add MPLS interface group
1011 l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2)
1012 mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2)
1013 l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
1014 mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
1015 #add L3VPN groups
1016 mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
1017 index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True)
1018 mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
1019 index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
1020
Flavio Castro12296312015-12-15 17:48:26 -05001021 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023])
1022 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
1023
1024 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
1025 eth_dst=dst_mac_str,
1026 eth_src=port1_mac_str,
1027 ip_ttl=64,
1028 ip_src=src_ip_str,
1029 ip_dst=dst_ip_str)
1030 pkt=str(parsed_pkt)
1031 self.dataplane.send(port1, pkt)
1032 label = (in_vlan, 0, 1, 63)
1033 parsed_pkt = mpls_packet(pktlen=100,
1034 eth_dst=dst_mac_str,
1035 eth_src=intf_src_mac_str,
1036 ip_ttl=63,
1037 ip_src=src_ip_str, label= [label],
1038 ip_dst=dst_ip_str)
1039 pkt=str(parsed_pkt)
1040 verify_packet(self, pkt, port2)
1041 verify_packet(self, pkt, port3)
1042 verify_no_other_packets(self)
castroflavio30c6cc52016-01-07 15:19:42 -08001043
1044class LPM(base_tests.SimpleDataPlane):
1045 """
1046 Insert IP packet
1047 Receive MPLS packet
1048 """
1049 def runTest(self):
1050 delete_all_flows(self.controller)
1051 delete_all_groups(self.controller)
1052
1053 if len(config["port_map"]) <2:
1054 logging.info("Port count less than 2, can't run this case")
1055 return
1056
1057 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1058 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
1059 dip=0xc0a80001
1060 index=1
1061 ports = config["port_map"].keys()
1062 for port in ports:
1063 #add l2 interface group
1064 vlan_id=port
1065 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
1066 dst_mac[5]=vlan_id
1067 #add MPLS interface group
1068 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
1069 #add MPLS L3 VPN group
1070 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
1071 index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
Flavio Castro5edf3132016-01-27 15:45:08 -05001072 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
castroflavio30c6cc52016-01-07 15:19:42 -08001073 do_barrier(self.controller)
1074 #add vlan flow table
Flavio Castroa8a767b2016-02-02 17:41:32 -05001075 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_TAG)
castroflavio30c6cc52016-01-07 15:19:42 -08001076 #add termination flow
1077 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
1078 #add routing flow
1079 dst_ip = dip + (vlan_id<<8)
Flavio Castro5edf3132016-01-27 15:45:08 -05001080 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid, vrf=2)
Flavio Castroa8a767b2016-02-02 17:41:32 -05001081 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id)
castroflavio30c6cc52016-01-07 15:19:42 -08001082 #add entries in the Bridging table to avoid packet-in from mac learning
1083 group_id = encode_l2_interface_group_id(vlan_id, port)
1084 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
1085 port = ports[0]
1086 #add l2 interface group
1087 vlan_id=port
1088 l2_gid = encode_l2_interface_group_id(vlan_id, port)
1089 dst_mac[5]=vlan_id
1090 #add MPLS interface group
1091 mpls_gid = encode_mpls_interface_group_id(0, port)
1092 #add MPLS L3 VPN group
1093 mpls_label_gid = encode_mpls_label_group_id(OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=port)
Flavio Castro5edf3132016-01-27 15:45:08 -05001094 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
castroflavio30c6cc52016-01-07 15:19:42 -08001095 do_barrier(self.controller)
1096 #add routing flow
1097 dst_ip = 0x0
Flavio Castro5edf3132016-01-27 15:45:08 -05001098 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, mpls_label_gid, vrf=2)
Flavio Castroa8a767b2016-02-02 17:41:32 -05001099 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, ecmp_msg.group_id)
castroflavio30c6cc52016-01-07 15:19:42 -08001100
1101 do_barrier(self.controller)
1102
1103 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
1104 for in_port in ports:
1105 mac_src='00:00:00:22:22:%02X' % in_port
1106 ip_src='192.168.%02d.1' % in_port
1107 for out_port in ports:
1108 if in_port == out_port:
1109 continue
1110 ip_dst='192.168.%02d.1' % out_port
1111 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1112 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
1113 ip_dst=ip_dst)
1114 pkt=str(parsed_pkt)
1115 self.dataplane.send(in_port, pkt)
1116 #build expect packet
1117 mac_dst='00:00:00:22:22:%02X' % out_port
1118 label = (out_port, 0, 1, 32)
1119 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
1120 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
1121 pkt=str(exp_pkt)
1122 verify_packet(self, pkt, out_port)
1123 verify_no_other_packets(self)
Flavio Castroa8a767b2016-02-02 17:41:32 -05001124 ip_dst='1.168.%02d.1' % ports[0]
castroflavio30c6cc52016-01-07 15:19:42 -08001125 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1126 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst)
1127 pkt=str(parsed_pkt)
1128 self.dataplane.send(in_port, pkt)
1129 #build expect packet
Flavio Castroa8a767b2016-02-02 17:41:32 -05001130 mac_dst='00:00:00:22:22:%02X' % ports[0]
1131 label = (ports[0], 0, 1, 32)
1132 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=ports[0], ip_ttl=63, ip_src=ip_src,
castroflavio30c6cc52016-01-07 15:19:42 -08001133 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
1134 pkt=str(exp_pkt)
Flavio Castroa8a767b2016-02-02 17:41:32 -05001135 verify_packet(self, pkt, ports[0])
castroflavio30c6cc52016-01-07 15:19:42 -08001136 verify_no_other_packets(self)