blob: 7d2a6c2b7680d8b1d9f25e52c4d28526accbd97e [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"""
Flavio Castro1c9b1252016-02-04 18:42:58 -050016import Queue
Flavio Castro05d20bc2015-11-16 15:06:14 -050017
Flavio Castro05d20bc2015-11-16 15:06:14 -050018from oftest import config
Flavio Castro67d8bd52016-02-03 14:22:14 -050019import inspect
Flavio Castro167f5bd2015-12-02 19:33:53 -050020import logging
21import oftest.base_tests as base_tests
Flavio Castro05d20bc2015-11-16 15:06:14 -050022import ofp
23from oftest.testutils import *
24from accton_util import *
Pierbaa8a182016-08-24 16:59:20 -070025from utils import *
Flavio Castrod8f8af22015-12-02 18:19:26 -050026
Flavio Castro1c9b1252016-02-04 18:42:58 -050027
Flavio Castro7fb6ca92015-12-16 15:50:14 -050028class PacketInUDP(base_tests.SimpleDataPlane):
Flavio Castro6d498522015-12-15 14:05:04 -050029 """
Flavio Castro1c9b1252016-02-04 18:42:58 -050030 Verify a ACL rule that matches on IP_PROTO 2 will not match a UDP packet.
31 Next it verify a rule that matches on IP_PROTO 17 WILL match a UDP packet.
Flavio Castro6d498522015-12-15 14:05:04 -050032 """
33
34 def runTest(self):
Flavio Castro1c9b1252016-02-04 18:42:58 -050035 parsed_vlan_pkt = simple_udp_packet(pktlen=104,
36 vlan_vid=0x1001,
37 dl_vlan_enable=True)
Flavio Castro6d498522015-12-15 14:05:04 -050038 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6d498522015-12-15 14:05:04 -050039 # create match
40 match = ofp.match()
41 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
Flavio Castro1c9b1252016-02-04 18:42:58 -050042 match.oxm_list.append(ofp.oxm.ip_proto(2))
Flavio Castro6d498522015-12-15 14:05:04 -050043 request = ofp.message.flow_add(
Flavio Castro1c9b1252016-02-04 18:42:58 -050044 table_id=60,
45 cookie=42,
46 match=match,
47 instructions=[
48 ofp.instruction.apply_actions(
49 actions=[
50 ofp.action.output(
51 port=ofp.OFPP_CONTROLLER,
52 max_len=ofp.OFPCML_NO_BUFFER)]), ],
53 buffer_id=ofp.OFP_NO_BUFFER,
54 priority=1)
55 logging.info("Inserting packet in flow to controller")
56 self.controller.message_send(request)
57
58 for of_port in config["port_map"].keys():
59 logging.info("PacketInMiss test, port %d", of_port)
60 self.dataplane.send(of_port, vlan_pkt)
61
Flavio Castro6da7e462016-02-04 18:56:29 -050062 verify_no_packet_in(self, vlan_pkt, of_port)
63 delete_all_flows(self.controller)
Flavio Castro6d498522015-12-15 14:05:04 -050064 do_barrier(self.controller)
65
Flavio Castro1c9b1252016-02-04 18:42:58 -050066 match = ofp.match()
67 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
68 match.oxm_list.append(ofp.oxm.ip_proto(17))
69 request = ofp.message.flow_add(
70 table_id=60,
71 cookie=42,
72 match=match,
73 instructions=[
74 ofp.instruction.apply_actions(
75 actions=[
76 ofp.action.output(
77 port=ofp.OFPP_CONTROLLER,
78 max_len=ofp.OFPCML_NO_BUFFER)]), ],
79 buffer_id=ofp.OFP_NO_BUFFER,
80 priority=1)
81 logging.info("Inserting packet in flow to controller")
82 self.controller.message_send(request)
Flavio Castro6da7e462016-02-04 18:56:29 -050083 do_barrier(self.controller)
Flavio Castro1c9b1252016-02-04 18:42:58 -050084
Flavio Castro6d498522015-12-15 14:05:04 -050085 for of_port in config["port_map"].keys():
86 logging.info("PacketInMiss test, port %d", of_port)
87 self.dataplane.send(of_port, vlan_pkt)
88
89 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
90
91 verify_no_other_packets(self)
Flavio Castroaf2b4502016-02-02 17:41:32 -050092
Flavio Castro1c9b1252016-02-04 18:42:58 -050093 delete_all_flows(self.controller)
94
Flavio Castroaf2b4502016-02-02 17:41:32 -050095
Flavio Castro67d8bd52016-02-03 14:22:14 -050096@disabled
Flavio Castro7fb6ca92015-12-16 15:50:14 -050097class ArpNL2(base_tests.SimpleDataPlane):
Flavio Castro1c9b1252016-02-04 18:42:58 -050098 def runTest(self):
Flavio Castro7fb6ca92015-12-16 15:50:14 -050099 delete_all_flows(self.controller)
100 delete_all_groups(self.controller)
101
102 ports = sorted(config["port_map"].keys())
103 match = ofp.match()
104 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
105 request = ofp.message.flow_add(
Flavio Castro1c9b1252016-02-04 18:42:58 -0500106 table_id=60,
107 cookie=42,
108 match=match,
109 instructions=[
110 ofp.instruction.apply_actions(
111 actions=[
112 ofp.action.output(
113 port=ofp.OFPP_CONTROLLER,
114 max_len=ofp.OFPCML_NO_BUFFER)]),
115 ],
116 buffer_id=ofp.OFP_NO_BUFFER,
117 priority=40000)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500118 self.controller.message_send(request)
119 for port in ports:
Flavio Castro932014b2016-01-05 18:29:15 -0500120 add_one_l2_interface_group(self.controller, port, 1, False, False)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500121 add_one_vlan_table_flow(self.controller, port, 1,
122 flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500123 group_id = encode_l2_interface_group_id(1, port)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500124 add_bridge_flow(self.controller,
125 [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id,
126 True)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500127 do_barrier(self.controller)
128 parsed_arp_pkt = simple_arp_packet()
129 arp_pkt = str(parsed_arp_pkt)
130
131 for out_port in ports:
132 self.dataplane.send(out_port, arp_pkt)
133 verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION)
134 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500135 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500136 for in_port in ports:
137 if in_port == out_port:
138 continue
139 # change source based on port number to avoid packet-ins from learning
Flavio Castro1c9b1252016-02-04 18:42:58 -0500140 mac_src = '00:12:34:56:78:%02X' % in_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500141 parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src)
142 pkt = str(parsed_pkt)
143 self.dataplane.send(in_port, pkt)
144
145 for ofport in ports:
146 if ofport in [out_port]:
147 verify_packet(self, pkt, ofport)
148 else:
149 verify_no_packet(self, pkt, ofport)
150
151 verify_no_other_packets(self)
152
Flavio Castro1c9b1252016-02-04 18:42:58 -0500153
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500154class PacketInArp(base_tests.SimpleDataPlane):
155 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500156 Verify an ACL rule matching on ethertyper 0x806 will result in a packet-in
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500157 """
158
159 def runTest(self):
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500160 parsed_arp_pkt = simple_arp_packet()
161 arp_pkt = str(parsed_arp_pkt)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500162 # create match
163 match = ofp.match()
164 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
165 request = ofp.message.flow_add(
Flavio Castro1c9b1252016-02-04 18:42:58 -0500166 table_id=60,
167 cookie=42,
168 match=match,
169 instructions=[
170 ofp.instruction.apply_actions(
171 actions=[
172 ofp.action.output(
173 port=ofp.OFPP_CONTROLLER,
174 max_len=ofp.OFPCML_NO_BUFFER)]),
175 ],
176 buffer_id=ofp.OFP_NO_BUFFER,
177 priority=1)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500178
179 logging.info("Inserting packet in flow to controller")
180 self.controller.message_send(request)
181 do_barrier(self.controller)
182
183 for of_port in config["port_map"].keys():
184 logging.info("PacketInMiss test, port %d", of_port)
185 self.dataplane.send(of_port, arp_pkt)
186
187 verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION)
188
189 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500190 delete_all_flows(self.controller)
191
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500192
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500193class L2FloodQinQ(base_tests.SimpleDataPlane):
194 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500195 Verify a tagged frame can be flooded based on its outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500196 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500197
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500198 def runTest(self):
199 ports = sorted(config["port_map"].keys())
Flavio Castro1c9b1252016-02-04 18:42:58 -0500200 vlan_id = 1
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500201
Flavio Castro1c9b1252016-02-04 18:42:58 -0500202 Groups = Queue.LifoQueue()
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500203 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500204 L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
205 vlan_id, True, False)
206 add_one_vlan_table_flow(self.controller, port, vlan_id,
207 flag=VLAN_TABLE_FLAG_ONLY_TAG)
208 Groups.put(L2gid)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500209
Flavio Castro1c9b1252016-02-04 18:42:58 -0500210 msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
Flavio Castro6da7e462016-02-04 18:56:29 -0500211 Groups.put(msg.group_id)
Flavio Castro8628adb2016-02-03 17:30:57 -0500212 add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500213 do_barrier(self.controller)
214
Flavio Castro1c9b1252016-02-04 18:42:58 -0500215 # verify flood
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500216 for ofport in ports:
217 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500218 mac_src = '00:12:34:56:78:%02X' % ofport
219 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108,
220 out_dl_vlan_enable=True,
221 out_vlan_vid=vlan_id,
222 in_dl_vlan_enable=True,
223 in_vlan_vid=10,
224 eth_dst='00:12:34:56:78:9a',
225 eth_src=mac_src)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500226 pkt = str(parsed_pkt)
227 self.dataplane.send(ofport, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500228 # self won't rx packet
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500229 verify_no_packet(self, pkt, ofport)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500230 # others will rx packet
231 tmp_ports = list(ports)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500232 tmp_ports.remove(ofport)
233 verify_packets(self, pkt, tmp_ports)
234
235 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500236 delete_all_flows(self.controller)
237 delete_groups(self.controller, Groups)
238
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500239
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500240@disabled
Flavio Castro184cefe2015-11-19 20:52:49 -0500241class L2FloodTagged(base_tests.SimpleDataPlane):
242 """
243 Test L2 flood to a vlan
244 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
Flavio Castro184cefe2015-11-19 20:52:49 -0500245 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500246
Flavio Castro184cefe2015-11-19 20:52:49 -0500247 def runTest(self):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500248 # Hashes Test Name and uses it as id for installing unique groups
249 vlan_id = abs(hash(inspect.stack()[0][3])) % (256)
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500250 print vlan_id
Flavio Castroaba28ff2016-02-03 16:47:48 -0500251
Flavio Castro184cefe2015-11-19 20:52:49 -0500252 ports = sorted(config["port_map"].keys())
Flavio Castro34352e72015-12-07 20:01:51 -0500253
Flavio Castro184cefe2015-11-19 20:52:49 -0500254 delete_all_flows(self.controller)
255 delete_all_groups(self.controller)
256
Flavio Castro184cefe2015-11-19 20:52:49 -0500257 # Installing flows to avoid packet-in
258 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500259 add_one_l2_interface_group(self.controller, port, vlan_id, True,
260 False)
261 add_one_vlan_table_flow(self.controller, port, vlan_id,
262 flag=VLAN_TABLE_FLAG_ONLY_TAG)
263 msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
Flavio Castroaba28ff2016-02-03 16:47:48 -0500264 add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
Flavio Castro184cefe2015-11-19 20:52:49 -0500265 do_barrier(self.controller)
266
Flavio Castro1c9b1252016-02-04 18:42:58 -0500267 # verify flood
Flavio Castro184cefe2015-11-19 20:52:49 -0500268 for ofport in ports:
269 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500270 pkt = str(simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
271 eth_dst='00:12:34:56:78:9a'))
Flavio Castro184cefe2015-11-19 20:52:49 -0500272 self.dataplane.send(ofport, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500273 # self won't rx packet
Flavio Castro184cefe2015-11-19 20:52:49 -0500274 verify_no_packet(self, pkt, ofport)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500275 # others will rx packet
276 tmp_ports = list(ports)
Flavio Castro184cefe2015-11-19 20:52:49 -0500277 tmp_ports.remove(ofport)
278 verify_packets(self, pkt, tmp_ports)
Flavio Castro184cefe2015-11-19 20:52:49 -0500279 verify_no_other_packets(self)
Flavio Castroaabb5792015-11-18 19:03:50 -0500280
Flavio Castro1c9b1252016-02-04 18:42:58 -0500281
Flavio Castroaabb5792015-11-18 19:03:50 -0500282class L2UnicastTagged(base_tests.SimpleDataPlane):
283 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500284 Verify L2 forwarding works
Flavio Castroaabb5792015-11-18 19:03:50 -0500285 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500286
Flavio Castroaabb5792015-11-18 19:03:50 -0500287 def runTest(self):
288 ports = sorted(config["port_map"].keys())
Flavio Castro1c9b1252016-02-04 18:42:58 -0500289 vlan_id = 1;
290 Groups = Queue.LifoQueue()
Flavio Castroaabb5792015-11-18 19:03:50 -0500291 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500292 L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
293 vlan_id, True, False)
294 add_one_vlan_table_flow(self.controller, port, vlan_id,
295 flag=VLAN_TABLE_FLAG_ONLY_TAG)
296 Groups.put(L2gid)
297 add_bridge_flow(self.controller,
298 [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
299 L2gid, True)
Flavio Castro6efe1862015-11-18 16:28:06 -0500300 do_barrier(self.controller)
301
Flavio Castroaabb5792015-11-18 19:03:50 -0500302 for out_port in ports:
303 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500304 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castroaabb5792015-11-18 19:03:50 -0500305 for in_port in ports:
306 if in_port == out_port:
307 continue
Flavio Castro1c9b1252016-02-04 18:42:58 -0500308 pkt = str(
309 simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
310 eth_dst=mac_dst))
Flavio Castroaabb5792015-11-18 19:03:50 -0500311 self.dataplane.send(in_port, pkt)
Flavio Castroaabb5792015-11-18 19:03:50 -0500312 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)
Flavio Castroaabb5792015-11-18 19:03:50 -0500317 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500318 delete_all_flows(self.controller)
319 delete_groups(self.controller, Groups)
320
Flavio Castro6efe1862015-11-18 16:28:06 -0500321
Flavio Castrob6773032015-11-19 22:49:24 -0500322class Mtu1500(base_tests.SimpleDataPlane):
Flavio Castrob6773032015-11-19 22:49:24 -0500323 def runTest(self):
324 ports = sorted(config["port_map"].keys())
Flavio Castro1c9b1252016-02-04 18:42:58 -0500325 vlan_id = 18
326 Groups = Queue.LifoQueue()
Flavio Castrob6773032015-11-19 22:49:24 -0500327 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500328 L2gid, msg = add_one_l2_interface_group(self.controller, port,
329 vlan_id, True, False)
330 add_one_vlan_table_flow(self.controller, port, vlan_id,
331 flag=VLAN_TABLE_FLAG_ONLY_TAG)
332 Groups.put(L2gid)
333 add_bridge_flow(self.controller,
334 [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
335 L2gid, True)
Flavio Castrob6773032015-11-19 22:49:24 -0500336 do_barrier(self.controller)
337
338 for out_port in ports:
339 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500340 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castrob6773032015-11-19 22:49:24 -0500341 for in_port in ports:
342 if in_port == out_port:
343 continue
Flavio Castro1c9b1252016-02-04 18:42:58 -0500344 pkt = str(simple_tcp_packet(pktlen=1500, dl_vlan_enable=True,
345 vlan_vid=vlan_id, eth_dst=mac_dst))
Flavio Castrob6773032015-11-19 22:49:24 -0500346 self.dataplane.send(in_port, pkt)
Flavio Castrob6773032015-11-19 22:49:24 -0500347 for ofport in ports:
348 if ofport in [out_port]:
349 verify_packet(self, pkt, ofport)
350 else:
351 verify_no_packet(self, pkt, ofport)
Flavio Castrob6773032015-11-19 22:49:24 -0500352 verify_no_other_packets(self)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500353 delete_all_flows(self.controller)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500354 delete_groups(self.controller, Groups)
355
356
357class _32UcastTagged(base_tests.SimpleDataPlane):
358 """
359 Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
360 """
361
362 def runTest(self):
363 test_id = 26
364 if len(config["port_map"]) < 2:
Flavio Castro05d20bc2015-11-16 15:06:14 -0500365 logging.info("Port count less than 2, can't run this case")
366 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500367
Flavio Castro1c9b1252016-02-04 18:42:58 -0500368 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
369 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
370 dip = 0xc0a80001
Flavio Castroa8233862015-12-02 14:41:11 -0500371 ports = config["port_map"].keys()
Flavio Castro1c9b1252016-02-04 18:42:58 -0500372 Groups = Queue.LifoQueue()
Flavio Castroa8233862015-12-02 14:41:11 -0500373 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500374 # add l2 interface group
375 vlan_id = port + test_id
376 l2gid, msg = add_one_l2_interface_group(self.controller, port,
377 vlan_id=vlan_id,
378 is_tagged=True,
379 send_barrier=False)
380 dst_mac[5] = vlan_id
381 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
382 id=vlan_id, src_mac=intf_src_mac,
383 dst_mac=dst_mac)
384 # add vlan flow table
385 add_one_vlan_table_flow(self.controller, port, vlan_id,
386 flag=VLAN_TABLE_FLAG_ONLY_TAG)
387 # add termination flow
388 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
389 vlan_id)
390 # add unicast routing flow
391 dst_ip = dip + (vlan_id << 8)
392 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
393 0xffffffff, l3_msg.group_id)
394 Groups.put(l2gid)
395 Groups.put(l3_msg.group_id)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500396 do_barrier(self.controller)
397
Flavio Castro05d20bc2015-11-16 15:06:14 -0500398 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
Flavio Castroa8233862015-12-02 14:41:11 -0500399 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500400 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
401 ip_src = '192.168.%02d.1' % (test_id + in_port)
Flavio Castroa8233862015-12-02 14:41:11 -0500402 for out_port in ports:
403 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500404 continue
405 ip_dst = '192.168.%02d.1' % (test_id + out_port)
406 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
407 vlan_vid=(test_id + in_port),
408 eth_dst=switch_mac,
409 eth_src=mac_src, ip_ttl=64,
410 ip_src=ip_src,
411 ip_dst=ip_dst)
412 pkt = str(parsed_pkt)
Flavio Castroa8233862015-12-02 14:41:11 -0500413 self.dataplane.send(in_port, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500414 # build expected packet
415 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
416 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
417 vlan_vid=(test_id + out_port),
418 eth_dst=mac_dst, eth_src=switch_mac,
419 ip_ttl=63,
420 ip_src=ip_src, ip_dst=ip_dst)
421 pkt = str(exp_pkt)
Flavio Castroa8233862015-12-02 14:41:11 -0500422 verify_packet(self, pkt, out_port)
423 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500424 delete_all_flows(self.controller)
425 delete_groups(self.controller, Groups)
426
Flavio Castro05d20bc2015-11-16 15:06:14 -0500427
Flavio Castro2262fd42016-02-04 19:03:36 -0500428class _32VPN(base_tests.SimpleDataPlane):
429 """
430 Insert IP packet
431 Receive MPLS packet
432 """
433
434 def runTest(self):
435 if len(config["port_map"]) < 2:
436 logging.info("Port count less than 2, can't run this case")
437 return
438
439 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
440 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
441 dip = 0xc0a80001
442 ports = config["port_map"].keys()
443 Groups = Queue.LifoQueue()
444 for port in ports:
445 # add l2 interface group
446 id = port
447 vlan_id = port
448 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
449 vlan_id, True, True)
450 dst_mac[5] = vlan_id
451 # add MPLS interface group
452 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
453 dst_mac, intf_src_mac,
454 vlan_id, id)
455 # add MPLS L3 VPN group
456 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
457 self.controller,
458 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
459 index=id, ref_gid=mpls_gid, push_mpls_header=True,
460 set_mpls_label=port, set_bos=1, set_ttl=32)
461 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
462 do_barrier(self.controller)
463 # add vlan flow table
464 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
465 flag=VLAN_TABLE_FLAG_ONLY_TAG)
466 # add termination flow
467 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
468 vlan_id)
469 # add routing flow
470 dst_ip = dip + (vlan_id << 8)
471 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
472 0xffffffff, mpls_label_gid)
473 Groups._put(l2_gid)
474 Groups._put(mpls_gid)
475 Groups._put(mpls_label_gid)
476 do_barrier(self.controller)
477
478 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
479 for in_port in ports:
480 ip_src = '192.168.%02d.1' % (in_port)
481 for out_port in ports:
482 if in_port == out_port:
483 continue
484 ip_dst = '192.168.%02d.1' % (out_port)
485 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
486 vlan_vid=(in_port),
487 eth_dst=switch_mac, ip_ttl=64,
488 ip_src=ip_src,
489 ip_dst=ip_dst)
490 pkt = str(parsed_pkt)
491 self.dataplane.send(in_port, pkt)
492 # build expect packet
493 mac_dst = '00:00:00:22:22:%02X' % (out_port)
494 label = (out_port, 0, 1, 32)
495 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
496 vlan_vid=(out_port), ip_ttl=63,
497 ip_src=ip_src,
498 ip_dst=ip_dst, eth_dst=mac_dst,
499 eth_src=switch_mac, label=[label])
500 pkt = str(exp_pkt)
501 verify_packet(self, pkt, out_port)
502 verify_no_other_packets(self)
503 delete_all_flows(self.controller)
504 delete_groups(self.controller, Groups)
505
506class _32EcmpVpn(base_tests.SimpleDataPlane):
507 """
508 Insert IP packet
509 Receive MPLS packet
510 """
511
512 def runTest(self):
513 if len(config["port_map"]) < 2:
514 logging.info("Port count less than 2, can't run this case")
515 return
516
517 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
518 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
519 dip = 0xc0a80001
520 ports = config["port_map"].keys()
521 Groups = Queue.LifoQueue()
522 for port in ports:
523 # add l2 interface group
524 id = port
525 vlan_id = port
526 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
527 vlan_id, True, True)
528 dst_mac[5] = vlan_id
529 # add MPLS interface group
530 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
531 dst_mac, intf_src_mac,
532 vlan_id, id)
533 # add MPLS L3 VPN group
534 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
535 self.controller,
536 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
537 index=id, ref_gid=mpls_gid, push_mpls_header=True,
538 set_mpls_label=port, set_bos=1, set_ttl=32)
539 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
540 do_barrier(self.controller)
541 # add vlan flow table
542 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
543 flag=VLAN_TABLE_FLAG_ONLY_TAG)
544 # add termination flow
545 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
546 vlan_id)
547 # add routing flow
548 dst_ip = dip + (vlan_id << 8)
549 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
550 0xffffffff, ecmp_msg.group_id)
551 Groups._put(l2_gid)
552 Groups._put(mpls_gid)
553 Groups._put(mpls_label_gid)
554 Groups._put(ecmp_msg.group_id)
555 do_barrier(self.controller)
556
557 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
558 for in_port in ports:
559 ip_src = '192.168.%02d.1' % (in_port)
560 for out_port in ports:
561 if in_port == out_port:
562 continue
563 ip_dst = '192.168.%02d.1' % (out_port)
564 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
565 vlan_vid=(in_port),
566 eth_dst=switch_mac, ip_ttl=64,
567 ip_src=ip_src,
568 ip_dst=ip_dst)
569 pkt = str(parsed_pkt)
570 self.dataplane.send(in_port, pkt)
571 # build expect packet
572 mac_dst = '00:00:00:22:22:%02X' % (out_port)
573 label = (out_port, 0, 1, 32)
574 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
575 vlan_vid=(out_port), ip_ttl=63,
576 ip_src=ip_src,
577 ip_dst=ip_dst, eth_dst=mac_dst,
578 eth_src=switch_mac, label=[label])
579 pkt = str(exp_pkt)
580 verify_packet(self, pkt, out_port)
581 verify_no_other_packets(self)
582 delete_all_flows(self.controller)
583 delete_groups(self.controller, Groups)
584
585class _32ECMPL3(base_tests.SimpleDataPlane):
586 """
587 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
588 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
589 """
590
591 def runTest(self):
592 Groups = Queue.LifoQueue()
593 if len(config["port_map"]) < 2:
594 logging.info("Port count less than 2, can't run this case")
595 return
596
597 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
598 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
599 dip = 0xc0a80001
600 # Hashes Test Name and uses it as id for installing unique groups
601 ports = config["port_map"].keys()
602 for port in ports:
603 vlan_id = port
604 id = port
605 # add l2 interface group
606 l2_gid, msg = add_one_l2_interface_group(self.controller, port,
607 vlan_id=vlan_id,
608 is_tagged=True,
609 send_barrier=False)
610 dst_mac[5] = vlan_id
611 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
612 id=id, src_mac=intf_src_mac,
613 dst_mac=dst_mac)
614 ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
615 # add vlan flow table
616 add_one_vlan_table_flow(self.controller, port, vlan_id,
617 flag=VLAN_TABLE_FLAG_ONLY_TAG)
618 # add termination flow
619 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
620 vlan_id)
621 # add unicast routing flow
622 dst_ip = dip + (vlan_id << 8)
623 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
624 0xffffffff, ecmp_msg.group_id)
625 Groups._put(l2_gid)
626 Groups._put(l3_msg.group_id)
627 Groups._put(ecmp_msg.group_id)
628 do_barrier(self.controller)
629
630 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
631 for in_port in ports:
632 mac_src = '00:00:00:22:22:%02X' % in_port
633 ip_src = '192.168.%02d.1' % in_port
634 for out_port in ports:
635 if in_port == out_port:
636 continue
637 ip_dst = '192.168.%02d.1' % out_port
638 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
639 vlan_vid=in_port,
640 eth_dst=switch_mac,
641 eth_src=mac_src, ip_ttl=64,
642 ip_src=ip_src,
643 ip_dst=ip_dst)
644 pkt = str(parsed_pkt)
645 self.dataplane.send(in_port, pkt)
646 # build expected packet
647 mac_dst = '00:00:00:22:22:%02X' % out_port
648 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
649 vlan_vid=out_port,
650 eth_dst=mac_dst, eth_src=switch_mac,
651 ip_ttl=63,
652 ip_src=ip_src, ip_dst=ip_dst)
653 pkt = str(exp_pkt)
654 verify_packet(self, pkt, out_port)
655 verify_no_other_packets(self)
656 delete_all_flows(self.controller)
657 delete_groups(self.controller, Groups)
658
659
660class _24VPN(base_tests.SimpleDataPlane):
661 """
662 Insert IP packet
663 Receive MPLS packet
664 """
665
666 def runTest(self):
667 if len(config["port_map"]) < 2:
668 logging.info("Port count less than 2, can't run this case")
669 return
670
671 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
672 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
673 dip = 0xc0a80001
674 ports = config["port_map"].keys()
675 Groups = Queue.LifoQueue()
676 for port in ports:
677 # add l2 interface group
678 id = port
679 vlan_id = port
680 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
681 vlan_id, True, True)
682 dst_mac[5] = vlan_id
683 # add MPLS interface group
684 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
685 dst_mac, intf_src_mac,
686 vlan_id, id)
687 # add MPLS L3 VPN group
688 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
689 self.controller,
690 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
691 index=id, ref_gid=mpls_gid, push_mpls_header=True,
692 set_mpls_label=port, set_bos=1, set_ttl=32)
693 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
694 do_barrier(self.controller)
695 # add vlan flow table
696 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
697 flag=VLAN_TABLE_FLAG_ONLY_TAG)
698 # add termination flow
699 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
700 vlan_id)
701 # add routing flow
702 dst_ip = dip + (vlan_id << 8)
703 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
704 0xffffff00, mpls_label_gid)
705 Groups._put(l2_gid)
706 Groups._put(mpls_gid)
707 Groups._put(mpls_label_gid)
708 do_barrier(self.controller)
709
710 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
711 for in_port in ports:
712 ip_src = '192.168.%02d.1' % (in_port)
713 for out_port in ports:
714 if in_port == out_port:
715 continue
716 ip_dst = '192.168.%02d.1' % (out_port)
717 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
718 vlan_vid=(in_port),
719 eth_dst=switch_mac, ip_ttl=64,
720 ip_src=ip_src,
721 ip_dst=ip_dst)
722 pkt = str(parsed_pkt)
723 self.dataplane.send(in_port, pkt)
724 # build expect packet
725 mac_dst = '00:00:00:22:22:%02X' % (out_port)
726 label = (out_port, 0, 1, 32)
727 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
728 vlan_vid=(out_port), ip_ttl=63,
729 ip_src=ip_src,
730 ip_dst=ip_dst, eth_dst=mac_dst,
731 eth_src=switch_mac, label=[label])
732 pkt = str(exp_pkt)
733 verify_packet(self, pkt, out_port)
734 verify_no_other_packets(self)
735 delete_all_flows(self.controller)
736 delete_groups(self.controller, Groups)
737
738
739class _24EcmpVpn(base_tests.SimpleDataPlane):
Flavio Castrod8f8af22015-12-02 18:19:26 -0500740 """
741 Insert IP packet
742 Receive MPLS packet
743 """
Flavio Castro72a45d52015-12-02 16:37:05 -0500744
Flavio Castro1c9b1252016-02-04 18:42:58 -0500745 def runTest(self):
746 if len(config["port_map"]) < 2:
Flavio Castro72a45d52015-12-02 16:37:05 -0500747 logging.info("Port count less than 2, can't run this case")
748 return
Flavio Castro1c9b1252016-02-04 18:42:58 -0500749 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
750 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
751 dip = 0xc0a80001
752 Groups = Queue.LifoQueue()
Flavio Castro72a45d52015-12-02 16:37:05 -0500753 ports = config["port_map"].keys()
754 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500755 # add l2 interface group
756 id = port
757 vlan_id = id
758 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
759 vlan_id, True, True)
760 dst_mac[5] = vlan_id
761 # add MPLS interface group
762 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
763 dst_mac, intf_src_mac,
764 vlan_id, id)
765 # add MPLS L3 VPN group
766 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
767 self.controller,
768 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
769 index=id, ref_gid=mpls_gid, push_mpls_header=True,
770 set_mpls_label=port, set_bos=1, set_ttl=32)
771 ecmp_msg = add_l3_ecmp_group(self.controller, id, [mpls_label_gid])
Flavio Castro80730822015-12-11 15:38:47 -0500772 do_barrier(self.controller)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500773 # add vlan flow table
774 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
775 flag=VLAN_TABLE_FLAG_ONLY_TAG)
776 # add termination flow
777 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
778 vlan_id)
779 # add routing flow
780 dst_ip = dip + (vlan_id << 8)
781 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
782 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
783 0xffffff00, ecmp_msg.group_id, vrf=0)
784 Groups._put(l2_gid)
785 Groups._put(mpls_gid)
786 Groups._put(mpls_label_gid)
787 Groups._put(ecmp_msg.group_id)
Flavio Castro80730822015-12-11 15:38:47 -0500788
789 do_barrier(self.controller)
790
791 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
792 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500793 mac_src = '00:00:00:22:22:%02X' % (in_port)
794 ip_src = '192.168.%02d.1' % (in_port)
Flavio Castro80730822015-12-11 15:38:47 -0500795 for out_port in ports:
796 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500797 continue
798 ip_dst = '192.168.%02d.1' % (out_port)
799 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
800 vlan_vid=(in_port),
801 eth_dst=switch_mac,
802 eth_src=mac_src, ip_ttl=64,
803 ip_src=ip_src,
804 ip_dst=ip_dst)
805 pkt = str(parsed_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500806 self.dataplane.send(in_port, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500807 # build expect packet
808 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castro80730822015-12-11 15:38:47 -0500809 label = (out_port, 0, 1, 32)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500810 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
811 vlan_vid=(out_port), ip_ttl=63,
812 ip_src=ip_src,
813 ip_dst=ip_dst, eth_dst=mac_dst,
814 eth_src=switch_mac, label=[label])
815 pkt = str(exp_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500816 verify_packet(self, pkt, out_port)
817 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500818 delete_all_flows(self.controller)
819 delete_groups(self.controller, Groups)
820
castroflavioee294842016-01-06 15:54:28 -0800821
Flavio Castro2262fd42016-02-04 19:03:36 -0500822
823class _24ECMPL3(base_tests.SimpleDataPlane):
Flavio Castro80730822015-12-11 15:38:47 -0500824 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500825 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
826 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
Flavio Castro80730822015-12-11 15:38:47 -0500827 """
Flavio Castro80730822015-12-11 15:38:47 -0500828
Flavio Castro1c9b1252016-02-04 18:42:58 -0500829 def runTest(self):
Flavio Castro2262fd42016-02-04 19:03:36 -0500830 Groups = Queue.LifoQueue()
Flavio Castro1c9b1252016-02-04 18:42:58 -0500831 if len(config["port_map"]) < 2:
Flavio Castro80730822015-12-11 15:38:47 -0500832 logging.info("Port count less than 2, can't run this case")
833 return
834
Flavio Castro1c9b1252016-02-04 18:42:58 -0500835 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
836 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
837 dip = 0xc0a80001
Flavio Castro2262fd42016-02-04 19:03:36 -0500838 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castro80730822015-12-11 15:38:47 -0500839 ports = config["port_map"].keys()
840 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500841 vlan_id = port
Flavio Castro2262fd42016-02-04 19:03:36 -0500842 id = port
843 # add l2 interface group
844 l2_gid, msg = add_one_l2_interface_group(self.controller, port,
845 vlan_id=vlan_id,
846 is_tagged=True,
847 send_barrier=False)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500848 dst_mac[5] = vlan_id
Flavio Castro2262fd42016-02-04 19:03:36 -0500849 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
850 id=id, src_mac=intf_src_mac,
851 dst_mac=dst_mac)
852 ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
Flavio Castro1c9b1252016-02-04 18:42:58 -0500853 # add vlan flow table
Flavio Castro2262fd42016-02-04 19:03:36 -0500854 add_one_vlan_table_flow(self.controller, port, vlan_id,
Flavio Castro1c9b1252016-02-04 18:42:58 -0500855 flag=VLAN_TABLE_FLAG_ONLY_TAG)
856 # add termination flow
857 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
858 vlan_id)
Flavio Castro2262fd42016-02-04 19:03:36 -0500859 # add unicast routing flow
Flavio Castro1c9b1252016-02-04 18:42:58 -0500860 dst_ip = dip + (vlan_id << 8)
861 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
Flavio Castro2262fd42016-02-04 19:03:36 -0500862 0xffffff00, ecmp_msg.group_id)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500863 Groups._put(l2_gid)
Flavio Castro2262fd42016-02-04 19:03:36 -0500864 Groups._put(l3_msg.group_id)
865 Groups._put(ecmp_msg.group_id)
Flavio Castro72a45d52015-12-02 16:37:05 -0500866 do_barrier(self.controller)
867
868 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
869 for in_port in ports:
Flavio Castro2262fd42016-02-04 19:03:36 -0500870 mac_src = '00:00:00:22:22:%02X' % in_port
871 ip_src = '192.168.%02d.1' % in_port
Flavio Castro72a45d52015-12-02 16:37:05 -0500872 for out_port in ports:
873 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500874 continue
Flavio Castro2262fd42016-02-04 19:03:36 -0500875 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro1c9b1252016-02-04 18:42:58 -0500876 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
Flavio Castro2262fd42016-02-04 19:03:36 -0500877 vlan_vid=in_port,
878 eth_dst=switch_mac,
879 eth_src=mac_src, ip_ttl=64,
Flavio Castro1c9b1252016-02-04 18:42:58 -0500880 ip_src=ip_src,
881 ip_dst=ip_dst)
882 pkt = str(parsed_pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500883 self.dataplane.send(in_port, pkt)
Flavio Castro2262fd42016-02-04 19:03:36 -0500884 # build expected packet
885 mac_dst = '00:00:00:22:22:%02X' % out_port
886 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
887 vlan_vid=out_port,
888 eth_dst=mac_dst, eth_src=switch_mac,
889 ip_ttl=63,
890 ip_src=ip_src, ip_dst=ip_dst)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500891 pkt = str(exp_pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500892 verify_packet(self, pkt, out_port)
893 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500894 delete_all_flows(self.controller)
895 delete_groups(self.controller, Groups)
896
Flavio Castroaba28ff2016-02-03 16:47:48 -0500897@disabled
Flavio Castro80730822015-12-11 15:38:47 -0500898class MPLSBUG(base_tests.SimpleDataPlane):
Flavio Castro80730822015-12-11 15:38:47 -0500899 def runTest(self):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500900 if len(config["port_map"]) < 2:
Flavio Castro80730822015-12-11 15:38:47 -0500901 logging.info("Port count less than 2, can't run this case")
902 return
Flavio Castro1c9b1252016-02-04 18:42:58 -0500903 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
904 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
905 dip = 0xc0a80001
906 Groups = Queue.LifoQueue()
Flavio Castro80730822015-12-11 15:38:47 -0500907 ports = config["port_map"].keys()
908 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500909 # add l2 interface group
910 vlan_id = port
911 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
912 vlan_id, True, False)
913 dst_mac[5] = vlan_id
914 # add L3 Unicast group
915 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
916 id=vlan_id, src_mac=intf_src_mac,
917 dst_mac=dst_mac)
918 # add vlan flow table
919 add_one_vlan_table_flow(self.controller, port, vlan_id,
920 flag=VLAN_TABLE_FLAG_ONLY_BOTH)
921 # add termination flow
922 add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
923 vlan_id, goto_table=24)
924 # add mpls flow
Flavio Castro80730822015-12-11 15:38:47 -0500925 add_mpls_flow(self.controller, l3_msg.group_id, port)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500926 # add termination flow
927 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
928 vlan_id)
929 # add unicast routing flow
930 dst_ip = dip + (vlan_id << 8)
931 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
932 0xffffffff, l3_msg.group_id)
933 Groups._put(l2_gid)
934 Groups._put(l3_msg.group_id)
Flavio Castro80730822015-12-11 15:38:47 -0500935 do_barrier(self.controller)
936
937 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
938 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500939 mac_src = '00:00:00:22:22:%02X' % in_port
940 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -0500941 for out_port in ports:
942 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500943 continue
944 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -0500945 switch_mac = "00:00:00:cc:cc:cc"
946 label = (out_port, 0, 1, 32)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500947 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
948 vlan_vid=in_port, ip_src=ip_src,
949 ip_dst=ip_dst, eth_dst=switch_mac,
950 eth_src=mac_src, label=[label])
951 pkt = str(parsed_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500952 self.dataplane.send(in_port, pkt)
953
Flavio Castro1c9b1252016-02-04 18:42:58 -0500954 # build expect packet
955 mac_dst = '00:00:00:22:22:%02X' % out_port
956 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
957 vlan_vid=out_port,
958 eth_dst=mac_dst, eth_src=switch_mac,
959 ip_ttl=31, ip_src=ip_src,
960 ip_dst=ip_dst)
961 pkt = str(exp_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500962 verify_packet(self, pkt, out_port)
963 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500964
965 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
966 vlan_vid=in_port,
967 eth_dst=switch_mac,
968 eth_src=mac_src, ip_ttl=64,
969 ip_src=ip_src,
970 ip_dst=ip_dst)
971 pkt = str(parsed_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500972 self.dataplane.send(in_port, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500973 # build expected packet
974 mac_dst = '00:00:00:22:22:%02X' % out_port
975 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
976 vlan_vid=out_port,
977 eth_dst=mac_dst, eth_src=switch_mac,
978 ip_ttl=63,
979 ip_src=ip_src, ip_dst=ip_dst)
980 pkt = str(exp_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500981 verify_packet(self, pkt, out_port)
982 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500983 delete_all_flows(self.controller)
984 delete_groups(self.controller, Groups)
985
Flavio Castro80730822015-12-11 15:38:47 -0500986
Flavio Castro12296312015-12-15 17:48:26 -0500987class L3McastToL2(base_tests.SimpleDataPlane):
castroflaviocc403a92015-12-15 14:04:19 -0500988 """
Flavio Castro12296312015-12-15 17:48:26 -0500989 Mcast routing to L2
castroflaviocc403a92015-12-15 14:04:19 -0500990 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500991
castroflaviocc403a92015-12-15 14:04:19 -0500992 def runTest(self):
993 """
994 port1 (vlan 300)-> All Ports (vlan 300)
995 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500996 if len(config["port_map"]) < 3:
castroflavio4a09c962016-01-05 13:13:41 -0800997 logging.info("Port count less than 3, can't run this case")
Flavio Castro1c9b1252016-02-04 18:42:58 -0500998 assert (False)
castroflaviocc403a92015-12-15 14:04:19 -0500999 return
Flavio Castro1c9b1252016-02-04 18:42:58 -05001000 Groups = Queue.LifoQueue()
1001 vlan_id = 300
1002 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1003 intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
1004 dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
1005 dst_mac_str = ':'.join(['%02X' % x for x in dst_mac])
1006 port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
1007 port1_mac_str = ':'.join(['%02X' % x for x in port1_mac])
1008 src_ip = 0xc0a80101
1009 src_ip_str = "192.168.1.1"
1010 dst_ip = 0xe0010101
1011 dst_ip_str = "224.1.1.1"
castroflaviocc403a92015-12-15 14:04:19 -05001012
Flavio Castro1c9b1252016-02-04 18:42:58 -05001013 port1 = config["port_map"].keys()[0]
1014 port2 = config["port_map"].keys()[1]
castroflaviocc403a92015-12-15 14:04:19 -05001015
1016 switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]
1017
Flavio Castro1c9b1252016-02-04 18:42:58 -05001018 # add l2 interface group
1019 l2_intf_group_list = []
castroflaviocc403a92015-12-15 14:04:19 -05001020 for port in config["port_map"].keys():
Flavio Castro1c9b1252016-02-04 18:42:58 -05001021 add_one_vlan_table_flow(self.controller, port, vlan_id,
1022 flag=VLAN_TABLE_FLAG_ONLY_TAG)
castroflaviocc403a92015-12-15 14:04:19 -05001023 if port == port2:
1024 continue
Flavio Castro1c9b1252016-02-04 18:42:58 -05001025 l2_intf_gid, msg = add_one_l2_interface_group(self.controller, port,
1026 vlan_id=vlan_id,
1027 is_tagged=True,
1028 send_barrier=False)
castroflaviocc403a92015-12-15 14:04:19 -05001029 l2_intf_group_list.append(l2_intf_gid)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001030 Groups.put(l2_intf_gid)
castroflaviocc403a92015-12-15 14:04:19 -05001031
Flavio Castro1c9b1252016-02-04 18:42:58 -05001032 # add termination flow
1033 add_termination_flow(self.controller, port1, 0x0800, switch_mac,
1034 vlan_id)
castroflaviocc403a92015-12-15 14:04:19 -05001035
Flavio Castro1c9b1252016-02-04 18:42:58 -05001036 # add l3 interface group
1037 mcat_group_msg = add_l3_mcast_group(self.controller, vlan_id, 2,
1038 l2_intf_group_list)
1039 add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip,
1040 mcat_group_msg.group_id)
1041 Groups._put(mcat_group_msg.group_id)
castroflaviocc403a92015-12-15 14:04:19 -05001042
Flavio Castro1c9b1252016-02-04 18:42:58 -05001043 parsed_pkt = simple_udp_packet(pktlen=100,
Flavio Castro89933f22016-02-03 15:53:16 -05001044 dl_vlan_enable=True,
1045 vlan_vid=vlan_id,
castroflaviocc403a92015-12-15 14:04:19 -05001046 eth_dst=dst_mac_str,
1047 eth_src=port1_mac_str,
1048 ip_ttl=64,
1049 ip_src=src_ip_str,
1050 ip_dst=dst_ip_str)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001051 pkt = str(parsed_pkt)
castroflaviocc403a92015-12-15 14:04:19 -05001052 self.dataplane.send(port1, pkt)
1053 for port in config["port_map"].keys():
Flavio Castro12296312015-12-15 17:48:26 -05001054 if port == port2 or port == port1:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001055 verify_no_packet(self, pkt, port)
1056 continue
castroflaviocc403a92015-12-15 14:04:19 -05001057 verify_packet(self, pkt, port)
1058 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001059 delete_all_flows(self.controller)
1060 delete_groups(self.controller, Groups)
1061
castroflaviocc403a92015-12-15 14:04:19 -05001062
Pierbaa8a182016-08-24 16:59:20 -07001063class L3McastToL3( base_tests.SimpleDataPlane ):
Flavio Castro12296312015-12-15 17:48:26 -05001064 """
Pierbaa8a182016-08-24 16:59:20 -07001065 Mcast routing, in this test case the traffic comes in tagged.
1066 port+1 is used as ingress vlan_id. The packet goes out tagged on
1067 all ports (also in the in_port). 4094-port is used as egress vlan_id.
Flavio Castro12296312015-12-15 17:48:26 -05001068 """
Pierbaa8a182016-08-24 16:59:20 -07001069 def runTest( self ):
1070 Groups = Queue.LifoQueue( )
1071 try:
1072 # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
1073 if len( config[ "port_map" ] ) < 1:
1074 logging.info( "Port count less than 1, can't run this case" )
1075 assert (False)
1076 return
1077 ports = config[ "port_map" ].keys( )
1078 dst_ip_str = "224.0.0.1"
1079 (
1080 port_to_in_vlan,
1081 port_to_out_vlan,
1082 port_to_src_mac_str,
1083 port_to_dst_mac_str,
1084 port_to_src_ip_str,
1085 port_to_intf_src_mac_str,
1086 Groups) = fill_mcast_pipeline_L3toL3(
1087 self.controller,
1088 logging,
1089 ports,
1090 is_ingress_tagged = True,
1091 is_egress_tagged = True,
1092 is_vlan_translated = True,
1093 is_max_vlan = False
1094 )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001095
Pierbaa8a182016-08-24 16:59:20 -07001096 for in_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001097
Pierbaa8a182016-08-24 16:59:20 -07001098 parsed_pkt = simple_udp_packet(
1099 pktlen = 100,
1100 dl_vlan_enable = True,
1101 vlan_vid = port_to_in_vlan[in_port],
1102 eth_dst = port_to_dst_mac_str[in_port],
1103 eth_src = port_to_src_mac_str[in_port],
1104 ip_ttl = 64,
1105 ip_src = port_to_src_ip_str[in_port],
1106 ip_dst = dst_ip_str
1107 )
1108 pkt = str( parsed_pkt )
1109 self.dataplane.send( in_port, pkt )
Flavio Castro12296312015-12-15 17:48:26 -05001110
Pierbaa8a182016-08-24 16:59:20 -07001111 for out_port in ports:
Flavio Castro12296312015-12-15 17:48:26 -05001112
Pierbaa8a182016-08-24 16:59:20 -07001113 parsed_pkt = simple_udp_packet(
1114 pktlen = 100,
1115 dl_vlan_enable = True,
1116 vlan_vid = port_to_out_vlan[out_port],
1117 eth_dst = port_to_dst_mac_str[in_port],
1118 eth_src = port_to_intf_src_mac_str[out_port],
1119 ip_ttl = 63,
1120 ip_src = port_to_src_ip_str[in_port],
1121 ip_dst = dst_ip_str
1122 )
1123 pkt = str( parsed_pkt )
1124 verify_packet( self, pkt, out_port )
Flavio Castro12296312015-12-15 17:48:26 -05001125
Pierbaa8a182016-08-24 16:59:20 -07001126 verify_no_other_packets( self )
Flavio Castro1c9b1252016-02-04 18:42:58 -05001127
Pierbaa8a182016-08-24 16:59:20 -07001128 finally:
1129 delete_all_flows( self.controller )
1130 delete_groups( self.controller, Groups )
1131 delete_all_groups( self.controller )
Flavio Castro54947942016-02-03 16:05:20 -05001132
Flavio Castrof54be492016-02-03 16:26:22 -05001133class _MplsTermination(base_tests.SimpleDataPlane):
Flavio Castro12296312015-12-15 17:48:26 -05001134 """
Flavio Castro54947942016-02-03 16:05:20 -05001135 Insert IP packet
1136 Receive MPLS packet
castroflavio30c6cc52016-01-07 15:19:42 -08001137 """
castroflavio30c6cc52016-01-07 15:19:42 -08001138
Flavio Castro1c9b1252016-02-04 18:42:58 -05001139 def runTest(self):
1140 Groups = Queue.LifoQueue()
1141 if len(config["port_map"]) < 2:
castroflavio30c6cc52016-01-07 15:19:42 -08001142 logging.info("Port count less than 2, can't run this case")
1143 return
1144
Flavio Castro1c9b1252016-02-04 18:42:58 -05001145 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1146 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
1147 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
castroflavio30c6cc52016-01-07 15:19:42 -08001148 ports = config["port_map"].keys()
1149 for port in ports:
Charles Chand2a65312016-08-22 15:35:03 -07001150 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1151 vlan_id = port + 16
1152 mpls_label = port + 16
1153
Flavio Castro1c9b1252016-02-04 18:42:58 -05001154 # add l2 interface group
1155 id = port
Flavio Castro1c9b1252016-02-04 18:42:58 -05001156 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
1157 vlan_id, True, False)
Charles Chand2a65312016-08-22 15:35:03 -07001158 dst_mac[5] = port
Flavio Castro1c9b1252016-02-04 18:42:58 -05001159 # add L3 Unicast group
1160 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
1161 id=id, src_mac=intf_src_mac,
1162 dst_mac=dst_mac)
1163 # add L3 ecmp group
Flavio Castro54947942016-02-03 16:05:20 -05001164 ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
Flavio Castro1c9b1252016-02-04 18:42:58 -05001165 # add vlan flow table
1166 add_one_vlan_table_flow(self.controller, port, vlan_id,
1167 flag=VLAN_TABLE_FLAG_ONLY_TAG)
1168 # add termination flow
1169 add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
1170 vlan_id, goto_table=24)
Charles Chand2a65312016-08-22 15:35:03 -07001171 add_mpls_flow(self.controller, ecmp_msg.group_id, mpls_label)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001172 Groups._put(l2_gid)
1173 Groups._put(l3_msg.group_id)
1174 Groups._put(ecmp_msg.group_id)
castroflavio30c6cc52016-01-07 15:19:42 -08001175 do_barrier(self.controller)
1176
1177 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
1178 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001179 ip_src = '192.168.%02d.1' % (in_port)
castroflavio30c6cc52016-01-07 15:19:42 -08001180 for out_port in ports:
1181 if in_port == out_port:
Flavio Castro54947942016-02-03 16:05:20 -05001182 continue
Flavio Castro54947942016-02-03 16:05:20 -05001183
Charles Chand2a65312016-08-22 15:35:03 -07001184 # Shift MPLS label and VLAN ID by 16 to avoid reserved values
1185 out_mpls_label = out_port + 16
1186 in_vlan_vid = in_port + 16
1187 out_vlan_vid = out_port + 16
1188
1189 ip_dst = '192.168.%02d.1' % (out_port)
1190 label = (out_mpls_label, 0, 1, 32)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001191 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
Charles Chand2a65312016-08-22 15:35:03 -07001192 vlan_vid=(in_vlan_vid), ip_src=ip_src,
Flavio Castro1c9b1252016-02-04 18:42:58 -05001193 ip_dst=ip_dst, eth_dst=switch_mac,
1194 label=[label])
1195 pkt = str(parsed_pkt)
castroflavio30c6cc52016-01-07 15:19:42 -08001196 self.dataplane.send(in_port, pkt)
Flavio Castro54947942016-02-03 16:05:20 -05001197
Flavio Castro1c9b1252016-02-04 18:42:58 -05001198 # build expect packet
1199 mac_dst = '00:00:00:22:22:%02X' % (out_port)
1200 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
Charles Chand2a65312016-08-22 15:35:03 -07001201 vlan_vid=(out_vlan_vid),
Flavio Castro1c9b1252016-02-04 18:42:58 -05001202 eth_dst=mac_dst, eth_src=switch_mac,
1203 ip_ttl=31, ip_src=ip_src,
1204 ip_dst=ip_dst)
1205 pkt = str(exp_pkt)
castroflavio30c6cc52016-01-07 15:19:42 -08001206 verify_packet(self, pkt, out_port)
1207 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001208 delete_all_flows(self.controller)
1209 delete_groups(self.controller, Groups)
1210
Flavio Castrod0619992016-02-04 15:10:28 -05001211
Flavio Castro1c9b1252016-02-04 18:42:58 -05001212
1213
1214class _24UcastTagged(base_tests.SimpleDataPlane):
1215 """
1216 Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
1217 """
1218
1219 def runTest(self):
1220 test_id = 26
1221 if len(config["port_map"]) < 2:
1222 logging.info("Port count less than 2, can't run this case")
1223 return
1224
1225 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1226 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
1227 dip = 0xc0a80001
1228 ports = config["port_map"].keys()
1229 Groups = Queue.LifoQueue()
1230 for port in ports:
1231 # add l2 interface group
1232 vlan_id = port + test_id
1233 l2gid, msg = add_one_l2_interface_group(self.controller, port,
1234 vlan_id=vlan_id,
1235 is_tagged=True,
1236 send_barrier=False)
1237 dst_mac[5] = vlan_id
1238 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
1239 id=vlan_id, src_mac=intf_src_mac,
1240 dst_mac=dst_mac)
1241 # add vlan flow table
1242 add_one_vlan_table_flow(self.controller, port, vlan_id,
1243 flag=VLAN_TABLE_FLAG_ONLY_TAG)
1244 # add termination flow
1245 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
1246 vlan_id)
1247 # add unicast routing flow
1248 dst_ip = dip + (vlan_id << 8)
1249 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
1250 0xffffff00, l3_msg.group_id)
1251 Groups.put(l2gid)
1252 Groups.put(l3_msg.group_id)
1253 do_barrier(self.controller)
1254
1255 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
1256 for in_port in ports:
1257 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1258 ip_src = '192.168.%02d.1' % (test_id + in_port)
1259 for out_port in ports:
1260 if in_port == out_port:
1261 continue
1262 ip_dst = '192.168.%02d.1' % (test_id + out_port)
1263 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
1264 vlan_vid=(test_id + in_port),
1265 eth_dst=switch_mac,
1266 eth_src=mac_src, ip_ttl=64,
1267 ip_src=ip_src,
1268 ip_dst=ip_dst)
1269 pkt = str(parsed_pkt)
1270 self.dataplane.send(in_port, pkt)
1271 # build expected packet
1272 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
1273 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
1274 vlan_vid=(test_id + out_port),
1275 eth_dst=mac_dst, eth_src=switch_mac,
1276 ip_ttl=63,
1277 ip_src=ip_src, ip_dst=ip_dst)
1278 pkt = str(exp_pkt)
1279 verify_packet(self, pkt, out_port)
1280 verify_no_other_packets(self)
1281 delete_all_flows(self.controller)
1282 delete_groups(self.controller, Groups)
Pier04d421b2016-08-25 15:04:21 -07001283
1284class Untagged( base_tests.SimpleDataPlane ):
1285 """
1286 Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0.
1287 This should be fixed in OFDPA 2.0 GA and above, the test fails with
1288 previous versions of the OFDPA.
1289
1290 Two rules are necessary in VLAN table (10):
1291 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20
1292 2) Filtering: match 0x100A/0x1FFF, goto 20
1293
1294 In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no).
1295 The remaining part of the test is based on the use of the bridging table
1296 """
1297
1298 MAX_INTERNAL_VLAN = 4094
1299
1300 def runTest( self ):
1301 groups = Queue.LifoQueue( )
1302 try:
1303 if len( config[ "port_map" ] ) < 2:
1304 logging.info( "Port count less than 2, can't run this case" )
1305 return
1306
1307 ports = sorted( config[ "port_map" ].keys( ) )
1308 for port in ports:
1309 vlan_id = Untagged.MAX_INTERNAL_VLAN - port
1310 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
1311 add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG )
1312 for other_port in ports:
1313 if other_port == port:
1314 continue
1315 L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False )
1316 groups.put( L2gid )
1317 add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True )
1318
1319 do_barrier( self.controller )
1320
1321 for out_port in ports:
1322 # change dest based on port number
1323 mac_dst = '00:12:34:56:78:%02X' % out_port
1324 for in_port in ports:
1325 if in_port == out_port:
1326 continue
1327 pkt = str( simple_tcp_packet( eth_dst=mac_dst ) )
1328 self.dataplane.send( in_port, pkt )
1329 for ofport in ports:
1330 if ofport in [ out_port ]:
1331 verify_packet( self, pkt, ofport )
1332 else:
1333 verify_no_packet( self, pkt, ofport )
1334 verify_no_other_packets( self )
1335 finally:
1336 delete_all_flows( self.controller )
1337 delete_groups( self.controller, groups )
1338 delete_all_groups( self.controller )