blob: 283ca7d7b71414e0cd94db3bc7d61840db121e0d [file] [log] [blame]
Flavio Castro05d20bc2015-11-16 15:06:14 -05001"""
2Flow Test
Flavio Castro3aec8902015-11-20 10:51:38 -050031) PacketInSrcMacMiss
42) L2FloodTagged
53) L2Flood Tagged Unknown Src
64) L2 Unicast Tagged
75) L3 Unicast Tagged
86) MTU 1500
97) MTU 4100
108) MTU 4500
Flavio Castro05d20bc2015-11-16 15:06:14 -050011"""
12
Flavio Castro05d20bc2015-11-16 15:06:14 -050013from oftest import config
Flavio Castro167f5bd2015-12-02 19:33:53 -050014import logging
15import oftest.base_tests as base_tests
Flavio Castro05d20bc2015-11-16 15:06:14 -050016import ofp
17from oftest.testutils import *
18from accton_util import *
Flavio Castrod8f8af22015-12-02 18:19:26 -050019
Flavio Castro05d20bc2015-11-16 15:06:14 -050020
Flavio Castroaabb5792015-11-18 19:03:50 -050021class PacketInSrcMacMiss(base_tests.SimpleDataPlane):
22 """
23 Test packet in function on a src-mac miss
24 Send a packet to each dataplane port and verify that a packet
25 in message is received from the controller for each
26 #todo verify you stop receiving after adding rule
27 """
28
Flavio Castro6efe1862015-11-18 16:28:06 -050029 def runTest(self):
30 delete_all_flows(self.controller)
31 delete_all_groups(self.controller)
32
Flavio Castro34352e72015-12-07 20:01:51 -050033 ports = sorted(config["port_map"].keys())
34 for port in ports:
35 add_one_l2_interface_grouop(self.controller, port, 1, True, False)
36 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
37
Flavio Castroaabb5792015-11-18 19:03:50 -050038 parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
39 vlan_vid=0x1001, dl_vlan_enable=True)
40 vlan_pkt = str(parsed_vlan_pkt)
Flavio Castro6efe1862015-11-18 16:28:06 -050041
Flavio Castroaabb5792015-11-18 19:03:50 -050042 for of_port in config["port_map"].keys():
43 logging.info("PacketInMiss test, port %d", of_port)
44 self.dataplane.send(of_port, vlan_pkt)
45
46 verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH)
47
48 verify_no_other_packets(self)
49
Flavio Castro184cefe2015-11-19 20:52:49 -050050class L2FloodTagged(base_tests.SimpleDataPlane):
51 """
52 Test L2 flood to a vlan
53 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
54 #todo take in account unknown src
55 """
56 def runTest(self):
57 ports = sorted(config["port_map"].keys())
Flavio Castro34352e72015-12-07 20:01:51 -050058
Flavio Castro184cefe2015-11-19 20:52:49 -050059 delete_all_flows(self.controller)
60 delete_all_groups(self.controller)
61
Flavio Castro184cefe2015-11-19 20:52:49 -050062 # Installing flows to avoid packet-in
63 for port in ports:
Flavio Castro34352e72015-12-07 20:01:51 -050064 add_one_l2_interface_grouop(self.controller, port, 1, True, False)
65 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
66
Flavio Castro184cefe2015-11-19 20:52:49 -050067 group_id = encode_l2_interface_group_id(1, port)
68 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro34352e72015-12-07 20:01:51 -050069 msg=add_l2_flood_group(self.controller, ports, 1, 1)
70 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
Flavio Castro184cefe2015-11-19 20:52:49 -050071 do_barrier(self.controller)
72
73 #verify flood
74 for ofport in ports:
75 # change dest based on port number
76 mac_src= '00:12:34:56:78:%02X' % ofport
77 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a', eth_src=mac_src)
78 pkt = str(parsed_pkt)
79 self.dataplane.send(ofport, pkt)
80 #self won't rx packet
81 verify_no_packet(self, pkt, ofport)
82 #others will rx packet
83 tmp_ports=list(ports)
84 tmp_ports.remove(ofport)
85 verify_packets(self, pkt, tmp_ports)
86
87 verify_no_other_packets(self)
88
Flavio Castroaabb5792015-11-18 19:03:50 -050089class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane):
90 """
91 Test L2 flood to a vlan
92 Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport
93 #todo take in account unknown src
94 """
95 def runTest(self):
Flavio Castroaabb5792015-11-18 19:03:50 -050096 delete_all_flows(self.controller)
97 delete_all_groups(self.controller)
98
Flavio Castro34352e72015-12-07 20:01:51 -050099 ports = sorted(config["port_map"].keys())
100 for port in ports:
101 add_one_l2_interface_grouop(self.controller, port, 1, True, False)
102 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500103
104 msg=add_l2_flood_group(self.controller, ports, 1, 1)
105 add_bridge_flow(self.controller, None, 1, msg.group_id, True)
106
107 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a')
108 pkt = str(parsed_pkt)
109 #verify flood
110 for ofport in ports:
111 self.dataplane.send(ofport, pkt)
112 #self won't rx packet
113 verify_no_packet(self, pkt, ofport)
114 #others will rx packet
115 tmp_ports=list(ports)
116 tmp_ports.remove(ofport)
117 verify_packets(self, pkt, tmp_ports)
118
119 verify_no_other_packets(self)
120
Flavio Castroaabb5792015-11-18 19:03:50 -0500121class L2UnicastTagged(base_tests.SimpleDataPlane):
122 """
123 Test output function for an exact-match flow
124
125 For each port A, adds a flow directing matching packets to that port.
126 Then, for all other ports B != A, verifies that sending a matching packet
127 to B results in an output to A.
128 """
129 def runTest(self):
130 ports = sorted(config["port_map"].keys())
131
132 delete_all_flows(self.controller)
133 delete_all_groups(self.controller)
134
Flavio Castroaabb5792015-11-18 19:03:50 -0500135 for port in ports:
Flavio Castro34352e72015-12-07 20:01:51 -0500136 add_one_l2_interface_grouop(self.controller, port, 1, True, False)
137 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castroaabb5792015-11-18 19:03:50 -0500138 group_id = encode_l2_interface_group_id(1, port)
139 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
Flavio Castro6efe1862015-11-18 16:28:06 -0500140 do_barrier(self.controller)
141
Flavio Castroaabb5792015-11-18 19:03:50 -0500142 for out_port in ports:
143 # change dest based on port number
144 mac_dst= '00:12:34:56:78:%02X' % out_port
145 for in_port in ports:
146 if in_port == out_port:
147 continue
148 # change source based on port number to avoid packet-ins from learning
149 mac_src= '00:12:34:56:78:%02X' % in_port
150 parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
151 pkt = str(parsed_pkt)
152 self.dataplane.send(in_port, pkt)
153
154 for ofport in ports:
155 if ofport in [out_port]:
156 verify_packet(self, pkt, ofport)
157 else:
158 verify_no_packet(self, pkt, ofport)
159
160 verify_no_other_packets(self)
Flavio Castro6efe1862015-11-18 16:28:06 -0500161
162
Flavio Castrob6773032015-11-19 22:49:24 -0500163class Mtu4500(base_tests.SimpleDataPlane):
164
165 def runTest(self):
166 ports = sorted(config["port_map"].keys())
167
168 delete_all_flows(self.controller)
169 delete_all_groups(self.controller)
170
Flavio Castrob6773032015-11-19 22:49:24 -0500171 for port in ports:
Flavio Castro34352e72015-12-07 20:01:51 -0500172 add_one_l2_interface_grouop(self.controller, port, 1, True, False)
173 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500174 group_id = encode_l2_interface_group_id(1, port)
175 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
176 do_barrier(self.controller)
177
178 for out_port in ports:
179 # change dest based on port number
180 mac_dst= '00:12:34:56:78:%02X' % out_port
181 for in_port in ports:
182 if in_port == out_port:
183 continue
184 # change source based on port number to avoid packet-ins from learning
185 mac_src= '00:12:34:56:78:%02X' % in_port
186 parsed_pkt = simple_tcp_packet(pktlen=4500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
187 pkt = str(parsed_pkt)
188 self.dataplane.send(in_port, pkt)
189
190 for ofport in ports:
191 if ofport in [out_port]:
192 verify_packet(self, pkt, ofport)
193 else:
194 verify_no_packet(self, pkt, ofport)
195
196 verify_no_other_packets(self)
197
198
199class Mtu1500(base_tests.SimpleDataPlane):
200
201 def runTest(self):
202 ports = sorted(config["port_map"].keys())
203
204 delete_all_flows(self.controller)
205 delete_all_groups(self.controller)
206
Flavio Castro34352e72015-12-07 20:01:51 -0500207 # set up tag groups for each port
208 add_l2_interface_grouop(self.controller, ports, 1, True, 1)
Flavio Castrob6773032015-11-19 22:49:24 -0500209
Flavio Castro34352e72015-12-07 20:01:51 -0500210 add_vlan_table_flow(self.controller, ports)
Flavio Castrob6773032015-11-19 22:49:24 -0500211
212 for port in ports:
Flavio Castro34352e72015-12-07 20:01:51 -0500213 add_one_l2_interface_grouop(self.controller, port, 1, True, False)
214 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500215 group_id = encode_l2_interface_group_id(1, port)
216 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
217 do_barrier(self.controller)
218
219 for out_port in ports:
220 # change dest based on port number
221 mac_dst= '00:12:34:56:78:%02X' % out_port
222 for in_port in ports:
223 if in_port == out_port:
224 continue
225 # change source based on port number to avoid packet-ins from learning
226 mac_src= '00:12:34:56:78:%02X' % in_port
227 parsed_pkt = simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
228 pkt = str(parsed_pkt)
229 self.dataplane.send(in_port, pkt)
230
231 for ofport in ports:
232 if ofport in [out_port]:
233 verify_packet(self, pkt, ofport)
234 else:
235 verify_no_packet(self, pkt, ofport)
236
237 verify_no_other_packets(self)
238
239
240class Mtu4000(base_tests.SimpleDataPlane):
241 """
242 Test output function for an exact-match flow
243 For each port A, adds a flow directing matching packets to that port.
244 Then, for all other ports B != A, verifies that sending a matching packet
245 to B results in an output to A.
246 """
247 def runTest(self):
248 ports = sorted(config["port_map"].keys())
249
250 delete_all_flows(self.controller)
251 delete_all_groups(self.controller)
252
253 add_vlan_table_flow(self.controller, config["port_map"].keys())
254
255 # set up tag groups for each port
256 add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, True, 1)
257
258 for port in ports:
Flavio Castro34352e72015-12-07 20:01:51 -0500259 add_one_l2_interface_grouop(self.controller, port, 1, True, False)
260 add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castrob6773032015-11-19 22:49:24 -0500261 group_id = encode_l2_interface_group_id(1, port)
262 add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True)
263 do_barrier(self.controller)
264
265 for out_port in ports:
266 # change dest based on port number
267 mac_dst= '00:12:34:56:78:%02X' % out_port
268 for in_port in ports:
269 if in_port == out_port:
270 continue
271 # change source based on port number to avoid packet-ins from learning
272 mac_src= '00:12:34:56:78:%02X' % in_port
273 parsed_pkt = simple_tcp_packet(pktlen=4000,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src)
274 pkt = str(parsed_pkt)
275 self.dataplane.send(in_port, pkt)
276
277 for ofport in ports:
278 if ofport in [out_port]:
279 verify_packet(self, pkt, ofport)
280 else:
281 verify_no_packet(self, pkt, ofport)
282
283 verify_no_other_packets(self)
Flavio Castroaabb5792015-11-18 19:03:50 -0500284
285class L3UcastTagged(base_tests.SimpleDataPlane):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500286 """
Flavio Castro35e64392015-12-02 16:53:14 -0500287 Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) ,
288 Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500289 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500290 def runTest(self):
Flavio Castro05d20bc2015-11-16 15:06:14 -0500291 delete_all_flows(self.controller)
292 delete_all_groups(self.controller)
293
294 if len(config["port_map"]) <2:
295 logging.info("Port count less than 2, can't run this case")
296 return
Flavio Castrod8f8af22015-12-02 18:19:26 -0500297
Flavio Castro05d20bc2015-11-16 15:06:14 -0500298 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
299 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
300 dip=0xc0a80001
Flavio Castroa8233862015-12-02 14:41:11 -0500301 ports = config["port_map"].keys()
302 for port in ports:
Flavio Castro05d20bc2015-11-16 15:06:14 -0500303 #add l2 interface group
Flavio Castroa8233862015-12-02 14:41:11 -0500304 vlan_id=port
Flavio Castro05d20bc2015-11-16 15:06:14 -0500305 add_one_l2_interface_grouop(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False)
306 dst_mac[5]=vlan_id
307 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
308 #add vlan flow table
Flavio Castro34352e72015-12-07 20:01:51 -0500309 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500310 #add termination flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500311 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500312 #add unicast routing flow
Flavio Castrod8f8af22015-12-02 18:19:26 -0500313 dst_ip = dip + (vlan_id<<8)
Flavio Castro6efe1862015-11-18 16:28:06 -0500314 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, l3_msg.group_id)
Flavio Castro6efe1862015-11-18 16:28:06 -0500315 #add entries in the Bridging table to avoid packet-in from mac learning
316 group_id = encode_l2_interface_group_id(vlan_id, port)
317 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500318
319 do_barrier(self.controller)
320
Flavio Castro05d20bc2015-11-16 15:06:14 -0500321 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
Flavio Castroa8233862015-12-02 14:41:11 -0500322 for in_port in ports:
323 mac_src='00:00:00:22:22:%02X' % in_port
324 ip_src='192.168.%02d.1' % in_port
325 for out_port in ports:
326 if in_port == out_port:
327 continue
328 ip_dst='192.168.%02d.1' % out_port
329 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
330 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
Flavio Castrod8f8af22015-12-02 18:19:26 -0500331 ip_dst=ip_dst)
Flavio Castroa8233862015-12-02 14:41:11 -0500332 pkt=str(parsed_pkt)
333 self.dataplane.send(in_port, pkt)
Flavio Castro72a45d52015-12-02 16:37:05 -0500334 #build expected packet
Flavio Castroa8233862015-12-02 14:41:11 -0500335 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castrod8f8af22015-12-02 18:19:26 -0500336 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
Flavio Castroa8233862015-12-02 14:41:11 -0500337 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
338 ip_src=ip_src, ip_dst=ip_dst)
339 pkt=str(exp_pkt)
340 verify_packet(self, pkt, out_port)
341 verify_no_other_packets(self)
Flavio Castro05d20bc2015-11-16 15:06:14 -0500342
Flavio Castrod8f8af22015-12-02 18:19:26 -0500343class L3VPNMPLS(base_tests.SimpleDataPlane):
344 """
345 Insert IP packet
346 Receive MPLS packet
347 """
Flavio Castro72a45d52015-12-02 16:37:05 -0500348 def runTest(self):
349 delete_all_flows(self.controller)
350 delete_all_groups(self.controller)
351
352 if len(config["port_map"]) <2:
353 logging.info("Port count less than 2, can't run this case")
354 return
355
356 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
357 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
358 dip=0xc0a80001
359 index=1
360 ports = config["port_map"].keys()
361 for port in ports:
362 #add l2 interface group
363 vlan_id=port
Flavio Castro34352e72015-12-07 20:01:51 -0500364 l2_gid, l2_msg = add_one_l2_interface_grouop(self.controller, port, vlan_id, True, True)
Flavio Castro72a45d52015-12-02 16:37:05 -0500365 dst_mac[5]=vlan_id
Flavio Castro35e64392015-12-02 16:53:14 -0500366 #add MPLS interface group
Flavio Castro72a45d52015-12-02 16:37:05 -0500367 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
Flavio Castro35e64392015-12-02 16:53:14 -0500368 #add MPLS L3 VPN group
Flavio Castrod8f8af22015-12-02 18:19:26 -0500369 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
Flavio Castro72a45d52015-12-02 16:37:05 -0500370 index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
371 #add vlan flow table
Flavio Castro34352e72015-12-07 20:01:51 -0500372 add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro72a45d52015-12-02 16:37:05 -0500373 #add termination flow
374 add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
Flavio Castro35e64392015-12-02 16:53:14 -0500375 #add routing flow
Flavio Castro72a45d52015-12-02 16:37:05 -0500376 dst_ip = dip + (vlan_id<<8)
Flavio Castro34352e72015-12-07 20:01:51 -0500377 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2)
Flavio Castro72a45d52015-12-02 16:37:05 -0500378 #add entries in the Bridging table to avoid packet-in from mac learning
379 group_id = encode_l2_interface_group_id(vlan_id, port)
380 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
381
382 do_barrier(self.controller)
383
384 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
385 for in_port in ports:
386 mac_src='00:00:00:22:22:%02X' % in_port
387 ip_src='192.168.%02d.1' % in_port
388 for out_port in ports:
389 if in_port == out_port:
390 continue
391 ip_dst='192.168.%02d.1' % out_port
392 parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port,
393 eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src,
394 ip_dst=ip_dst)
395 pkt=str(parsed_pkt)
396 self.dataplane.send(in_port, pkt)
397 #build expect packet
398 mac_dst='00:00:00:22:22:%02X' % out_port
399 label = (out_port, 0, 1, 32)
Flavio Castro34352e72015-12-07 20:01:51 -0500400 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src,
Flavio Castro72a45d52015-12-02 16:37:05 -0500401 ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
402 pkt=str(exp_pkt)
403 verify_packet(self, pkt, out_port)
404 verify_no_other_packets(self)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500405
406class MplsTermination(base_tests.SimpleDataPlane):
Flavio Castro34352e72015-12-07 20:01:51 -0500407 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500408 Insert IP packet
409 Receive MPLS packet
Flavio Castro34352e72015-12-07 20:01:51 -0500410 """
Flavio Castrod8f8af22015-12-02 18:19:26 -0500411 def runTest(self):
412 delete_all_flows(self.controller)
413 delete_all_groups(self.controller)
414
415 if len(config["port_map"]) <2:
416 logging.info("Port count less than 2, can't run this case")
417 return
418
419 intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
420 dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
421 dip=0xc0a80001
422 index=1
423 ports = config["port_map"].keys()
424 for port in ports:
425 #add l2 interface group
426 vlan_id=port
427 l2_gid, l2_msg = add_one_l2_interface_grouop(self.controller, port, vlan_id, True, False)
428 dst_mac[5]=vlan_id
429 #add L3 Unicast group
430 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500431 #add L3 ecmp group
432 ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500433 #add vlan flow table
434 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
435 #add termination flow
Flavio Castro167f5bd2015-12-02 19:33:53 -0500436 add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500437 #add routing flow
438 dst_ip = dip + (vlan_id<<8)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500439 add_mpls_flow(self.controller, ecmp_msg.group_id, port)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500440 #add entries in the Bridging table to avoid packet-in from mac learning
441 group_id = encode_l2_interface_group_id(vlan_id, port)
442 add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
443
444 do_barrier(self.controller)
445
446 switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
447 for in_port in ports:
448 mac_src='00:00:00:22:22:%02X' % in_port
449 ip_src='192.168.%02d.1' % in_port
450 for out_port in ports:
451 if in_port == out_port:
452 continue
453 ip_dst='192.168.%02d.1' % out_port
Flavio Castro167f5bd2015-12-02 19:33:53 -0500454
455 label = (out_port, 0, 1, 32)
456 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src,
457 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label])
Flavio Castrod8f8af22015-12-02 18:19:26 -0500458 pkt=str(parsed_pkt)
459 self.dataplane.send(in_port, pkt)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500460
Flavio Castrod8f8af22015-12-02 18:19:26 -0500461 #build expect packet
462 mac_dst='00:00:00:22:22:%02X' % out_port
Flavio Castro167f5bd2015-12-02 19:33:53 -0500463 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
464 eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst)
Flavio Castrod8f8af22015-12-02 18:19:26 -0500465 pkt=str(exp_pkt)
466 verify_packet(self, pkt, out_port)
Flavio Castro167f5bd2015-12-02 19:33:53 -0500467 verify_no_other_packets(self)
468
Flavio Castro34352e72015-12-07 20:01:51 -0500469