blob: 86c7053a50285c365662f51c07d93fc187f5fd5c [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 Castro05d20bc2015-11-16 15:06:14 -050024
Flavio Castroaabb5792015-11-18 19:03:50 -050025class PacketInSrcMacMiss(base_tests.SimpleDataPlane):
26 """
27 Test packet in function on a src-mac miss
28 Send a packet to each dataplane port and verify that a packet
29 in message is received from the controller for each
30 #todo verify you stop receiving after adding rule
31 """
32
Flavio Castro6efe1862015-11-18 16:28:06 -050033 def runTest(self):
34 delete_all_flows(self.controller)
35 delete_all_groups(self.controller)
36
Flavio Castro34352e72015-12-07 20:01:51 -050037 ports = sorted(config["port_map"].keys())
38 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -050039 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -050040 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
41
Flavio Castroaabb5792015-11-18 19:03:50 -050042 parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
43 vlan_vid=0x1001, dl_vlan_enable=True)
44 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6efe1862015-11-18 16:28:06 -050045
Flavio Castroaabb5792015-11-18 19:03:50 -050046 for of_port in config["port_map"].keys():
47 logging.info("PacketInMiss test, port %d", of_port)
48 self.dataplane.send(of_port, vlan_pkt)
49
50 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
51
52 verify_no_other_packets(self)
53
Flavio Castro6d498522015-12-15 14:05:04 -050054class PacketInMiss(base_tests.SimpleDataPlane):
55 """
56 Test packet in function for a table-miss flow
57 Send a packet to each dataplane port and verify that a packet
58 in message is received from the controller for each
59
60 NOTE: Verify This case the oft option shall not use --switch-ip
61 """
62
63 def runTest(self):
64 delete_all_flows(self.controller)
65 delete_all_groups(self.controller)
66
67 parsed_vlan_pkt = simple_udp_packet(pktlen=104,
68 vlan_vid=0x1001, dl_vlan_enable=True)
69 vlan_pkt = str(parsed_vlan_pkt)
70 ports = sorted(config["port_map"].keys())
71 for port in ports:
72 add_one_l2_interface_group(self.controller, port, 1, True, False)
73 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
74
75 # create match
76 match = ofp.match()
77 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
78 match.oxm_list.append(ofp.oxm.ip_proto(17))
79 request = ofp.message.flow_add(
80 table_id=60,
81 cookie=42,
82 match=match,
83 instructions=[
84 ofp.instruction.apply_actions(
85 actions=[
86 ofp.action.output(
87 port=ofp.OFPP_CONTROLLER,
88 max_len=ofp.OFPCML_NO_BUFFER)]),
89 ],
90 buffer_id=ofp.OFP_NO_BUFFER,
91 priority=1)
92
93 logging.info("Inserting packet in flow to controller")
94 self.controller.message_send(request)
95 do_barrier(self.controller)
96
97 for of_port in config["port_map"].keys():
98 logging.info("PacketInMiss test, port %d", of_port)
99 self.dataplane.send(of_port, vlan_pkt)
100
101 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
102
103 verify_no_other_packets(self)
104
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500105class VlanSupport(base_tests.SimpleDataPlane):
Flavio Castroc36621e2015-12-08 12:57:07 -0500106 """
castroflavio046c1fe2015-12-08 14:33:32 -0500107 Test L2 forwarding of both, untagged and double-tagged packets
Flavio Castroc36621e2015-12-08 12:57:07 -0500108 Sends a packet and expects the same packet on the other port
castroflavio046c1fe2015-12-08 14:33:32 -0500109 Repeats for double tagged
Flavio Castroc36621e2015-12-08 12:57:07 -0500110 """
Flavio Castrod4c44d12015-12-08 14:44:18 -0500111 def runTest(self):
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500112 delete_all_flows(self.controller)
113 delete_all_groups(self.controller)
114 ports = sorted(config["port_map"].keys())
115 # group table
116 # set up untag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500117 add_l2_interface_group(self.controller, config["port_map"].keys(), 4093, False, 1)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500118 for port in ports:
119 add_one_vlan_table_flow(self.controller, port, 4093, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
120 group_id = encode_l2_interface_group_id(4093, port)
121 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 4093, group_id, True)
122 #add flow match for vlan 300
castroflavio046c1fe2015-12-08 14:33:32 -0500123 add_one_l2_interface_group(self.controller, port, 300, True, False)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500124 add_one_vlan_table_flow(self.controller, port, 300, flag=VLAN_TABLE_FLAG_ONLY_TAG)
castroflavio046c1fe2015-12-08 14:33:32 -0500125 msg=add_l2_flood_group(self.controller, ports, 300, 1)
126 add_bridge_flow(self.controller, None, 300, msg.group_id, True)
castroflavio21894482015-12-08 15:29:55 -0500127 msg=add_l2_flood_group(self.controller, ports, 4093, 1)
128 add_bridge_flow(self.controller, None, 4093, msg.group_id, True)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500129 do_barrier(self.controller)
130
131 for out_port in ports:
132 # change dest based on port number
133 mac_dst= '00:12:34:56:78:%02X' % out_port
134
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
Flavio Castroc36621e2015-12-08 12:57:07 -0500140 #sends an untagged packet
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500141 parsed_pkt = simple_tcp_packet(dl_vlan_enable=False, vlan_vid=4093, eth_dst=mac_dst, eth_src=mac_src)
142 pkt = str(parsed_pkt)
143 logging.info("OutputExact test, ports %d to %d", in_port, out_port)
144 self.dataplane.send(in_port, pkt)
145
146 for ofport in ports:
147 if ofport in [out_port]:
148 verify_packet(self, pkt, ofport)
149 else:
150 verify_no_packet(self, pkt, ofport)
151
152 verify_no_other_packets(self)
castroflavio046c1fe2015-12-08 14:33:32 -0500153 # sends a double tagged packet
154 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=300,
155 in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500156 pkt = str(parsed_pkt)
157 logging.info("OutputExact test, ports %d to %d", in_port, out_port)
158 self.dataplane.send(in_port, pkt)
159
160 for ofport in ports:
161 if ofport in [out_port]:
162 verify_packet(self, pkt, ofport)
163 else:
164 verify_no_packet(self, pkt, ofport)
165
166 verify_no_other_packets(self)
167
168class L2FloodQinQ(base_tests.SimpleDataPlane):
169 """
Flavio Castroc36621e2015-12-08 12:57:07 -0500170 Test L2 flood of double tagged vlan packets (802.1Q)
171 Sends a double tagged packet and verifies flooding behavior according to outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500172 """
173 def runTest(self):
174 ports = sorted(config["port_map"].keys())
175
176 delete_all_flows(self.controller)
177 delete_all_groups(self.controller)
178
179 # Installing flows to avoid packet-in
180 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500181 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500182 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
183
184 group_id = encode_l2_interface_group_id(1, port)
185 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
186 msg=add_l2_flood_group(self.controller, ports, 1, 1)
187 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
188 do_barrier(self.controller)
189
190 #verify flood
191 for ofport in ports:
192 # change dest based on port number
193 mac_src= '00:12:34:56:78:%02X' % ofport
194 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=1,
195 in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
196 pkt = str(parsed_pkt)
197 self.dataplane.send(ofport, pkt)
198 #self won't rx packet
199 verify_no_packet(self, pkt, ofport)
200 #others will rx packet
201 tmp_ports=list(ports)
202 tmp_ports.remove(ofport)
203 verify_packets(self, pkt, tmp_ports)
204
205 verify_no_other_packets(self)
206
207
Flavio Castro184cefe2015-11-19 20:52:49 -0500208class L2FloodTagged(base_tests.SimpleDataPlane):
209 """
210 Test L2 flood to a vlan
211 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
212 #todo take in account unknown src
213 """
214 def runTest(self):
215 ports = sorted(config["port_map"].keys())
Flavio Castro34352e72015-12-07 20:01:51 -0500216
Flavio Castro184cefe2015-11-19 20:52:49 -0500217 delete_all_flows(self.controller)
218 delete_all_groups(self.controller)
219
Flavio Castro184cefe2015-11-19 20:52:49 -0500220 # Installing flows to avoid packet-in
221 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500222 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500223 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
224
Flavio Castro184cefe2015-11-19 20:52:49 -0500225 group_id = encode_l2_interface_group_id(1, port)
226 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro34352e72015-12-07 20:01:51 -0500227 msg=add_l2_flood_group(self.controller, ports, 1, 1)
228 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
Flavio Castro184cefe2015-11-19 20:52:49 -0500229 do_barrier(self.controller)
230
231 #verify flood
232 for ofport in ports:
233 # change dest based on port number
234 mac_src= '00:12:34:56:78:%02X' % ofport
235 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
236 pkt = str(parsed_pkt)
237 self.dataplane.send(ofport, pkt)
238 #self won't rx packet
239 verify_no_packet(self, pkt, ofport)
240 #others will rx packet
241 tmp_ports=list(ports)
242 tmp_ports.remove(ofport)
243 verify_packets(self, pkt, tmp_ports)
244
245 verify_no_other_packets(self)
246
Flavio Castroaabb5792015-11-18 19:03:50 -0500247class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane):
248 """
249 Test L2 flood to a vlan
250 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
251 #todo take in account unknown src
252 """
253 def runTest(self):
Flavio Castroaabb5792015-11-18 19:03:50 -0500254 delete_all_flows(self.controller)
255 delete_all_groups(self.controller)
256
Flavio Castro34352e72015-12-07 20:01:51 -0500257 ports = sorted(config["port_map"].keys())
258 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500259 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500260 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500261
262 msg=add_l2_flood_group(self.controller, ports, 1, 1)
263 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
264
265 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a')
266 pkt = str(parsed_pkt)
267 #verify flood
268 for ofport in ports:
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 L2UnicastTagged(base_tests.SimpleDataPlane):
280 """
281 Test output function for an exact-match flow
282
283 For each port A, adds a flow directing matching packets to that port.
284 Then, for all other ports B != A, verifies that sending a matching packet
285 to B results in an output to A.
286 """
287 def runTest(self):
288 ports = sorted(config["port_map"].keys())
289
290 delete_all_flows(self.controller)
291 delete_all_groups(self.controller)
292
Flavio Castroaabb5792015-11-18 19:03:50 -0500293 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500294 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500295 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500296 group_id = encode_l2_interface_group_id(1, port)
297 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro6efe1862015-11-18 16:28:06 -0500298 do_barrier(self.controller)
299
Flavio Castroaabb5792015-11-18 19:03:50 -0500300 for out_port in ports:
301 # change dest based on port number
302 mac_dst= '00:12:34:56:78:%02X' % out_port
303 for in_port in ports:
304 if in_port == out_port:
305 continue
306 # change source based on port number to avoid packet-ins from learning
307 mac_src= '00:12:34:56:78:%02X' % in_port
308 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
309 pkt = str(parsed_pkt)
310 self.dataplane.send(in_port, pkt)
311
312 for ofport in ports:
313 if ofport in [out_port]:
314 verify_packet(self, pkt, ofport)
315 else:
316 verify_no_packet(self, pkt, ofport)
317
318 verify_no_other_packets(self)
Flavio Castro6efe1862015-11-18 16:28:06 -0500319
320
Flavio Castrob6773032015-11-19 22:49:24 -0500321class Mtu4500(base_tests.SimpleDataPlane):
322
323 def runTest(self):
324 ports = sorted(config["port_map"].keys())
325
326 delete_all_flows(self.controller)
327 delete_all_groups(self.controller)
328
Flavio Castrob6773032015-11-19 22:49:24 -0500329 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500330 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500331 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500332 group_id = encode_l2_interface_group_id(1, port)
333 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
334 do_barrier(self.controller)
335
336 for out_port in ports:
337 # change dest based on port number
338 mac_dst= '00:12:34:56:78:%02X' % out_port
339 for in_port in ports:
340 if in_port == out_port:
341 continue
342 # change source based on port number to avoid packet-ins from learning
343 mac_src= '00:12:34:56:78:%02X' % in_port
344 parsed_pkt = simple_tcp_packet(pktlen=4500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
345 pkt = str(parsed_pkt)
346 self.dataplane.send(in_port, pkt)
347
348 for ofport in ports:
349 if ofport in [out_port]:
350 verify_packet(self, pkt, ofport)
351 else:
352 verify_no_packet(self, pkt, ofport)
353
354 verify_no_other_packets(self)
355
356
357class Mtu1500(base_tests.SimpleDataPlane):
358
359 def runTest(self):
360 ports = sorted(config["port_map"].keys())
361
362 delete_all_flows(self.controller)
363 delete_all_groups(self.controller)
364
Flavio Castro34352e72015-12-07 20:01:51 -0500365 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500366 add_l2_interface_group(self.controller, ports, 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500367
Flavio Castro34352e72015-12-07 20:01:51 -0500368 add_vlan_table_flow(self.controller, ports)
Flavio Castrob6773032015-11-19 22:49:24 -0500369
370 for port in ports:
castroflaviodd171472015-12-08 13:55:58 -0500371 add_one_l2_interface_group(self.controller, port, 1, True, False)
Flavio Castro34352e72015-12-07 20:01:51 -0500372 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500373 group_id = encode_l2_interface_group_id(1, port)
374 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
375 do_barrier(self.controller)
376
377 for out_port in ports:
378 # change dest based on port number
379 mac_dst= '00:12:34:56:78:%02X' % out_port
380 for in_port in ports:
381 if in_port == out_port:
382 continue
383 # change source based on port number to avoid packet-ins from learning
384 mac_src= '00:12:34:56:78:%02X' % in_port
385 parsed_pkt = simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
386 pkt = str(parsed_pkt)
387 self.dataplane.send(in_port, pkt)
388
389 for ofport in ports:
390 if ofport in [out_port]:
391 verify_packet(self, pkt, ofport)
392 else:
393 verify_no_packet(self, pkt, ofport)
394
395 verify_no_other_packets(self)
396
397
398class Mtu4000(base_tests.SimpleDataPlane):
399 """
400 Test output function for an exact-match flow
401 For each port A, adds a flow directing matching packets to that port.
402 Then, for all other ports B != A, verifies that sending a matching packet
403 to B results in an output to A.
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
411 add_vlan_table_flow(self.controller, config["port_map"].keys())
412
413 # set up tag groups for each port
Flavio Castrod4c44d12015-12-08 14:44:18 -0500414 add_l2_interface_group(self.controller, config["port_map"].keys(), 1, True, 1)
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=4000,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)
Flavio Castroaabb5792015-11-18 19:03:50 -0500442
443class L3UcastTagged(base_tests.SimpleDataPlane):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500444 """
Flavio Castro35e64392015-12-02 16:53:14 -0500445 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
446 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500447 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500448 def runTest(self):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500449 delete_all_flows(self.controller)
450 delete_all_groups(self.controller)
451
452 if len(config["port_map"]) <2:
453 logging.info("Port count less than 2, can't run this case")
454 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500455
Flavio Castro05d20bc2015-11-16 15:06:14 -0500456 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
457 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
458 dip=0xc0a80001
Flavio Castroa8233862015-12-02 14:41:11 -0500459 ports = config["port_map"].keys()
460 for port in ports:
Flavio Castro05d20bc2015-11-16 15:06:14 -0500461 #add l2 interface group
Flavio Castroa8233862015-12-02 14:41:11 -0500462 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500463 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 -0500464 dst_mac[5]=vlan_id
465 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
466 #add vlan flow table
Flavio Castro34352e72015-12-07 20:01:51 -0500467 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500468 #add termination flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500469 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500470 #add unicast routing flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500471 dst_ip = dip + (vlan_id<<8)
Flavio Castro6efe1862015-11-18 16:28:06 -0500472 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, l3_msg.group_id)
Flavio Castro6efe1862015-11-18 16:28:06 -0500473 #add entries in the Bridging table to avoid packet-in from mac learning
474 group_id = encode_l2_interface_group_id(vlan_id, port)
475 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500476
477 do_barrier(self.controller)
478
Flavio Castro05d20bc2015-11-16 15:06:14 -0500479 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
Flavio Castroa8233862015-12-02 14:41:11 -0500480 for in_port in ports:
481 mac_src='00:00:00:22:22:%02X' % in_port
482 ip_src='192.168.%02d.1' % in_port
483 for out_port in ports:
484 if in_port == out_port:
485 continue
486 ip_dst='192.168.%02d.1' % out_port
487 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
488 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
Flavio Castrod8f8af22015-12-02 18:19:26 -0500489 ip_dst=ip_dst)
Flavio Castroa8233862015-12-02 14:41:11 -0500490 pkt=str(parsed_pkt)
491 self.dataplane.send(in_port, pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500492 #build expected packet
Flavio Castroa8233862015-12-02 14:41:11 -0500493 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castrod8f8af22015-12-02 18:19:26 -0500494 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castroa8233862015-12-02 14:41:11 -0500495 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
496 ip_src=ip_src, ip_dst=ip_dst)
497 pkt=str(exp_pkt)
498 verify_packet(self, pkt, out_port)
499 verify_no_other_packets(self)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500500
Flavio Castrod8f8af22015-12-02 18:19:26 -0500501class L3VPNMPLS(base_tests.SimpleDataPlane):
502 """
503 Insert IP packet
504 Receive MPLS packet
505 """
Flavio Castro72a45d52015-12-02 16:37:05 -0500506 def runTest(self):
507 delete_all_flows(self.controller)
508 delete_all_groups(self.controller)
509
510 if len(config["port_map"]) <2:
511 logging.info("Port count less than 2, can't run this case")
512 return
513
514 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
515 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
516 dip=0xc0a80001
517 index=1
518 ports = config["port_map"].keys()
519 for port in ports:
520 #add l2 interface group
521 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500522 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
Flavio Castro72a45d52015-12-02 16:37:05 -0500523 dst_mac[5]=vlan_id
Flavio Castro35e64392015-12-02 16:53:14 -0500524 #add MPLS interface group
Flavio Castro72a45d52015-12-02 16:37:05 -0500525 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 -0500526 #add MPLS L3 VPN group
Flavio Castrod8f8af22015-12-02 18:19:26 -0500527 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 -0500528 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 -0500529 #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
530 do_barrier(self.controller)
Flavio Castro72a45d52015-12-02 16:37:05 -0500531 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500532 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 -0500533 #add termination flow
534 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro35e64392015-12-02 16:53:14 -0500535 #add routing flow
Flavio Castro72a45d52015-12-02 16:37:05 -0500536 dst_ip = dip + (vlan_id<<8)
Flavio Castro80730822015-12-11 15:38:47 -0500537 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid, vrf=2)
538 #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, vrf=2)
539 #add entries in the Bridging table to avoid packet-in from mac learning
540 group_id = encode_l2_interface_group_id(vlan_id, port)
541 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
542
543 do_barrier(self.controller)
544
545 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
546 for in_port in ports:
547 mac_src='00:00:00:22:22:%02X' % in_port
548 ip_src='192.168.%02d.1' % in_port
549 for out_port in ports:
550 if in_port == out_port:
551 continue
552 ip_dst='192.168.%02d.1' % out_port
553 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
554 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
555 ip_dst=ip_dst)
556 pkt=str(parsed_pkt)
557 self.dataplane.send(in_port, pkt)
558 #build expect packet
559 mac_dst='00:00:00:22:22:%02X' % out_port
560 label = (out_port, 0, 1, 32)
561 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
562 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
563 pkt=str(exp_pkt)
564 verify_packet(self, pkt, out_port)
565 verify_no_other_packets(self)
566
567class L3VPN_32(base_tests.SimpleDataPlane):
568 """
569 Insert IP packet
570 Receive MPLS packet
571 """
572 def runTest(self):
573 delete_all_flows(self.controller)
574 delete_all_groups(self.controller)
575
576 if len(config["port_map"]) <2:
577 logging.info("Port count less than 2, can't run this case")
578 return
579
580 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
581 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
582 dip=0xc0a80001
583 index=1
584 ports = config["port_map"].keys()
585 for port in ports:
586 #add l2 interface group
587 vlan_id=port
588 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True)
589 dst_mac[5]=vlan_id
590 #add MPLS interface group
591 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
592 #add MPLS L3 VPN group
593 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
594 index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
595 #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
596 do_barrier(self.controller)
597 #add vlan flow table
598 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, flag=VLAN_TABLE_FLAG_ONLY_TAG)
599 #add termination flow
600 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
601 #add routing flow
602 dst_ip = dip + (vlan_id<<8)
603 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_gid, vrf=2)
604 #ecmp_msg.group_id, vrf=2)
Flavio Castro72a45d52015-12-02 16:37:05 -0500605 #add entries in the Bridging table to avoid packet-in from mac learning
606 group_id = encode_l2_interface_group_id(vlan_id, port)
607 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
608
609 do_barrier(self.controller)
610
611 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
612 for in_port in ports:
613 mac_src='00:00:00:22:22:%02X' % in_port
614 ip_src='192.168.%02d.1' % in_port
615 for out_port in ports:
616 if in_port == out_port:
617 continue
618 ip_dst='192.168.%02d.1' % out_port
619 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
620 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
621 ip_dst=ip_dst)
622 pkt=str(parsed_pkt)
623 self.dataplane.send(in_port, pkt)
624 #build expect packet
625 mac_dst='00:00:00:22:22:%02X' % out_port
626 label = (out_port, 0, 1, 32)
Flavio Castro34352e72015-12-07 20:01:51 -0500627 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 -0500628 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
629 pkt=str(exp_pkt)
630 verify_packet(self, pkt, out_port)
631 verify_no_other_packets(self)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500632
633class MplsTermination(base_tests.SimpleDataPlane):
Flavio Castro34352e72015-12-07 20:01:51 -0500634 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500635 Insert IP packet
636 Receive MPLS packet
Flavio Castro34352e72015-12-07 20:01:51 -0500637 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500638 def runTest(self):
639 delete_all_flows(self.controller)
640 delete_all_groups(self.controller)
641
642 if len(config["port_map"]) <2:
643 logging.info("Port count less than 2, can't run this case")
644 return
645
646 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
647 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
648 dip=0xc0a80001
649 index=1
650 ports = config["port_map"].keys()
651 for port in ports:
652 #add l2 interface group
653 vlan_id=port
castroflaviodd171472015-12-08 13:55:58 -0500654 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500655 dst_mac[5]=vlan_id
656 #add L3 Unicast group
657 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 -0500658 #add L3 ecmp group
659 ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500660 #add vlan flow table
Flavio Castro80730822015-12-11 15:38:47 -0500661 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500662 #add termination flow
Flavio Castro167f5bd2015-12-02 19:33:53 -0500663 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500664 #add routing flow
665 dst_ip = dip + (vlan_id<<8)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500666 add_mpls_flow(self.controller, ecmp_msg.group_id, port)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500667 #add entries in the Bridging table to avoid packet-in from mac learning
668 group_id = encode_l2_interface_group_id(vlan_id, port)
669 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
670
671 do_barrier(self.controller)
672
673 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
674 for in_port in ports:
675 mac_src='00:00:00:22:22:%02X' % in_port
676 ip_src='192.168.%02d.1' % in_port
677 for out_port in ports:
678 if in_port == out_port:
679 continue
680 ip_dst='192.168.%02d.1' % out_port
Flavio Castro167f5bd2015-12-02 19:33:53 -0500681
682 label = (out_port, 0, 1, 32)
683 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
684 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500685 pkt=str(parsed_pkt)
686 self.dataplane.send(in_port, pkt)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500687
Flavio Castrod8f8af22015-12-02 18:19:26 -0500688 #build expect packet
689 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castro167f5bd2015-12-02 19:33:53 -0500690 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
691 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 -0500692 pkt=str(exp_pkt)
693 verify_packet(self, pkt, out_port)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500694 verify_no_other_packets(self)
695
Flavio Castro80730822015-12-11 15:38:47 -0500696class MPLSBUG(base_tests.SimpleDataPlane):
697
698 def runTest(self):
699 delete_all_flows(self.controller)
700 delete_all_groups(self.controller)
701
702 if len(config["port_map"]) <2:
703 logging.info("Port count less than 2, can't run this case")
704 return
705
706 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
707 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
708 dip=0xc0a80001
709 index=1
710 ports = config["port_map"].keys()
711 for port in ports:
712 #add l2 interface group
713 vlan_id=port
714 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False)
715 dst_mac[5]=vlan_id
716 #add L3 Unicast group
717 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
718 #add vlan flow table
719 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
720 #add termination flow
721 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
722 #add mpls flow
723 add_mpls_flow(self.controller, l3_msg.group_id, port)
724 #add termination flow
725 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
726 #add unicast routing flow
727 dst_ip = dip + (vlan_id<<8)
728 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, l3_msg.group_id)
729
730 #add entries in the Bridging table to avoid packet-in from mac learning
731 group_id = encode_l2_interface_group_id(vlan_id, port)
732 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
733
734 do_barrier(self.controller)
735
736 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
737 for in_port in ports:
738 mac_src='00:00:00:22:22:%02X' % in_port
739 ip_src='192.168.%02d.1' % in_port
740 for out_port in ports:
741 if in_port == out_port:
742 continue
743 ip_dst='192.168.%02d.1' % out_port
744 switch_mac = "00:00:00:cc:cc:cc"
745 label = (out_port, 0, 1, 32)
746 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
747 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
748 pkt=str(parsed_pkt)
749 self.dataplane.send(in_port, pkt)
750
751 #build expect packet
752 mac_dst='00:00:00:22:22:%02X' % out_port
753 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
754 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst)
755 pkt=str(exp_pkt)
756 verify_packet(self, pkt, out_port)
757 verify_no_other_packets(self)
758
759 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
760 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
761 ip_dst=ip_dst)
762 pkt=str(parsed_pkt)
763 self.dataplane.send(in_port, pkt)
764 #build expected packet
765 mac_dst='00:00:00:22:22:%02X' % out_port
766 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
767 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
768 ip_src=ip_src, ip_dst=ip_dst)
769 pkt=str(exp_pkt)
770 verify_packet(self, pkt, out_port)
771 verify_no_other_packets(self)
772
Flavio Castro12296312015-12-15 17:48:26 -0500773class L3McastToL2(base_tests.SimpleDataPlane):
castroflaviocc403a92015-12-15 14:04:19 -0500774 """
Flavio Castro12296312015-12-15 17:48:26 -0500775 Mcast routing to L2
castroflaviocc403a92015-12-15 14:04:19 -0500776 """
777 def runTest(self):
778 """
779 port1 (vlan 300)-> All Ports (vlan 300)
780 """
781 delete_all_flows(self.controller)
782 delete_all_groups(self.controller)
783
784 if len(config["port_map"]) <2:
785 logging.info("Port count less than 2, can't run this case")
786 return
787
788 vlan_id =300
789 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
790 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
791 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
792 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
793 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
794 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
795 src_ip=0xc0a80101
796 src_ip_str="192.168.1.1"
797 dst_ip=0xe0010101
798 dst_ip_str="224.1.1.1"
799
800 port1=config["port_map"].keys()[0]
801 port2=config["port_map"].keys()[1]
802
803 switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]
804
805
806 #add l2 interface group
807 l2_intf_group_list=[]
808 for port in config["port_map"].keys():
809 if port == port2:
810 continue
Flavio Castro12296312015-12-15 17:48:26 -0500811 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 -0500812 l2_intf_group_list.append(l2_intf_gid)
813 #add vlan flow table
814 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
815
816 #add termination flow
817 add_termination_flow(self.controller, port1, 0x0800, switch_mac, vlan_id)
818
819 #add l3 interface group
820 mcat_group_msg=add_l3_mcast_group(self.controller, vlan_id, 2, l2_intf_group_list)
821 add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id)
822
823 parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=300,
824 eth_dst=dst_mac_str,
825 eth_src=port1_mac_str,
826 ip_ttl=64,
827 ip_src=src_ip_str,
828 ip_dst=dst_ip_str)
829 pkt=str(parsed_pkt)
830 self.dataplane.send(port1, pkt)
831 for port in config["port_map"].keys():
Flavio Castro12296312015-12-15 17:48:26 -0500832 if port == port2 or port == port1:
castroflaviocc403a92015-12-15 14:04:19 -0500833 verify_no_packet(self, pkt, port)
Flavio Castro12296312015-12-15 17:48:26 -0500834 continue
castroflaviocc403a92015-12-15 14:04:19 -0500835 verify_packet(self, pkt, port)
836 verify_no_other_packets(self)
837
Flavio Castro12296312015-12-15 17:48:26 -0500838class L3McastToL3(base_tests.SimpleDataPlane):
839 """
840 Mcast routing
841 """
842 def runTest(self):
843 """
844 port1 (vlan 1)-> port 2 (vlan 2)
845 """
846 delete_all_flows(self.controller)
847 delete_all_groups(self.controller)
848
849 if len(config["port_map"]) <3:
850 logging.info("Port count less than 2, can't run this case")
851 return
852
853 vlan_id =1
854 port2_out_vlan=2
855 port3_out_vlan=3
856 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
857 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
858 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
859 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
860 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
861 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
862 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
863 src_ip=0xc0a80101
864 src_ip_str="192.168.1.1"
865 dst_ip=0xe0010101
866 dst_ip_str="224.1.1.1"
867
868 port1=config["port_map"].keys()[0]
869 port2=config["port_map"].keys()[1]
870 port3=config["port_map"].keys()[2]
871
872 #add l2 interface group
873 for port in config["port_map"].keys():
874 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
875 #add vlan flow table
876 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
877 vlan_id +=1
878
879 #add termination flow
880 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
881
882 #add l3 interface group
883 port2_ucast_msg=add_l3_interface_group(self.controller, port2, port2_out_vlan, 2, intf_src_mac)
884 port3_ucast_msg=add_l3_interface_group(self.controller, port3, port3_out_vlan, 3, intf_src_mac)
885 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [port2_ucast_msg.group_id, port3_ucast_msg.group_id])
886 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
887
888 parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
889 eth_dst=dst_mac_str,
890 eth_src=port1_mac_str,
891 ip_ttl=64,
892 ip_src=src_ip_str,
893 ip_dst=dst_ip_str)
894 pkt=str(parsed_pkt)
895 self.dataplane.send(port1, pkt)
896 parsed_pkt = simple_udp_packet(pktlen=96,
897 eth_dst=dst_mac_str,
898 eth_src=intf_src_mac_str,
899 ip_ttl=63,
900 ip_src=src_ip_str,
901 ip_dst=dst_ip_str)
902 pkt=str(parsed_pkt)
903 verify_packet(self, pkt, port2)
904 verify_packet(self, pkt, port3)
905 verify_no_other_packets(self)
906
907class L3McastToVPN(base_tests.SimpleDataPlane):
908 """
909 Mcast routing
910 """
911 def runTest(self):
912 """
913 port1 (vlan 1)-> port 2 (vlan 2)
914 """
915 #delete_all_flows(self.controller)
916 #delete_all_groups(self.controller)
917
918 if len(config["port_map"]) <3:
919 logging.info("Port count less than 2, can't run this case")
920 return
921
922 vlan_id =1
923 port2_out_vlan=2
924 port3_out_vlan=3
925 in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
926 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
927 intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
928 dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
929 dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
930 port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
931 port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
932 src_ip=0xc0a80101
933 src_ip_str="192.168.1.1"
934 dst_ip=0xe0010101
935 dst_ip_str="224.1.1.1"
936
937 port1=config["port_map"].keys()[0]
938 port2=config["port_map"].keys()[1]
939 port3=config["port_map"].keys()[2]
940
941 #add l2 interface group
942 for port in config["port_map"].keys():
943 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
944 #add vlan flow table
945 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
946 vlan_id +=1
947
948 #add termination flow
949 add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
950
951 #add MPLS interface group
952 l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2)
953 mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2)
954 l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3)
955 mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3)
956 #add L3VPN groups
957 mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
958 index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True)
959 mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
960 index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True)
961
962
963
964 mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023])
965 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
966
967 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1,
968 eth_dst=dst_mac_str,
969 eth_src=port1_mac_str,
970 ip_ttl=64,
971 ip_src=src_ip_str,
972 ip_dst=dst_ip_str)
973 pkt=str(parsed_pkt)
974 self.dataplane.send(port1, pkt)
975 label = (in_vlan, 0, 1, 63)
976 parsed_pkt = mpls_packet(pktlen=100,
977 eth_dst=dst_mac_str,
978 eth_src=intf_src_mac_str,
979 ip_ttl=63,
980 ip_src=src_ip_str, label= [label],
981 ip_dst=dst_ip_str)
982 pkt=str(parsed_pkt)
983 verify_packet(self, pkt, port2)
984 verify_packet(self, pkt, port3)
985 verify_no_other_packets(self)
986
Flavio Castro34352e72015-12-07 20:01:51 -0500987