blob: fcb840b18d777223787b8481d5deeb8405ef7c59 [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
41 #get datapath_id from feature message
42 feature_reply=get_featureReplay(self)
43 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
44 dst_mac=dst_mac_mcast,
45 phy_port=network_port_phy_port,
46 vlan=network_port_vlan)
47 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
48 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == False)
49
50 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
51 dst_mac=dst_mac,
52 phy_port=network_port_phy_port,
53 vlan=network_port_vlan)
54 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
55 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == False)
56
57 vni_config_xml=get_vni_config_xml(vni_id=vnid,
58 mcast_ipv4=mcast_ipv4,
59 next_hop_id=next_hop_id_mcast)
60 logging.info("config VNI %lx", vnid);
61 assert(send_edit_config(config["switch_ip"], vni_config_xml) == False)
62
63 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
64 lport=access_lport, phy_port=access_phy_port,
65 vlan=access_port_vid, vnid=vnid)
66 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport, access_phy_port, access_port_vid, vnid);
67 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == False)
68
69 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
70 lport=network_lport,
71 src_ip=network_port_sip, dst_ip=network_port_dip,
72 next_hop_id=next_hop_id,
73 vnid=vnid)
74 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);
75 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == False)
76
77 get_edit_config(config["switch_ip"])
78
79 #exit verification so clear all configuration
80 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
81 lport=access_lport, phy_port=access_phy_port,
82 vlan=access_port_vid, vnid=vnid, operation="delete")
83 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == False)
84
85 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
86 lport=network_lport,
87 src_ip=network_port_sip, dst_ip=network_port_dip,
88 next_hop_id=next_hop_id,
89 vnid=vnid, operation="delete")
90 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == False)
91
92 vni_config_xml=get_vni_config_xml(vni_id=vnid,
93 mcast_ipv4=mcast_ipv4,
94 next_hop_id=next_hop_id_mcast, operation="delete")
95 assert(send_edit_config(config["switch_ip"], vni_config_xml) == False)
96
97 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
98 dst_mac=dst_mac,
99 phy_port=network_port_phy_port,
100 vlan=network_port_vlan, operation="delete")
101 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == False)
102
103 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
104 dst_mac=dst_mac_mcast,
105 phy_port=network_port_phy_port,
106 vlan=network_port_vlan, operation="delete")
107 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == False)
108
109 get_edit_config(config["switch_ip"])
110
111class OverlayFloodGroup(base_tests.SimpleDataPlane):
112 """
113 create two lport
114 """
115 def runTest(self):
116 """
117 first verify flood over unicast,
118 second verify flood over mcast
119 """
120 if config["switch_ip"] == None:
121 logging.error("Doesn't configure switch IP")
122 return
123
124 delete_all_flows(self.controller)
125 delete_all_groups(self.controller)
126 #paramaters
127 access_port_vid=1
128 access_phy_port=1
129 access_lport=0x10001
130 vnid=103
131 next_hop_id=1
132 next_hop_id_mcast=2
133 dst_mac="00:00:11:22:22:11"
134 mcast_ipv4="224.1.1.1"
135 dst_mac_mcast="01:00:5e:01:01:01"
136 network_port_phy_port=2
137 network_lport=0x10002
138 network_port_vlan=2
139 network_port_sip="192.168.1.1"
140 network_port_dip="192.168.2.1"
141
142 feature_reply=get_featureReplay(self)
143 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
144 dst_mac=dst_mac_mcast,
145 phy_port=network_port_phy_port,
146 vlan=network_port_vlan)
147 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
148 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
149 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
150 logging.info("config VNI %lx", vnid);
151 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
152
153 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
154 lport=access_lport, phy_port=access_phy_port,
155 vlan=access_port_vid, vnid=vnid)
156 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport, access_phy_port, access_port_vid, vnid);
157 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
158 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
159 dst_mac=dst_mac,
160 phy_port=network_port_phy_port,
161 vlan=network_port_vlan)
162 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
163 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
164 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
165 lport=network_lport,
166 src_ip=network_port_sip, dst_ip=network_port_dip,
167 next_hop_id=next_hop_id,
168 vnid=vnid)
169 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);
170 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
171
172 #add flow over unicast group
173 msg=add_l2_overlay_flood_over_unicast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
174 #verify
175 stats = get_stats(self, ofp.message.group_desc_stats_request())
176 verify_group_stats=(ofp.group_desc_stats_entry(
177 group_type=msg.group_type,
178 group_id=msg.group_id,
179 buckets=msg.buckets))
180
181 self.assertEquals(stats, [verify_group_stats])
182 #clear all group
183 delete_all_groups(self.controller)
184 #
185 #flood over mcast
186 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
187
188 stats = get_stats(self, ofp.message.group_desc_stats_request())
189
190 verify_group_stats=(ofp.group_desc_stats_entry(
191 group_type=msg.group_type,
192 group_id=msg.group_id,
193 buckets=msg.buckets))
194
195 self.assertEquals(stats, [verify_group_stats])
196 #clear all group
197 delete_all_groups(self.controller)
198 #exit verification so clear all configuration
199 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
200 lport=access_lport, phy_port=access_phy_port,
201 vlan=access_port_vid, vnid=vnid, operation="delete")
202 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
203 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
204 lport=network_lport,
205 src_ip=network_port_sip, dst_ip=network_port_dip,
206 next_hop_id=next_hop_id,
207 vnid=vnid, operation="delete")
208 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
209
210 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
211 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
212
213 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
214 dst_mac=dst_mac,
215 phy_port=network_port_phy_port,
216 vlan=network_port_vlan, operation="delete")
217 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
218
219 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
220 dst_mac=dst_mac_mcast,
221 phy_port=network_port_phy_port,
222 vlan=network_port_vlan, operation="delete")
223 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
224
225class OverlayMcastGroup(base_tests.SimpleDataPlane):
226 """
227 create two lport
228 """
229 def runTest(self):
230 if config["switch_ip"] == None:
231 logging.error("Doesn't configure switch IP")
232 return
233
234 delete_all_flows(self.controller)
235 delete_all_groups(self.controller)
236 #paramaters
237 access_port_vid=1
238 access_phy_port=1
239 access_lport=0x10001
240 vnid=103
241 next_hop_id=1
242 next_hop_id_mcast=2
243 dst_mac="00:00:11:22:22:11"
244 mcast_ipv4="224.1.1.1"
245 dst_mac_mcast="01:00:5e:01:01:01"
246 network_port_phy_port=2
247 network_lport=0x10002
248 network_port_vlan=2
249 network_port_sip="192.168.1.1"
250 network_port_dip="192.168.2.1"
251
252 feature_reply=get_featureReplay(self)
253 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
254 dst_mac=dst_mac_mcast,
255 phy_port=network_port_phy_port,
256 vlan=network_port_vlan)
257 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
258 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
259 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
260 logging.info("config VNI %lx", vnid);
261 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
262
263 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
264 lport=access_lport, phy_port=access_phy_port,
265 vlan=access_port_vid, vnid=vnid)
266 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport, access_phy_port, access_port_vid, vnid);
267 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
268 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
269 dst_mac=dst_mac,
270 phy_port=network_port_phy_port,
271 vlan=network_port_vlan)
272 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
273 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
274 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
275 lport=network_lport,
276 src_ip=network_port_sip, dst_ip=network_port_dip,
277 next_hop_id=next_hop_id,
278 vnid=vnid)
279 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);
280 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
281
282 #add flow over unicast group
283 msg=msg=add_l2_overlay_mcast_over_unicast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
284 #verify
285 stats = get_stats(self, ofp.message.group_desc_stats_request())
286 verify_group_stats=(ofp.group_desc_stats_entry(
287 group_type=msg.group_type,
288 group_id=msg.group_id,
289 buckets=msg.buckets))
290
291 self.assertEquals(stats, [verify_group_stats])
292 #clear all group
293 delete_all_groups(self.controller)
294 #
295 #flood over mcast
296 msg=add_l2_overlay_mcast_over_mcast_tunnel_group(self.controller, vnid, [access_lport, network_lport], 1)
297
298 stats = get_stats(self, ofp.message.group_desc_stats_request())
299
300 verify_group_stats=(ofp.group_desc_stats_entry(
301 group_type=msg.group_type,
302 group_id=msg.group_id,
303 buckets=msg.buckets))
304
305 self.assertEquals(stats, [verify_group_stats])
306 #clear all group
307 delete_all_groups(self.controller)
308 #exit verification so clear all configuration
309 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
310 lport=access_lport, phy_port=access_phy_port,
311 vlan=access_port_vid, vnid=vnid, operation="delete")
312 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
313 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
314 lport=network_lport,
315 src_ip=network_port_sip, dst_ip=network_port_dip,
316 next_hop_id=next_hop_id,
317 vnid=vnid, operation="delete")
318 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
319
320 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
321 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
322
323 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
324 dst_mac=dst_mac,
325 phy_port=network_port_phy_port,
326 vlan=network_port_vlan, operation="delete")
327 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
328
329 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
330 dst_mac=dst_mac_mcast,
331 phy_port=network_port_phy_port,
332 vlan=network_port_vlan, operation="delete")
333 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
334
335class AccessToNetworkDLFMcast(base_tests.SimpleDataPlane):
336 def runTest(self):
337 """
338 first verify flood over unicast,
339 second verify flood over mcast
340 """
341 if config["switch_ip"] == None:
342 logging.error("Doesn't configure switch IP")
343 return
344
345 delete_all_flows(self.controller)
346 delete_all_groups(self.controller)
347
348 access_port1_vid=1
349 access_phy_port1=config["port_map"].keys()[0]
350 access_lport1=0x10001
351 access_port2_vid=0
352 access_phy_port2=config["port_map"].keys()[1]
353 access_lport2=0x10002
354 vnid=10
355 next_hop_id=1
356 next_hop_id_mcast=2
357 dst_mac="00:00:11:22:22:11"
358 mcast_ipv4="224.1.1.1"
359 dst_mac_mcast="01:00:5e:01:01:01"
360 network_port_phy_port=config["port_map"].keys()[2]
361 network_lport=0x10003
362 network_port_vlan=2
363 network_port_sip="192.168.1.1"
364 network_port_dip="192.168.2.1"
365
366 feature_reply=get_featureReplay(self)
367 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
368 dst_mac=dst_mac,
369 phy_port=network_port_phy_port,
370 vlan=network_port_vlan)
371 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
372 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
373
374 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
375 dst_mac=dst_mac_mcast,
376 phy_port=network_port_phy_port,
377 vlan=network_port_vlan)
378 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
379 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
380
381 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
382 logging.info("config VNI %lx", vnid);
383 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
384
385 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
386 lport=access_lport1, phy_port=access_phy_port1,
387 vlan=access_port1_vid, vnid=vnid)
388 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
389 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
390
391 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
392 lport=access_lport2, phy_port=access_phy_port2,
393 vlan=access_port2_vid, vnid=vnid)
394 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
395 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
396 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
397 dst_mac=dst_mac,
398 phy_port=network_port_phy_port,
399 vlan=network_port_vlan)
400 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
401 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
402 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
403 lport=network_lport,
404 src_ip=network_port_sip, dst_ip=network_port_dip,
405 next_hop_id=next_hop_id,
406 vnid=vnid)
407 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);
408 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
409
410 #get_edit_config(config["switch_ip"])
411
412 #add port table to have vxlan ability
413 add_port_table_flow(self.controller)
414
415 #for network port need l2 interface group to decide vlan tag or not
416 add_one_l2_interface_grouop(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
417
418 #add DLF bridge flow
419 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, network_lport], 1)
420 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
421
422 #send packet on access port
423 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
424 dl_vlan_enable= True,
425 vlan_vid=access_port1_vid)
426 pkt = str(parsed_pkt)
427 self.dataplane.send(access_phy_port1, pkt)
428
429 #verify packet on access port
430 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
431 pkt = str(parsed_pkt)
432 verify_packet(self, pkt, access_phy_port2)
433 #vxlan packet IP header have some parmater decide by HW,
434 #we can easy to check VxLAN IP header
435 verify_packet(self, pkt, network_port_phy_port)
436 verify_no_other_packets(self)
437
438 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, network_lport, False, True)
439 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
440 dl_vlan_enable= True,
441 vlan_vid=access_port1_vid)
442 pkt = str(parsed_pkt)
443 self.dataplane.send(access_phy_port1, pkt)
444 #verify packet on network port
445 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
446 pkt = str(parsed_pkt)
447 verify_packet(self, pkt, network_port_phy_port)
448 verify_no_other_packets(self)
449
450 #exit verification so clear all configuration
451 delete_all_flows(self.controller)
452 delete_all_groups(self.controller)
453
454 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
455 lport=access_lport1, phy_port=access_phy_port1,
456 vlan=access_port1_vid, vnid=vnid, operation="delete")
457 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
458 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
459 lport=access_lport2, phy_port=access_phy_port2,
460 vlan=access_port2_vid, vnid=vnid, operation="delete")
461 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
462 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
463 lport=network_lport,
464 src_ip=network_port_sip, dst_ip=network_port_dip,
465 next_hop_id=next_hop_id,
466 vnid=vnid, operation="delete")
467 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
468
469 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
470 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
471
472 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
473 dst_mac=dst_mac,
474 phy_port=network_port_phy_port,
475 vlan=network_port_vlan, operation="delete")
476 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
477
478 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
479 dst_mac=dst_mac_mcast,
480 phy_port=network_port_phy_port,
481 vlan=network_port_vlan, operation="delete")
482 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
483
484class AccessToNetworkDLFUcast(base_tests.SimpleDataPlane):
485 def runTest(self):
486 """
487 first verify flood over unicast,
488 second verify flood over mcast
489 """
490 if config["switch_ip"] == None:
491 logging.error("Doesn't configure switch IP")
492 return
493
494 delete_all_flows(self.controller)
495 delete_all_groups(self.controller)
496
497 access_port1_vid=1
498 access_phy_port1=config["port_map"].keys()[0]
499 access_lport1=0x10001
500 access_port2_vid=0
501 access_phy_port2=config["port_map"].keys()[1]
502 access_lport2=0x10002
503 vnid=10
504 next_hop_id=1
505 next_hop_id_mcast=2
506 dst_mac="00:00:11:22:22:11"
507 mcast_ipv4="224.1.1.1"
508 dst_mac_mcast="01:00:5e:01:01:01"
509 network_port_phy_port=config["port_map"].keys()[2]
510 network_lport=0x10003
511 network_port_vlan=2
512 network_port_sip="192.168.1.1"
513 network_port_dip="192.168.2.1"
514
515 feature_reply=get_featureReplay(self)
516 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
517 dst_mac=dst_mac,
518 phy_port=network_port_phy_port,
519 vlan=network_port_vlan)
520 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
521 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
522
523 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
524 dst_mac=dst_mac_mcast,
525 phy_port=network_port_phy_port,
526 vlan=network_port_vlan)
527 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
528 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
529
530 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
531 logging.info("config VNI %lx", vnid);
532 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
533
534 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
535 lport=access_lport1, phy_port=access_phy_port1,
536 vlan=access_port1_vid, vnid=vnid)
537 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
538 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
539
540 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
541 lport=access_lport2, phy_port=access_phy_port2,
542 vlan=access_port2_vid, vnid=vnid)
543 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
544 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
545 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
546 dst_mac=dst_mac,
547 phy_port=network_port_phy_port,
548 vlan=network_port_vlan)
549 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
550 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
551 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
552 lport=network_lport,
553 src_ip=network_port_sip, dst_ip=network_port_dip,
554 next_hop_id=next_hop_id,
555 vnid=vnid)
556 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);
557 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
558
559 #get_edit_config(config["switch_ip"])
560
561 #add port table to have vxlan ability
562 add_port_table_flow(self.controller)
563
564 #for network port need l2 interface group to decide vlan tag or not
565 add_one_l2_interface_grouop(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
566
567 #add DLF bridge flow
568 msg=add_l2_overlay_flood_over_unicast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, network_lport], 1)
569 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
570
571 #send packet on access port
572 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
573 dl_vlan_enable= True,
574 vlan_vid=access_port1_vid)
575 pkt = str(parsed_pkt)
576 self.dataplane.send(access_phy_port1, pkt)
577
578 #verify packet on access port
579 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
580 pkt = str(parsed_pkt)
581 verify_packet(self, pkt, access_phy_port2)
582 #vxlan packet IP header have some parmater decide by HW,
583 #we can easy to check VxLAN IP header
584 verify_packet(self, pkt, network_port_phy_port)
585 verify_no_other_packets(self)
586
587 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, network_lport, False, True)
588 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
589 dl_vlan_enable= True,
590 vlan_vid=access_port1_vid)
591 pkt = str(parsed_pkt)
592 self.dataplane.send(access_phy_port1, pkt)
593 #verify packet on network port
594 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
595 pkt = str(parsed_pkt)
596 verify_packet(self, pkt, network_port_phy_port)
597 verify_no_other_packets(self)
598
599 #exit verification so clear all configuration
600 delete_all_flows(self.controller)
601 delete_all_groups(self.controller)
602
603 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
604 lport=access_lport1, phy_port=access_phy_port1,
605 vlan=access_port1_vid, vnid=vnid, operation="delete")
606 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
607 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
608 lport=access_lport2, phy_port=access_phy_port2,
609 vlan=access_port2_vid, vnid=vnid, operation="delete")
610 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
611 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
612 lport=network_lport,
613 src_ip=network_port_sip, dst_ip=network_port_dip,
614 next_hop_id=next_hop_id,
615 vnid=vnid, operation="delete")
616 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
617
618 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
619 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
620
621 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
622 dst_mac=dst_mac,
623 phy_port=network_port_phy_port,
624 vlan=network_port_vlan, operation="delete")
625 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
626
627 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
628 dst_mac=dst_mac_mcast,
629 phy_port=network_port_phy_port,
630 vlan=network_port_vlan, operation="delete")
631 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
632
633class AccessWithAccess(base_tests.SimpleDataPlane):
634 def runTest(self):
635 """
636 first verify flood over unicast,
637 second verify flood over mcast
638 """
639 if config["switch_ip"] == None:
640 logging.error("Doesn't configure switch IP")
641 return
642
643 delete_all_flows(self.controller)
644 delete_all_groups(self.controller)
645
646 access_port1_vid=1
647 access_phy_port1=config["port_map"].keys()[0]
648 access_lport1=0x10001
649 access_port2_vid=0
650 access_phy_port2=config["port_map"].keys()[1]
651 access_lport2=0x10002
652 access_port3_vid=3
653 access_phy_port3=config["port_map"].keys()[2]
654 access_lport3=0x10003
655 vnid=10
656 next_hop_id_mcast=1
657 mcast_ipv4="224.1.1.1"
658 dst_mac_mcast="01:00:5e:01:01:01"
659
660 feature_reply=get_featureReplay(self)
661
662 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
663 dst_mac=dst_mac_mcast,
664 phy_port=access_phy_port3,
665 vlan=access_port3_vid)
666 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);
667 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
668
669 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
670 logging.info("config VNI %lx", vnid);
671 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
672
673 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
674 lport=access_lport1, phy_port=access_phy_port1,
675 vlan=access_port1_vid, vnid=vnid)
676 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
677 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
678
679 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
680 lport=access_lport2, phy_port=access_phy_port2,
681 vlan=access_port2_vid, vnid=vnid)
682 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
683 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
684
685 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
686 lport=access_lport3, phy_port=access_phy_port3,
687 vlan=access_port3_vid, vnid=vnid)
688 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
689 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
690
691
692 #add port table to have vxlan ability
693 add_port_table_flow(self.controller)
694
695 #add DLF bridge flow
696 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, access_lport3], 1)
697 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
698
699 #send packet on access port
700 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
701 dl_vlan_enable= True,
702 vlan_vid=access_port1_vid)
703 pkt = str(parsed_pkt)
704 self.dataplane.send(access_phy_port1, pkt)
705
706 #verify packet on access port 2, vid=0, so untag
707 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
708 pkt = str(parsed_pkt)
709 verify_packet(self, pkt, access_phy_port2)
710 #verify packet on access port 3
711 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
712 dl_vlan_enable= True,
713 vlan_vid=access_port3_vid)
714 pkt = str(parsed_pkt)
715 verify_packet(self, pkt, access_phy_port3)
716 verify_no_other_packets(self)
717
718 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, access_lport2, False, True)
719 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
720 dl_vlan_enable= True,
721 vlan_vid=access_port1_vid)
722 pkt = str(parsed_pkt)
723 self.dataplane.send(access_phy_port1, pkt)
724 #verify packet on access port
725 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
726 pkt = str(parsed_pkt)
727 verify_packet(self, pkt, access_phy_port2)
728 verify_no_other_packets(self)
729
730
731 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0xaa], vnid, access_lport3, False, True)
732 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
733 dl_vlan_enable= True,
734 vlan_vid=access_port1_vid)
735 pkt = str(parsed_pkt)
736 self.dataplane.send(access_phy_port1, pkt)
737 #verify packet on access port
738 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
739 dl_vlan_enable= True,
740 vlan_vid=access_port3_vid)
741 pkt = str(parsed_pkt)
742 verify_packet(self, pkt, access_phy_port3)
743 verify_no_other_packets(self)
744
745
746
747 #exit verification so clear all configuration
748 delete_all_flows(self.controller)
749 delete_all_groups(self.controller)
750
751 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
752 lport=access_lport1, phy_port=access_phy_port1,
753 vlan=access_port1_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_lport2, phy_port=access_phy_port2,
757 vlan=access_port2_vid, vnid=vnid, operation="delete")
758 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
759 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
760 lport=access_lport3, phy_port=access_phy_port3,
761 vlan=access_port3_vid, vnid=vnid, operation="delete")
762 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
763 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
764
765 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
766 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
767
768 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
769 dst_mac=dst_mac_mcast,
770 phy_port=access_phy_port3,
771 vlan=access_port3_vid, operation="delete")
772 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
773
774class AccessWithNetwork(base_tests.SimpleDataPlane):
775 def runTest(self):
776 delete_all_flows(self.controller)
777 delete_all_groups(self.controller)
778
779class NetworkToNetwork(base_tests.SimpleDataPlane):
780 def runTest(self):
781 delete_all_flows(self.controller)
782 delete_all_groups(self.controller)