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