blob: 0033468aadf365e9c4ac640aa4087808cbef4144 [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 *
Flavio Castrod8f8af22015-12-02 18:19:26 -050025
Flavio Castro1c9b1252016-02-04 18:42:58 -050026
Flavio Castro7fb6ca92015-12-16 15:50:14 -050027class PacketInUDP(base_tests.SimpleDataPlane):
Flavio Castro6d498522015-12-15 14:05:04 -050028 """
Flavio Castro1c9b1252016-02-04 18:42:58 -050029 Verify a ACL rule that matches on IP_PROTO 2 will not match a UDP packet.
30 Next it verify a rule that matches on IP_PROTO 17 WILL match a UDP packet.
Flavio Castro6d498522015-12-15 14:05:04 -050031 """
32
33 def runTest(self):
Flavio Castro1c9b1252016-02-04 18:42:58 -050034 parsed_vlan_pkt = simple_udp_packet(pktlen=104,
35 vlan_vid=0x1001,
36 dl_vlan_enable=True)
Flavio Castro6d498522015-12-15 14:05:04 -050037 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6d498522015-12-15 14:05:04 -050038 # create match
39 match = ofp.match()
40 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
Flavio Castro1c9b1252016-02-04 18:42:58 -050041 match.oxm_list.append(ofp.oxm.ip_proto(2))
Flavio Castro6d498522015-12-15 14:05:04 -050042 request = ofp.message.flow_add(
Flavio Castro1c9b1252016-02-04 18:42:58 -050043 table_id=60,
44 cookie=42,
45 match=match,
46 instructions=[
47 ofp.instruction.apply_actions(
48 actions=[
49 ofp.action.output(
50 port=ofp.OFPP_CONTROLLER,
51 max_len=ofp.OFPCML_NO_BUFFER)]), ],
52 buffer_id=ofp.OFP_NO_BUFFER,
53 priority=1)
54 logging.info("Inserting packet in flow to controller")
55 self.controller.message_send(request)
56
57 for of_port in config["port_map"].keys():
58 logging.info("PacketInMiss test, port %d", of_port)
59 self.dataplane.send(of_port, vlan_pkt)
60
Flavio Castro6da7e462016-02-04 18:56:29 -050061 verify_no_packet_in(self, vlan_pkt, of_port)
62 delete_all_flows(self.controller)
Flavio Castro6d498522015-12-15 14:05:04 -050063 do_barrier(self.controller)
64
Flavio Castro1c9b1252016-02-04 18:42:58 -050065 match = ofp.match()
66 match.oxm_list.append(ofp.oxm.eth_type(0x0800))
67 match.oxm_list.append(ofp.oxm.ip_proto(17))
68 request = ofp.message.flow_add(
69 table_id=60,
70 cookie=42,
71 match=match,
72 instructions=[
73 ofp.instruction.apply_actions(
74 actions=[
75 ofp.action.output(
76 port=ofp.OFPP_CONTROLLER,
77 max_len=ofp.OFPCML_NO_BUFFER)]), ],
78 buffer_id=ofp.OFP_NO_BUFFER,
79 priority=1)
80 logging.info("Inserting packet in flow to controller")
81 self.controller.message_send(request)
Flavio Castro6da7e462016-02-04 18:56:29 -050082 do_barrier(self.controller)
Flavio Castro1c9b1252016-02-04 18:42:58 -050083
Flavio Castro6d498522015-12-15 14:05:04 -050084 for of_port in config["port_map"].keys():
85 logging.info("PacketInMiss test, port %d", of_port)
86 self.dataplane.send(of_port, vlan_pkt)
87
88 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
89
90 verify_no_other_packets(self)
Flavio Castroaf2b4502016-02-02 17:41:32 -050091
Flavio Castro1c9b1252016-02-04 18:42:58 -050092 delete_all_flows(self.controller)
93
Flavio Castroaf2b4502016-02-02 17:41:32 -050094
Flavio Castro67d8bd52016-02-03 14:22:14 -050095@disabled
Flavio Castro7fb6ca92015-12-16 15:50:14 -050096class ArpNL2(base_tests.SimpleDataPlane):
Flavio Castro1c9b1252016-02-04 18:42:58 -050097 def runTest(self):
Flavio Castro7fb6ca92015-12-16 15:50:14 -050098 delete_all_flows(self.controller)
99 delete_all_groups(self.controller)
100
101 ports = sorted(config["port_map"].keys())
102 match = ofp.match()
103 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
104 request = ofp.message.flow_add(
Flavio Castro1c9b1252016-02-04 18:42:58 -0500105 table_id=60,
106 cookie=42,
107 match=match,
108 instructions=[
109 ofp.instruction.apply_actions(
110 actions=[
111 ofp.action.output(
112 port=ofp.OFPP_CONTROLLER,
113 max_len=ofp.OFPCML_NO_BUFFER)]),
114 ],
115 buffer_id=ofp.OFP_NO_BUFFER,
116 priority=40000)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500117 self.controller.message_send(request)
118 for port in ports:
Flavio Castro932014b2016-01-05 18:29:15 -0500119 add_one_l2_interface_group(self.controller, port, 1, False, False)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500120 add_one_vlan_table_flow(self.controller, port, 1,
121 flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500122 group_id = encode_l2_interface_group_id(1, port)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500123 add_bridge_flow(self.controller,
124 [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id,
125 True)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500126 do_barrier(self.controller)
127 parsed_arp_pkt = simple_arp_packet()
128 arp_pkt = str(parsed_arp_pkt)
129
130 for out_port in ports:
131 self.dataplane.send(out_port, arp_pkt)
132 verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION)
133 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500134 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500135 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
Flavio Castro1c9b1252016-02-04 18:42:58 -0500139 mac_src = '00:12:34:56:78:%02X' % in_port
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500140 parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src)
141 pkt = str(parsed_pkt)
142 self.dataplane.send(in_port, pkt)
143
144 for ofport in ports:
145 if ofport in [out_port]:
146 verify_packet(self, pkt, ofport)
147 else:
148 verify_no_packet(self, pkt, ofport)
149
150 verify_no_other_packets(self)
151
Flavio Castro1c9b1252016-02-04 18:42:58 -0500152
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500153class PacketInArp(base_tests.SimpleDataPlane):
154 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500155 Verify an ACL rule matching on ethertyper 0x806 will result in a packet-in
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500156 """
157
158 def runTest(self):
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500159 parsed_arp_pkt = simple_arp_packet()
160 arp_pkt = str(parsed_arp_pkt)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500161 # create match
162 match = ofp.match()
163 match.oxm_list.append(ofp.oxm.eth_type(0x0806))
164 request = ofp.message.flow_add(
Flavio Castro1c9b1252016-02-04 18:42:58 -0500165 table_id=60,
166 cookie=42,
167 match=match,
168 instructions=[
169 ofp.instruction.apply_actions(
170 actions=[
171 ofp.action.output(
172 port=ofp.OFPP_CONTROLLER,
173 max_len=ofp.OFPCML_NO_BUFFER)]),
174 ],
175 buffer_id=ofp.OFP_NO_BUFFER,
176 priority=1)
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500177
178 logging.info("Inserting packet in flow to controller")
179 self.controller.message_send(request)
180 do_barrier(self.controller)
181
182 for of_port in config["port_map"].keys():
183 logging.info("PacketInMiss test, port %d", of_port)
184 self.dataplane.send(of_port, arp_pkt)
185
186 verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION)
187
188 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500189 delete_all_flows(self.controller)
190
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500191
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500192class L2FloodQinQ(base_tests.SimpleDataPlane):
193 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500194 Verify a tagged frame can be flooded based on its outer vlan
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500195 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500196
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500197 def runTest(self):
198 ports = sorted(config["port_map"].keys())
Flavio Castro1c9b1252016-02-04 18:42:58 -0500199 vlan_id = 1
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500200
Flavio Castro1c9b1252016-02-04 18:42:58 -0500201 Groups = Queue.LifoQueue()
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500202 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500203 L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
204 vlan_id, True, False)
205 add_one_vlan_table_flow(self.controller, port, vlan_id,
206 flag=VLAN_TABLE_FLAG_ONLY_TAG)
207 Groups.put(L2gid)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500208
Flavio Castro1c9b1252016-02-04 18:42:58 -0500209 msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
Flavio Castro6da7e462016-02-04 18:56:29 -0500210 Groups.put(msg.group_id)
Flavio Castro8628adb2016-02-03 17:30:57 -0500211 add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500212 do_barrier(self.controller)
213
Flavio Castro1c9b1252016-02-04 18:42:58 -0500214 # verify flood
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500215 for ofport in ports:
216 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500217 mac_src = '00:12:34:56:78:%02X' % ofport
218 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108,
219 out_dl_vlan_enable=True,
220 out_vlan_vid=vlan_id,
221 in_dl_vlan_enable=True,
222 in_vlan_vid=10,
223 eth_dst='00:12:34:56:78:9a',
224 eth_src=mac_src)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500225 pkt = str(parsed_pkt)
226 self.dataplane.send(ofport, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500227 # self won't rx packet
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500228 verify_no_packet(self, pkt, ofport)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500229 # others will rx packet
230 tmp_ports = list(ports)
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500231 tmp_ports.remove(ofport)
232 verify_packets(self, pkt, tmp_ports)
233
234 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500235 delete_all_flows(self.controller)
236 delete_groups(self.controller, Groups)
237
Flavio Castro1b5c21d2015-12-08 12:41:56 -0500238
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500239@disabled
Flavio Castro184cefe2015-11-19 20:52:49 -0500240class L2FloodTagged(base_tests.SimpleDataPlane):
241 """
242 Test L2 flood to a vlan
243 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
Flavio Castro184cefe2015-11-19 20:52:49 -0500244 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500245
Flavio Castro184cefe2015-11-19 20:52:49 -0500246 def runTest(self):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500247 # Hashes Test Name and uses it as id for installing unique groups
248 vlan_id = abs(hash(inspect.stack()[0][3])) % (256)
Flavio Castroce3bfeb2016-02-04 14:06:55 -0500249 print vlan_id
Flavio Castroaba28ff2016-02-03 16:47:48 -0500250
Flavio Castro184cefe2015-11-19 20:52:49 -0500251 ports = sorted(config["port_map"].keys())
Flavio Castro34352e72015-12-07 20:01:51 -0500252
Flavio Castro184cefe2015-11-19 20:52:49 -0500253 delete_all_flows(self.controller)
254 delete_all_groups(self.controller)
255
Flavio Castro184cefe2015-11-19 20:52:49 -0500256 # Installing flows to avoid packet-in
257 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500258 add_one_l2_interface_group(self.controller, port, vlan_id, True,
259 False)
260 add_one_vlan_table_flow(self.controller, port, vlan_id,
261 flag=VLAN_TABLE_FLAG_ONLY_TAG)
262 msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id)
Flavio Castroaba28ff2016-02-03 16:47:48 -0500263 add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True)
Flavio Castro184cefe2015-11-19 20:52:49 -0500264 do_barrier(self.controller)
265
Flavio Castro1c9b1252016-02-04 18:42:58 -0500266 # verify flood
Flavio Castro184cefe2015-11-19 20:52:49 -0500267 for ofport in ports:
268 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500269 pkt = str(simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
270 eth_dst='00:12:34:56:78:9a'))
Flavio Castro184cefe2015-11-19 20:52:49 -0500271 self.dataplane.send(ofport, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500272 # self won't rx packet
Flavio Castro184cefe2015-11-19 20:52:49 -0500273 verify_no_packet(self, pkt, ofport)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500274 # others will rx packet
275 tmp_ports = list(ports)
Flavio Castro184cefe2015-11-19 20:52:49 -0500276 tmp_ports.remove(ofport)
277 verify_packets(self, pkt, tmp_ports)
Flavio Castro184cefe2015-11-19 20:52:49 -0500278 verify_no_other_packets(self)
Flavio Castroaabb5792015-11-18 19:03:50 -0500279
Flavio Castro1c9b1252016-02-04 18:42:58 -0500280
Flavio Castroaabb5792015-11-18 19:03:50 -0500281class L2UnicastTagged(base_tests.SimpleDataPlane):
282 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500283 Verify L2 forwarding works
Flavio Castroaabb5792015-11-18 19:03:50 -0500284 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500285
Flavio Castroaabb5792015-11-18 19:03:50 -0500286 def runTest(self):
287 ports = sorted(config["port_map"].keys())
Flavio Castro1c9b1252016-02-04 18:42:58 -0500288 vlan_id = 1;
289 Groups = Queue.LifoQueue()
Flavio Castroaabb5792015-11-18 19:03:50 -0500290 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500291 L2gid, l2msg = add_one_l2_interface_group(self.controller, port,
292 vlan_id, True, False)
293 add_one_vlan_table_flow(self.controller, port, vlan_id,
294 flag=VLAN_TABLE_FLAG_ONLY_TAG)
295 Groups.put(L2gid)
296 add_bridge_flow(self.controller,
297 [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
298 L2gid, True)
Flavio Castro6efe1862015-11-18 16:28:06 -0500299 do_barrier(self.controller)
300
Flavio Castroaabb5792015-11-18 19:03:50 -0500301 for out_port in ports:
302 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500303 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castroaabb5792015-11-18 19:03:50 -0500304 for in_port in ports:
305 if in_port == out_port:
306 continue
Flavio Castro1c9b1252016-02-04 18:42:58 -0500307 pkt = str(
308 simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id,
309 eth_dst=mac_dst))
Flavio Castroaabb5792015-11-18 19:03:50 -0500310 self.dataplane.send(in_port, pkt)
Flavio Castroaabb5792015-11-18 19:03:50 -0500311 for ofport in ports:
312 if ofport in [out_port]:
313 verify_packet(self, pkt, ofport)
314 else:
315 verify_no_packet(self, pkt, ofport)
Flavio Castroaabb5792015-11-18 19:03:50 -0500316 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500317 delete_all_flows(self.controller)
318 delete_groups(self.controller, Groups)
319
Flavio Castro6efe1862015-11-18 16:28:06 -0500320
Flavio Castrob6773032015-11-19 22:49:24 -0500321class Mtu1500(base_tests.SimpleDataPlane):
Flavio Castrob6773032015-11-19 22:49:24 -0500322 def runTest(self):
323 ports = sorted(config["port_map"].keys())
Flavio Castro1c9b1252016-02-04 18:42:58 -0500324 vlan_id = 18
325 Groups = Queue.LifoQueue()
Flavio Castrob6773032015-11-19 22:49:24 -0500326 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500327 L2gid, msg = add_one_l2_interface_group(self.controller, port,
328 vlan_id, True, False)
329 add_one_vlan_table_flow(self.controller, port, vlan_id,
330 flag=VLAN_TABLE_FLAG_ONLY_TAG)
331 Groups.put(L2gid)
332 add_bridge_flow(self.controller,
333 [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id,
334 L2gid, True)
Flavio Castrob6773032015-11-19 22:49:24 -0500335 do_barrier(self.controller)
336
337 for out_port in ports:
338 # change dest based on port number
Flavio Castro1c9b1252016-02-04 18:42:58 -0500339 mac_dst = '00:12:34:56:78:%02X' % out_port
Flavio Castrob6773032015-11-19 22:49:24 -0500340 for in_port in ports:
341 if in_port == out_port:
342 continue
Flavio Castro1c9b1252016-02-04 18:42:58 -0500343 pkt = str(simple_tcp_packet(pktlen=1500, dl_vlan_enable=True,
344 vlan_vid=vlan_id, eth_dst=mac_dst))
Flavio Castrob6773032015-11-19 22:49:24 -0500345 self.dataplane.send(in_port, pkt)
Flavio Castrob6773032015-11-19 22:49:24 -0500346 for ofport in ports:
347 if ofport in [out_port]:
348 verify_packet(self, pkt, ofport)
349 else:
350 verify_no_packet(self, pkt, ofport)
Flavio Castrob6773032015-11-19 22:49:24 -0500351 verify_no_other_packets(self)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500352 delete_all_flows(self.controller)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500353 delete_groups(self.controller, Groups)
354
355
356class _32UcastTagged(base_tests.SimpleDataPlane):
357 """
358 Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
359 """
360
361 def runTest(self):
362 test_id = 26
363 if len(config["port_map"]) < 2:
Flavio Castro05d20bc2015-11-16 15:06:14 -0500364 logging.info("Port count less than 2, can't run this case")
365 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500366
Flavio Castro1c9b1252016-02-04 18:42:58 -0500367 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
368 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
369 dip = 0xc0a80001
Flavio Castroa8233862015-12-02 14:41:11 -0500370 ports = config["port_map"].keys()
Flavio Castro1c9b1252016-02-04 18:42:58 -0500371 Groups = Queue.LifoQueue()
Flavio Castroa8233862015-12-02 14:41:11 -0500372 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500373 # add l2 interface group
374 vlan_id = port + test_id
375 l2gid, msg = add_one_l2_interface_group(self.controller, port,
376 vlan_id=vlan_id,
377 is_tagged=True,
378 send_barrier=False)
379 dst_mac[5] = vlan_id
380 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
381 id=vlan_id, src_mac=intf_src_mac,
382 dst_mac=dst_mac)
383 # add vlan flow table
384 add_one_vlan_table_flow(self.controller, port, vlan_id,
385 flag=VLAN_TABLE_FLAG_ONLY_TAG)
386 # add termination flow
387 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
388 vlan_id)
389 # add unicast routing flow
390 dst_ip = dip + (vlan_id << 8)
391 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
392 0xffffffff, l3_msg.group_id)
393 Groups.put(l2gid)
394 Groups.put(l3_msg.group_id)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500395 do_barrier(self.controller)
396
Flavio Castro05d20bc2015-11-16 15:06:14 -0500397 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
Flavio Castroa8233862015-12-02 14:41:11 -0500398 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500399 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
400 ip_src = '192.168.%02d.1' % (test_id + in_port)
Flavio Castroa8233862015-12-02 14:41:11 -0500401 for out_port in ports:
402 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500403 continue
404 ip_dst = '192.168.%02d.1' % (test_id + out_port)
405 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
406 vlan_vid=(test_id + in_port),
407 eth_dst=switch_mac,
408 eth_src=mac_src, ip_ttl=64,
409 ip_src=ip_src,
410 ip_dst=ip_dst)
411 pkt = str(parsed_pkt)
Flavio Castroa8233862015-12-02 14:41:11 -0500412 self.dataplane.send(in_port, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500413 # build expected packet
414 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
415 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
416 vlan_vid=(test_id + out_port),
417 eth_dst=mac_dst, eth_src=switch_mac,
418 ip_ttl=63,
419 ip_src=ip_src, ip_dst=ip_dst)
420 pkt = str(exp_pkt)
Flavio Castroa8233862015-12-02 14:41:11 -0500421 verify_packet(self, pkt, out_port)
422 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500423 delete_all_flows(self.controller)
424 delete_groups(self.controller, Groups)
425
Flavio Castro05d20bc2015-11-16 15:06:14 -0500426
Flavio Castro2262fd42016-02-04 19:03:36 -0500427class _32VPN(base_tests.SimpleDataPlane):
428 """
429 Insert IP packet
430 Receive MPLS packet
431 """
432
433 def runTest(self):
434 if len(config["port_map"]) < 2:
435 logging.info("Port count less than 2, can't run this case")
436 return
437
438 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
439 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
440 dip = 0xc0a80001
441 ports = config["port_map"].keys()
442 Groups = Queue.LifoQueue()
443 for port in ports:
444 # add l2 interface group
445 id = port
446 vlan_id = port
447 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
448 vlan_id, True, True)
449 dst_mac[5] = vlan_id
450 # add MPLS interface group
451 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
452 dst_mac, intf_src_mac,
453 vlan_id, id)
454 # add MPLS L3 VPN group
455 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
456 self.controller,
457 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
458 index=id, ref_gid=mpls_gid, push_mpls_header=True,
459 set_mpls_label=port, set_bos=1, set_ttl=32)
460 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
461 do_barrier(self.controller)
462 # add vlan flow table
463 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
464 flag=VLAN_TABLE_FLAG_ONLY_TAG)
465 # add termination flow
466 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
467 vlan_id)
468 # add routing flow
469 dst_ip = dip + (vlan_id << 8)
470 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
471 0xffffffff, mpls_label_gid)
472 Groups._put(l2_gid)
473 Groups._put(mpls_gid)
474 Groups._put(mpls_label_gid)
475 do_barrier(self.controller)
476
477 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
478 for in_port in ports:
479 ip_src = '192.168.%02d.1' % (in_port)
480 for out_port in ports:
481 if in_port == out_port:
482 continue
483 ip_dst = '192.168.%02d.1' % (out_port)
484 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
485 vlan_vid=(in_port),
486 eth_dst=switch_mac, ip_ttl=64,
487 ip_src=ip_src,
488 ip_dst=ip_dst)
489 pkt = str(parsed_pkt)
490 self.dataplane.send(in_port, pkt)
491 # build expect packet
492 mac_dst = '00:00:00:22:22:%02X' % (out_port)
493 label = (out_port, 0, 1, 32)
494 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
495 vlan_vid=(out_port), ip_ttl=63,
496 ip_src=ip_src,
497 ip_dst=ip_dst, eth_dst=mac_dst,
498 eth_src=switch_mac, label=[label])
499 pkt = str(exp_pkt)
500 verify_packet(self, pkt, out_port)
501 verify_no_other_packets(self)
502 delete_all_flows(self.controller)
503 delete_groups(self.controller, Groups)
504
505class _32EcmpVpn(base_tests.SimpleDataPlane):
506 """
507 Insert IP packet
508 Receive MPLS packet
509 """
510
511 def runTest(self):
512 if len(config["port_map"]) < 2:
513 logging.info("Port count less than 2, can't run this case")
514 return
515
516 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
517 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
518 dip = 0xc0a80001
519 ports = config["port_map"].keys()
520 Groups = Queue.LifoQueue()
521 for port in ports:
522 # add l2 interface group
523 id = port
524 vlan_id = port
525 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
526 vlan_id, True, True)
527 dst_mac[5] = vlan_id
528 # add MPLS interface group
529 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
530 dst_mac, intf_src_mac,
531 vlan_id, id)
532 # add MPLS L3 VPN group
533 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
534 self.controller,
535 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
536 index=id, ref_gid=mpls_gid, push_mpls_header=True,
537 set_mpls_label=port, set_bos=1, set_ttl=32)
538 ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
539 do_barrier(self.controller)
540 # add vlan flow table
541 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
542 flag=VLAN_TABLE_FLAG_ONLY_TAG)
543 # add termination flow
544 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
545 vlan_id)
546 # add routing flow
547 dst_ip = dip + (vlan_id << 8)
548 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
549 0xffffffff, ecmp_msg.group_id)
550 Groups._put(l2_gid)
551 Groups._put(mpls_gid)
552 Groups._put(mpls_label_gid)
553 Groups._put(ecmp_msg.group_id)
554 do_barrier(self.controller)
555
556 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
557 for in_port in ports:
558 ip_src = '192.168.%02d.1' % (in_port)
559 for out_port in ports:
560 if in_port == out_port:
561 continue
562 ip_dst = '192.168.%02d.1' % (out_port)
563 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
564 vlan_vid=(in_port),
565 eth_dst=switch_mac, ip_ttl=64,
566 ip_src=ip_src,
567 ip_dst=ip_dst)
568 pkt = str(parsed_pkt)
569 self.dataplane.send(in_port, pkt)
570 # build expect packet
571 mac_dst = '00:00:00:22:22:%02X' % (out_port)
572 label = (out_port, 0, 1, 32)
573 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
574 vlan_vid=(out_port), ip_ttl=63,
575 ip_src=ip_src,
576 ip_dst=ip_dst, eth_dst=mac_dst,
577 eth_src=switch_mac, label=[label])
578 pkt = str(exp_pkt)
579 verify_packet(self, pkt, out_port)
580 verify_no_other_packets(self)
581 delete_all_flows(self.controller)
582 delete_groups(self.controller, Groups)
583
584class _32ECMPL3(base_tests.SimpleDataPlane):
585 """
586 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
587 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
588 """
589
590 def runTest(self):
591 Groups = Queue.LifoQueue()
592 if len(config["port_map"]) < 2:
593 logging.info("Port count less than 2, can't run this case")
594 return
595
596 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
597 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
598 dip = 0xc0a80001
599 # Hashes Test Name and uses it as id for installing unique groups
600 ports = config["port_map"].keys()
601 for port in ports:
602 vlan_id = port
603 id = port
604 # add l2 interface group
605 l2_gid, msg = add_one_l2_interface_group(self.controller, port,
606 vlan_id=vlan_id,
607 is_tagged=True,
608 send_barrier=False)
609 dst_mac[5] = vlan_id
610 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
611 id=id, src_mac=intf_src_mac,
612 dst_mac=dst_mac)
613 ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
614 # add vlan flow table
615 add_one_vlan_table_flow(self.controller, port, vlan_id,
616 flag=VLAN_TABLE_FLAG_ONLY_TAG)
617 # add termination flow
618 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
619 vlan_id)
620 # add unicast routing flow
621 dst_ip = dip + (vlan_id << 8)
622 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
623 0xffffffff, ecmp_msg.group_id)
624 Groups._put(l2_gid)
625 Groups._put(l3_msg.group_id)
626 Groups._put(ecmp_msg.group_id)
627 do_barrier(self.controller)
628
629 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
630 for in_port in ports:
631 mac_src = '00:00:00:22:22:%02X' % in_port
632 ip_src = '192.168.%02d.1' % in_port
633 for out_port in ports:
634 if in_port == out_port:
635 continue
636 ip_dst = '192.168.%02d.1' % out_port
637 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
638 vlan_vid=in_port,
639 eth_dst=switch_mac,
640 eth_src=mac_src, ip_ttl=64,
641 ip_src=ip_src,
642 ip_dst=ip_dst)
643 pkt = str(parsed_pkt)
644 self.dataplane.send(in_port, pkt)
645 # build expected packet
646 mac_dst = '00:00:00:22:22:%02X' % out_port
647 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
648 vlan_vid=out_port,
649 eth_dst=mac_dst, eth_src=switch_mac,
650 ip_ttl=63,
651 ip_src=ip_src, ip_dst=ip_dst)
652 pkt = str(exp_pkt)
653 verify_packet(self, pkt, out_port)
654 verify_no_other_packets(self)
655 delete_all_flows(self.controller)
656 delete_groups(self.controller, Groups)
657
658
659class _24VPN(base_tests.SimpleDataPlane):
660 """
661 Insert IP packet
662 Receive MPLS packet
663 """
664
665 def runTest(self):
666 if len(config["port_map"]) < 2:
667 logging.info("Port count less than 2, can't run this case")
668 return
669
670 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
671 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
672 dip = 0xc0a80001
673 ports = config["port_map"].keys()
674 Groups = Queue.LifoQueue()
675 for port in ports:
676 # add l2 interface group
677 id = port
678 vlan_id = port
679 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
680 vlan_id, True, True)
681 dst_mac[5] = vlan_id
682 # add MPLS interface group
683 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
684 dst_mac, intf_src_mac,
685 vlan_id, id)
686 # add MPLS L3 VPN group
687 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
688 self.controller,
689 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
690 index=id, ref_gid=mpls_gid, push_mpls_header=True,
691 set_mpls_label=port, set_bos=1, set_ttl=32)
692 # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid])
693 do_barrier(self.controller)
694 # add vlan flow table
695 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
696 flag=VLAN_TABLE_FLAG_ONLY_TAG)
697 # add termination flow
698 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
699 vlan_id)
700 # add routing flow
701 dst_ip = dip + (vlan_id << 8)
702 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
703 0xffffff00, mpls_label_gid)
704 Groups._put(l2_gid)
705 Groups._put(mpls_gid)
706 Groups._put(mpls_label_gid)
707 do_barrier(self.controller)
708
709 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
710 for in_port in ports:
711 ip_src = '192.168.%02d.1' % (in_port)
712 for out_port in ports:
713 if in_port == out_port:
714 continue
715 ip_dst = '192.168.%02d.1' % (out_port)
716 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
717 vlan_vid=(in_port),
718 eth_dst=switch_mac, ip_ttl=64,
719 ip_src=ip_src,
720 ip_dst=ip_dst)
721 pkt = str(parsed_pkt)
722 self.dataplane.send(in_port, pkt)
723 # build expect packet
724 mac_dst = '00:00:00:22:22:%02X' % (out_port)
725 label = (out_port, 0, 1, 32)
726 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
727 vlan_vid=(out_port), ip_ttl=63,
728 ip_src=ip_src,
729 ip_dst=ip_dst, eth_dst=mac_dst,
730 eth_src=switch_mac, label=[label])
731 pkt = str(exp_pkt)
732 verify_packet(self, pkt, out_port)
733 verify_no_other_packets(self)
734 delete_all_flows(self.controller)
735 delete_groups(self.controller, Groups)
736
737
738class _24EcmpVpn(base_tests.SimpleDataPlane):
Flavio Castrod8f8af22015-12-02 18:19:26 -0500739 """
740 Insert IP packet
741 Receive MPLS packet
742 """
Flavio Castro72a45d52015-12-02 16:37:05 -0500743
Flavio Castro1c9b1252016-02-04 18:42:58 -0500744 def runTest(self):
745 if len(config["port_map"]) < 2:
Flavio Castro72a45d52015-12-02 16:37:05 -0500746 logging.info("Port count less than 2, can't run this case")
747 return
Flavio Castro1c9b1252016-02-04 18:42:58 -0500748 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
749 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
750 dip = 0xc0a80001
751 Groups = Queue.LifoQueue()
Flavio Castro72a45d52015-12-02 16:37:05 -0500752 ports = config["port_map"].keys()
753 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500754 # add l2 interface group
755 id = port
756 vlan_id = id
757 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
758 vlan_id, True, True)
759 dst_mac[5] = vlan_id
760 # add MPLS interface group
761 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid,
762 dst_mac, intf_src_mac,
763 vlan_id, id)
764 # add MPLS L3 VPN group
765 mpls_label_gid, mpls_label_msg = add_mpls_label_group(
766 self.controller,
767 subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
768 index=id, ref_gid=mpls_gid, push_mpls_header=True,
769 set_mpls_label=port, set_bos=1, set_ttl=32)
770 ecmp_msg = add_l3_ecmp_group(self.controller, id, [mpls_label_gid])
Flavio Castro80730822015-12-11 15:38:47 -0500771 do_barrier(self.controller)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500772 # add vlan flow table
773 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0,
774 flag=VLAN_TABLE_FLAG_ONLY_TAG)
775 # add termination flow
776 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
777 vlan_id)
778 # add routing flow
779 dst_ip = dip + (vlan_id << 8)
780 # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
781 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
782 0xffffff00, ecmp_msg.group_id, vrf=0)
783 Groups._put(l2_gid)
784 Groups._put(mpls_gid)
785 Groups._put(mpls_label_gid)
786 Groups._put(ecmp_msg.group_id)
Flavio Castro80730822015-12-11 15:38:47 -0500787
788 do_barrier(self.controller)
789
790 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
791 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500792 mac_src = '00:00:00:22:22:%02X' % (in_port)
793 ip_src = '192.168.%02d.1' % (in_port)
Flavio Castro80730822015-12-11 15:38:47 -0500794 for out_port in ports:
795 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500796 continue
797 ip_dst = '192.168.%02d.1' % (out_port)
798 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
799 vlan_vid=(in_port),
800 eth_dst=switch_mac,
801 eth_src=mac_src, ip_ttl=64,
802 ip_src=ip_src,
803 ip_dst=ip_dst)
804 pkt = str(parsed_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500805 self.dataplane.send(in_port, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500806 # build expect packet
807 mac_dst = '00:00:00:22:22:%02X' % out_port
Flavio Castro80730822015-12-11 15:38:47 -0500808 label = (out_port, 0, 1, 32)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500809 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
810 vlan_vid=(out_port), ip_ttl=63,
811 ip_src=ip_src,
812 ip_dst=ip_dst, eth_dst=mac_dst,
813 eth_src=switch_mac, label=[label])
814 pkt = str(exp_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500815 verify_packet(self, pkt, out_port)
816 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500817 delete_all_flows(self.controller)
818 delete_groups(self.controller, Groups)
819
castroflavioee294842016-01-06 15:54:28 -0800820
Flavio Castro2262fd42016-02-04 19:03:36 -0500821
822class _24ECMPL3(base_tests.SimpleDataPlane):
Flavio Castro80730822015-12-11 15:38:47 -0500823 """
Flavio Castro2262fd42016-02-04 19:03:36 -0500824 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
825 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
Flavio Castro80730822015-12-11 15:38:47 -0500826 """
Flavio Castro80730822015-12-11 15:38:47 -0500827
Flavio Castro1c9b1252016-02-04 18:42:58 -0500828 def runTest(self):
Flavio Castro2262fd42016-02-04 19:03:36 -0500829 Groups = Queue.LifoQueue()
Flavio Castro1c9b1252016-02-04 18:42:58 -0500830 if len(config["port_map"]) < 2:
Flavio Castro80730822015-12-11 15:38:47 -0500831 logging.info("Port count less than 2, can't run this case")
832 return
833
Flavio Castro1c9b1252016-02-04 18:42:58 -0500834 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
835 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
836 dip = 0xc0a80001
Flavio Castro2262fd42016-02-04 19:03:36 -0500837 # Hashes Test Name and uses it as id for installing unique groups
Flavio Castro80730822015-12-11 15:38:47 -0500838 ports = config["port_map"].keys()
839 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500840 vlan_id = port
Flavio Castro2262fd42016-02-04 19:03:36 -0500841 id = port
842 # add l2 interface group
843 l2_gid, msg = add_one_l2_interface_group(self.controller, port,
844 vlan_id=vlan_id,
845 is_tagged=True,
846 send_barrier=False)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500847 dst_mac[5] = vlan_id
Flavio Castro2262fd42016-02-04 19:03:36 -0500848 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
849 id=id, src_mac=intf_src_mac,
850 dst_mac=dst_mac)
851 ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
Flavio Castro1c9b1252016-02-04 18:42:58 -0500852 # add vlan flow table
Flavio Castro2262fd42016-02-04 19:03:36 -0500853 add_one_vlan_table_flow(self.controller, port, vlan_id,
Flavio Castro1c9b1252016-02-04 18:42:58 -0500854 flag=VLAN_TABLE_FLAG_ONLY_TAG)
855 # add termination flow
856 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
857 vlan_id)
Flavio Castro2262fd42016-02-04 19:03:36 -0500858 # add unicast routing flow
Flavio Castro1c9b1252016-02-04 18:42:58 -0500859 dst_ip = dip + (vlan_id << 8)
860 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
Flavio Castro2262fd42016-02-04 19:03:36 -0500861 0xffffff00, ecmp_msg.group_id)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500862 Groups._put(l2_gid)
Flavio Castro2262fd42016-02-04 19:03:36 -0500863 Groups._put(l3_msg.group_id)
864 Groups._put(ecmp_msg.group_id)
Flavio Castro72a45d52015-12-02 16:37:05 -0500865 do_barrier(self.controller)
866
867 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
868 for in_port in ports:
Flavio Castro2262fd42016-02-04 19:03:36 -0500869 mac_src = '00:00:00:22:22:%02X' % in_port
870 ip_src = '192.168.%02d.1' % in_port
Flavio Castro72a45d52015-12-02 16:37:05 -0500871 for out_port in ports:
872 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500873 continue
Flavio Castro2262fd42016-02-04 19:03:36 -0500874 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro1c9b1252016-02-04 18:42:58 -0500875 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
Flavio Castro2262fd42016-02-04 19:03:36 -0500876 vlan_vid=in_port,
877 eth_dst=switch_mac,
878 eth_src=mac_src, ip_ttl=64,
Flavio Castro1c9b1252016-02-04 18:42:58 -0500879 ip_src=ip_src,
880 ip_dst=ip_dst)
881 pkt = str(parsed_pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500882 self.dataplane.send(in_port, pkt)
Flavio Castro2262fd42016-02-04 19:03:36 -0500883 # build expected packet
884 mac_dst = '00:00:00:22:22:%02X' % out_port
885 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
886 vlan_vid=out_port,
887 eth_dst=mac_dst, eth_src=switch_mac,
888 ip_ttl=63,
889 ip_src=ip_src, ip_dst=ip_dst)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500890 pkt = str(exp_pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500891 verify_packet(self, pkt, out_port)
892 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500893 delete_all_flows(self.controller)
894 delete_groups(self.controller, Groups)
895
Flavio Castroaba28ff2016-02-03 16:47:48 -0500896@disabled
Flavio Castro80730822015-12-11 15:38:47 -0500897class MPLSBUG(base_tests.SimpleDataPlane):
Flavio Castro80730822015-12-11 15:38:47 -0500898 def runTest(self):
Flavio Castro1c9b1252016-02-04 18:42:58 -0500899 if len(config["port_map"]) < 2:
Flavio Castro80730822015-12-11 15:38:47 -0500900 logging.info("Port count less than 2, can't run this case")
901 return
Flavio Castro1c9b1252016-02-04 18:42:58 -0500902 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
903 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
904 dip = 0xc0a80001
905 Groups = Queue.LifoQueue()
Flavio Castro80730822015-12-11 15:38:47 -0500906 ports = config["port_map"].keys()
907 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500908 # add l2 interface group
909 vlan_id = port
910 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
911 vlan_id, True, False)
912 dst_mac[5] = vlan_id
913 # add L3 Unicast group
914 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
915 id=vlan_id, src_mac=intf_src_mac,
916 dst_mac=dst_mac)
917 # add vlan flow table
918 add_one_vlan_table_flow(self.controller, port, vlan_id,
919 flag=VLAN_TABLE_FLAG_ONLY_BOTH)
920 # add termination flow
921 add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
922 vlan_id, goto_table=24)
923 # add mpls flow
Flavio Castro80730822015-12-11 15:38:47 -0500924 add_mpls_flow(self.controller, l3_msg.group_id, port)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500925 # add termination flow
926 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
927 vlan_id)
928 # add unicast routing flow
929 dst_ip = dip + (vlan_id << 8)
930 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
931 0xffffffff, l3_msg.group_id)
932 Groups._put(l2_gid)
933 Groups._put(l3_msg.group_id)
Flavio Castro80730822015-12-11 15:38:47 -0500934 do_barrier(self.controller)
935
936 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
937 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500938 mac_src = '00:00:00:22:22:%02X' % in_port
939 ip_src = '192.168.%02d.1' % in_port
Flavio Castro80730822015-12-11 15:38:47 -0500940 for out_port in ports:
941 if in_port == out_port:
Flavio Castro1c9b1252016-02-04 18:42:58 -0500942 continue
943 ip_dst = '192.168.%02d.1' % out_port
Flavio Castro80730822015-12-11 15:38:47 -0500944 switch_mac = "00:00:00:cc:cc:cc"
945 label = (out_port, 0, 1, 32)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500946 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
947 vlan_vid=in_port, ip_src=ip_src,
948 ip_dst=ip_dst, eth_dst=switch_mac,
949 eth_src=mac_src, label=[label])
950 pkt = str(parsed_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500951 self.dataplane.send(in_port, pkt)
952
Flavio Castro1c9b1252016-02-04 18:42:58 -0500953 # build expect packet
954 mac_dst = '00:00:00:22:22:%02X' % out_port
955 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
956 vlan_vid=out_port,
957 eth_dst=mac_dst, eth_src=switch_mac,
958 ip_ttl=31, ip_src=ip_src,
959 ip_dst=ip_dst)
960 pkt = str(exp_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500961 verify_packet(self, pkt, out_port)
962 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500963
964 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
965 vlan_vid=in_port,
966 eth_dst=switch_mac,
967 eth_src=mac_src, ip_ttl=64,
968 ip_src=ip_src,
969 ip_dst=ip_dst)
970 pkt = str(parsed_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500971 self.dataplane.send(in_port, pkt)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500972 # build expected packet
973 mac_dst = '00:00:00:22:22:%02X' % out_port
974 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
975 vlan_vid=out_port,
976 eth_dst=mac_dst, eth_src=switch_mac,
977 ip_ttl=63,
978 ip_src=ip_src, ip_dst=ip_dst)
979 pkt = str(exp_pkt)
Flavio Castro80730822015-12-11 15:38:47 -0500980 verify_packet(self, pkt, out_port)
981 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -0500982 delete_all_flows(self.controller)
983 delete_groups(self.controller, Groups)
984
Flavio Castro80730822015-12-11 15:38:47 -0500985
Flavio Castro12296312015-12-15 17:48:26 -0500986class L3McastToL2(base_tests.SimpleDataPlane):
castroflaviocc403a92015-12-15 14:04:19 -0500987 """
Flavio Castro12296312015-12-15 17:48:26 -0500988 Mcast routing to L2
castroflaviocc403a92015-12-15 14:04:19 -0500989 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500990
castroflaviocc403a92015-12-15 14:04:19 -0500991 def runTest(self):
992 """
993 port1 (vlan 300)-> All Ports (vlan 300)
994 """
Flavio Castro1c9b1252016-02-04 18:42:58 -0500995 if len(config["port_map"]) < 3:
castroflavio4a09c962016-01-05 13:13:41 -0800996 logging.info("Port count less than 3, can't run this case")
Flavio Castro1c9b1252016-02-04 18:42:58 -0500997 assert (False)
castroflaviocc403a92015-12-15 14:04:19 -0500998 return
Flavio Castro1c9b1252016-02-04 18:42:58 -0500999 Groups = Queue.LifoQueue()
1000 vlan_id = 300
1001 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1002 intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
1003 dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
1004 dst_mac_str = ':'.join(['%02X' % x for x in dst_mac])
1005 port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
1006 port1_mac_str = ':'.join(['%02X' % x for x in port1_mac])
1007 src_ip = 0xc0a80101
1008 src_ip_str = "192.168.1.1"
1009 dst_ip = 0xe0010101
1010 dst_ip_str = "224.1.1.1"
castroflaviocc403a92015-12-15 14:04:19 -05001011
Flavio Castro1c9b1252016-02-04 18:42:58 -05001012 port1 = config["port_map"].keys()[0]
1013 port2 = config["port_map"].keys()[1]
castroflaviocc403a92015-12-15 14:04:19 -05001014
1015 switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00]
1016
Flavio Castro1c9b1252016-02-04 18:42:58 -05001017 # add l2 interface group
1018 l2_intf_group_list = []
castroflaviocc403a92015-12-15 14:04:19 -05001019 for port in config["port_map"].keys():
Flavio Castro1c9b1252016-02-04 18:42:58 -05001020 add_one_vlan_table_flow(self.controller, port, vlan_id,
1021 flag=VLAN_TABLE_FLAG_ONLY_TAG)
castroflaviocc403a92015-12-15 14:04:19 -05001022 if port == port2:
1023 continue
Flavio Castro1c9b1252016-02-04 18:42:58 -05001024 l2_intf_gid, msg = add_one_l2_interface_group(self.controller, port,
1025 vlan_id=vlan_id,
1026 is_tagged=True,
1027 send_barrier=False)
castroflaviocc403a92015-12-15 14:04:19 -05001028 l2_intf_group_list.append(l2_intf_gid)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001029 Groups.put(l2_intf_gid)
castroflaviocc403a92015-12-15 14:04:19 -05001030
Flavio Castro1c9b1252016-02-04 18:42:58 -05001031 # add termination flow
1032 add_termination_flow(self.controller, port1, 0x0800, switch_mac,
1033 vlan_id)
castroflaviocc403a92015-12-15 14:04:19 -05001034
Flavio Castro1c9b1252016-02-04 18:42:58 -05001035 # add l3 interface group
1036 mcat_group_msg = add_l3_mcast_group(self.controller, vlan_id, 2,
1037 l2_intf_group_list)
1038 add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip,
1039 mcat_group_msg.group_id)
1040 Groups._put(mcat_group_msg.group_id)
castroflaviocc403a92015-12-15 14:04:19 -05001041
Flavio Castro1c9b1252016-02-04 18:42:58 -05001042 parsed_pkt = simple_udp_packet(pktlen=100,
Flavio Castro89933f22016-02-03 15:53:16 -05001043 dl_vlan_enable=True,
1044 vlan_vid=vlan_id,
castroflaviocc403a92015-12-15 14:04:19 -05001045 eth_dst=dst_mac_str,
1046 eth_src=port1_mac_str,
1047 ip_ttl=64,
1048 ip_src=src_ip_str,
1049 ip_dst=dst_ip_str)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001050 pkt = str(parsed_pkt)
castroflaviocc403a92015-12-15 14:04:19 -05001051 self.dataplane.send(port1, pkt)
1052 for port in config["port_map"].keys():
Flavio Castro12296312015-12-15 17:48:26 -05001053 if port == port2 or port == port1:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001054 verify_no_packet(self, pkt, port)
1055 continue
castroflaviocc403a92015-12-15 14:04:19 -05001056 verify_packet(self, pkt, port)
1057 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001058 delete_all_flows(self.controller)
1059 delete_groups(self.controller, Groups)
1060
castroflaviocc403a92015-12-15 14:04:19 -05001061
Flavio Castro12296312015-12-15 17:48:26 -05001062class L3McastToL3(base_tests.SimpleDataPlane):
1063 """
1064 Mcast routing
1065 """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001066
1067 def runTest(self):
Flavio Castro12296312015-12-15 17:48:26 -05001068 """
1069 port1 (vlan 1)-> port 2 (vlan 2)
1070 """
Flavio Castro1c9b1252016-02-04 18:42:58 -05001071 Groups = Queue.LifoQueue()
1072 if len(config["port_map"]) < 3:
castroflavio4a09c962016-01-05 13:13:41 -08001073 logging.info("Port count less than 3, can't run this case")
Flavio Castro1c9b1252016-02-04 18:42:58 -05001074 assert (False)
Flavio Castro12296312015-12-15 17:48:26 -05001075 return
1076
Flavio Castro1c9b1252016-02-04 18:42:58 -05001077 vlan_id = 1
1078 port2_out_vlan = 2
1079 port3_out_vlan = 3
1080 in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
1081 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1082 intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac])
1083 dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
1084 dst_mac_str = ':'.join(['%02X' % x for x in dst_mac])
1085 port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
1086 port1_mac_str = ':'.join(['%02X' % x for x in port1_mac])
1087 src_ip = 0xc0a80101
1088 src_ip_str = "192.168.1.1"
1089 dst_ip = 0xe0010101
1090 dst_ip_str = "224.1.1.1"
Flavio Castro12296312015-12-15 17:48:26 -05001091
Flavio Castro1c9b1252016-02-04 18:42:58 -05001092 port1 = config["port_map"].keys()[0]
1093 port2 = config["port_map"].keys()[1]
1094 port3 = config["port_map"].keys()[2]
Flavio Castro12296312015-12-15 17:48:26 -05001095
Flavio Castro1c9b1252016-02-04 18:42:58 -05001096 # add l2 interface group
1097 for port in config["port_map"].keys():
1098 l2gid, msg = add_one_l2_interface_group(self.controller, port,
1099 vlan_id=vlan_id,
1100 is_tagged=False,
1101 send_barrier=False)
1102 # add vlan flow table
1103 add_one_vlan_table_flow(self.controller, port, vlan_id,
1104 flag=VLAN_TABLE_FLAG_ONLY_TAG)
1105 vlan_id += 1
1106 Groups._put(l2gid)
Flavio Castro12296312015-12-15 17:48:26 -05001107
Flavio Castro1c9b1252016-02-04 18:42:58 -05001108 # add termination flow
1109 add_termination_flow(self.controller, port1, 0x0800,
1110 [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
1111
1112 # add l3 interface group
1113 port2_ucast_msg = add_l3_interface_group(self.controller, port2,
1114 port2_out_vlan, 2,
1115 intf_src_mac)
1116 port3_ucast_msg = add_l3_interface_group(self.controller, port3,
1117 port3_out_vlan, 3,
1118 intf_src_mac)
1119 mcat_group_msg = add_l3_mcast_group(self.controller, in_vlan, 2,
1120 [port2_ucast_msg.group_id,
1121 port3_ucast_msg.group_id])
1122 add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip,
1123 mcat_group_msg.group_id)
1124 Groups._put(port2_ucast_msg.group_id)
1125 Groups._put(port3_ucast_msg.group_id)
1126 Groups._put(mcat_group_msg.group_id)
1127 parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True,
1128 vlan_vid=1,
Flavio Castro12296312015-12-15 17:48:26 -05001129 eth_dst=dst_mac_str,
1130 eth_src=port1_mac_str,
1131 ip_ttl=64,
1132 ip_src=src_ip_str,
1133 ip_dst=dst_ip_str)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001134 pkt = str(parsed_pkt)
1135 self.dataplane.send(port1, pkt)
1136 parsed_pkt = simple_udp_packet(pktlen=96,
Flavio Castro12296312015-12-15 17:48:26 -05001137 eth_dst=dst_mac_str,
1138 eth_src=intf_src_mac_str,
1139 ip_ttl=63,
1140 ip_src=src_ip_str,
1141 ip_dst=dst_ip_str)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001142 pkt = str(parsed_pkt)
Flavio Castro12296312015-12-15 17:48:26 -05001143 verify_packet(self, pkt, port2)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001144 verify_packet(self, pkt, port3)
1145 verify_no_other_packets(self)
1146 delete_all_flows(self.controller)
1147 delete_groups(self.controller, Groups)
Flavio Castro54947942016-02-03 16:05:20 -05001148
1149
Flavio Castrof54be492016-02-03 16:26:22 -05001150class _MplsTermination(base_tests.SimpleDataPlane):
Flavio Castro12296312015-12-15 17:48:26 -05001151 """
Flavio Castro54947942016-02-03 16:05:20 -05001152 Insert IP packet
1153 Receive MPLS packet
castroflavio30c6cc52016-01-07 15:19:42 -08001154 """
castroflavio30c6cc52016-01-07 15:19:42 -08001155
Flavio Castro1c9b1252016-02-04 18:42:58 -05001156 def runTest(self):
1157 Groups = Queue.LifoQueue()
1158 if len(config["port_map"]) < 2:
castroflavio30c6cc52016-01-07 15:19:42 -08001159 logging.info("Port count less than 2, can't run this case")
1160 return
1161
Flavio Castro1c9b1252016-02-04 18:42:58 -05001162 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1163 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
1164 # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules
castroflavio30c6cc52016-01-07 15:19:42 -08001165 ports = config["port_map"].keys()
1166 for port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001167 # add l2 interface group
1168 id = port
1169 vlan_id = id
1170 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port,
1171 vlan_id, True, False)
1172 dst_mac[5] = vlan_id
1173 # add L3 Unicast group
1174 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
1175 id=id, src_mac=intf_src_mac,
1176 dst_mac=dst_mac)
1177 # add L3 ecmp group
Flavio Castro54947942016-02-03 16:05:20 -05001178 ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id])
Flavio Castro1c9b1252016-02-04 18:42:58 -05001179 # add vlan flow table
1180 add_one_vlan_table_flow(self.controller, port, vlan_id,
1181 flag=VLAN_TABLE_FLAG_ONLY_TAG)
1182 # add termination flow
1183 add_termination_flow(self.controller, port, 0x8847, intf_src_mac,
1184 vlan_id, goto_table=24)
Flavio Castro54947942016-02-03 16:05:20 -05001185 add_mpls_flow(self.controller, ecmp_msg.group_id, port)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001186 Groups._put(l2_gid)
1187 Groups._put(l3_msg.group_id)
1188 Groups._put(ecmp_msg.group_id)
castroflavio30c6cc52016-01-07 15:19:42 -08001189 do_barrier(self.controller)
1190
1191 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
1192 for in_port in ports:
Flavio Castro1c9b1252016-02-04 18:42:58 -05001193 ip_src = '192.168.%02d.1' % (in_port)
castroflavio30c6cc52016-01-07 15:19:42 -08001194 for out_port in ports:
1195 if in_port == out_port:
Flavio Castro54947942016-02-03 16:05:20 -05001196 continue
Flavio Castro1c9b1252016-02-04 18:42:58 -05001197 ip_dst = '192.168.%02d.1' % (out_port)
Flavio Castro54947942016-02-03 16:05:20 -05001198
1199 label = (out_port, 0, 1, 32)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001200 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,
1201 vlan_vid=(in_port), ip_src=ip_src,
1202 ip_dst=ip_dst, eth_dst=switch_mac,
1203 label=[label])
1204 pkt = str(parsed_pkt)
castroflavio30c6cc52016-01-07 15:19:42 -08001205 self.dataplane.send(in_port, pkt)
Flavio Castro54947942016-02-03 16:05:20 -05001206
Flavio Castro1c9b1252016-02-04 18:42:58 -05001207 # build expect packet
1208 mac_dst = '00:00:00:22:22:%02X' % (out_port)
1209 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
1210 vlan_vid=(out_port),
1211 eth_dst=mac_dst, eth_src=switch_mac,
1212 ip_ttl=31, ip_src=ip_src,
1213 ip_dst=ip_dst)
1214 pkt = str(exp_pkt)
castroflavio30c6cc52016-01-07 15:19:42 -08001215 verify_packet(self, pkt, out_port)
1216 verify_no_other_packets(self)
Flavio Castro1c9b1252016-02-04 18:42:58 -05001217 delete_all_flows(self.controller)
1218 delete_groups(self.controller, Groups)
1219
Flavio Castrod0619992016-02-04 15:10:28 -05001220
Flavio Castro1c9b1252016-02-04 18:42:58 -05001221
1222
1223class _24UcastTagged(base_tests.SimpleDataPlane):
1224 """
1225 Verify a IP forwarding works for a /32 rule to L3 Unicast Interface
1226 """
1227
1228 def runTest(self):
1229 test_id = 26
1230 if len(config["port_map"]) < 2:
1231 logging.info("Port count less than 2, can't run this case")
1232 return
1233
1234 intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
1235 dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
1236 dip = 0xc0a80001
1237 ports = config["port_map"].keys()
1238 Groups = Queue.LifoQueue()
1239 for port in ports:
1240 # add l2 interface group
1241 vlan_id = port + test_id
1242 l2gid, msg = add_one_l2_interface_group(self.controller, port,
1243 vlan_id=vlan_id,
1244 is_tagged=True,
1245 send_barrier=False)
1246 dst_mac[5] = vlan_id
1247 l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id,
1248 id=vlan_id, src_mac=intf_src_mac,
1249 dst_mac=dst_mac)
1250 # add vlan flow table
1251 add_one_vlan_table_flow(self.controller, port, vlan_id,
1252 flag=VLAN_TABLE_FLAG_ONLY_TAG)
1253 # add termination flow
1254 add_termination_flow(self.controller, port, 0x0800, intf_src_mac,
1255 vlan_id)
1256 # add unicast routing flow
1257 dst_ip = dip + (vlan_id << 8)
1258 add_unicast_routing_flow(self.controller, 0x0800, dst_ip,
1259 0xffffff00, l3_msg.group_id)
1260 Groups.put(l2gid)
1261 Groups.put(l3_msg.group_id)
1262 do_barrier(self.controller)
1263
1264 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
1265 for in_port in ports:
1266 mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
1267 ip_src = '192.168.%02d.1' % (test_id + in_port)
1268 for out_port in ports:
1269 if in_port == out_port:
1270 continue
1271 ip_dst = '192.168.%02d.1' % (test_id + out_port)
1272 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
1273 vlan_vid=(test_id + in_port),
1274 eth_dst=switch_mac,
1275 eth_src=mac_src, ip_ttl=64,
1276 ip_src=ip_src,
1277 ip_dst=ip_dst)
1278 pkt = str(parsed_pkt)
1279 self.dataplane.send(in_port, pkt)
1280 # build expected packet
1281 mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
1282 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True,
1283 vlan_vid=(test_id + out_port),
1284 eth_dst=mac_dst, eth_src=switch_mac,
1285 ip_ttl=63,
1286 ip_src=ip_src, ip_dst=ip_dst)
1287 pkt = str(exp_pkt)
1288 verify_packet(self, pkt, out_port)
1289 verify_no_other_packets(self)
1290 delete_all_flows(self.controller)
1291 delete_groups(self.controller, Groups)