blob: c066c700a1ae1d98b09da3076b4ce1aaf155932a [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
623class AccessWithAccess(base_tests.SimpleDataPlane):
624 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
764class AccessWithNetwork(base_tests.SimpleDataPlane):
765 def runTest(self):
macauleyee5bfa72015-08-03 10:11:14 +0800766 """
767 first verify flood over unicast,
768 second verify flood over mcast
769 """
770 if config["switch_ip"] == None:
771 logging.error("Doesn't configure switch IP")
772 return
macauley68ace672015-07-27 17:40:50 +0800773 delete_all_flows(self.controller)
774 delete_all_groups(self.controller)
macauleyee5bfa72015-08-03 10:11:14 +0800775
776 access_port1_vid=1
777 access_phy_port1=config["port_map"].keys()[0]
778 access_lport1=0x10001
779 access_lport1_mac=[0x00, 0x00, 0x00, 0x77, 0x77, 0x77]
780 access_lport1_mac_str=(":".join(map(str, map(hex, access_lport1_mac)))).replace("0x", "")
781 access_port2_vid=0
782 access_phy_port2=config["port_map"].keys()[1]
783 access_lport2=0x10002
784 access_lport2_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x02]
785 access_lport2_mac_str=(":".join(map(str, map(hex, access_lport2_mac)))).replace("0x", "")
786 vnid=10
787 next_hop_id=1
788 next_hop_id_mcast=2
789 dst_mac="00:00:11:22:22:11"
790 mcast_ipv4="224.1.1.1"
791 dst_mac_mcast="01:00:5e:01:01:01"
792 network_port_phy_port=config["port_map"].keys()[2]
793 network_lport=0x10003
794 network_port_vlan=2
795 network_port_sip="192.168.1.1"
796 network_port_dip="192.168.2.1"
797 network_lport_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x03]
798 network_lport_mac_str=(":".join(map(str, map(hex, network_lport_mac)))).replace("0x", "")
799
800
801
802 feature_reply=get_featureReplay(self)
803 #get switch CPU mac
804 str_datapath_id_f= "{:016x}".format(feature_reply.datapath_id)
805 str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
806 switch_cpu_mac_str=str_datapath_id[6:]
807 switch_cpu_mac = switch_cpu_mac_str.split(":")
808 switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))]
809
810 #add config vtep/vtap/nexthop/vni
811 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
812 dst_mac=dst_mac,
813 phy_port=network_port_phy_port,
814 vlan=network_port_vlan)
815 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
816 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
817
818 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
819 dst_mac=dst_mac_mcast,
820 phy_port=network_port_phy_port,
821 vlan=network_port_vlan)
822 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", next_hop_id, dst_mac, network_port_phy_port, network_port_vlan);
823
824 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
825
826 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
827 #vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None)
828 logging.info("config VNI %lx", vnid);
829 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
830
831 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
832 lport=access_lport1, phy_port=access_phy_port1,
833 vlan=access_port1_vid, vnid=vnid)
834 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
835 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
836
837 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
838 lport=access_lport2, phy_port=access_phy_port2,
839 vlan=access_port2_vid, vnid=vnid)
840 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport2, access_phy_port2, access_port2_vid, vnid);
841 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
842 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
843 lport=network_lport,
844 src_ip=network_port_sip, dst_ip=network_port_dip,
845 next_hop_id=next_hop_id,
846 vnid=vnid)
847 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);
848 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
849
850 #add port table to have vxlan ability
851 add_port_table_flow(self.controller)
852 add_port_table_flow(self.controller, is_overlay=False)
853
854 #for network port need l2 interface group to decide vlan tag or not
855 add_one_l2_interface_grouop(self.controller, network_port_phy_port, vlan_id=network_port_vlan)
856 #add network mac
857 add_overlay_bridge_flow(self.controller, network_lport_mac, vnid, network_lport, False, True)
858 add_overlay_bridge_flow(self.controller, access_lport1_mac, vnid, access_lport1, False, True)
859
860 #add termination table for network port
861 add_termination_flow(self.controller, in_port=network_port_phy_port, eth_type=0x0800,
862 dst_mac=switch_cpu_mac, vlanid=network_port_vlan)
863 #add vlan table for network port rx packet class vlan
864 add_one_vlan_table_flow(self.controller, of_port=network_port_phy_port,
865 vlan_id=network_port_vlan)
866
867 #tx packet on access lport 1
868 parsed_pkt = simple_udp_packet(pktlen=96, eth_dst=network_lport_mac_str,
869 dl_vlan_enable= True,
870 vlan_vid=access_port1_vid)
871 pkt = str(parsed_pkt)
872 self.dataplane.send(access_phy_port1, pkt)
873 #verify packet on network port
874 #need find a way to verify vxlan header
875 parsed_pkt = simple_udp_packet(pktlen=92, eth_dst=network_lport_mac_str)
876 pkt = str(parsed_pkt)
877 verify_packet(self, pkt, network_port_phy_port)
878 verify_no_other_packets(self)
879
880 #tx packet on network lport
881 inner_pkt = simple_udp_packet(pktlen=96, eth_dst=access_lport1_mac_str)
882 vxlan_pkt = simple_vxlan_packet(eth_dst=switch_cpu_mac_str,
883 vnid=vnid,
884 ip_dst= network_port_sip,
885 ip_src=network_port_dip,
886 inner_payload=inner_pkt)
887 self.dataplane.send(network_port_phy_port, str(vxlan_pkt))
888 #verify
889 inner_pkt = simple_udp_packet(pktlen=100, eth_dst=access_lport1_mac_str,
890 dl_vlan_enable= True,
891 vlan_vid=access_port1_vid)
892
893 verify_packet(self, inner_pkt, access_phy_port1)
894 verify_no_other_packets(self)
895
896
897 #exit verification so clear all configuration
898 delete_all_flows(self.controller)
899 delete_all_groups(self.controller)
900
901 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
902 lport=access_lport1, phy_port=access_phy_port1,
903 vlan=access_port1_vid, vnid=vnid, operation="delete")
904 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
905 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
906 lport=access_lport2, phy_port=access_phy_port2,
907 vlan=access_port2_vid, vnid=vnid, operation="delete")
908 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
909 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
910 lport=network_lport,
911 src_ip=network_port_sip, dst_ip=network_port_dip,
912 next_hop_id=next_hop_id,
913 vnid=vnid, operation="delete")
914 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
915
916 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
917 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
918
919 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id,
920 dst_mac=dst_mac,
921 phy_port=network_port_phy_port,
922 vlan=network_port_vlan, operation="delete")
923 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
924
925 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
926 dst_mac=dst_mac_mcast,
927 phy_port=network_port_phy_port,
928 vlan=network_port_vlan, operation="delete")
929 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
macauley68ace672015-07-27 17:40:50 +0800930
931class NetworkToNetwork(base_tests.SimpleDataPlane):
932 def runTest(self):
macauleyee5bfa72015-08-03 10:11:14 +0800933 """
934 This case can't work, can't identify it is chip limitation or not
935 """
936 return
937 if config["switch_ip"] == None:
938 logging.error("Doesn't configure switch IP")
939 return
940
macauley68ace672015-07-27 17:40:50 +0800941 delete_all_flows(self.controller)
macauleyee5bfa72015-08-03 10:11:14 +0800942 delete_all_groups(self.controller)
943
944 vnid=10
945 mcast_ipv4="224.1.1.1"
946 dst_mac_mcast="01:00:5e:01:01:01"
947 next_hop_id_mcast=3
948
949 access_port1_vid=1
950 access_phy_port1=config["port_map"].keys()[0]
951 access_lport1=0x10001
952
953 network_port1_phy_port=config["port_map"].keys()[1]
954 network_lport1=0x10003
955 network_port1_vlan=2
956 network_port1_sip="192.168.1.1"
957 network_port1_dip="192.168.2.1"
958 network_port1_next_hop_id=1
959 network_port1_dst_mac="00:00:11:22:22:11"
960 network_lport1_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x33]
961 network_lport1_mac_str=(":".join(map(str, map(hex, network_lport1_mac)))).replace("0x", "")
962
963 network_port2_phy_port=config["port_map"].keys()[2]
964 network_lport2=0x10004
965 network_port2_vlan=3
966 network_port2_sip="192.168.3.1"
967 network_port2_dip="192.168.4.1"
968 network_port2_next_hop_id=2
969 network_port2_dst_mac="00:00:11:22:22:22"
970 network_lport2_mac=[0x00,0x00, 0x00, 0x00, 0x00, 0x44]
971 network_lport2_mac_str=(":".join(map(str, map(hex, network_lport2_mac)))).replace("0x", "")
972
973 feature_reply=get_featureReplay(self)
974 #get switch CPU mac
975 str_datapath_id_f= "{:016x}".format(feature_reply.datapath_id)
976 str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
977 switch_cpu_mac_str=str_datapath_id[6:]
978 switch_cpu_mac = switch_cpu_mac_str.split(":")
979 switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))]
980 #config vlxan
981 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port1_next_hop_id,
982 dst_mac=network_port1_dst_mac,
983 phy_port=network_port1_phy_port,
984 vlan=network_port1_vlan)
985 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);
986 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
987 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port2_next_hop_id,
988 dst_mac=network_port2_dst_mac,
989 phy_port=network_port2_phy_port,
990 vlan=network_port2_vlan)
991 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);
992 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
993
994 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
995 dst_mac=dst_mac_mcast,
996 phy_port=network_port1_phy_port,
997 vlan=network_port1_vlan)
998 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);
999 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
1000
1001 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=mcast_ipv4, next_hop_id=next_hop_id_mcast)
1002 logging.info("config VNI %lx", vnid);
1003 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
1004
1005 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1006 lport=access_lport1, phy_port=access_phy_port1,
1007 vlan=access_port1_vid, vnid=vnid)
1008 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", access_lport1, access_phy_port1, access_port1_vid, vnid);
1009 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1010
1011 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1012 lport=network_lport1,
1013 src_ip=network_port1_sip, dst_ip=network_port1_dip,
1014 next_hop_id=network_port1_next_hop_id,
1015 vnid=vnid)
1016 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);
1017 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1018 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1019 lport=network_lport2,
1020 src_ip=network_port2_sip, dst_ip=network_port2_dip,
1021 next_hop_id=network_port2_next_hop_id,
1022 vnid=vnid)
1023 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);
1024 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1025
1026 #add port table to have vxlan ability
1027 add_port_table_flow(self.controller)
1028
1029 #for network port need l2 interface group to decide vlan tag or not
1030 add_one_l2_interface_grouop(self.controller, network_port1_phy_port, vlan_id=network_port1_vlan)
1031 add_one_l2_interface_grouop(self.controller, network_port2_phy_port, vlan_id=network_port2_vlan)
1032 #add network mac
1033 add_overlay_bridge_flow(self.controller, network_lport1_mac, vnid, network_lport1, False, True)
1034 add_overlay_bridge_flow(self.controller, network_lport2_mac, vnid, network_lport2, False, True)
1035
1036 #add termination table for network port
1037 add_termination_flow(self.controller, in_port=network_port1_phy_port, eth_type=0x0800,
1038 dst_mac=switch_cpu_mac, vlanid=network_port1_vlan)
1039 add_termination_flow(self.controller, in_port=network_port2_phy_port, eth_type=0x0800,
1040 dst_mac=switch_cpu_mac, vlanid=network_port2_vlan)
1041 #add vlan table for network port rx packet class vlan
1042 add_one_vlan_table_flow(self.controller, of_port=network_port1_phy_port,
1043 vlan_id=network_port1_vlan)
1044 add_one_vlan_table_flow(self.controller, of_port=network_port2_phy_port,
1045 vlan_id=network_port2_vlan)
1046
1047 #packet tx on network port 1 rx on network port 2
1048 inner_pkt = simple_udp_packet(pktlen=96, eth_dst=network_lport2_mac_str)
1049 vxlan_pkt = simple_vxlan_packet(eth_dst=switch_cpu_mac_str,
1050 vnid=vnid,
1051 ip_dst= network_port1_sip,
1052 ip_src=network_port1_dip,
1053 inner_payload=inner_pkt)
1054 self.dataplane.send(network_port1_phy_port, str(vxlan_pkt))
1055 #verify
1056 verify_packet(self, str(inner_pkt), network_port2_phy_port)
1057 verify_no_other_packets(self)
1058
1059
1060
1061 #exit verification so clear all configuration
1062 delete_all_flows(self.controller)
1063 delete_all_groups(self.controller)
1064
1065 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
1066 lport=access_lport1, phy_port=access_phy_port1,
1067 vlan=access_port1_vid, vnid=vnid, operation="delete")
1068 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
1069
1070 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1071 lport=network_lport1,
1072 src_ip=network_port1_sip, dst_ip=network_port1_dip,
1073 next_hop_id=network_port1_next_hop_id,
1074 vnid=vnid, operation="delete")
1075 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1076 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
1077 lport=network_lport2,
1078 src_ip=network_port2_sip, dst_ip=network_port2_dip,
1079 next_hop_id=network_port2_next_hop_id,
1080 vnid=vnid, operation="delete")
1081 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
1082 vni_config_xml=get_vni_config_xml(vni_id=vnid, mcast_ipv4=None, next_hop_id=None, operation="delete")
1083 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
1084
1085 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port1_next_hop_id,
1086 dst_mac=network_port1_dst_mac,
1087 phy_port=network_port1_phy_port,
1088 vlan=network_port1_vlan, operation="delete")
1089 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1090 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=network_port2_next_hop_id,
1091 dst_mac=network_port2_dst_mac,
1092 phy_port=network_port2_phy_port,
1093 vlan=network_port2_vlan, operation="delete")
1094 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1095 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=next_hop_id_mcast,
1096 dst_mac=dst_mac_mcast,
1097 phy_port=network_port1_phy_port,
1098 vlan=network_port1_vlan, operation="delete")
1099 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml) == True)
1100