blob: b8276526e3fa72b1dc5c233f338f5b1912db30e5 [file] [log] [blame]
macauley68ace672015-07-27 17:40:50 +08001"""
2Flow Test
3
4Test each flow table can set entry, and packet rx correctly.
5"""
6
7import logging
8
9from oftest import config
10import oftest.base_tests as base_tests
11import ofp
12from oftest.testutils import *
13from accton_util import *
14import oftest.parse as decode
15
16class VxlanConfigNetconf(base_tests.SimpleDataPlane):
17 """
18 Verify netconf to configure Vxlan port
19 """
20 def runTest(self):
21 if config["switch_ip"] == None:
22 logging.error("Doesn't configure switch IP")
23 return
24
macauley_cheng681958a2015-11-11 10:32:05 +080025 delete_all_flows(self.controller)
26 delete_all_groups(self.controller)
27
macauley68ace672015-07-27 17:40:50 +080028 #paramaters
29 access_port_vid=1
30 access_phy_port=1
31 access_lport=0x10001
32 vnid=103
33 next_hop_id=1
34 next_hop_id_mcast=2
35 dst_mac="00:00:11:22:22:11"
36 mcast_ipv4="224.1.1.1"
37 dst_mac_mcast="01:00:5e:01:01:01"
38 network_port_phy_port=2
39 network_lport=0x10002
40 network_port_vlan=2
41 network_port_sip="192.168.1.1"
42 network_port_dip="192.168.2.1"
43
macauley6f6ceb22015-08-07 09:37:12 +080044 xml_before=get_edit_config(config["switch_ip"])
macauley68ace672015-07-27 17:40:50 +080045 #get datapath_id from feature message
46 feature_reply=get_featureReplay(self)
47 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
48 dst_mac=dst_mac_mcast,
49 phy_port=network_port_phy_port,
50 vlan=network_port_vlan)
macauley6f6ceb22015-08-07 09:37:12 +080051 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id_mcast, dst_mac_mcast, network_port_phy_port, network_port_vlan);
52 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +080053
54 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
55 dst_mac=dst_mac,
56 phy_port=network_port_phy_port,
57 vlan=network_port_vlan)
58 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
macauley6f6ceb22015-08-07 09:37:12 +080059 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +080060
61 vni_config_xml=get_vni_config_xml(vni_id=vnid,
62 mcast_ipv4=mcast_ipv4,
63 next_hop_id=next_hop_id_mcast)
64 logging.info("config VNI %lx", vnid);
macauley6f6ceb22015-08-07 09:37:12 +080065 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
macauley68ace672015-07-27 17:40:50 +080066
67 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
68 lport=access_lport, phy_port=access_phy_port,
69 vlan=access_port_vid, vnid=vnid)
70 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport, access_phy_port, access_port_vid, vnid);
macauley6f6ceb22015-08-07 09:37:12 +080071 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +080072
73 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
74 lport=network_lport,
75 src_ip=network_port_sip, dst_ip=network_port_dip,
76 next_hop_id=next_hop_id,
77 vnid=vnid)
78 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport, network_port_sip, network_port_dip, next_hop_id);
macauley6f6ceb22015-08-07 09:37:12 +080079 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +080080
81 get_edit_config(config["switch_ip"])
82
83 #exit verification so clear all configuration
84 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
85 lport=access_lport, phy_port=access_phy_port,
86 vlan=access_port_vid, vnid=vnid, operation="delete")
macauley6f6ceb22015-08-07 09:37:12 +080087 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +080088
89 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
90 lport=network_lport,
91 src_ip=network_port_sip, dst_ip=network_port_dip,
92 next_hop_id=next_hop_id,
93 vnid=vnid, operation="delete")
macauley6f6ceb22015-08-07 09:37:12 +080094 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +080095
96 vni_config_xml=get_vni_config_xml(vni_id=vnid,
97 mcast_ipv4=mcast_ipv4,
98 next_hop_id=next_hop_id_mcast, operation="delete")
macauley6f6ceb22015-08-07 09:37:12 +080099 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800100
101 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
102 dst_mac=dst_mac,
103 phy_port=network_port_phy_port,
104 vlan=network_port_vlan, operation="delete")
macauley6f6ceb22015-08-07 09:37:12 +0800105 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800106
107 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
108 dst_mac=dst_mac_mcast,
109 phy_port=network_port_phy_port,
110 vlan=network_port_vlan, operation="delete")
macauley6f6ceb22015-08-07 09:37:12 +0800111 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800112
macauley6f6ceb22015-08-07 09:37:12 +0800113 xml_after=get_edit_config(config["switch_ip"])
macauley_cheng681958a2015-11-11 10:32:05 +0800114 #logging.info("xml_before\n %s", xml_before)
115 #logging.info("xml_after\n %s", xml_after)
116 #netopeer may have problem on xml process
117 #assert(xml_before == xml_after)
macauley68ace672015-07-27 17:40:50 +0800118
119class OverlayFloodGroup(base_tests.SimpleDataPlane):
120 """
121 create two lport
122 """
123 def runTest(self):
124 """
125 first verify flood over unicast,
126 second verify flood over mcast
127 """
128 if config["switch_ip"] == None:
129 logging.error("Doesn't configure switch IP")
130 return
131
132 delete_all_flows(self.controller)
133 delete_all_groups(self.controller)
134 #paramaters
135 access_port_vid=1
136 access_phy_port=1
137 access_lport=0x10001
138 vnid=103
139 next_hop_id=1
140 next_hop_id_mcast=2
141 dst_mac="00:00:11:22:22:11"
142 mcast_ipv4="224.1.1.1"
143 dst_mac_mcast="01:00:5e:01:01:01"
144 network_port_phy_port=2
145 network_lport=0x10002
146 network_port_vlan=2
147 network_port_sip="192.168.1.1"
148 network_port_dip="192.168.2.1"
149
150 feature_reply=get_featureReplay(self)
151 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
152 dst_mac=dst_mac_mcast,
153 phy_port=network_port_phy_port,
154 vlan=network_port_vlan)
155 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
156 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
157 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
158 logging.info("config VNI %lx", vnid);
159 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
160
161 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
162 lport=access_lport, phy_port=access_phy_port,
163 vlan=access_port_vid, vnid=vnid)
164 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport, access_phy_port, access_port_vid, vnid);
165 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
166 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
167 dst_mac=dst_mac,
168 phy_port=network_port_phy_port,
169 vlan=network_port_vlan)
170 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
171 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
172 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
173 lport=network_lport,
174 src_ip=network_port_sip, dst_ip=network_port_dip,
175 next_hop_id=next_hop_id,
176 vnid=vnid)
177 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport, network_port_sip, network_port_dip, next_hop_id);
178 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
179
180 #add flow over unicast group
181 msg=add_l2_overlay_flood_over_unicast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
182 #verify
183 stats = get_stats(self, ofp.message.group_desc_stats_request())
184 verify_group_stats=(ofp.group_desc_stats_entry(
185 group_type=msg.group_type,
186 group_id=msg.group_id,
187 buckets=msg.buckets))
188
189 self.assertEquals(stats, [verify_group_stats])
190 #clear all group
191 delete_all_groups(self.controller)
192 #
193 #flood over mcast
194 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
195
196 stats = get_stats(self, ofp.message.group_desc_stats_request())
197
198 verify_group_stats=(ofp.group_desc_stats_entry(
199 group_type=msg.group_type,
200 group_id=msg.group_id,
201 buckets=msg.buckets))
202
203 self.assertEquals(stats, [verify_group_stats])
204 #clear all group
205 delete_all_groups(self.controller)
206 #exit verification so clear all configuration
207 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
208 lport=access_lport, phy_port=access_phy_port,
209 vlan=access_port_vid, vnid=vnid, operation="delete")
210 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
211 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
212 lport=network_lport,
213 src_ip=network_port_sip, dst_ip=network_port_dip,
214 next_hop_id=next_hop_id,
215 vnid=vnid, operation="delete")
216 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
217
218 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
219 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
220
221 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
222 dst_mac=dst_mac,
223 phy_port=network_port_phy_port,
224 vlan=network_port_vlan, operation="delete")
225 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
226
227 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
228 dst_mac=dst_mac_mcast,
229 phy_port=network_port_phy_port,
230 vlan=network_port_vlan, operation="delete")
231 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
232
233class OverlayMcastGroup(base_tests.SimpleDataPlane):
234 """
235 create two lport
236 """
237 def runTest(self):
238 if config["switch_ip"] == None:
239 logging.error("Doesn't configure switch IP")
240 return
241
242 delete_all_flows(self.controller)
243 delete_all_groups(self.controller)
244 #paramaters
245 access_port_vid=1
246 access_phy_port=1
247 access_lport=0x10001
248 vnid=103
249 next_hop_id=1
250 next_hop_id_mcast=2
251 dst_mac="00:00:11:22:22:11"
252 mcast_ipv4="224.1.1.1"
253 dst_mac_mcast="01:00:5e:01:01:01"
254 network_port_phy_port=2
255 network_lport=0x10002
256 network_port_vlan=2
257 network_port_sip="192.168.1.1"
258 network_port_dip="192.168.2.1"
259
260 feature_reply=get_featureReplay(self)
261 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
262 dst_mac=dst_mac_mcast,
263 phy_port=network_port_phy_port,
264 vlan=network_port_vlan)
265 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
266 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
267 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
268 logging.info("config VNI %lx", vnid);
269 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
270
271 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
272 lport=access_lport, phy_port=access_phy_port,
273 vlan=access_port_vid, vnid=vnid)
274 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport, access_phy_port, access_port_vid, vnid);
275 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
276 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
277 dst_mac=dst_mac,
278 phy_port=network_port_phy_port,
279 vlan=network_port_vlan)
280 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
281 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
282 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
283 lport=network_lport,
284 src_ip=network_port_sip, dst_ip=network_port_dip,
285 next_hop_id=next_hop_id,
286 vnid=vnid)
287 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport, network_port_sip, network_port_dip, next_hop_id);
288 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
289
290 #add flow over unicast group
291 msg=msg=add_l2_overlay_mcast_over_unicast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
292 #verify
293 stats = get_stats(self, ofp.message.group_desc_stats_request())
294 verify_group_stats=(ofp.group_desc_stats_entry(
295 group_type=msg.group_type,
296 group_id=msg.group_id,
297 buckets=msg.buckets))
298
299 self.assertEquals(stats, [verify_group_stats])
300 #clear all group
301 delete_all_groups(self.controller)
302 #
303 #flood over mcast
304 msg=add_l2_overlay_mcast_over_mcast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
305
306 stats = get_stats(self, ofp.message.group_desc_stats_request())
307
308 verify_group_stats=(ofp.group_desc_stats_entry(
309 group_type=msg.group_type,
310 group_id=msg.group_id,
311 buckets=msg.buckets))
312
313 self.assertEquals(stats, [verify_group_stats])
314 #clear all group
315 delete_all_groups(self.controller)
316 #exit verification so clear all configuration
317 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
318 lport=access_lport, phy_port=access_phy_port,
319 vlan=access_port_vid, vnid=vnid, operation="delete")
320 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
321 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
322 lport=network_lport,
323 src_ip=network_port_sip, dst_ip=network_port_dip,
324 next_hop_id=next_hop_id,
325 vnid=vnid, operation="delete")
326 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
327
328 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
329 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
330
331 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
332 dst_mac=dst_mac,
333 phy_port=network_port_phy_port,
334 vlan=network_port_vlan, operation="delete")
335 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
336
337 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
338 dst_mac=dst_mac_mcast,
339 phy_port=network_port_phy_port,
340 vlan=network_port_vlan, operation="delete")
341 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
342
343class AccessToNetworkDLFMcast(base_tests.SimpleDataPlane):
344 def runTest(self):
345 """
346 first verify flood over unicast,
347 second verify flood over mcast
348 """
349 if config["switch_ip"] == None:
350 logging.error("Doesn't configure switch IP")
351 return
352
353 delete_all_flows(self.controller)
354 delete_all_groups(self.controller)
355
356 access_port1_vid=1
357 access_phy_port1=config["port_map"].keys()[0]
358 access_lport1=0x10001
359 access_port2_vid=0
360 access_phy_port2=config["port_map"].keys()[1]
361 access_lport2=0x10002
362 vnid=10
363 next_hop_id=1
364 next_hop_id_mcast=2
365 dst_mac="00:00:11:22:22:11"
366 mcast_ipv4="224.1.1.1"
367 dst_mac_mcast="01:00:5e:01:01:01"
368 network_port_phy_port=config["port_map"].keys()[2]
369 network_lport=0x10003
370 network_port_vlan=2
371 network_port_sip="192.168.1.1"
372 network_port_dip="192.168.2.1"
373
374 feature_reply=get_featureReplay(self)
375 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
376 dst_mac=dst_mac,
377 phy_port=network_port_phy_port,
378 vlan=network_port_vlan)
379 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
380 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
381
382 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
383 dst_mac=dst_mac_mcast,
384 phy_port=network_port_phy_port,
385 vlan=network_port_vlan)
386 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
387 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
388
389 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
390 logging.info("config VNI %lx", vnid);
391 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
392
393 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
394 lport=access_lport1, phy_port=access_phy_port1,
395 vlan=access_port1_vid, vnid=vnid)
396 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
397 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
398
399 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
400 lport=access_lport2, phy_port=access_phy_port2,
401 vlan=access_port2_vid, vnid=vnid)
402 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
403 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800404 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
405 lport=network_lport,
406 src_ip=network_port_sip, dst_ip=network_port_dip,
407 next_hop_id=next_hop_id,
408 vnid=vnid)
409 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport, network_port_sip, network_port_dip, next_hop_id);
410 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
411
412 #get_edit_config(config["switch_ip"])
413
414 #add port table to have vxlan ability
415 add_port_table_flow(self.controller)
416
417 #for network port need l2 interface group to decide vlan tag or not
castroflaviodd171472015-12-08 13:55:58 -0500418 add_one_l2_interface_group(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
macauley68ace672015-07-27 17:40:50 +0800419
420 #add DLF bridge flow
421 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, network_lport], 1)
422 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
423
424 #send packet on access port
425 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
426 dl_vlan_enable= True,
427 vlan_vid=access_port1_vid)
428 pkt = str(parsed_pkt)
429 self.dataplane.send(access_phy_port1, pkt)
430
431 #verify packet on access port
432 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
433 pkt = str(parsed_pkt)
434 verify_packet(self, pkt, access_phy_port2)
435 #vxlan packet IP header have some parmater decide by HW,
436 #we can easy to check VxLAN IP header
437 verify_packet(self, pkt, network_port_phy_port)
438 verify_no_other_packets(self)
439
440 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, network_lport, False, True)
441 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
442 dl_vlan_enable= True,
443 vlan_vid=access_port1_vid)
444 pkt = str(parsed_pkt)
445 self.dataplane.send(access_phy_port1, pkt)
446 #verify packet on network port
447 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
448 pkt = str(parsed_pkt)
449 verify_packet(self, pkt, network_port_phy_port)
450 verify_no_other_packets(self)
451
452 #exit verification so clear all configuration
453 delete_all_flows(self.controller)
454 delete_all_groups(self.controller)
455
456 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
457 lport=access_lport1, phy_port=access_phy_port1,
458 vlan=access_port1_vid, vnid=vnid, operation="delete")
459 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
460 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
461 lport=access_lport2, phy_port=access_phy_port2,
462 vlan=access_port2_vid, vnid=vnid, operation="delete")
463 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
464 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
465 lport=network_lport,
466 src_ip=network_port_sip, dst_ip=network_port_dip,
467 next_hop_id=next_hop_id,
468 vnid=vnid, operation="delete")
469 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
470
471 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
472 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
473
474 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
475 dst_mac=dst_mac,
476 phy_port=network_port_phy_port,
477 vlan=network_port_vlan, operation="delete")
478 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
479
480 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
481 dst_mac=dst_mac_mcast,
482 phy_port=network_port_phy_port,
483 vlan=network_port_vlan, operation="delete")
484 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
485
486class AccessToNetworkDLFUcast(base_tests.SimpleDataPlane):
487 def runTest(self):
488 """
489 first verify flood over unicast,
490 second verify flood over mcast
491 """
492 if config["switch_ip"] == None:
493 logging.error("Doesn't configure switch IP")
494 return
495
496 delete_all_flows(self.controller)
497 delete_all_groups(self.controller)
498
499 access_port1_vid=1
500 access_phy_port1=config["port_map"].keys()[0]
501 access_lport1=0x10001
502 access_port2_vid=0
503 access_phy_port2=config["port_map"].keys()[1]
504 access_lport2=0x10002
505 vnid=10
506 next_hop_id=1
507 next_hop_id_mcast=2
508 dst_mac="00:00:11:22:22:11"
509 mcast_ipv4="224.1.1.1"
510 dst_mac_mcast="01:00:5e:01:01:01"
511 network_port_phy_port=config["port_map"].keys()[2]
512 network_lport=0x10003
513 network_port_vlan=2
514 network_port_sip="192.168.1.1"
515 network_port_dip="192.168.2.1"
516
517 feature_reply=get_featureReplay(self)
518 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
519 dst_mac=dst_mac,
520 phy_port=network_port_phy_port,
521 vlan=network_port_vlan)
522 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
523 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
524
525 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
526 dst_mac=dst_mac_mcast,
527 phy_port=network_port_phy_port,
528 vlan=network_port_vlan)
529 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
530 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
531
532 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
533 logging.info("config VNI %lx", vnid);
534 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
535
536 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
537 lport=access_lport1, phy_port=access_phy_port1,
538 vlan=access_port1_vid, vnid=vnid)
539 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
540 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
541
542 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
543 lport=access_lport2, phy_port=access_phy_port2,
544 vlan=access_port2_vid, vnid=vnid)
545 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
546 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800547 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
548 lport=network_lport,
549 src_ip=network_port_sip, dst_ip=network_port_dip,
550 next_hop_id=next_hop_id,
551 vnid=vnid)
552 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport, network_port_sip, network_port_dip, next_hop_id);
553 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
554
555 #get_edit_config(config["switch_ip"])
556
557 #add port table to have vxlan ability
558 add_port_table_flow(self.controller)
559
560 #for network port need l2 interface group to decide vlan tag or not
castroflaviodd171472015-12-08 13:55:58 -0500561 add_one_l2_interface_group(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
macauley68ace672015-07-27 17:40:50 +0800562
563 #add DLF bridge flow
564 msg=add_l2_overlay_flood_over_unicast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, network_lport], 1)
565 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
566
567 #send packet on access port
568 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
569 dl_vlan_enable= True,
570 vlan_vid=access_port1_vid)
571 pkt = str(parsed_pkt)
572 self.dataplane.send(access_phy_port1, pkt)
573
574 #verify packet on access port
575 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
576 pkt = str(parsed_pkt)
577 verify_packet(self, pkt, access_phy_port2)
578 #vxlan packet IP header have some parmater decide by HW,
579 #we can easy to check VxLAN IP header
580 verify_packet(self, pkt, network_port_phy_port)
581 verify_no_other_packets(self)
582
583 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, network_lport, False, True)
584 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
585 dl_vlan_enable= True,
586 vlan_vid=access_port1_vid)
587 pkt = str(parsed_pkt)
588 self.dataplane.send(access_phy_port1, pkt)
589 #verify packet on network port
590 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
591 pkt = str(parsed_pkt)
592 verify_packet(self, pkt, network_port_phy_port)
593 verify_no_other_packets(self)
594
595 #exit verification so clear all configuration
596 delete_all_flows(self.controller)
597 delete_all_groups(self.controller)
598
599 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
600 lport=access_lport1, phy_port=access_phy_port1,
601 vlan=access_port1_vid, vnid=vnid, operation="delete")
602 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
603 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
604 lport=access_lport2, phy_port=access_phy_port2,
605 vlan=access_port2_vid, vnid=vnid, operation="delete")
606 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
607 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
608 lport=network_lport,
609 src_ip=network_port_sip, dst_ip=network_port_dip,
610 next_hop_id=next_hop_id,
611 vnid=vnid, operation="delete")
612 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
613
614 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
615 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
616
617 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
618 dst_mac=dst_mac,
619 phy_port=network_port_phy_port,
620 vlan=network_port_vlan, operation="delete")
621 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
622
623 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
624 dst_mac=dst_mac_mcast,
625 phy_port=network_port_phy_port,
626 vlan=network_port_vlan, operation="delete")
627 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
628
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800629class AccessWithAccessDiffPortVlan(base_tests.SimpleDataPlane):
macauley68ace672015-07-27 17:40:50 +0800630 def runTest(self):
631 """
632 first verify flood over unicast,
633 second verify flood over mcast
634 """
635 if config["switch_ip"] == None:
636 logging.error("Doesn't configure switch IP")
637 return
638
639 delete_all_flows(self.controller)
640 delete_all_groups(self.controller)
641
642 access_port1_vid=1
643 access_phy_port1=config["port_map"].keys()[0]
644 access_lport1=0x10001
645 access_port2_vid=0
646 access_phy_port2=config["port_map"].keys()[1]
647 access_lport2=0x10002
648 access_port3_vid=3
649 access_phy_port3=config["port_map"].keys()[2]
650 access_lport3=0x10003
651 vnid=10
652 next_hop_id_mcast=1
653 mcast_ipv4="224.1.1.1"
654 dst_mac_mcast="01:00:5e:01:01:01"
655
656 feature_reply=get_featureReplay(self)
657
658 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
659 dst_mac=dst_mac_mcast,
660 phy_port=access_phy_port3,
661 vlan=access_port3_vid)
662 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id_mcast, dst_mac_mcast, access_phy_port3, access_port3_vid);
663 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
664
665 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
666 logging.info("config VNI %lx", vnid);
667 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
668
669 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
670 lport=access_lport1, phy_port=access_phy_port1,
671 vlan=access_port1_vid, vnid=vnid)
672 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
673 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
674
675 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
676 lport=access_lport2, phy_port=access_phy_port2,
677 vlan=access_port2_vid, vnid=vnid)
678 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
679 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
680
681 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
682 lport=access_lport3, phy_port=access_phy_port3,
683 vlan=access_port3_vid, vnid=vnid)
684 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
685 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
686
687
688 #add port table to have vxlan ability
689 add_port_table_flow(self.controller)
690
691 #add DLF bridge flow
692 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, access_lport3], 1)
693 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
694
695 #send packet on access port
696 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
697 dl_vlan_enable= True,
698 vlan_vid=access_port1_vid)
699 pkt = str(parsed_pkt)
700 self.dataplane.send(access_phy_port1, pkt)
701
702 #verify packet on access port 2, vid=0, so untag
703 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
704 pkt = str(parsed_pkt)
705 verify_packet(self, pkt, access_phy_port2)
706 #verify packet on access port 3
707 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
708 dl_vlan_enable= True,
709 vlan_vid=access_port3_vid)
710 pkt = str(parsed_pkt)
711 verify_packet(self, pkt, access_phy_port3)
712 verify_no_other_packets(self)
713
714 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, access_lport2, False, True)
715 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
716 dl_vlan_enable= True,
717 vlan_vid=access_port1_vid)
718 pkt = str(parsed_pkt)
719 self.dataplane.send(access_phy_port1, pkt)
720 #verify packet on access port
721 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
722 pkt = str(parsed_pkt)
723 verify_packet(self, pkt, access_phy_port2)
724 verify_no_other_packets(self)
725
726
727 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0xaa], vnid, access_lport3, False, True)
728 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
729 dl_vlan_enable= True,
730 vlan_vid=access_port1_vid)
731 pkt = str(parsed_pkt)
732 self.dataplane.send(access_phy_port1, pkt)
733 #verify packet on access port
734 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
735 dl_vlan_enable= True,
736 vlan_vid=access_port3_vid)
737 pkt = str(parsed_pkt)
738 verify_packet(self, pkt, access_phy_port3)
739 verify_no_other_packets(self)
740
741
742
743 #exit verification so clear all configuration
744 delete_all_flows(self.controller)
745 delete_all_groups(self.controller)
746
747 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
748 lport=access_lport1, phy_port=access_phy_port1,
749 vlan=access_port1_vid, vnid=vnid, operation="delete")
750 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
751 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
752 lport=access_lport2, phy_port=access_phy_port2,
753 vlan=access_port2_vid, vnid=vnid, operation="delete")
754 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
755 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
756 lport=access_lport3, phy_port=access_phy_port3,
757 vlan=access_port3_vid, vnid=vnid, operation="delete")
758 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
759 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
760
761 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
762 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
763
764 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
765 dst_mac=dst_mac_mcast,
766 phy_port=access_phy_port3,
767 vlan=access_port3_vid, operation="delete")
768 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
769
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800770
771class AccessWithAccessSamePortDiffVlan(base_tests.SimpleDataPlane):
772 def runTest(self):
773 """
774 first verify flood over unicast,
775 second verify flood over mcast
776 """
777 if config["switch_ip"] == None:
778 logging.error("Doesn't configure switch IP")
779 return
780
781 delete_all_flows(self.controller)
782 delete_all_groups(self.controller)
783
784 access_port1_vid=1
785 access_phy_port1=config["port_map"].keys()[0]
786 access_lport1=0x10001
macauley_cheng681958a2015-11-11 10:32:05 +0800787 access_port2_vid=2
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800788 access_phy_port2= access_phy_port1
789 access_lport2=0x10002
790 access_port3_vid=3
791 access_phy_port3=access_phy_port1
792 access_lport3=0x10003
793 vnid=10
794 next_hop_id_mcast=1
795 mcast_ipv4="224.1.1.1"
796 dst_mac_mcast="01:00:5e:01:01:01"
797
798 feature_reply=get_featureReplay(self)
799
800 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
801 dst_mac=dst_mac_mcast,
802 phy_port=access_phy_port3,
803 vlan=access_port3_vid)
804 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id_mcast, dst_mac_mcast, access_phy_port3, access_port3_vid);
805 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
806
807 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
808 logging.info("config VNI %lx", vnid);
809 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
810
811 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
812 lport=access_lport1, phy_port=access_phy_port1,
813 vlan=access_port1_vid, vnid=vnid)
814 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
815 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
816
817 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
818 lport=access_lport2, phy_port=access_phy_port2,
819 vlan=access_port2_vid, vnid=vnid)
820 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
821 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
822
823 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
824 lport=access_lport3, phy_port=access_phy_port3,
825 vlan=access_port3_vid, vnid=vnid)
826 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
827 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
828
829
830 #add port table to have vxlan ability
831 add_port_table_flow(self.controller)
832
833 #add DLF bridge flow
834 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, access_lport3], 1)
835 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
836
837 #send packet on access port
838 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
839 dl_vlan_enable= True,
840 vlan_vid=access_port1_vid)
841 pkt = str(parsed_pkt)
842 self.dataplane.send(access_phy_port1, pkt)
843
844 #verify packet on access port 2, vid=0, so untag
macauley_cheng681958a2015-11-11 10:32:05 +0800845 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
846 dl_vlan_enable = True,
847 vlan_vid = access_port2_vid)
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800848 pkt = str(parsed_pkt)
849 verify_packet(self, pkt, access_phy_port2)
850 #verify packet on access port 3
851 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
852 dl_vlan_enable= True,
853 vlan_vid=access_port3_vid)
854 pkt = str(parsed_pkt)
855 verify_packet(self, pkt, access_phy_port3)
856 verify_no_other_packets(self)
857
858 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, access_lport2, False, True)
859 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
860 dl_vlan_enable= True,
861 vlan_vid=access_port1_vid)
862 pkt = str(parsed_pkt)
863 self.dataplane.send(access_phy_port1, pkt)
864 #verify packet on access port
macauley_cheng681958a2015-11-11 10:32:05 +0800865 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
866 dl_vlan_enable = True,
867 vlan_vid = access_port2_vid)
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800868 pkt = str(parsed_pkt)
869 verify_packet(self, pkt, access_phy_port2)
870 verify_no_other_packets(self)
871
872
873 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0xaa], vnid, access_lport3, False, True)
874 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
875 dl_vlan_enable= True,
876 vlan_vid=access_port1_vid)
877 pkt = str(parsed_pkt)
878 self.dataplane.send(access_phy_port1, pkt)
879 #verify packet on access port
880 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
881 dl_vlan_enable= True,
882 vlan_vid=access_port3_vid)
883 pkt = str(parsed_pkt)
884 verify_packet(self, pkt, access_phy_port3)
885 verify_no_other_packets(self)
886
887 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0xbb], vnid, access_lport2, False, True)
macauley_cheng681958a2015-11-11 10:32:05 +0800888 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:bb',
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800889 dl_vlan_enable= True,
890 vlan_vid=access_port1_vid)
891 pkt = str(parsed_pkt)
892 self.dataplane.send(access_phy_port1, pkt)
893 #verify packet on access port
894 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:bb',
895 dl_vlan_enable= True,
896 vlan_vid=access_port2_vid)
897 pkt = str(parsed_pkt)
898 verify_packet(self, pkt, access_phy_port2)
899 verify_no_other_packets(self)
900
901 #exit verification so clear all configuration
902 delete_all_flows(self.controller)
903 delete_all_groups(self.controller)
904
905 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
906 lport=access_lport1, phy_port=access_phy_port1,
907 vlan=access_port1_vid, vnid=vnid, operation="delete")
908 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
909 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
910 lport=access_lport2, phy_port=access_phy_port2,
911 vlan=access_port2_vid, vnid=vnid, operation="delete")
912 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
913 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
914 lport=access_lport3, phy_port=access_phy_port3,
915 vlan=access_port3_vid, vnid=vnid, operation="delete")
916 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
917 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
918
919 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
920 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
921
922 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
923 dst_mac=dst_mac_mcast,
924 phy_port=access_phy_port3,
925 vlan=access_port3_vid, operation="delete")
926 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
927
928
macauley68ace672015-07-27 17:40:50 +0800929class AccessWithNetwork(base_tests.SimpleDataPlane):
930 def runTest(self):
macauleyee5bfa72015-08-03 10:11:14 +0800931 """
932 first verify flood over unicast,
933 second verify flood over mcast
934 """
935 if config["switch_ip"] == None:
936 logging.error("Doesn't configure switch IP")
937 return
macauley68ace672015-07-27 17:40:50 +0800938 delete_all_flows(self.controller)
939 delete_all_groups(self.controller)
macauleyee5bfa72015-08-03 10:11:14 +0800940
941 access_port1_vid=1
942 access_phy_port1=config["port_map"].keys()[0]
943 access_lport1=0x10001
944 access_lport1_mac=[0x00, 0x00, 0x00, 0x77, 0x77, 0x77]
945 access_lport1_mac_str=(":".join(map(str, map(hex, access_lport1_mac)))).replace("0x", "")
946 access_port2_vid=0
947 access_phy_port2=config["port_map"].keys()[1]
948 access_lport2=0x10002
949 access_lport2_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x02]
950 access_lport2_mac_str=(":".join(map(str, map(hex, access_lport2_mac)))).replace("0x", "")
951 vnid=10
952 next_hop_id=1
953 next_hop_id_mcast=2
954 dst_mac="00:00:11:22:22:11"
955 mcast_ipv4="224.1.1.1"
956 dst_mac_mcast="01:00:5e:01:01:01"
957 network_port_phy_port=config["port_map"].keys()[2]
958 network_lport=0x10003
959 network_port_vlan=2
960 network_port_sip="192.168.1.1"
961 network_port_dip="192.168.2.1"
962 network_lport_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x03]
963 network_lport_mac_str=(":".join(map(str, map(hex, network_lport_mac)))).replace("0x", "")
964
965
966
967 feature_reply=get_featureReplay(self)
968 #get switch CPU mac
969 str_datapath_id_f= "{:016x}".format(feature_reply.datapath_id)
970 str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
971 switch_cpu_mac_str=str_datapath_id[6:]
972 switch_cpu_mac = switch_cpu_mac_str.split(":")
973 switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))]
974
975 #add config vtep/vtap/nexthop/vni
976 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
977 dst_mac=dst_mac,
978 phy_port=network_port_phy_port,
979 vlan=network_port_vlan)
980 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
981 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
982
983 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
984 dst_mac=dst_mac_mcast,
985 phy_port=network_port_phy_port,
986 vlan=network_port_vlan)
987 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
988
989 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
990
991 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
992 #vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None)
993 logging.info("config VNI %lx", vnid);
994 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
995
996 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
997 lport=access_lport1, phy_port=access_phy_port1,
998 vlan=access_port1_vid, vnid=vnid)
999 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
1000 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1001
1002 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1003 lport=access_lport2, phy_port=access_phy_port2,
1004 vlan=access_port2_vid, vnid=vnid)
1005 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
1006 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1007 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1008 lport=network_lport,
1009 src_ip=network_port_sip, dst_ip=network_port_dip,
1010 next_hop_id=next_hop_id,
1011 vnid=vnid)
1012 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport, network_port_sip, network_port_dip, next_hop_id);
1013 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1014
1015 #add port table to have vxlan ability
1016 add_port_table_flow(self.controller)
1017 add_port_table_flow(self.controller, is_overlay=False)
1018
1019 #for network port need l2 interface group to decide vlan tag or not
castroflaviodd171472015-12-08 13:55:58 -05001020 add_one_l2_interface_group(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
macauleyee5bfa72015-08-03 10:11:14 +08001021 #add network mac
1022 add_overlay_bridge_flow(self.controller, network_lport_mac, vnid, network_lport, False, True)
1023 add_overlay_bridge_flow(self.controller, access_lport1_mac, vnid, access_lport1, False, True)
1024
1025 #add termination table for network port
1026 add_termination_flow(self.controller, in_port=network_port_phy_port, eth_type=0x0800,
1027 dst_mac=switch_cpu_mac, vlanid=network_port_vlan)
1028 #add vlan table for network port rx packet class vlan
1029 add_one_vlan_table_flow(self.controller, of_port=network_port_phy_port,
1030 vlan_id=network_port_vlan)
1031
1032 #tx packet on access lport 1
1033 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst=network_lport_mac_str,
1034 dl_vlan_enable= True,
1035 vlan_vid=access_port1_vid)
1036 pkt = str(parsed_pkt)
1037 self.dataplane.send(access_phy_port1, pkt)
1038 #verify packet on network port
1039 #need find a way to verify vxlan header
1040 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst=network_lport_mac_str)
1041 pkt = str(parsed_pkt)
1042 verify_packet(self, pkt, network_port_phy_port)
1043 verify_no_other_packets(self)
1044
1045 #tx packet on network lport
1046 inner_pkt = simple_udp_packet(pktlen=96, eth_dst=access_lport1_mac_str)
1047 vxlan_pkt = simple_vxlan_packet(eth_dst=switch_cpu_mac_str,
1048 vnid=vnid,
1049 ip_dst= network_port_sip,
1050 ip_src=network_port_dip,
1051 inner_payload=inner_pkt)
1052 self.dataplane.send(network_port_phy_port, str(vxlan_pkt))
1053 #verify
1054 inner_pkt = simple_udp_packet(pktlen=100, eth_dst=access_lport1_mac_str,
1055 dl_vlan_enable= True,
1056 vlan_vid=access_port1_vid)
1057
1058 verify_packet(self, inner_pkt, access_phy_port1)
1059 verify_no_other_packets(self)
1060
1061
1062 #exit verification so clear all configuration
1063 delete_all_flows(self.controller)
1064 delete_all_groups(self.controller)
1065
1066 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1067 lport=access_lport1, phy_port=access_phy_port1,
1068 vlan=access_port1_vid, vnid=vnid, operation="delete")
1069 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1070 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1071 lport=access_lport2, phy_port=access_phy_port2,
1072 vlan=access_port2_vid, vnid=vnid, operation="delete")
1073 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1074 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1075 lport=network_lport,
1076 src_ip=network_port_sip, dst_ip=network_port_dip,
1077 next_hop_id=next_hop_id,
1078 vnid=vnid, operation="delete")
1079 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1080
1081 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
1082 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
1083
1084 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
1085 dst_mac=dst_mac,
1086 phy_port=network_port_phy_port,
1087 vlan=network_port_vlan, operation="delete")
1088 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1089
1090 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
1091 dst_mac=dst_mac_mcast,
1092 phy_port=network_port_phy_port,
1093 vlan=network_port_vlan, operation="delete")
1094 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +08001095
1096class NetworkToNetwork(base_tests.SimpleDataPlane):
1097 def runTest(self):
macauleyee5bfa72015-08-03 10:11:14 +08001098 """
1099 This case can't work, can't identify it is chip limitation or not
1100 """
1101 return
1102 if config["switch_ip"] == None:
1103 logging.error("Doesn't configure switch IP")
1104 return
1105
macauley68ace672015-07-27 17:40:50 +08001106 delete_all_flows(self.controller)
macauleyee5bfa72015-08-03 10:11:14 +08001107 delete_all_groups(self.controller)
1108
1109 vnid=10
1110 mcast_ipv4="224.1.1.1"
1111 dst_mac_mcast="01:00:5e:01:01:01"
1112 next_hop_id_mcast=3
1113
1114 access_port1_vid=1
1115 access_phy_port1=config["port_map"].keys()[0]
1116 access_lport1=0x10001
1117
1118 network_port1_phy_port=config["port_map"].keys()[1]
1119 network_lport1=0x10003
1120 network_port1_vlan=2
1121 network_port1_sip="192.168.1.1"
1122 network_port1_dip="192.168.2.1"
1123 network_port1_next_hop_id=1
1124 network_port1_dst_mac="00:00:11:22:22:11"
1125 network_lport1_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x33]
1126 network_lport1_mac_str=(":".join(map(str, map(hex, network_lport1_mac)))).replace("0x", "")
1127
1128 network_port2_phy_port=config["port_map"].keys()[2]
1129 network_lport2=0x10004
1130 network_port2_vlan=3
1131 network_port2_sip="192.168.3.1"
1132 network_port2_dip="192.168.4.1"
1133 network_port2_next_hop_id=2
1134 network_port2_dst_mac="00:00:11:22:22:22"
1135 network_lport2_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x44]
1136 network_lport2_mac_str=(":".join(map(str, map(hex, network_lport2_mac)))).replace("0x", "")
1137
1138 feature_reply=get_featureReplay(self)
1139 #get switch CPU mac
1140 str_datapath_id_f= "{:016x}".format(feature_reply.datapath_id)
1141 str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
1142 switch_cpu_mac_str=str_datapath_id[6:]
1143 switch_cpu_mac = switch_cpu_mac_str.split(":")
1144 switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))]
1145 #config vlxan
1146 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port1_next_hop_id,
1147 dst_mac=network_port1_dst_mac,
1148 phy_port=network_port1_phy_port,
1149 vlan=network_port1_vlan)
1150 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", network_port1_next_hop_id, network_port1_dst_mac, network_port1_phy_port, network_port1_vlan);
1151 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
1152 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port2_next_hop_id,
1153 dst_mac=network_port2_dst_mac,
1154 phy_port=network_port2_phy_port,
1155 vlan=network_port2_vlan)
1156 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", network_port2_next_hop_id, network_port2_dst_mac, network_port2_phy_port, network_port2_vlan);
1157 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
1158
1159 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
1160 dst_mac=dst_mac_mcast,
1161 phy_port=network_port1_phy_port,
1162 vlan=network_port1_vlan)
1163 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id_mcast, dst_mac_mcast, network_port1_phy_port, network_port1_vlan);
1164 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
1165
1166 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
1167 logging.info("config VNI %lx", vnid);
1168 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
1169
1170 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1171 lport=access_lport1, phy_port=access_phy_port1,
1172 vlan=access_port1_vid, vnid=vnid)
1173 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
1174 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1175
1176 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1177 lport=network_lport1,
1178 src_ip=network_port1_sip, dst_ip=network_port1_dip,
1179 next_hop_id=network_port1_next_hop_id,
1180 vnid=vnid)
1181 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport1, network_port1_sip, network_port1_dip, network_port1_next_hop_id);
1182 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1183 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1184 lport=network_lport2,
1185 src_ip=network_port2_sip, dst_ip=network_port2_dip,
1186 next_hop_id=network_port2_next_hop_id,
1187 vnid=vnid)
1188 logging.info("config VTEP 0x%lx, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", network_lport2, network_port2_sip, network_port2_dip, network_port2_next_hop_id);
1189 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1190
1191 #add port table to have vxlan ability
1192 add_port_table_flow(self.controller)
1193
1194 #for network port need l2 interface group to decide vlan tag or not
castroflaviodd171472015-12-08 13:55:58 -05001195 add_one_l2_interface_group(self.controller, network_port1_phy_port, vlan_id=network_port1_vlan)
1196 add_one_l2_interface_group(self.controller, network_port2_phy_port, vlan_id=network_port2_vlan)
macauleyee5bfa72015-08-03 10:11:14 +08001197 #add network mac
1198 add_overlay_bridge_flow(self.controller, network_lport1_mac, vnid, network_lport1, False, True)
1199 add_overlay_bridge_flow(self.controller, network_lport2_mac, vnid, network_lport2, False, True)
1200
1201 #add termination table for network port
1202 add_termination_flow(self.controller, in_port=network_port1_phy_port, eth_type=0x0800,
1203 dst_mac=switch_cpu_mac, vlanid=network_port1_vlan)
1204 add_termination_flow(self.controller, in_port=network_port2_phy_port, eth_type=0x0800,
1205 dst_mac=switch_cpu_mac, vlanid=network_port2_vlan)
1206 #add vlan table for network port rx packet class vlan
1207 add_one_vlan_table_flow(self.controller, of_port=network_port1_phy_port,
1208 vlan_id=network_port1_vlan)
1209 add_one_vlan_table_flow(self.controller, of_port=network_port2_phy_port,
1210 vlan_id=network_port2_vlan)
1211
1212 #packet tx on network port 1 rx on network port 2
1213 inner_pkt = simple_udp_packet(pktlen=96, eth_dst=network_lport2_mac_str)
1214 vxlan_pkt = simple_vxlan_packet(eth_dst=switch_cpu_mac_str,
1215 vnid=vnid,
1216 ip_dst= network_port1_sip,
1217 ip_src=network_port1_dip,
1218 inner_payload=inner_pkt)
1219 self.dataplane.send(network_port1_phy_port, str(vxlan_pkt))
1220 #verify
1221 verify_packet(self, str(inner_pkt), network_port2_phy_port)
1222 verify_no_other_packets(self)
1223
1224
1225
1226 #exit verification so clear all configuration
1227 delete_all_flows(self.controller)
1228 delete_all_groups(self.controller)
1229
1230 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1231 lport=access_lport1, phy_port=access_phy_port1,
1232 vlan=access_port1_vid, vnid=vnid, operation="delete")
1233 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1234
1235 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1236 lport=network_lport1,
1237 src_ip=network_port1_sip, dst_ip=network_port1_dip,
1238 next_hop_id=network_port1_next_hop_id,
1239 vnid=vnid, operation="delete")
1240 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1241 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1242 lport=network_lport2,
1243 src_ip=network_port2_sip, dst_ip=network_port2_dip,
1244 next_hop_id=network_port2_next_hop_id,
1245 vnid=vnid, operation="delete")
1246 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1247 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
1248 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
1249
1250 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port1_next_hop_id,
1251 dst_mac=network_port1_dst_mac,
1252 phy_port=network_port1_phy_port,
1253 vlan=network_port1_vlan, operation="delete")
1254 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1255 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port2_next_hop_id,
1256 dst_mac=network_port2_dst_mac,
1257 phy_port=network_port2_phy_port,
1258 vlan=network_port2_vlan, operation="delete")
1259 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1260 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
1261 dst_mac=dst_mac_mcast,
1262 phy_port=network_port1_phy_port,
1263 vlan=network_port1_vlan, operation="delete")
1264 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1265