blob: 00e8587d682502e98e7af325b4151b6f57ac5b35 [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 Castro67d8bd52016-02-03 14:22:14 -050018import inspect
Flavio Castro167f5bd2015-12-02 19:33:53 -050019import logging
20import oftest.base_tests as base_tests
Flavio Castro05d20bc2015-11-16 15:06:14 -050021import ofp
22from oftest.testutils import *
23from accton_util import *
Flavio Castrod8f8af22015-12-02 18:19:26 -050024
Flavio Castro67d8bd52016-02-03 14:22:14 -050025@disabled
Flavio Castroaabb5792015-11-18 19:03:50 -050026class PacketInSrcMacMiss(base_tests.SimpleDataPlane):
27 """
28 Test packet in function on a src-mac miss
29 Send a packet to each dataplane port and verify that a packet
30 in message is received from the controller for each
31 #todo verify you stop receiving after adding rule
32 """
33
Flavio Castro6efe1862015-11-18 16:28:06 -050034 def runTest(self):
35 delete_all_flows(self.controller)
36 delete_all_groups(self.controller)
37
Flavio Castro34352e72015-12-07 20:01:51 -050038 ports = sorted(config["port_map"].keys())
39 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -050040 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -050041 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
42
Flavio Castroaabb5792015-11-18 19:03:50 -050043 parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
44 vlan_vid=0x1001, dl_vlan_enable=True)
45 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6efe1862015-11-18 16:28:06 -050046
Flavio Castroaabb5792015-11-18 19:03:50 -050047 for of_port in config["port_map"].keys():
48 logging.info("PacketInMiss test, port %d", of_port)
49 self.dataplane.send(of_port, vlan_pkt)
50
51 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
52
53 verify_no_other_packets(self)
54
Flavio Castro7fb6ca92015-12-16 15:50:14 -050055class PacketInUDP(base_tests.SimpleDataPlane):
Flavio Castro6d498522015-12-15 14:05:04 -050056 """
57 Test packet in function for a table-miss flow
58 Send a packet to each dataplane port and verify that a packet
59 in message is received from the controller for each
60
61 NOTE: Verify This case the oft option shall not use --switch-ip
62 """
63
64 def runTest(self):
65 delete_all_flows(self.controller)
66 delete_all_groups(self.controller)
67
68 parsed_vlan_pkt = simple_udp_packet(pktlen=104,
69 vlan_vid=0x1001, dl_vlan_enable=True)
70 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6d498522015-12-15 14:05:04 -050071 # create match
72 match = ofp.match()
73 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
castroflavio4a09c962016-01-05 13:13:41 -080074 match.oxm_list.append(ofp.oxm.ip_proto(17))
Flavio Castro6d498522015-12-15 14:05:04 -050075 request = ofp.message.flow_add(
76 table_id=60,
77 cookie=42,
78 match=match,
79 instructions=[
80 ofp.instruction.apply_actions(
81 actions=[
82 ofp.action.output(
83 port=ofp.OFPP_CONTROLLER,
84 max_len=ofp.OFPCML_NO_BUFFER)]),
85 ],
86 buffer_id=ofp.OFP_NO_BUFFER,
87 priority=1)
88
89 logging.info("Inserting packet in flow to controller")
90 self.controller.message_send(request)
91 do_barrier(self.controller)
92
93 for of_port in config["port_map"].keys():
94 logging.info("PacketInMiss test, port %d", of_port)
95 self.dataplane.send(of_port, vlan_pkt)
96
97 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
98
99 verify_no_other_packets(self)
Flavio Castro67d8bd52016-02-03 14:22:14 -0500100@disabled
Flavio Castroaf2b4502016-02-02 17:41:32 -0500101class 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
Flavio Castro67d8bd52016-02-03 14:22:14 -0500149@disabled
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500150class ArpNL2(base_tests.SimpleDataPlane):
151 def runTest(self):
152 delete_all_flows(self.controller)
153 delete_all_groups(self.controller)
154
155 ports = sorted(config["port_map"].keys())
156 match = ofp.match()
157 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
158 request = ofp.message.flow_add(
159 table_id=60,
160 cookie=42,
161 match=match,
162 instructions=[
163 ofp.instruction.apply_actions(
164 actions=[
165 ofp.action.output(
166 port=ofp.OFPP_CONTROLLER,
167 max_len=ofp.OFPCML_NO_BUFFER)]),
168 ],
169 buffer_id=ofp.OFP_NO_BUFFER,
170 priority=40000)
171 self.controller.message_send(request)
172 for port in ports:
Flavio Castro932014b2016-01-05 18:29:15 -0500173 add_one_l2_interface_group(self.controller, port, 1, False, False)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500174 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
175 group_id = encode_l2_interface_group_id(1, port)
176 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
177 do_barrier(self.controller)
178 parsed_arp_pkt = simple_arp_packet()
179 arp_pkt = str(parsed_arp_pkt)
180
181 for out_port in ports:
182 self.dataplane.send(out_port, arp_pkt)
183 verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION)
184 # change dest based on port number
185 mac_dst= '00:12:34:56:78:%02X' % out_port
186 for in_port in ports:
187 if in_port == out_port:
188 continue
189 # change source based on port number to avoid packet-ins from learning
190 mac_src= '00:12:34:56:78:%02X' % in_port
191 parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src)
192 pkt = str(parsed_pkt)
193 self.dataplane.send(in_port, pkt)
194
195 for ofport in ports:
196 if ofport in [out_port]:
197 verify_packet(self, pkt, ofport)
198 else:
199 verify_no_packet(self, pkt, ofport)
200
201 verify_no_other_packets(self)
202
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500203class PacketInArp(base_tests.SimpleDataPlane):
204 """
205 Test packet in function for a table-miss flow
206 Send a packet to each dataplane port and verify that a packet
207 in message is received from the controller for each
208
209 NOTE: Verify This case the oft option shall not use --switch-ip
210 """
211
212 def runTest(self):
213 delete_all_flows(self.controller)
214 delete_all_groups(self.controller)
215
216 parsed_arp_pkt = simple_arp_packet()
217 arp_pkt = str(parsed_arp_pkt)
218 ports = sorted(config["port_map"].keys())
219 #for port in ports:
220 # add_one_l2_interface_group(self.controller, port, 1, True, False)
221 # add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
222
223 # create match
224 match = ofp.match()
225 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
226 request = ofp.message.flow_add(
227 table_id=60,
228 cookie=42,
229 match=match,
230 instructions=[
231 ofp.instruction.apply_actions(
232 actions=[
233 ofp.action.output(
234 port=ofp.OFPP_CONTROLLER,
235 max_len=ofp.OFPCML_NO_BUFFER)]),
236 ],
237 buffer_id=ofp.OFP_NO_BUFFER,
238 priority=1)
239
240 logging.info("Inserting packet in flow to controller")
241 self.controller.message_send(request)
242 do_barrier(self.controller)
243
244 for of_port in config["port_map"].keys():
245 logging.info("PacketInMiss test, port %d", of_port)
246 self.dataplane.send(of_port, arp_pkt)
247
248 verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION)
249
250 verify_no_other_packets(self)
251
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500252class L2FloodQinQ(base_tests.SimpleDataPlane):
253 """
Flavio Castroc36621e2015-12-08 12:57:07 -0500254 Test L2 flood of double tagged vlan packets (802.1Q)
255 Sends a double tagged packet and verifies flooding behavior according to outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500256 """
257 def runTest(self):
258 ports = sorted(config["port_map"].keys())
259
260 delete_all_flows(self.controller)
261 delete_all_groups(self.controller)
262
263 # Installing flows to avoid packet-in
264 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500265 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500266 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
267
268 group_id = encode_l2_interface_group_id(1, port)
269 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
270 msg=add_l2_flood_group(self.controller, ports, 1, 1)
271 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
272 do_barrier(self.controller)
273
274 #verify flood
275 for ofport in ports:
276 # change dest based on port number
277 mac_src= '00:12:34:56:78:%02X' % ofport
278 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=1,
279 in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
280 pkt = str(parsed_pkt)
281 self.dataplane.send(ofport, pkt)
282 #self won't rx packet
283 verify_no_packet(self, pkt, ofport)
284 #others will rx packet
285 tmp_ports=list(ports)
286 tmp_ports.remove(ofport)
287 verify_packets(self, pkt, tmp_ports)
288
289 verify_no_other_packets(self)
290
Flavio Castro184cefe2015-11-19 20:52:49 -0500291class L2FloodTagged(base_tests.SimpleDataPlane):
292 """
293 Test L2 flood to a vlan
294 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
295 #todo take in account unknown src
296 """
297 def runTest(self):
298 ports = sorted(config["port_map"].keys())
Flavio Castro34352e72015-12-07 20:01:51 -0500299
Flavio Castro184cefe2015-11-19 20:52:49 -0500300 delete_all_flows(self.controller)
301 delete_all_groups(self.controller)
302
Flavio Castro184cefe2015-11-19 20:52:49 -0500303 # Installing flows to avoid packet-in
304 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500305 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500306 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
307
Flavio Castro184cefe2015-11-19 20:52:49 -0500308 group_id = encode_l2_interface_group_id(1, port)
309 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro34352e72015-12-07 20:01:51 -0500310 msg=add_l2_flood_group(self.controller, ports, 1, 1)
311 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
Flavio Castro184cefe2015-11-19 20:52:49 -0500312 do_barrier(self.controller)
313
314 #verify flood
315 for ofport in ports:
316 # change dest based on port number
317 mac_src= '00:12:34:56:78:%02X' % ofport
318 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
319 pkt = str(parsed_pkt)
320 self.dataplane.send(ofport, pkt)
321 #self won't rx packet
322 verify_no_packet(self, pkt, ofport)
323 #others will rx packet
324 tmp_ports=list(ports)
325 tmp_ports.remove(ofport)
326 verify_packets(self, pkt, tmp_ports)
327
328 verify_no_other_packets(self)
Flavio Castro67d8bd52016-02-03 14:22:14 -0500329@disabled
Flavio Castroaabb5792015-11-18 19:03:50 -0500330class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane):
331 """
332 Test L2 flood to a vlan
333 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
334 #todo take in account unknown src
335 """
336 def runTest(self):
Flavio Castroaabb5792015-11-18 19:03:50 -0500337 delete_all_flows(self.controller)
338 delete_all_groups(self.controller)
339
Flavio Castro34352e72015-12-07 20:01:51 -0500340 ports = sorted(config["port_map"].keys())
341 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500342 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500343 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500344
345 msg=add_l2_flood_group(self.controller, ports, 1, 1)
346 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
347
348 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a')
349 pkt = str(parsed_pkt)
350 #verify flood
351 for ofport in ports:
352 self.dataplane.send(ofport, pkt)
353 #self won't rx packet
354 verify_no_packet(self, pkt, ofport)
355 #others will rx packet
356 tmp_ports=list(ports)
357 tmp_ports.remove(ofport)
358 verify_packets(self, pkt, tmp_ports)
359
360 verify_no_other_packets(self)
361
Flavio Castroaabb5792015-11-18 19:03:50 -0500362class L2UnicastTagged(base_tests.SimpleDataPlane):
363 """
364 Test output function for an exact-match flow
365
366 For each port A, adds a flow directing matching packets to that port.
367 Then, for all other ports B != A, verifies that sending a matching packet
368 to B results in an output to A.
369 """
370 def runTest(self):
371 ports = sorted(config["port_map"].keys())
372
373 delete_all_flows(self.controller)
374 delete_all_groups(self.controller)
375
Flavio Castroaabb5792015-11-18 19:03:50 -0500376 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500377 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500378 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500379 group_id = encode_l2_interface_group_id(1, port)
380 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro6efe1862015-11-18 16:28:06 -0500381 do_barrier(self.controller)
382
Flavio Castroaabb5792015-11-18 19:03:50 -0500383 for out_port in ports:
384 # change dest based on port number
385 mac_dst= '00:12:34:56:78:%02X' % out_port
386 for in_port in ports:
387 if in_port == out_port:
388 continue
389 # change source based on port number to avoid packet-ins from learning
390 mac_src= '00:12:34:56:78:%02X' % in_port
391 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
392 pkt = str(parsed_pkt)
393 self.dataplane.send(in_port, pkt)
394
395 for ofport in ports:
396 if ofport in [out_port]:
397 verify_packet(self, pkt, ofport)
398 else:
399 verify_no_packet(self, pkt, ofport)
400
401 verify_no_other_packets(self)
Flavio Castro6efe1862015-11-18 16:28:06 -0500402
Flavio Castrob6773032015-11-19 22:49:24 -0500403class Mtu1500(base_tests.SimpleDataPlane):
404
405 def runTest(self):
406 ports = sorted(config["port_map"].keys())
407
408 delete_all_flows(self.controller)
409 delete_all_groups(self.controller)
410
Flavio Castro34352e72015-12-07 20:01:51 -0500411 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500412 add_l2_interface_group(self.controller, ports, 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500413
Flavio Castro34352e72015-12-07 20:01:51 -0500414 add_vlan_table_flow(self.controller, ports)
Flavio Castrob6773032015-11-19 22:49:24 -0500415
416 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500417 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500418 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500419 group_id = encode_l2_interface_group_id(1, port)
420 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
421 do_barrier(self.controller)
422
423 for out_port in ports:
424 # change dest based on port number
425 mac_dst= '00:12:34:56:78:%02X' % out_port
426 for in_port in ports:
427 if in_port == out_port:
428 continue
429 # change source based on port number to avoid packet-ins from learning
430 mac_src= '00:12:34:56:78:%02X' % in_port
431 parsed_pkt = simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
432 pkt = str(parsed_pkt)
433 self.dataplane.send(in_port, pkt)
434
435 for ofport in ports:
436 if ofport in [out_port]:
437 verify_packet(self, pkt, ofport)
438 else:
439 verify_no_packet(self, pkt, ofport)
440
441 verify_no_other_packets(self)
442
Flavio Castro67d8bd52016-02-03 14:22:14 -0500443@disabled
Flavio Castrob6773032015-11-19 22:49:24 -0500444class Mtu4000(base_tests.SimpleDataPlane):
445 """
446 Test output function for an exact-match flow
447 For each port A, adds a flow directing matching packets to that port.
448 Then, for all other ports B != A, verifies that sending a matching packet
449 to B results in an output to A.
450 """
451 def runTest(self):
452 ports = sorted(config["port_map"].keys())
453
454 delete_all_flows(self.controller)
455 delete_all_groups(self.controller)
456
457 add_vlan_table_flow(self.controller, config["port_map"].keys())
458
459 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500460 add_l2_interface_group(self.controller, config["port_map"].keys(), 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500461
462 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500463 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500464 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500465 group_id = encode_l2_interface_group_id(1, port)
466 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
467 do_barrier(self.controller)
468
469 for out_port in ports:
470 # change dest based on port number
471 mac_dst= '00:12:34:56:78:%02X' % out_port
472 for in_port in ports:
473 if in_port == out_port:
474 continue
475 # change source based on port number to avoid packet-ins from learning
476 mac_src= '00:12:34:56:78:%02X' % in_port
477 parsed_pkt = simple_tcp_packet(pktlen=4000,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
478 pkt = str(parsed_pkt)
479 self.dataplane.send(in_port, pkt)
480
481 for ofport in ports:
482 if ofport in [out_port]:
483 verify_packet(self, pkt, ofport)
484 else:
485 verify_no_packet(self, pkt, ofport)
486
487 verify_no_other_packets(self)
Flavio Castroaabb5792015-11-18 19:03:50 -0500488
489class L3UcastTagged(base_tests.SimpleDataPlane):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500490 """
Flavio Castro35e64392015-12-02 16:53:14 -0500491 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
492 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500493 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500494 def runTest(self):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500495 delete_all_flows(self.controller)
496 delete_all_groups(self.controller)
497
498 if len(config["port_map"]) <2:
499 logging.info("Port count less than 2, can't run this case")
500 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500501
Flavio Castro05d20bc2015-11-16 15:06:14 -0500502 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
503 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
504 dip=0xc0a80001
Flavio Castroa8233862015-12-02 14:41:11 -0500505 ports = config["port_map"].keys()
506 for port in ports:
Flavio Castro05d20bc2015-11-16 15:06:14 -0500507 #add l2 interface group
Flavio Castroa8233862015-12-02 14:41:11 -0500508 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500509 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 -0500510 dst_mac[5]=vlan_id
511 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
512 #add vlan flow table
Flavio Castro34352e72015-12-07 20:01:51 -0500513 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500514 #add termination flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500515 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500516 #add unicast routing flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500517 dst_ip = dip + (vlan_id<<8)
Flavio Castroaf2b4502016-02-02 17:41:32 -0500518 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id)
Flavio Castro6efe1862015-11-18 16:28:06 -0500519 #add entries in the Bridging table to avoid packet-in from mac learning
520 group_id = encode_l2_interface_group_id(vlan_id, port)
521 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500522
523 do_barrier(self.controller)
524
Flavio Castro05d20bc2015-11-16 15:06:14 -0500525 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
Flavio Castroa8233862015-12-02 14:41:11 -0500526 for in_port in ports:
527 mac_src='00:00:00:22:22:%02X' % in_port
528 ip_src='192.168.%02d.1' % in_port
529 for out_port in ports:
530 if in_port == out_port:
531 continue
532 ip_dst='192.168.%02d.1' % out_port
533 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
534 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
Flavio Castrod8f8af22015-12-02 18:19:26 -0500535 ip_dst=ip_dst)
Flavio Castroa8233862015-12-02 14:41:11 -0500536 pkt=str(parsed_pkt)
537 self.dataplane.send(in_port, pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500538 #build expected packet
Flavio Castroa8233862015-12-02 14:41:11 -0500539 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castrod8f8af22015-12-02 18:19:26 -0500540 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castroa8233862015-12-02 14:41:11 -0500541 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
542 ip_src=ip_src, ip_dst=ip_dst)
543 pkt=str(exp_pkt)
544 verify_packet(self, pkt, out_port)
545 verify_no_other_packets(self)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500546
Flavio Castrod8f8af22015-12-02 18:19:26 -0500547class L3VPNMPLS(base_tests.SimpleDataPlane):
548 """
549 Insert IP packet
550 Receive MPLS packet
551 """
Flavio Castro72a45d52015-12-02 16:37:05 -0500552 def runTest(self):
553 delete_all_flows(self.controller)
554 delete_all_groups(self.controller)
555
556 if len(config["port_map"]) <2:
557 logging.info("Port count less than 2, can't run this case")
558 return
559
560 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
561 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
562 dip=0xc0a80001
563 index=1
564 ports = config["port_map"].keys()
565 for port in ports:
566 #add l2 interface group
567 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500568 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
Flavio Castro72a45d52015-12-02 16:37:05 -0500569 dst_mac[5]=vlan_id
Flavio Castro35e64392015-12-02 16:53:14 -0500570 #add MPLS interface group
Flavio Castro72a45d52015-12-02 16:37:05 -0500571 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 -0500572 #add MPLS L3 VPN group
Flavio Castrod8f8af22015-12-02 18:19:26 -0500573 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 -0500574 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 -0500575 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
Flavio Castro80730822015-12-11 15:38:47 -0500576 do_barrier(self.controller)
Flavio Castro72a45d52015-12-02 16:37:05 -0500577 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500578 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 -0500579 #add termination flow
580 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro35e64392015-12-02 16:53:14 -0500581 #add routing flow
Flavio Castroaf2b4502016-02-02 17:41:32 -0500582 dst_ip = dip + (vlan_id<<8)
Flavio Castro5edf3132016-01-27 15:45:08 -0500583 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
584 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, vrf=2)
Flavio Castro80730822015-12-11 15:38:47 -0500585 #add entries in the Bridging table to avoid packet-in from mac learning
586 group_id = encode_l2_interface_group_id(vlan_id, port)
587 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
588
589 do_barrier(self.controller)
590
591 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
592 for in_port in ports:
593 mac_src='00:00:00:22:22:%02X' % in_port
594 ip_src='192.168.%02d.1' % in_port
595 for out_port in ports:
596 if in_port == out_port:
597 continue
598 ip_dst='192.168.%02d.1' % out_port
599 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
600 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
601 ip_dst=ip_dst)
602 pkt=str(parsed_pkt)
603 self.dataplane.send(in_port, pkt)
604 #build expect packet
605 mac_dst='00:00:00:22:22:%02X' % out_port
606 label = (out_port, 0, 1, 32)
607 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
608 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
609 pkt=str(exp_pkt)
610 verify_packet(self, pkt, out_port)
611 verify_no_other_packets(self)
castroflavioee294842016-01-06 15:54:28 -0800612
Flavio Castro80730822015-12-11 15:38:47 -0500613
Flavio Castro67d8bd52016-02-03 14:22:14 -0500614class _32VPN(base_tests.SimpleDataPlane):
Flavio Castro80730822015-12-11 15:38:47 -0500615 """
616 Insert IP packet
617 Receive MPLS packet
618 """
619 def runTest(self):
620 delete_all_flows(self.controller)
621 delete_all_groups(self.controller)
622
623 if len(config["port_map"]) <2:
624 logging.info("Port count less than 2, can't run this case")
625 return
626
627 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
628 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
629 dip=0xc0a80001
Flavio Castro67d8bd52016-02-03 14:22:14 -0500630 #Hashes Test Name and uses it as id for installing unique groups
Flavio Castro443c95e2016-02-03 15:05:28 -0500631 class_id=abs(hash(inspect.stack()[0][3])) % (256)
Flavio Castro80730822015-12-11 15:38:47 -0500632 ports = config["port_map"].keys()
633 for port in ports:
634 #add l2 interface group
Flavio Castro443c95e2016-02-03 15:05:28 -0500635 id=port+class_id<<8
Flavio Castro80730822015-12-11 15:38:47 -0500636 vlan_id=port
637 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
638 dst_mac[5]=vlan_id
639 #add MPLS interface group
Flavio Castro67d8bd52016-02-03 14:22:14 -0500640 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, id)
Flavio Castro80730822015-12-11 15:38:47 -0500641 #add MPLS L3 VPN group
642 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
Flavio Castro67d8bd52016-02-03 14:22:14 -0500643 index=id, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
Flavio Castro80730822015-12-11 15:38:47 -0500644 #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
645 do_barrier(self.controller)
646 #add vlan flow table
Flavio Castro67d8bd52016-02-03 14:22:14 -0500647 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castro80730822015-12-11 15:38:47 -0500648 #add termination flow
649 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
650 #add routing flow
651 dst_ip = dip + (vlan_id<<8)
Flavio Castro67d8bd52016-02-03 14:22:14 -0500652 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid)
Flavio Castro72a45d52015-12-02 16:37:05 -0500653
654 do_barrier(self.controller)
655
656 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
657 for in_port in ports:
Flavio Castro72a45d52015-12-02 16:37:05 -0500658 ip_src='192.168.%02d.1' % in_port
659 for out_port in ports:
660 if in_port == out_port:
661 continue
662 ip_dst='192.168.%02d.1' % out_port
663 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
Flavio Castro67d8bd52016-02-03 14:22:14 -0500664 eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src,
Flavio Castro72a45d52015-12-02 16:37:05 -0500665 ip_dst=ip_dst)
666 pkt=str(parsed_pkt)
667 self.dataplane.send(in_port, pkt)
668 #build expect packet
669 mac_dst='00:00:00:22:22:%02X' % out_port
670 label = (out_port, 0, 1, 32)
Flavio Castro34352e72015-12-07 20:01:51 -0500671 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 -0500672 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
673 pkt=str(exp_pkt)
674 verify_packet(self, pkt, out_port)
675 verify_no_other_packets(self)
Flavio Castro67d8bd52016-02-03 14:22:14 -0500676@disabled
677class UniqueMplsTermination(base_tests.SimpleDataPlane):
Flavio Castro34352e72015-12-07 20:01:51 -0500678 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500679 Insert IP packet
680 Receive MPLS packet
Flavio Castro34352e72015-12-07 20:01:51 -0500681 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500682 def runTest(self):
683 delete_all_flows(self.controller)
684 delete_all_groups(self.controller)
685
686 if len(config["port_map"]) <2:
687 logging.info("Port count less than 2, can't run this case")
688 return
689
690 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
691 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500692 mcast_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x01]
693
Flavio Castrod8f8af22015-12-02 18:19:26 -0500694 dip=0xc0a80001
695 index=1
696 ports = config["port_map"].keys()
697 for port in ports:
698 #add l2 interface group
699 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500700 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500701 dst_mac[5]=vlan_id
702 #add L3 Unicast group
Flavio Castro932014b2016-01-05 18:29:15 -0500703 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 -0500704 #add L3 ecmp group
705 ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500706 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500707 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500708 #add termination flow
Flavio Castro167f5bd2015-12-02 19:33:53 -0500709 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500710 #add routing flow
711 dst_ip = dip + (vlan_id<<8)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500712 add_mpls_flow(self.controller, ecmp_msg.group_id, port)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500713 #add entries in the Bridging table to avoid packet-in from mac learning
714 group_id = encode_l2_interface_group_id(vlan_id, port)
715 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
716
717 do_barrier(self.controller)
718
719 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
720 for in_port in ports:
721 mac_src='00:00:00:22:22:%02X' % in_port
722 ip_src='192.168.%02d.1' % in_port
723 for out_port in ports:
724 if in_port == out_port:
725 continue
726 ip_dst='192.168.%02d.1' % out_port
Flavio Castro167f5bd2015-12-02 19:33:53 -0500727
728 label = (out_port, 0, 1, 32)
729 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
730 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500731 pkt=str(parsed_pkt)
732 self.dataplane.send(in_port, pkt)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500733
Flavio Castrod8f8af22015-12-02 18:19:26 -0500734 #build expect packet
735 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500736 mcast='01:00:5e:00:00:01'
Flavio Castro167f5bd2015-12-02 19:33:53 -0500737 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castro932014b2016-01-05 18:29:15 -0500738 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 -0500739 pkt=str(exp_pkt)
740 verify_packet(self, pkt, out_port)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500741 verify_no_other_packets(self)
742
Flavio Castro80730822015-12-11 15:38:47 -0500743class MPLSBUG(base_tests.SimpleDataPlane):
744
745 def runTest(self):
746 delete_all_flows(self.controller)
747 delete_all_groups(self.controller)
748
749 if len(config["port_map"]) <2:
750 logging.info("Port count less than 2, can't run this case")
751 return
752
753 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
754 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
755 dip=0xc0a80001
756 index=1
757 ports = config["port_map"].keys()
758 for port in ports:
759 #add l2 interface group
760 vlan_id=port
761 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
762 dst_mac[5]=vlan_id
763 #add L3 Unicast group
764 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
765 #add vlan flow table
766 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
767 #add termination flow
768 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
769 #add mpls flow
770 add_mpls_flow(self.controller, l3_msg.group_id, port)
771 #add termination flow
772 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
773 #add unicast routing flow
774 dst_ip = dip + (vlan_id<<8)
Flavio Castroaf2b4502016-02-02 17:41:32 -0500775 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id)
Flavio Castro80730822015-12-11 15:38:47 -0500776
777 #add entries in the Bridging table to avoid packet-in from mac learning
778 group_id = encode_l2_interface_group_id(vlan_id, port)
779 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
780
781 do_barrier(self.controller)
782
783 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
784 for in_port in ports:
785 mac_src='00:00:00:22:22:%02X' % in_port
786 ip_src='192.168.%02d.1' % in_port
787 for out_port in ports:
788 if in_port == out_port:
789 continue
790 ip_dst='192.168.%02d.1' % out_port
791 switch_mac = "00:00:00:cc:cc:cc"
792 label = (out_port, 0, 1, 32)
793 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
794 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
795 pkt=str(parsed_pkt)
796 self.dataplane.send(in_port, pkt)
797
798 #build expect packet
799 mac_dst='00:00:00:22:22:%02X' % out_port
800 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
801 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst)
802 pkt=str(exp_pkt)
803 verify_packet(self, pkt, out_port)
804 verify_no_other_packets(self)
805
806 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
807 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
808 ip_dst=ip_dst)
809 pkt=str(parsed_pkt)
810 self.dataplane.send(in_port, pkt)
811 #build expected packet
812 mac_dst='00:00:00:22:22:%02X' % out_port
813 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
814 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
815 ip_src=ip_src, ip_dst=ip_dst)
816 pkt=str(exp_pkt)
817 verify_packet(self, pkt, out_port)
818 verify_no_other_packets(self)
819
Flavio Castro12296312015-12-15 17:48:26 -0500820class L3McastToL2(base_tests.SimpleDataPlane):
castroflaviocc403a92015-12-15 14:04:19 -0500821 """
Flavio Castro12296312015-12-15 17:48:26 -0500822 Mcast routing to L2
castroflaviocc403a92015-12-15 14:04:19 -0500823 """
824 def runTest(self):
825 """
826 port1 (vlan 300)-> All Ports (vlan 300)
827 """
Flavio Castro932014b2016-01-05 18:29:15 -0500828 #delete_all_flows(self.controller)
829 #delete_all_groups(self.controller)
castroflaviocc403a92015-12-15 14:04:19 -0500830
castroflavio4a09c962016-01-05 13:13:41 -0800831 if len(config["port_map"]) <3:
832 logging.info("Port count less than 3, can't run this case")
833 assert(False)
castroflaviocc403a92015-12-15 14:04:19 -0500834 return
835
836 vlan_id =300
837 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
838 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
839 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
840 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
841 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
842 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
843 src_ip=0xc0a80101
844 src_ip_str="192.168.1.1"
845 dst_ip=0xe0010101
846 dst_ip_str="224.1.1.1"
847
848 port1=config["port_map"].keys()[0]
849 port2=config["port_map"].keys()[1]
850
851 switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]
852
853
854 #add l2 interface group
855 l2_intf_group_list=[]
856 for port in config["port_map"].keys():
Flavio Castro932014b2016-01-05 18:29:15 -0500857 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=4)
castroflaviocc403a92015-12-15 14:04:19 -0500858 if port == port2:
859 continue
Flavio Castro12296312015-12-15 17:48:26 -0500860 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 -0500861 l2_intf_group_list.append(l2_intf_gid)
castroflaviocc403a92015-12-15 14:04:19 -0500862
863 #add termination flow
864 add_termination_flow(self.controller, port1, 0x0800, switch_mac, vlan_id)
865
866 #add l3 interface group
867 mcat_group_msg=add_l3_mcast_group(self.controller, vlan_id, 2, l2_intf_group_list)
868 add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id)
869
Flavio Castro932014b2016-01-05 18:29:15 -0500870 parsed_pkt = simple_udp_packet(pktlen=100,
871 dl_vlan_enable=True,
castroflaviocc403a92015-12-15 14:04:19 -0500872 eth_dst=dst_mac_str,
873 eth_src=port1_mac_str,
874 ip_ttl=64,
875 ip_src=src_ip_str,
876 ip_dst=dst_ip_str)
877 pkt=str(parsed_pkt)
878 self.dataplane.send(port1, pkt)
879 for port in config["port_map"].keys():
Flavio Castro12296312015-12-15 17:48:26 -0500880 if port == port2 or port == port1:
castroflaviocc403a92015-12-15 14:04:19 -0500881 verify_no_packet(self, pkt, port)
Flavio Castro12296312015-12-15 17:48:26 -0500882 continue
castroflaviocc403a92015-12-15 14:04:19 -0500883 verify_packet(self, pkt, port)
884 verify_no_other_packets(self)
885
Flavio Castro12296312015-12-15 17:48:26 -0500886class L3McastToL3(base_tests.SimpleDataPlane):
887 """
888 Mcast routing
889 """
890 def runTest(self):
891 """
892 port1 (vlan 1)-> port 2 (vlan 2)
893 """
894 delete_all_flows(self.controller)
895 delete_all_groups(self.controller)
896
897 if len(config["port_map"]) <3:
castroflavio4a09c962016-01-05 13:13:41 -0800898 logging.info("Port count less than 3, can't run this case")
899 assert(False)
Flavio Castro12296312015-12-15 17:48:26 -0500900 return
901
902 vlan_id =1
903 port2_out_vlan=2
904 port3_out_vlan=3
905 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
906 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
907 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
908 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
909 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
910 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
911 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
912 src_ip=0xc0a80101
913 src_ip_str="192.168.1.1"
914 dst_ip=0xe0010101
915 dst_ip_str="224.1.1.1"
916
917 port1=config["port_map"].keys()[0]
918 port2=config["port_map"].keys()[1]
919 port3=config["port_map"].keys()[2]
920
921 #add l2 interface group
922 for port in config["port_map"].keys():
923 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
924 #add vlan flow table
925 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
926 vlan_id +=1
927
928 #add termination flow
929 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
930
931 #add l3 interface group
932 port2_ucast_msg=add_l3_interface_group(self.controller, port2, port2_out_vlan, 2, intf_src_mac)
933 port3_ucast_msg=add_l3_interface_group(self.controller, port3, port3_out_vlan, 3, intf_src_mac)
934 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [port2_ucast_msg.group_id, port3_ucast_msg.group_id])
935 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
936
937 parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
938 eth_dst=dst_mac_str,
939 eth_src=port1_mac_str,
940 ip_ttl=64,
941 ip_src=src_ip_str,
942 ip_dst=dst_ip_str)
943 pkt=str(parsed_pkt)
944 self.dataplane.send(port1, pkt)
945 parsed_pkt = simple_udp_packet(pktlen=96,
946 eth_dst=dst_mac_str,
947 eth_src=intf_src_mac_str,
948 ip_ttl=63,
949 ip_src=src_ip_str,
950 ip_dst=dst_ip_str)
951 pkt=str(parsed_pkt)
952 verify_packet(self, pkt, port2)
953 verify_packet(self, pkt, port3)
954 verify_no_other_packets(self)
955
956class L3McastToVPN(base_tests.SimpleDataPlane):
957 """
958 Mcast routing
959 """
960 def runTest(self):
961 """
962 port1 (vlan 1)-> port 2 (vlan 2)
963 """
964 #delete_all_flows(self.controller)
965 #delete_all_groups(self.controller)
966
967 if len(config["port_map"]) <3:
castroflavio4a09c962016-01-05 13:13:41 -0800968 logging.info("Port count less than 3, can't run this case")
969 assert(False)
Flavio Castro12296312015-12-15 17:48:26 -0500970 return
971
972 vlan_id =1
973 port2_out_vlan=2
974 port3_out_vlan=3
975 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
976 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
977 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
978 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
979 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
980 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
981 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
982 src_ip=0xc0a80101
983 src_ip_str="192.168.1.1"
984 dst_ip=0xe0010101
985 dst_ip_str="224.1.1.1"
986
987 port1=config["port_map"].keys()[0]
988 port2=config["port_map"].keys()[1]
989 port3=config["port_map"].keys()[2]
990
991 #add l2 interface group
992 for port in config["port_map"].keys():
993 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
994 #add vlan flow table
995 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
996 vlan_id +=1
997
998 #add termination flow
999 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
1000
1001 #add MPLS interface group
1002 l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2)
1003 mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2)
1004 l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
1005 mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
1006 #add L3VPN groups
1007 mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
1008 index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True)
1009 mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
1010 index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
1011
Flavio Castro12296312015-12-15 17:48:26 -05001012 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023])
1013 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
1014
1015 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
1016 eth_dst=dst_mac_str,
1017 eth_src=port1_mac_str,
1018 ip_ttl=64,
1019 ip_src=src_ip_str,
1020 ip_dst=dst_ip_str)
1021 pkt=str(parsed_pkt)
1022 self.dataplane.send(port1, pkt)
1023 label = (in_vlan, 0, 1, 63)
1024 parsed_pkt = mpls_packet(pktlen=100,
1025 eth_dst=dst_mac_str,
1026 eth_src=intf_src_mac_str,
1027 ip_ttl=63,
1028 ip_src=src_ip_str, label= [label],
1029 ip_dst=dst_ip_str)
1030 pkt=str(parsed_pkt)
1031 verify_packet(self, pkt, port2)
1032 verify_packet(self, pkt, port3)
1033 verify_no_other_packets(self)
Flavio Castro67d8bd52016-02-03 14:22:14 -05001034@disabled
castroflavio30c6cc52016-01-07 15:19:42 -08001035class LPM(base_tests.SimpleDataPlane):
1036 """
1037 Insert IP packet
1038 Receive MPLS packet
1039 """
1040 def runTest(self):
1041 delete_all_flows(self.controller)
1042 delete_all_groups(self.controller)
1043
1044 if len(config["port_map"]) <2:
1045 logging.info("Port count less than 2, can't run this case")
1046 return
1047
1048 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1049 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
1050 dip=0xc0a80001
1051 index=1
1052 ports = config["port_map"].keys()
1053 for port in ports:
1054 #add l2 interface group
1055 vlan_id=port
1056 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
1057 dst_mac[5]=vlan_id
1058 #add MPLS interface group
1059 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
1060 #add MPLS L3 VPN group
1061 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
1062 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 -05001063 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
castroflavio30c6cc52016-01-07 15:19:42 -08001064 do_barrier(self.controller)
1065 #add vlan flow table
Flavio Castroaf2b4502016-02-02 17:41:32 -05001066 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_TAG)
castroflavio30c6cc52016-01-07 15:19:42 -08001067 #add termination flow
1068 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
1069 #add routing flow
1070 dst_ip = dip + (vlan_id<<8)
Flavio Castro5edf3132016-01-27 15:45:08 -05001071 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid, vrf=2)
Flavio Castroaf2b4502016-02-02 17:41:32 -05001072 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id)
castroflavio30c6cc52016-01-07 15:19:42 -08001073 #add entries in the Bridging table to avoid packet-in from mac learning
1074 group_id = encode_l2_interface_group_id(vlan_id, port)
1075 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
1076 port = ports[0]
1077 #add l2 interface group
1078 vlan_id=port
1079 l2_gid = encode_l2_interface_group_id(vlan_id, port)
1080 dst_mac[5]=vlan_id
1081 #add MPLS interface group
1082 mpls_gid = encode_mpls_interface_group_id(0, port)
1083 #add MPLS L3 VPN group
1084 mpls_label_gid = encode_mpls_label_group_id(OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=port)
Flavio Castro5edf3132016-01-27 15:45:08 -05001085 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
castroflavio30c6cc52016-01-07 15:19:42 -08001086 do_barrier(self.controller)
1087 #add routing flow
1088 dst_ip = 0x0
Flavio Castro5edf3132016-01-27 15:45:08 -05001089 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, mpls_label_gid, vrf=2)
Flavio Castroaf2b4502016-02-02 17:41:32 -05001090 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, ecmp_msg.group_id)
castroflavio30c6cc52016-01-07 15:19:42 -08001091
1092 do_barrier(self.controller)
1093
1094 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
1095 for in_port in ports:
1096 mac_src='00:00:00:22:22:%02X' % in_port
1097 ip_src='192.168.%02d.1' % in_port
1098 for out_port in ports:
1099 if in_port == out_port:
1100 continue
1101 ip_dst='192.168.%02d.1' % out_port
1102 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1103 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
1104 ip_dst=ip_dst)
1105 pkt=str(parsed_pkt)
1106 self.dataplane.send(in_port, pkt)
1107 #build expect packet
1108 mac_dst='00:00:00:22:22:%02X' % out_port
1109 label = (out_port, 0, 1, 32)
1110 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
1111 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
1112 pkt=str(exp_pkt)
1113 verify_packet(self, pkt, out_port)
1114 verify_no_other_packets(self)
Flavio Castroaf2b4502016-02-02 17:41:32 -05001115 ip_dst='1.168.%02d.1' % ports[0]
castroflavio30c6cc52016-01-07 15:19:42 -08001116 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
1117 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst)
1118 pkt=str(parsed_pkt)
1119 self.dataplane.send(in_port, pkt)
1120 #build expect packet
Flavio Castroaf2b4502016-02-02 17:41:32 -05001121 mac_dst='00:00:00:22:22:%02X' % ports[0]
1122 label = (ports[0], 0, 1, 32)
1123 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 -08001124 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
1125 pkt=str(exp_pkt)
Flavio Castroaf2b4502016-02-02 17:41:32 -05001126 verify_packet(self, pkt, ports[0])
castroflavio30c6cc52016-01-07 15:19:42 -08001127 verify_no_other_packets(self)