blob: 15006c9a493e257cd60f87baf2ebe8ea1c459d88 [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 Castroaabb5792015-11-18 19:03:50 -050024class PacketInSrcMacMiss(base_tests.SimpleDataPlane):
25 """
26 Test packet in function on a src-mac miss
27 Send a packet to each dataplane port and verify that a packet
28 in message is received from the controller for each
29 #todo verify you stop receiving after adding rule
30 """
31
Flavio Castro6efe1862015-11-18 16:28:06 -050032 def runTest(self):
33 delete_all_flows(self.controller)
34 delete_all_groups(self.controller)
35
Flavio Castro34352e72015-12-07 20:01:51 -050036 ports = sorted(config["port_map"].keys())
37 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -050038 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -050039 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
40
Flavio Castroaabb5792015-11-18 19:03:50 -050041 parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
42 vlan_vid=0x1001, dl_vlan_enable=True)
43 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6efe1862015-11-18 16:28:06 -050044
Flavio Castroaabb5792015-11-18 19:03:50 -050045 for of_port in config["port_map"].keys():
46 logging.info("PacketInMiss test, port %d", of_port)
47 self.dataplane.send(of_port, vlan_pkt)
48
49 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
50
51 verify_no_other_packets(self)
52
Flavio Castro7fb6ca92015-12-16 15:50:14 -050053class PacketInUDP(base_tests.SimpleDataPlane):
Flavio Castro6d498522015-12-15 14:05:04 -050054 """
55 Test packet in function for a table-miss flow
56 Send a packet to each dataplane port and verify that a packet
57 in message is received from the controller for each
58
59 NOTE: Verify This case the oft option shall not use --switch-ip
60 """
61
62 def runTest(self):
63 delete_all_flows(self.controller)
64 delete_all_groups(self.controller)
65
66 parsed_vlan_pkt = simple_udp_packet(pktlen=104,
67 vlan_vid=0x1001, dl_vlan_enable=True)
68 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6d498522015-12-15 14:05:04 -050069 # create match
70 match = ofp.match()
71 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
castroflavio4a09c962016-01-05 13:13:41 -080072 match.oxm_list.append(ofp.oxm.ip_proto(17))
Flavio Castro6d498522015-12-15 14:05:04 -050073 request = ofp.message.flow_add(
74 table_id=60,
75 cookie=42,
76 match=match,
77 instructions=[
78 ofp.instruction.apply_actions(
79 actions=[
80 ofp.action.output(
81 port=ofp.OFPP_CONTROLLER,
82 max_len=ofp.OFPCML_NO_BUFFER)]),
83 ],
84 buffer_id=ofp.OFP_NO_BUFFER,
85 priority=1)
86
87 logging.info("Inserting packet in flow to controller")
88 self.controller.message_send(request)
89 do_barrier(self.controller)
90
91 for of_port in config["port_map"].keys():
92 logging.info("PacketInMiss test, port %d", of_port)
93 self.dataplane.send(of_port, vlan_pkt)
94
95 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
96
97 verify_no_other_packets(self)
98
Flavio Castro7fb6ca92015-12-16 15:50:14 -050099class ArpNL2(base_tests.SimpleDataPlane):
100 def runTest(self):
101 delete_all_flows(self.controller)
102 delete_all_groups(self.controller)
103
104 ports = sorted(config["port_map"].keys())
105 match = ofp.match()
106 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
107 request = ofp.message.flow_add(
108 table_id=60,
109 cookie=42,
110 match=match,
111 instructions=[
112 ofp.instruction.apply_actions(
113 actions=[
114 ofp.action.output(
115 port=ofp.OFPP_CONTROLLER,
116 max_len=ofp.OFPCML_NO_BUFFER)]),
117 ],
118 buffer_id=ofp.OFP_NO_BUFFER,
119 priority=40000)
120 self.controller.message_send(request)
121 for port in ports:
Flavio Castro932014b2016-01-05 18:29:15 -0500122 add_one_l2_interface_group(self.controller, port, 1, False, False)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500123 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
124 group_id = encode_l2_interface_group_id(1, port)
125 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
126 do_barrier(self.controller)
127 parsed_arp_pkt = simple_arp_packet()
128 arp_pkt = str(parsed_arp_pkt)
129
130 for out_port in ports:
131 self.dataplane.send(out_port, arp_pkt)
132 verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION)
133 # change dest based on port number
134 mac_dst= '00:12:34:56:78:%02X' % out_port
135 for in_port in ports:
136 if in_port == out_port:
137 continue
138 # change source based on port number to avoid packet-ins from learning
139 mac_src= '00:12:34:56:78:%02X' % in_port
140 parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src)
141 pkt = str(parsed_pkt)
142 self.dataplane.send(in_port, pkt)
143
144 for ofport in ports:
145 if ofport in [out_port]:
146 verify_packet(self, pkt, ofport)
147 else:
148 verify_no_packet(self, pkt, ofport)
149
150 verify_no_other_packets(self)
151
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500152class PacketInArp(base_tests.SimpleDataPlane):
153 """
154 Test packet in function for a table-miss flow
155 Send a packet to each dataplane port and verify that a packet
156 in message is received from the controller for each
157
158 NOTE: Verify This case the oft option shall not use --switch-ip
159 """
160
161 def runTest(self):
162 delete_all_flows(self.controller)
163 delete_all_groups(self.controller)
164
165 parsed_arp_pkt = simple_arp_packet()
166 arp_pkt = str(parsed_arp_pkt)
167 ports = sorted(config["port_map"].keys())
168 #for port in ports:
169 # add_one_l2_interface_group(self.controller, port, 1, True, False)
170 # add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
171
172 # create match
173 match = ofp.match()
174 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
175 request = ofp.message.flow_add(
176 table_id=60,
177 cookie=42,
178 match=match,
179 instructions=[
180 ofp.instruction.apply_actions(
181 actions=[
182 ofp.action.output(
183 port=ofp.OFPP_CONTROLLER,
184 max_len=ofp.OFPCML_NO_BUFFER)]),
185 ],
186 buffer_id=ofp.OFP_NO_BUFFER,
187 priority=1)
188
189 logging.info("Inserting packet in flow to controller")
190 self.controller.message_send(request)
191 do_barrier(self.controller)
192
193 for of_port in config["port_map"].keys():
194 logging.info("PacketInMiss test, port %d", of_port)
195 self.dataplane.send(of_port, arp_pkt)
196
197 verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION)
198
199 verify_no_other_packets(self)
200
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500201class L2FloodQinQ(base_tests.SimpleDataPlane):
202 """
Flavio Castroc36621e2015-12-08 12:57:07 -0500203 Test L2 flood of double tagged vlan packets (802.1Q)
204 Sends a double tagged packet and verifies flooding behavior according to outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500205 """
206 def runTest(self):
207 ports = sorted(config["port_map"].keys())
208
209 delete_all_flows(self.controller)
210 delete_all_groups(self.controller)
211
212 # Installing flows to avoid packet-in
213 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500214 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500215 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
216
217 group_id = encode_l2_interface_group_id(1, port)
218 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
219 msg=add_l2_flood_group(self.controller, ports, 1, 1)
220 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
221 do_barrier(self.controller)
222
223 #verify flood
224 for ofport in ports:
225 # change dest based on port number
226 mac_src= '00:12:34:56:78:%02X' % ofport
227 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=1,
228 in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
229 pkt = str(parsed_pkt)
230 self.dataplane.send(ofport, pkt)
231 #self won't rx packet
232 verify_no_packet(self, pkt, ofport)
233 #others will rx packet
234 tmp_ports=list(ports)
235 tmp_ports.remove(ofport)
236 verify_packets(self, pkt, tmp_ports)
237
238 verify_no_other_packets(self)
239
Flavio Castro184cefe2015-11-19 20:52:49 -0500240class L2FloodTagged(base_tests.SimpleDataPlane):
241 """
242 Test L2 flood to a vlan
243 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
244 #todo take in account unknown src
245 """
246 def runTest(self):
247 ports = sorted(config["port_map"].keys())
Flavio Castro34352e72015-12-07 20:01:51 -0500248
Flavio Castro184cefe2015-11-19 20:52:49 -0500249 delete_all_flows(self.controller)
250 delete_all_groups(self.controller)
251
Flavio Castro184cefe2015-11-19 20:52:49 -0500252 # Installing flows to avoid packet-in
253 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500254 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500255 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
256
Flavio Castro184cefe2015-11-19 20:52:49 -0500257 group_id = encode_l2_interface_group_id(1, port)
258 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro34352e72015-12-07 20:01:51 -0500259 msg=add_l2_flood_group(self.controller, ports, 1, 1)
260 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
Flavio Castro184cefe2015-11-19 20:52:49 -0500261 do_barrier(self.controller)
262
263 #verify flood
264 for ofport in ports:
265 # change dest based on port number
266 mac_src= '00:12:34:56:78:%02X' % ofport
267 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
268 pkt = str(parsed_pkt)
269 self.dataplane.send(ofport, pkt)
270 #self won't rx packet
271 verify_no_packet(self, pkt, ofport)
272 #others will rx packet
273 tmp_ports=list(ports)
274 tmp_ports.remove(ofport)
275 verify_packets(self, pkt, tmp_ports)
276
277 verify_no_other_packets(self)
278
Flavio Castroaabb5792015-11-18 19:03:50 -0500279class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane):
280 """
281 Test L2 flood to a vlan
282 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
283 #todo take in account unknown src
284 """
285 def runTest(self):
Flavio Castroaabb5792015-11-18 19:03:50 -0500286 delete_all_flows(self.controller)
287 delete_all_groups(self.controller)
288
Flavio Castro34352e72015-12-07 20:01:51 -0500289 ports = sorted(config["port_map"].keys())
290 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500291 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500292 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500293
294 msg=add_l2_flood_group(self.controller, ports, 1, 1)
295 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
296
297 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a')
298 pkt = str(parsed_pkt)
299 #verify flood
300 for ofport in ports:
301 self.dataplane.send(ofport, pkt)
302 #self won't rx packet
303 verify_no_packet(self, pkt, ofport)
304 #others will rx packet
305 tmp_ports=list(ports)
306 tmp_ports.remove(ofport)
307 verify_packets(self, pkt, tmp_ports)
308
309 verify_no_other_packets(self)
310
Flavio Castroaabb5792015-11-18 19:03:50 -0500311class L2UnicastTagged(base_tests.SimpleDataPlane):
312 """
313 Test output function for an exact-match flow
314
315 For each port A, adds a flow directing matching packets to that port.
316 Then, for all other ports B != A, verifies that sending a matching packet
317 to B results in an output to A.
318 """
319 def runTest(self):
320 ports = sorted(config["port_map"].keys())
321
322 delete_all_flows(self.controller)
323 delete_all_groups(self.controller)
324
Flavio Castroaabb5792015-11-18 19:03:50 -0500325 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500326 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500327 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500328 group_id = encode_l2_interface_group_id(1, port)
329 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro6efe1862015-11-18 16:28:06 -0500330 do_barrier(self.controller)
331
Flavio Castroaabb5792015-11-18 19:03:50 -0500332 for out_port in ports:
333 # change dest based on port number
334 mac_dst= '00:12:34:56:78:%02X' % out_port
335 for in_port in ports:
336 if in_port == out_port:
337 continue
338 # change source based on port number to avoid packet-ins from learning
339 mac_src= '00:12:34:56:78:%02X' % in_port
340 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
341 pkt = str(parsed_pkt)
342 self.dataplane.send(in_port, pkt)
343
344 for ofport in ports:
345 if ofport in [out_port]:
346 verify_packet(self, pkt, ofport)
347 else:
348 verify_no_packet(self, pkt, ofport)
349
350 verify_no_other_packets(self)
Flavio Castro6efe1862015-11-18 16:28:06 -0500351
Flavio Castrob6773032015-11-19 22:49:24 -0500352class Mtu1500(base_tests.SimpleDataPlane):
353
354 def runTest(self):
355 ports = sorted(config["port_map"].keys())
356
357 delete_all_flows(self.controller)
358 delete_all_groups(self.controller)
359
Flavio Castro34352e72015-12-07 20:01:51 -0500360 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500361 add_l2_interface_group(self.controller, ports, 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500362
Flavio Castro34352e72015-12-07 20:01:51 -0500363 add_vlan_table_flow(self.controller, ports)
Flavio Castrob6773032015-11-19 22:49:24 -0500364
365 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500366 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500367 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500368 group_id = encode_l2_interface_group_id(1, port)
369 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
370 do_barrier(self.controller)
371
372 for out_port in ports:
373 # change dest based on port number
374 mac_dst= '00:12:34:56:78:%02X' % out_port
375 for in_port in ports:
376 if in_port == out_port:
377 continue
378 # change source based on port number to avoid packet-ins from learning
379 mac_src= '00:12:34:56:78:%02X' % in_port
380 parsed_pkt = simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
381 pkt = str(parsed_pkt)
382 self.dataplane.send(in_port, pkt)
383
384 for ofport in ports:
385 if ofport in [out_port]:
386 verify_packet(self, pkt, ofport)
387 else:
388 verify_no_packet(self, pkt, ofport)
389
390 verify_no_other_packets(self)
391
392
393class Mtu4000(base_tests.SimpleDataPlane):
394 """
395 Test output function for an exact-match flow
396 For each port A, adds a flow directing matching packets to that port.
397 Then, for all other ports B != A, verifies that sending a matching packet
398 to B results in an output to A.
399 """
400 def runTest(self):
401 ports = sorted(config["port_map"].keys())
402
403 delete_all_flows(self.controller)
404 delete_all_groups(self.controller)
405
406 add_vlan_table_flow(self.controller, config["port_map"].keys())
407
408 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500409 add_l2_interface_group(self.controller, config["port_map"].keys(), 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500410
411 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500412 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500413 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500414 group_id = encode_l2_interface_group_id(1, port)
415 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
416 do_barrier(self.controller)
417
418 for out_port in ports:
419 # change dest based on port number
420 mac_dst= '00:12:34:56:78:%02X' % out_port
421 for in_port in ports:
422 if in_port == out_port:
423 continue
424 # change source based on port number to avoid packet-ins from learning
425 mac_src= '00:12:34:56:78:%02X' % in_port
426 parsed_pkt = simple_tcp_packet(pktlen=4000,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
427 pkt = str(parsed_pkt)
428 self.dataplane.send(in_port, pkt)
429
430 for ofport in ports:
431 if ofport in [out_port]:
432 verify_packet(self, pkt, ofport)
433 else:
434 verify_no_packet(self, pkt, ofport)
435
436 verify_no_other_packets(self)
Flavio Castroaabb5792015-11-18 19:03:50 -0500437
438class L3UcastTagged(base_tests.SimpleDataPlane):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500439 """
Flavio Castro35e64392015-12-02 16:53:14 -0500440 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
441 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500442 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500443 def runTest(self):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500444 delete_all_flows(self.controller)
445 delete_all_groups(self.controller)
446
447 if len(config["port_map"]) <2:
448 logging.info("Port count less than 2, can't run this case")
449 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500450
Flavio Castro05d20bc2015-11-16 15:06:14 -0500451 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
452 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
453 dip=0xc0a80001
Flavio Castroa8233862015-12-02 14:41:11 -0500454 ports = config["port_map"].keys()
455 for port in ports:
Flavio Castro05d20bc2015-11-16 15:06:14 -0500456 #add l2 interface group
Flavio Castroa8233862015-12-02 14:41:11 -0500457 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500458 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 -0500459 dst_mac[5]=vlan_id
460 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
461 #add vlan flow table
Flavio Castro34352e72015-12-07 20:01:51 -0500462 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500463 #add termination flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500464 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500465 #add unicast routing flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500466 dst_ip = dip + (vlan_id<<8)
Flavio Castro6efe1862015-11-18 16:28:06 -0500467 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, l3_msg.group_id)
Flavio Castro6efe1862015-11-18 16:28:06 -0500468 #add entries in the Bridging table to avoid packet-in from mac learning
469 group_id = encode_l2_interface_group_id(vlan_id, port)
470 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500471
472 do_barrier(self.controller)
473
Flavio Castro05d20bc2015-11-16 15:06:14 -0500474 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
Flavio Castroa8233862015-12-02 14:41:11 -0500475 for in_port in ports:
476 mac_src='00:00:00:22:22:%02X' % in_port
477 ip_src='192.168.%02d.1' % in_port
478 for out_port in ports:
479 if in_port == out_port:
480 continue
481 ip_dst='192.168.%02d.1' % out_port
482 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
483 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
Flavio Castrod8f8af22015-12-02 18:19:26 -0500484 ip_dst=ip_dst)
Flavio Castroa8233862015-12-02 14:41:11 -0500485 pkt=str(parsed_pkt)
486 self.dataplane.send(in_port, pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500487 #build expected packet
Flavio Castroa8233862015-12-02 14:41:11 -0500488 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castrod8f8af22015-12-02 18:19:26 -0500489 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castroa8233862015-12-02 14:41:11 -0500490 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
491 ip_src=ip_src, ip_dst=ip_dst)
492 pkt=str(exp_pkt)
493 verify_packet(self, pkt, out_port)
494 verify_no_other_packets(self)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500495
Flavio Castrod8f8af22015-12-02 18:19:26 -0500496class L3VPNMPLS(base_tests.SimpleDataPlane):
497 """
498 Insert IP packet
499 Receive MPLS packet
500 """
Flavio Castro72a45d52015-12-02 16:37:05 -0500501 def runTest(self):
502 delete_all_flows(self.controller)
503 delete_all_groups(self.controller)
504
505 if len(config["port_map"]) <2:
506 logging.info("Port count less than 2, can't run this case")
507 return
508
509 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
510 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
511 dip=0xc0a80001
512 index=1
513 ports = config["port_map"].keys()
514 for port in ports:
515 #add l2 interface group
516 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500517 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
Flavio Castro72a45d52015-12-02 16:37:05 -0500518 dst_mac[5]=vlan_id
Flavio Castro35e64392015-12-02 16:53:14 -0500519 #add MPLS interface group
Flavio Castro72a45d52015-12-02 16:37:05 -0500520 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 -0500521 #add MPLS L3 VPN group
Flavio Castrod8f8af22015-12-02 18:19:26 -0500522 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 -0500523 index=port, 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 -0500524 #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
525 do_barrier(self.controller)
Flavio Castro72a45d52015-12-02 16:37:05 -0500526 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500527 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 -0500528 #add termination flow
529 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro35e64392015-12-02 16:53:14 -0500530 #add routing flow
Flavio Castro72a45d52015-12-02 16:37:05 -0500531 dst_ip = dip + (vlan_id<<8)
Flavio Castro80730822015-12-11 15:38:47 -0500532 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid, vrf=2)
533 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, vrf=2)
534 #add entries in the Bridging table to avoid packet-in from mac learning
535 group_id = encode_l2_interface_group_id(vlan_id, port)
536 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
castroflavioee294842016-01-06 15:54:28 -0800537 port = ports[0]
538 #add l2 interface group
539 vlan_id=port
540 l2_gid = encode_l2_interface_group_id(vlan_id, port)
541 dst_mac[5]=vlan_id
542 #add MPLS interface group
543 mpls_gid = encode_mpls_interface_group_id(0, port)
544 #add MPLS L3 VPN group
545 mpls_label_gid = encode_mpls_label_group_id(OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=port)
546 #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
547 do_barrier(self.controller)
548 #add routing flow
549 dst_ip = 0x0
550 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, mpls_label_gid, vrf=2)
551 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, vrf=2)
Flavio Castro80730822015-12-11 15:38:47 -0500552
553 do_barrier(self.controller)
554
555 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
556 for in_port in ports:
557 mac_src='00:00:00:22:22:%02X' % in_port
558 ip_src='192.168.%02d.1' % in_port
559 for out_port in ports:
560 if in_port == out_port:
561 continue
562 ip_dst='192.168.%02d.1' % out_port
563 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
564 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
565 ip_dst=ip_dst)
566 pkt=str(parsed_pkt)
567 self.dataplane.send(in_port, pkt)
568 #build expect packet
569 mac_dst='00:00:00:22:22:%02X' % out_port
570 label = (out_port, 0, 1, 32)
571 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
572 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
573 pkt=str(exp_pkt)
574 verify_packet(self, pkt, out_port)
575 verify_no_other_packets(self)
castroflavioee294842016-01-06 15:54:28 -0800576 ip_dst='1.168.%02d.1' % out_port
577 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
578 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst)
579 pkt=str(parsed_pkt)
580 self.dataplane.send(in_port, pkt)
581 #build expect packet
582 mac_dst='00:00:00:22:22:%02X' % out_port
583 label = (out_port, 0, 1, 32)
584 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
585 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
586 pkt=str(exp_pkt)
587 verify_packet(self, pkt, out_port)
588 verify_no_other_packets(self)
589
Flavio Castro80730822015-12-11 15:38:47 -0500590
591class L3VPN_32(base_tests.SimpleDataPlane):
592 """
593 Insert IP packet
594 Receive MPLS packet
595 """
596 def runTest(self):
597 delete_all_flows(self.controller)
598 delete_all_groups(self.controller)
599
600 if len(config["port_map"]) <2:
601 logging.info("Port count less than 2, can't run this case")
602 return
603
604 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
605 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
606 dip=0xc0a80001
607 index=1
608 ports = config["port_map"].keys()
609 for port in ports:
610 #add l2 interface group
611 vlan_id=port
612 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
613 dst_mac[5]=vlan_id
614 #add MPLS interface group
615 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
616 #add MPLS L3 VPN group
617 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
618 index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
619 #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
620 do_barrier(self.controller)
621 #add vlan flow table
622 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, flag=VLAN_TABLE_FLAG_ONLY_TAG)
623 #add termination flow
624 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
625 #add routing flow
626 dst_ip = dip + (vlan_id<<8)
627 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_gid, vrf=2)
628 #ecmp_msg.group_id, vrf=2)
Flavio Castro72a45d52015-12-02 16:37:05 -0500629 #add entries in the Bridging table to avoid packet-in from mac learning
630 group_id = encode_l2_interface_group_id(vlan_id, port)
631 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
632
633 do_barrier(self.controller)
634
635 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
636 for in_port in ports:
637 mac_src='00:00:00:22:22:%02X' % in_port
638 ip_src='192.168.%02d.1' % in_port
639 for out_port in ports:
640 if in_port == out_port:
641 continue
642 ip_dst='192.168.%02d.1' % out_port
643 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
644 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
645 ip_dst=ip_dst)
646 pkt=str(parsed_pkt)
647 self.dataplane.send(in_port, pkt)
648 #build expect packet
649 mac_dst='00:00:00:22:22:%02X' % out_port
650 label = (out_port, 0, 1, 32)
Flavio Castro34352e72015-12-07 20:01:51 -0500651 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 -0500652 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
653 pkt=str(exp_pkt)
654 verify_packet(self, pkt, out_port)
655 verify_no_other_packets(self)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500656
657class MplsTermination(base_tests.SimpleDataPlane):
Flavio Castro34352e72015-12-07 20:01:51 -0500658 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500659 Insert IP packet
660 Receive MPLS packet
Flavio Castro34352e72015-12-07 20:01:51 -0500661 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500662 def runTest(self):
663 delete_all_flows(self.controller)
664 delete_all_groups(self.controller)
665
666 if len(config["port_map"]) <2:
667 logging.info("Port count less than 2, can't run this case")
668 return
669
670 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
671 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500672 mcast_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x01]
673
Flavio Castrod8f8af22015-12-02 18:19:26 -0500674 dip=0xc0a80001
675 index=1
676 ports = config["port_map"].keys()
677 for port in ports:
678 #add l2 interface group
679 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500680 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500681 dst_mac[5]=vlan_id
682 #add L3 Unicast group
Flavio Castro932014b2016-01-05 18:29:15 -0500683 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 -0500684 #add L3 ecmp group
685 ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500686 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500687 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500688 #add termination flow
Flavio Castro167f5bd2015-12-02 19:33:53 -0500689 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500690 #add routing flow
691 dst_ip = dip + (vlan_id<<8)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500692 add_mpls_flow(self.controller, ecmp_msg.group_id, port)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500693 #add entries in the Bridging table to avoid packet-in from mac learning
694 group_id = encode_l2_interface_group_id(vlan_id, port)
695 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
696
697 do_barrier(self.controller)
698
699 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
700 for in_port in ports:
701 mac_src='00:00:00:22:22:%02X' % in_port
702 ip_src='192.168.%02d.1' % in_port
703 for out_port in ports:
704 if in_port == out_port:
705 continue
706 ip_dst='192.168.%02d.1' % out_port
Flavio Castro167f5bd2015-12-02 19:33:53 -0500707
708 label = (out_port, 0, 1, 32)
709 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
710 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500711 pkt=str(parsed_pkt)
712 self.dataplane.send(in_port, pkt)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500713
Flavio Castrod8f8af22015-12-02 18:19:26 -0500714 #build expect packet
715 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500716 mcast='01:00:5e:00:00:01'
Flavio Castro167f5bd2015-12-02 19:33:53 -0500717 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castro932014b2016-01-05 18:29:15 -0500718 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 -0500719 pkt=str(exp_pkt)
720 verify_packet(self, pkt, out_port)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500721 verify_no_other_packets(self)
722
Flavio Castro80730822015-12-11 15:38:47 -0500723class MPLSBUG(base_tests.SimpleDataPlane):
724
725 def runTest(self):
726 delete_all_flows(self.controller)
727 delete_all_groups(self.controller)
728
729 if len(config["port_map"]) <2:
730 logging.info("Port count less than 2, can't run this case")
731 return
732
733 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
734 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
735 dip=0xc0a80001
736 index=1
737 ports = config["port_map"].keys()
738 for port in ports:
739 #add l2 interface group
740 vlan_id=port
741 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
742 dst_mac[5]=vlan_id
743 #add L3 Unicast group
744 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
745 #add vlan flow table
746 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
747 #add termination flow
748 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
749 #add mpls flow
750 add_mpls_flow(self.controller, l3_msg.group_id, port)
751 #add termination flow
752 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
753 #add unicast routing flow
754 dst_ip = dip + (vlan_id<<8)
755 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, l3_msg.group_id)
756
757 #add entries in the Bridging table to avoid packet-in from mac learning
758 group_id = encode_l2_interface_group_id(vlan_id, port)
759 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
760
761 do_barrier(self.controller)
762
763 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
764 for in_port in ports:
765 mac_src='00:00:00:22:22:%02X' % in_port
766 ip_src='192.168.%02d.1' % in_port
767 for out_port in ports:
768 if in_port == out_port:
769 continue
770 ip_dst='192.168.%02d.1' % out_port
771 switch_mac = "00:00:00:cc:cc:cc"
772 label = (out_port, 0, 1, 32)
773 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
774 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
775 pkt=str(parsed_pkt)
776 self.dataplane.send(in_port, pkt)
777
778 #build expect packet
779 mac_dst='00:00:00:22:22:%02X' % out_port
780 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
781 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst)
782 pkt=str(exp_pkt)
783 verify_packet(self, pkt, out_port)
784 verify_no_other_packets(self)
785
786 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
787 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
788 ip_dst=ip_dst)
789 pkt=str(parsed_pkt)
790 self.dataplane.send(in_port, pkt)
791 #build expected packet
792 mac_dst='00:00:00:22:22:%02X' % out_port
793 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
794 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
795 ip_src=ip_src, ip_dst=ip_dst)
796 pkt=str(exp_pkt)
797 verify_packet(self, pkt, out_port)
798 verify_no_other_packets(self)
799
Flavio Castro12296312015-12-15 17:48:26 -0500800class L3McastToL2(base_tests.SimpleDataPlane):
castroflaviocc403a92015-12-15 14:04:19 -0500801 """
Flavio Castro12296312015-12-15 17:48:26 -0500802 Mcast routing to L2
castroflaviocc403a92015-12-15 14:04:19 -0500803 """
804 def runTest(self):
805 """
806 port1 (vlan 300)-> All Ports (vlan 300)
807 """
Flavio Castro932014b2016-01-05 18:29:15 -0500808 #delete_all_flows(self.controller)
809 #delete_all_groups(self.controller)
castroflaviocc403a92015-12-15 14:04:19 -0500810
castroflavio4a09c962016-01-05 13:13:41 -0800811 if len(config["port_map"]) <3:
812 logging.info("Port count less than 3, can't run this case")
813 assert(False)
castroflaviocc403a92015-12-15 14:04:19 -0500814 return
815
816 vlan_id =300
817 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
818 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
819 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
820 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
821 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
822 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
823 src_ip=0xc0a80101
824 src_ip_str="192.168.1.1"
825 dst_ip=0xe0010101
826 dst_ip_str="224.1.1.1"
827
828 port1=config["port_map"].keys()[0]
829 port2=config["port_map"].keys()[1]
830
831 switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]
832
833
834 #add l2 interface group
835 l2_intf_group_list=[]
836 for port in config["port_map"].keys():
Flavio Castro932014b2016-01-05 18:29:15 -0500837 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=4)
castroflaviocc403a92015-12-15 14:04:19 -0500838 if port == port2:
839 continue
Flavio Castro12296312015-12-15 17:48:26 -0500840 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 -0500841 l2_intf_group_list.append(l2_intf_gid)
castroflaviocc403a92015-12-15 14:04:19 -0500842
843 #add termination flow
844 add_termination_flow(self.controller, port1, 0x0800, switch_mac, vlan_id)
845
846 #add l3 interface group
847 mcat_group_msg=add_l3_mcast_group(self.controller, vlan_id, 2, l2_intf_group_list)
848 add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id)
849
Flavio Castro932014b2016-01-05 18:29:15 -0500850 parsed_pkt = simple_udp_packet(pktlen=100,
851 dl_vlan_enable=True,
castroflaviocc403a92015-12-15 14:04:19 -0500852 eth_dst=dst_mac_str,
853 eth_src=port1_mac_str,
854 ip_ttl=64,
855 ip_src=src_ip_str,
856 ip_dst=dst_ip_str)
857 pkt=str(parsed_pkt)
858 self.dataplane.send(port1, pkt)
859 for port in config["port_map"].keys():
Flavio Castro12296312015-12-15 17:48:26 -0500860 if port == port2 or port == port1:
castroflaviocc403a92015-12-15 14:04:19 -0500861 verify_no_packet(self, pkt, port)
Flavio Castro12296312015-12-15 17:48:26 -0500862 continue
castroflaviocc403a92015-12-15 14:04:19 -0500863 verify_packet(self, pkt, port)
864 verify_no_other_packets(self)
865
Flavio Castro12296312015-12-15 17:48:26 -0500866class L3McastToL3(base_tests.SimpleDataPlane):
867 """
868 Mcast routing
869 """
870 def runTest(self):
871 """
872 port1 (vlan 1)-> port 2 (vlan 2)
873 """
874 delete_all_flows(self.controller)
875 delete_all_groups(self.controller)
876
877 if len(config["port_map"]) <3:
castroflavio4a09c962016-01-05 13:13:41 -0800878 logging.info("Port count less than 3, can't run this case")
879 assert(False)
Flavio Castro12296312015-12-15 17:48:26 -0500880 return
881
882 vlan_id =1
883 port2_out_vlan=2
884 port3_out_vlan=3
885 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
886 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
887 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
888 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
889 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
890 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
891 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
892 src_ip=0xc0a80101
893 src_ip_str="192.168.1.1"
894 dst_ip=0xe0010101
895 dst_ip_str="224.1.1.1"
896
897 port1=config["port_map"].keys()[0]
898 port2=config["port_map"].keys()[1]
899 port3=config["port_map"].keys()[2]
900
901 #add l2 interface group
902 for port in config["port_map"].keys():
903 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
904 #add vlan flow table
905 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
906 vlan_id +=1
907
908 #add termination flow
909 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
910
911 #add l3 interface group
912 port2_ucast_msg=add_l3_interface_group(self.controller, port2, port2_out_vlan, 2, intf_src_mac)
913 port3_ucast_msg=add_l3_interface_group(self.controller, port3, port3_out_vlan, 3, intf_src_mac)
914 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [port2_ucast_msg.group_id, port3_ucast_msg.group_id])
915 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
916
917 parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
918 eth_dst=dst_mac_str,
919 eth_src=port1_mac_str,
920 ip_ttl=64,
921 ip_src=src_ip_str,
922 ip_dst=dst_ip_str)
923 pkt=str(parsed_pkt)
924 self.dataplane.send(port1, pkt)
925 parsed_pkt = simple_udp_packet(pktlen=96,
926 eth_dst=dst_mac_str,
927 eth_src=intf_src_mac_str,
928 ip_ttl=63,
929 ip_src=src_ip_str,
930 ip_dst=dst_ip_str)
931 pkt=str(parsed_pkt)
932 verify_packet(self, pkt, port2)
933 verify_packet(self, pkt, port3)
934 verify_no_other_packets(self)
935
936class L3McastToVPN(base_tests.SimpleDataPlane):
937 """
938 Mcast routing
939 """
940 def runTest(self):
941 """
942 port1 (vlan 1)-> port 2 (vlan 2)
943 """
944 #delete_all_flows(self.controller)
945 #delete_all_groups(self.controller)
946
947 if len(config["port_map"]) <3:
castroflavio4a09c962016-01-05 13:13:41 -0800948 logging.info("Port count less than 3, can't run this case")
949 assert(False)
Flavio Castro12296312015-12-15 17:48:26 -0500950 return
951
952 vlan_id =1
953 port2_out_vlan=2
954 port3_out_vlan=3
955 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
956 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
957 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
958 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
959 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
960 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
961 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
962 src_ip=0xc0a80101
963 src_ip_str="192.168.1.1"
964 dst_ip=0xe0010101
965 dst_ip_str="224.1.1.1"
966
967 port1=config["port_map"].keys()[0]
968 port2=config["port_map"].keys()[1]
969 port3=config["port_map"].keys()[2]
970
971 #add l2 interface group
972 for port in config["port_map"].keys():
973 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
974 #add vlan flow table
975 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
976 vlan_id +=1
977
978 #add termination flow
979 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
980
981 #add MPLS interface group
982 l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2)
983 mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2)
984 l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
985 mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
986 #add L3VPN groups
987 mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
988 index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True)
989 mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
990 index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
991
Flavio Castro12296312015-12-15 17:48:26 -0500992 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023])
993 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
994
995 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
996 eth_dst=dst_mac_str,
997 eth_src=port1_mac_str,
998 ip_ttl=64,
999 ip_src=src_ip_str,
1000 ip_dst=dst_ip_str)
1001 pkt=str(parsed_pkt)
1002 self.dataplane.send(port1, pkt)
1003 label = (in_vlan, 0, 1, 63)
1004 parsed_pkt = mpls_packet(pktlen=100,
1005 eth_dst=dst_mac_str,
1006 eth_src=intf_src_mac_str,
1007 ip_ttl=63,
1008 ip_src=src_ip_str, label= [label],
1009 ip_dst=dst_ip_str)
1010 pkt=str(parsed_pkt)
1011 verify_packet(self, pkt, port2)
1012 verify_packet(self, pkt, port3)
1013 verify_no_other_packets(self)