blob: 8977b7a471e3c1bcb157038bf398f63868be569a [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)
macauley68ace672015-07-27 17:40:50 +0800396 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
397 lport=network_lport,
398 src_ip=network_port_sip, dst_ip=network_port_dip,
399 next_hop_id=next_hop_id,
400 vnid=vnid)
401 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);
402 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
403
404 #get_edit_config(config["switch_ip"])
405
406 #add port table to have vxlan ability
407 add_port_table_flow(self.controller)
408
409 #for network port need l2 interface group to decide vlan tag or not
410 add_one_l2_interface_grouop(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
411
412 #add DLF bridge flow
413 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, network_lport], 1)
414 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
415
416 #send packet on access port
417 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
418 dl_vlan_enable= True,
419 vlan_vid=access_port1_vid)
420 pkt = str(parsed_pkt)
421 self.dataplane.send(access_phy_port1, pkt)
422
423 #verify packet on access port
424 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
425 pkt = str(parsed_pkt)
426 verify_packet(self, pkt, access_phy_port2)
427 #vxlan packet IP header have some parmater decide by HW,
428 #we can easy to check VxLAN IP header
429 verify_packet(self, pkt, network_port_phy_port)
430 verify_no_other_packets(self)
431
432 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, network_lport, False, True)
433 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
434 dl_vlan_enable= True,
435 vlan_vid=access_port1_vid)
436 pkt = str(parsed_pkt)
437 self.dataplane.send(access_phy_port1, pkt)
438 #verify packet on network port
439 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
440 pkt = str(parsed_pkt)
441 verify_packet(self, pkt, network_port_phy_port)
442 verify_no_other_packets(self)
443
444 #exit verification so clear all configuration
445 delete_all_flows(self.controller)
446 delete_all_groups(self.controller)
447
448 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
449 lport=access_lport1, phy_port=access_phy_port1,
450 vlan=access_port1_vid, vnid=vnid, operation="delete")
451 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
452 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
453 lport=access_lport2, phy_port=access_phy_port2,
454 vlan=access_port2_vid, vnid=vnid, operation="delete")
455 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
456 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
457 lport=network_lport,
458 src_ip=network_port_sip, dst_ip=network_port_dip,
459 next_hop_id=next_hop_id,
460 vnid=vnid, operation="delete")
461 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
462
463 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
464 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
465
466 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
467 dst_mac=dst_mac,
468 phy_port=network_port_phy_port,
469 vlan=network_port_vlan, operation="delete")
470 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
471
472 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
473 dst_mac=dst_mac_mcast,
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
478class AccessToNetworkDLFUcast(base_tests.SimpleDataPlane):
479 def runTest(self):
480 """
481 first verify flood over unicast,
482 second verify flood over mcast
483 """
484 if config["switch_ip"] == None:
485 logging.error("Doesn't configure switch IP")
486 return
487
488 delete_all_flows(self.controller)
489 delete_all_groups(self.controller)
490
491 access_port1_vid=1
492 access_phy_port1=config["port_map"].keys()[0]
493 access_lport1=0x10001
494 access_port2_vid=0
495 access_phy_port2=config["port_map"].keys()[1]
496 access_lport2=0x10002
497 vnid=10
498 next_hop_id=1
499 next_hop_id_mcast=2
500 dst_mac="00:00:11:22:22:11"
501 mcast_ipv4="224.1.1.1"
502 dst_mac_mcast="01:00:5e:01:01:01"
503 network_port_phy_port=config["port_map"].keys()[2]
504 network_lport=0x10003
505 network_port_vlan=2
506 network_port_sip="192.168.1.1"
507 network_port_dip="192.168.2.1"
508
509 feature_reply=get_featureReplay(self)
510 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
511 dst_mac=dst_mac,
512 phy_port=network_port_phy_port,
513 vlan=network_port_vlan)
514 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
515 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
516
517 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
518 dst_mac=dst_mac_mcast,
519 phy_port=network_port_phy_port,
520 vlan=network_port_vlan)
521 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
522 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
523
524 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
525 logging.info("config VNI %lx", vnid);
526 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
527
528 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
529 lport=access_lport1, phy_port=access_phy_port1,
530 vlan=access_port1_vid, vnid=vnid)
531 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
532 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
533
534 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
535 lport=access_lport2, phy_port=access_phy_port2,
536 vlan=access_port2_vid, vnid=vnid)
537 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
538 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800539 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
540 lport=network_lport,
541 src_ip=network_port_sip, dst_ip=network_port_dip,
542 next_hop_id=next_hop_id,
543 vnid=vnid)
544 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);
545 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
546
547 #get_edit_config(config["switch_ip"])
548
549 #add port table to have vxlan ability
550 add_port_table_flow(self.controller)
551
552 #for network port need l2 interface group to decide vlan tag or not
553 add_one_l2_interface_grouop(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
554
555 #add DLF bridge flow
556 msg=add_l2_overlay_flood_over_unicast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, network_lport], 1)
557 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
558
559 #send packet on access port
560 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
561 dl_vlan_enable= True,
562 vlan_vid=access_port1_vid)
563 pkt = str(parsed_pkt)
564 self.dataplane.send(access_phy_port1, pkt)
565
566 #verify packet on access port
567 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
568 pkt = str(parsed_pkt)
569 verify_packet(self, pkt, access_phy_port2)
570 #vxlan packet IP header have some parmater decide by HW,
571 #we can easy to check VxLAN IP header
572 verify_packet(self, pkt, network_port_phy_port)
573 verify_no_other_packets(self)
574
575 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, network_lport, False, True)
576 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
577 dl_vlan_enable= True,
578 vlan_vid=access_port1_vid)
579 pkt = str(parsed_pkt)
580 self.dataplane.send(access_phy_port1, pkt)
581 #verify packet on network port
582 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
583 pkt = str(parsed_pkt)
584 verify_packet(self, pkt, network_port_phy_port)
585 verify_no_other_packets(self)
586
587 #exit verification so clear all configuration
588 delete_all_flows(self.controller)
589 delete_all_groups(self.controller)
590
591 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
592 lport=access_lport1, phy_port=access_phy_port1,
593 vlan=access_port1_vid, vnid=vnid, operation="delete")
594 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
595 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
596 lport=access_lport2, phy_port=access_phy_port2,
597 vlan=access_port2_vid, vnid=vnid, operation="delete")
598 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
599 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
600 lport=network_lport,
601 src_ip=network_port_sip, dst_ip=network_port_dip,
602 next_hop_id=next_hop_id,
603 vnid=vnid, operation="delete")
604 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
605
606 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
607 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
608
609 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
610 dst_mac=dst_mac,
611 phy_port=network_port_phy_port,
612 vlan=network_port_vlan, operation="delete")
613 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
614
615 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
616 dst_mac=dst_mac_mcast,
617 phy_port=network_port_phy_port,
618 vlan=network_port_vlan, operation="delete")
619 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
620
621class AccessWithAccess(base_tests.SimpleDataPlane):
622 def runTest(self):
623 """
624 first verify flood over unicast,
625 second verify flood over mcast
626 """
627 if config["switch_ip"] == None:
628 logging.error("Doesn't configure switch IP")
629 return
630
631 delete_all_flows(self.controller)
632 delete_all_groups(self.controller)
633
634 access_port1_vid=1
635 access_phy_port1=config["port_map"].keys()[0]
636 access_lport1=0x10001
637 access_port2_vid=0
638 access_phy_port2=config["port_map"].keys()[1]
639 access_lport2=0x10002
640 access_port3_vid=3
641 access_phy_port3=config["port_map"].keys()[2]
642 access_lport3=0x10003
643 vnid=10
644 next_hop_id_mcast=1
645 mcast_ipv4="224.1.1.1"
646 dst_mac_mcast="01:00:5e:01:01:01"
647
648 feature_reply=get_featureReplay(self)
649
650 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
651 dst_mac=dst_mac_mcast,
652 phy_port=access_phy_port3,
653 vlan=access_port3_vid)
654 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);
655 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
656
657 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
658 logging.info("config VNI %lx", vnid);
659 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
660
661 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
662 lport=access_lport1, phy_port=access_phy_port1,
663 vlan=access_port1_vid, vnid=vnid)
664 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
665 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
666
667 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
668 lport=access_lport2, phy_port=access_phy_port2,
669 vlan=access_port2_vid, vnid=vnid)
670 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
671 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
672
673 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
674 lport=access_lport3, phy_port=access_phy_port3,
675 vlan=access_port3_vid, vnid=vnid)
676 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
677 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
678
679
680 #add port table to have vxlan ability
681 add_port_table_flow(self.controller)
682
683 #add DLF bridge flow
684 msg=add_l2_overlay_flood_over_mcast_tunnel_group(self.controller, vnid, [access_lport1, access_lport2, access_lport3], 1)
685 add_overlay_bridge_flow(self.controller, None, vnid, msg.group_id, True, True)
686
687 #send packet on access port
688 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
689 dl_vlan_enable= True,
690 vlan_vid=access_port1_vid)
691 pkt = str(parsed_pkt)
692 self.dataplane.send(access_phy_port1, pkt)
693
694 #verify packet on access port 2, vid=0, so untag
695 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:00:11:11:11:11')
696 pkt = str(parsed_pkt)
697 verify_packet(self, pkt, access_phy_port2)
698 #verify packet on access port 3
699 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:00:11:11:11:11',
700 dl_vlan_enable= True,
701 vlan_vid=access_port3_vid)
702 pkt = str(parsed_pkt)
703 verify_packet(self, pkt, access_phy_port3)
704 verify_no_other_packets(self)
705
706 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0x9a], vnid, access_lport2, False, True)
707 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:9a',
708 dl_vlan_enable= True,
709 vlan_vid=access_port1_vid)
710 pkt = str(parsed_pkt)
711 self.dataplane.send(access_phy_port1, pkt)
712 #verify packet on access port
713 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst='00:12:34:56:78:9a')
714 pkt = str(parsed_pkt)
715 verify_packet(self, pkt, access_phy_port2)
716 verify_no_other_packets(self)
717
718
719 add_overlay_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, 0xaa], vnid, access_lport3, False, True)
720 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
721 dl_vlan_enable= True,
722 vlan_vid=access_port1_vid)
723 pkt = str(parsed_pkt)
724 self.dataplane.send(access_phy_port1, pkt)
725 #verify packet on access port
726 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst='00:12:34:56:78:aa',
727 dl_vlan_enable= True,
728 vlan_vid=access_port3_vid)
729 pkt = str(parsed_pkt)
730 verify_packet(self, pkt, access_phy_port3)
731 verify_no_other_packets(self)
732
733
734
735 #exit verification so clear all configuration
736 delete_all_flows(self.controller)
737 delete_all_groups(self.controller)
738
739 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
740 lport=access_lport1, phy_port=access_phy_port1,
741 vlan=access_port1_vid, vnid=vnid, operation="delete")
742 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
743 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
744 lport=access_lport2, phy_port=access_phy_port2,
745 vlan=access_port2_vid, vnid=vnid, operation="delete")
746 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
747 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
748 lport=access_lport3, phy_port=access_phy_port3,
749 vlan=access_port3_vid, vnid=vnid, operation="delete")
750 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport3, access_phy_port3, access_port3_vid, vnid);
751 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
752
753 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
754 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
755
756 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
757 dst_mac=dst_mac_mcast,
758 phy_port=access_phy_port3,
759 vlan=access_port3_vid, operation="delete")
760 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
761
762class AccessWithNetwork(base_tests.SimpleDataPlane):
763 def runTest(self):
macauleyee5bfa72015-08-03 10:11:14 +0800764 """
765 first verify flood over unicast,
766 second verify flood over mcast
767 """
768 if config["switch_ip"] == None:
769 logging.error("Doesn't configure switch IP")
770 return
macauley68ace672015-07-27 17:40:50 +0800771 delete_all_flows(self.controller)
772 delete_all_groups(self.controller)
macauleyee5bfa72015-08-03 10:11:14 +0800773
774 access_port1_vid=1
775 access_phy_port1=config["port_map"].keys()[0]
776 access_lport1=0x10001
777 access_lport1_mac=[0x00, 0x00, 0x00, 0x77, 0x77, 0x77]
778 access_lport1_mac_str=(":".join(map(str, map(hex, access_lport1_mac)))).replace("0x", "")
779 access_port2_vid=0
780 access_phy_port2=config["port_map"].keys()[1]
781 access_lport2=0x10002
782 access_lport2_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x02]
783 access_lport2_mac_str=(":".join(map(str, map(hex, access_lport2_mac)))).replace("0x", "")
784 vnid=10
785 next_hop_id=1
786 next_hop_id_mcast=2
787 dst_mac="00:00:11:22:22:11"
788 mcast_ipv4="224.1.1.1"
789 dst_mac_mcast="01:00:5e:01:01:01"
790 network_port_phy_port=config["port_map"].keys()[2]
791 network_lport=0x10003
792 network_port_vlan=2
793 network_port_sip="192.168.1.1"
794 network_port_dip="192.168.2.1"
795 network_lport_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x03]
796 network_lport_mac_str=(":".join(map(str, map(hex, network_lport_mac)))).replace("0x", "")
797
798
799
800 feature_reply=get_featureReplay(self)
801 #get switch CPU mac
802 str_datapath_id_f= "{:016x}".format(feature_reply.datapath_id)
803 str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
804 switch_cpu_mac_str=str_datapath_id[6:]
805 switch_cpu_mac = switch_cpu_mac_str.split(":")
806 switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))]
807
808 #add config vtep/vtap/nexthop/vni
809 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
810 dst_mac=dst_mac,
811 phy_port=network_port_phy_port,
812 vlan=network_port_vlan)
813 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
814 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
815
816 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
817 dst_mac=dst_mac_mcast,
818 phy_port=network_port_phy_port,
819 vlan=network_port_vlan)
820 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
821
822 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
823
824 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
825 #vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None)
826 logging.info("config VNI %lx", vnid);
827 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
828
829 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
830 lport=access_lport1, phy_port=access_phy_port1,
831 vlan=access_port1_vid, vnid=vnid)
832 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
833 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
834
835 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
836 lport=access_lport2, phy_port=access_phy_port2,
837 vlan=access_port2_vid, vnid=vnid)
838 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
839 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
840 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
841 lport=network_lport,
842 src_ip=network_port_sip, dst_ip=network_port_dip,
843 next_hop_id=next_hop_id,
844 vnid=vnid)
845 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);
846 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
847
848 #add port table to have vxlan ability
849 add_port_table_flow(self.controller)
850 add_port_table_flow(self.controller, is_overlay=False)
851
852 #for network port need l2 interface group to decide vlan tag or not
853 add_one_l2_interface_grouop(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
854 #add network mac
855 add_overlay_bridge_flow(self.controller, network_lport_mac, vnid, network_lport, False, True)
856 add_overlay_bridge_flow(self.controller, access_lport1_mac, vnid, access_lport1, False, True)
857
858 #add termination table for network port
859 add_termination_flow(self.controller, in_port=network_port_phy_port, eth_type=0x0800,
860 dst_mac=switch_cpu_mac, vlanid=network_port_vlan)
861 #add vlan table for network port rx packet class vlan
862 add_one_vlan_table_flow(self.controller, of_port=network_port_phy_port,
863 vlan_id=network_port_vlan)
864
865 #tx packet on access lport 1
866 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst=network_lport_mac_str,
867 dl_vlan_enable= True,
868 vlan_vid=access_port1_vid)
869 pkt = str(parsed_pkt)
870 self.dataplane.send(access_phy_port1, pkt)
871 #verify packet on network port
872 #need find a way to verify vxlan header
873 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst=network_lport_mac_str)
874 pkt = str(parsed_pkt)
875 verify_packet(self, pkt, network_port_phy_port)
876 verify_no_other_packets(self)
877
878 #tx packet on network lport
879 inner_pkt = simple_udp_packet(pktlen=96, eth_dst=access_lport1_mac_str)
880 vxlan_pkt = simple_vxlan_packet(eth_dst=switch_cpu_mac_str,
881 vnid=vnid,
882 ip_dst= network_port_sip,
883 ip_src=network_port_dip,
884 inner_payload=inner_pkt)
885 self.dataplane.send(network_port_phy_port, str(vxlan_pkt))
886 #verify
887 inner_pkt = simple_udp_packet(pktlen=100, eth_dst=access_lport1_mac_str,
888 dl_vlan_enable= True,
889 vlan_vid=access_port1_vid)
890
891 verify_packet(self, inner_pkt, access_phy_port1)
892 verify_no_other_packets(self)
893
894
895 #exit verification so clear all configuration
896 delete_all_flows(self.controller)
897 delete_all_groups(self.controller)
898
899 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
900 lport=access_lport1, phy_port=access_phy_port1,
901 vlan=access_port1_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_lport2, phy_port=access_phy_port2,
905 vlan=access_port2_vid, vnid=vnid, operation="delete")
906 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
907 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
908 lport=network_lport,
909 src_ip=network_port_sip, dst_ip=network_port_dip,
910 next_hop_id=next_hop_id,
911 vnid=vnid, operation="delete")
912 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
913
914 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
915 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
916
917 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
918 dst_mac=dst_mac,
919 phy_port=network_port_phy_port,
920 vlan=network_port_vlan, operation="delete")
921 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
922
923 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
924 dst_mac=dst_mac_mcast,
925 phy_port=network_port_phy_port,
926 vlan=network_port_vlan, operation="delete")
927 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800928
929class NetworkToNetwork(base_tests.SimpleDataPlane):
930 def runTest(self):
macauleyee5bfa72015-08-03 10:11:14 +0800931 """
932 This case can't work, can't identify it is chip limitation or not
933 """
934 return
935 if config["switch_ip"] == None:
936 logging.error("Doesn't configure switch IP")
937 return
938
macauley68ace672015-07-27 17:40:50 +0800939 delete_all_flows(self.controller)
macauleyee5bfa72015-08-03 10:11:14 +0800940 delete_all_groups(self.controller)
941
942 vnid=10
943 mcast_ipv4="224.1.1.1"
944 dst_mac_mcast="01:00:5e:01:01:01"
945 next_hop_id_mcast=3
946
947 access_port1_vid=1
948 access_phy_port1=config["port_map"].keys()[0]
949 access_lport1=0x10001
950
951 network_port1_phy_port=config["port_map"].keys()[1]
952 network_lport1=0x10003
953 network_port1_vlan=2
954 network_port1_sip="192.168.1.1"
955 network_port1_dip="192.168.2.1"
956 network_port1_next_hop_id=1
957 network_port1_dst_mac="00:00:11:22:22:11"
958 network_lport1_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x33]
959 network_lport1_mac_str=(":".join(map(str, map(hex, network_lport1_mac)))).replace("0x", "")
960
961 network_port2_phy_port=config["port_map"].keys()[2]
962 network_lport2=0x10004
963 network_port2_vlan=3
964 network_port2_sip="192.168.3.1"
965 network_port2_dip="192.168.4.1"
966 network_port2_next_hop_id=2
967 network_port2_dst_mac="00:00:11:22:22:22"
968 network_lport2_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x44]
969 network_lport2_mac_str=(":".join(map(str, map(hex, network_lport2_mac)))).replace("0x", "")
970
971 feature_reply=get_featureReplay(self)
972 #get switch CPU mac
973 str_datapath_id_f= "{:016x}".format(feature_reply.datapath_id)
974 str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
975 switch_cpu_mac_str=str_datapath_id[6:]
976 switch_cpu_mac = switch_cpu_mac_str.split(":")
977 switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))]
978 #config vlxan
979 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port1_next_hop_id,
980 dst_mac=network_port1_dst_mac,
981 phy_port=network_port1_phy_port,
982 vlan=network_port1_vlan)
983 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);
984 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
985 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port2_next_hop_id,
986 dst_mac=network_port2_dst_mac,
987 phy_port=network_port2_phy_port,
988 vlan=network_port2_vlan)
989 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);
990 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
991
992 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
993 dst_mac=dst_mac_mcast,
994 phy_port=network_port1_phy_port,
995 vlan=network_port1_vlan)
996 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);
997 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
998
999 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
1000 logging.info("config VNI %lx", vnid);
1001 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
1002
1003 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1004 lport=access_lport1, phy_port=access_phy_port1,
1005 vlan=access_port1_vid, vnid=vnid)
1006 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
1007 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1008
1009 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1010 lport=network_lport1,
1011 src_ip=network_port1_sip, dst_ip=network_port1_dip,
1012 next_hop_id=network_port1_next_hop_id,
1013 vnid=vnid)
1014 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);
1015 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1016 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1017 lport=network_lport2,
1018 src_ip=network_port2_sip, dst_ip=network_port2_dip,
1019 next_hop_id=network_port2_next_hop_id,
1020 vnid=vnid)
1021 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);
1022 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1023
1024 #add port table to have vxlan ability
1025 add_port_table_flow(self.controller)
1026
1027 #for network port need l2 interface group to decide vlan tag or not
1028 add_one_l2_interface_grouop(self.controller, network_port1_phy_port, vlan_id=network_port1_vlan)
1029 add_one_l2_interface_grouop(self.controller, network_port2_phy_port, vlan_id=network_port2_vlan)
1030 #add network mac
1031 add_overlay_bridge_flow(self.controller, network_lport1_mac, vnid, network_lport1, False, True)
1032 add_overlay_bridge_flow(self.controller, network_lport2_mac, vnid, network_lport2, False, True)
1033
1034 #add termination table for network port
1035 add_termination_flow(self.controller, in_port=network_port1_phy_port, eth_type=0x0800,
1036 dst_mac=switch_cpu_mac, vlanid=network_port1_vlan)
1037 add_termination_flow(self.controller, in_port=network_port2_phy_port, eth_type=0x0800,
1038 dst_mac=switch_cpu_mac, vlanid=network_port2_vlan)
1039 #add vlan table for network port rx packet class vlan
1040 add_one_vlan_table_flow(self.controller, of_port=network_port1_phy_port,
1041 vlan_id=network_port1_vlan)
1042 add_one_vlan_table_flow(self.controller, of_port=network_port2_phy_port,
1043 vlan_id=network_port2_vlan)
1044
1045 #packet tx on network port 1 rx on network port 2
1046 inner_pkt = simple_udp_packet(pktlen=96, eth_dst=network_lport2_mac_str)
1047 vxlan_pkt = simple_vxlan_packet(eth_dst=switch_cpu_mac_str,
1048 vnid=vnid,
1049 ip_dst= network_port1_sip,
1050 ip_src=network_port1_dip,
1051 inner_payload=inner_pkt)
1052 self.dataplane.send(network_port1_phy_port, str(vxlan_pkt))
1053 #verify
1054 verify_packet(self, str(inner_pkt), network_port2_phy_port)
1055 verify_no_other_packets(self)
1056
1057
1058
1059 #exit verification so clear all configuration
1060 delete_all_flows(self.controller)
1061 delete_all_groups(self.controller)
1062
1063 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1064 lport=access_lport1, phy_port=access_phy_port1,
1065 vlan=access_port1_vid, vnid=vnid, operation="delete")
1066 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1067
1068 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1069 lport=network_lport1,
1070 src_ip=network_port1_sip, dst_ip=network_port1_dip,
1071 next_hop_id=network_port1_next_hop_id,
1072 vnid=vnid, operation="delete")
1073 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1074 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1075 lport=network_lport2,
1076 src_ip=network_port2_sip, dst_ip=network_port2_dip,
1077 next_hop_id=network_port2_next_hop_id,
1078 vnid=vnid, operation="delete")
1079 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1080 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
1081 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
1082
1083 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port1_next_hop_id,
1084 dst_mac=network_port1_dst_mac,
1085 phy_port=network_port1_phy_port,
1086 vlan=network_port1_vlan, operation="delete")
1087 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1088 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port2_next_hop_id,
1089 dst_mac=network_port2_dst_mac,
1090 phy_port=network_port2_phy_port,
1091 vlan=network_port2_vlan, operation="delete")
1092 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1093 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
1094 dst_mac=dst_mac_mcast,
1095 phy_port=network_port1_phy_port,
1096 vlan=network_port1_vlan, operation="delete")
1097 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1098