blob: 166b67f6bd35af4a407f28e008fedd54e305030f [file] [log] [blame]
macauley1c0b6c42015-08-06 18:13:56 +08001"""
2This case test VM routing on same VNID
3"""
4
5import logging
6
7from oftest import config
8import oftest.base_tests as base_tests
9import ofp
10from oftest.testutils import *
11from accton_util import *
12
13NW1_ACCESS_LPORT=0x10001
14NW2_ACCESS_LPORT=0x10002
15NW1_NEWORK_LPORT=0x10003
16NW2_NEWORK_LPORT=0x10004
17
18NW1_VRF=1
19NW2_VRF=2
20NW_VRF=[NW1_VRF, NW2_VRF]
21SWITCH_VRF=0
22assert(NW1_VRF!=SWITCH_VRF)
23assert(NW2_VRF!=SWITCH_VRF)
24NW1_VNID=1
25NW2_VNID=2
26NW_VNID=[NW1_VNID, NW2_VNID]
27
28
29NW1_VLAN = 2
30NW2_VLAN = 3
31NW_VLAN=[NW1_VLAN, NW2_VLAN]
32SWITCH_VLAN=1
33
34#SWITCH_INTF_MAC = from feature.replay, because each switch is not the same,
35# current we just can use switch CPU MAC, due to tunnel terminator
36# have no way to set mac
37#SWITCH_INTF_MAC_STR
38SWITCH_IP=0XC0A80101 #192.168.1.1
39SWITCH_IP_STR=convertIP4toStr(SWITCH_IP)
40#H1 for NW1, H2 for NW2
41#remember for chip limitaion, it can't have nexthop
42#has same vid, port but diff dst_mac
43VXLAN_TNL_H1_IP=0XC0A80202#192.168.2.2
44VXLAN_TNL_H1_IP_STR=convertIP4toStr(VXLAN_TNL_H1_IP)
45VXLAN_TNL_H1_MAC=[0x00, 0x31, 0x31, 0x31, 0x31, 0x31] #like router MAC
46VXLAN_TNL_H1_MAC_STR=convertMACtoStr(VXLAN_TNL_H1_MAC)
47VXLAN_TNL_H2_IP=0XC0A80303#192.168.3.3
48VXLAN_TNL_H2_IP_STR=convertIP4toStr(VXLAN_TNL_H2_IP)
49VXLAN_TNL_H2_MAC=[0x00, 0x31, 0x31, 0x31, 0x31, 0x31] #like router MAC
50VXLAN_TNL_H2_MAC_STR=convertMACtoStr(VXLAN_TNL_H2_MAC)
51VXLAN_TNL_H_R_MAC=[0x00, 0x31, 0x31, 0x31, 0x31, 0x31]
52VXLAN_TNL_H_R_MAC_STR=convertMACtoStr(VXLAN_TNL_H_R_MAC)
53VXLAN_TNL_H_R_NHP_ID=1
54
55NW1_VM1_IP = 0XC0A80101
56NW1_VM1_IP_STR = convertIP4toStr(NW1_VM1_IP)
57NW1_VM1_MAC=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
58NW1_VM1_MAC_STR=convertMACtoStr(NW1_VM1_MAC)
59NW1_VM2_IP = 0XC0A80201
60NW1_VM2_IP_STR = convertIP4toStr(NW1_VM2_IP)
61NW1_VM2_MAC=[0x00, 0x12, 0x12, 0x12, 0x12, 0x12]
62NW1_VM2_MAC_STR=convertMACtoStr(NW1_VM2_MAC)
63NW2_VM1_IP = 0XC0A80101
64NW2_VM1_IP_STR = convertIP4toStr(NW2_VM1_IP)
65NW2_VM1_MAC=[0x00, 0x21, 0x21, 0x21, 0x21, 0x21]
66NW2_VM1_MAC_STR=convertMACtoStr(NW2_VM1_MAC)
67NW2_VM2_IP = 0XC0A80201
68NW2_VM2_IP_STR = convertIP4toStr(NW2_VM2_IP)
69NW2_VM2_MAC=[0x00, 0x22, 0x22, 0x22, 0x22, 0x22]
70NW2_VM2_MAC_STR=convertMACtoStr(NW2_VM2_MAC)
71
72NW1_GW_MAC=[0x00, 0x00, 0x00, 0x00, 0x11, 0x11]
73NW1_GW_MAC_STR=convertMACtoStr(NW1_GW_MAC)
74NW1_ROUTE1 =NW1_VM1_IP
75NW1_ROUTE1_STR =NW1_VM1_IP_STR
76NW1_ROUTE1_NEXT_HOP_MAC=NW1_VM1_MAC
77NW1_ROUTE2 =NW1_VM2_IP
78NW1_ROUTE2_NEXT_HOP_MAC=NW1_VM2_MAC
79NW1_ROUTE2_STR =NW1_VM2_IP_STR
80NW1_GW_ROUTE =[NW1_ROUTE1, NW1_ROUTE2]
81NW1_GW_ROUTE_STR=[NW1_ROUTE1_STR, NW1_ROUTE2_STR]
82NW1_GW_ROUTE_NHP=[NW1_ROUTE1_NEXT_HOP_MAC, NW1_ROUTE2_NEXT_HOP_MAC]
83
84NW2_GW_MAC=[0x00, 0x00, 0x00, 0x00, 0x22, 0x22]
85NW2_GW_MAC_STR=convertMACtoStr(NW2_GW_MAC)
86NW2_ROUTE1 =NW2_VM1_IP
87NW2_ROUTE1_STR =NW2_VM1_IP_STR
88NW2_ROUTE1_NEXT_HOP_MAC=NW2_VM1_MAC
89NW2_ROUTE2 =NW2_VM2_IP
90NW2_ROUTE2_STR =NW2_VM1_IP_STR
91NW2_ROUTE2_NEXT_HOP_MAC=NW2_VM2_MAC
92NW2_GW_ROUT_STR=[NW2_ROUTE1_STR, NW2_ROUTE2_STR]
93
94NW_GW_MAC=[NW1_GW_MAC, NW2_GW_MAC]
95NW_GW_MAC_STR=[NW1_GW_MAC_STR, NW2_GW_MAC_STR]
96
97
98#make sure array has same length
99assert(len(NW_GW_MAC) == len(NW_GW_MAC_STR))
100assert(len(NW_GW_MAC) == len(NW_VLAN))
101
102class vrouterSameVNIRouting(base_tests.SimpleDataPlane):
103 """
104 Topology:
105 === switch inner pipeline
106 --- switch forn port physical link
107 R: router
108 NP:netowrk port
109 AP:Access port
110 LP:loopback port
111 H1(VM1/VM2) -- R ----------- NP ==== AP --- LP
112 H2 --
113
114 VM1(192.168.1.1, NW1_VNID) <--> VM2(192.168.2.1, NW1_VNID)
115 VM1(192.168.1.1, NW2_VNID) <--> VM2(192.168.2.1, NW2_VNID)
116
117 Inner operation:
118 (decap/encap vxlan header)NP==(bridge inner DMAC)==AP(VNID->VLANID)----(VLANID->VRF)LP
119
120
121
122 """
123 def runTest(self):
124 delete_all_flows(self.controller)
125 delete_all_groups(self.controller)
126
127 ACCESS_PORT=config["port_map"].keys()[0]
128 NETWORK_PORT=config["port_map"].keys()[1]
129 LOOPBACK_PORT=config["port_map"].keys()[2]
130 print "access %ld, network %ld, loopback %ld"%(ACCESS_PORT, NETWORK_PORT, LOOPBACK_PORT)
131 """ add vxlan config"""
132 feature_reply=get_featureReplay(self)
133 SWITCH_INTF_MAC_STR, SWITCH_INTF_MAC=getSwitchCpuMACFromDPID(feature_reply.datapath_id)
134 #add vni
135 vni_config_xml=get_vni_config_xml(vni_id=NW1_VNID, mcast_ipv4=None, next_hop_id=None)
136 logging.info("config VNI %lx", NW1_VNID);
137 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
138 vni_config_xml=get_vni_config_xml(vni_id=NW2_VNID, mcast_ipv4=None, next_hop_id=None)
139 logging.info("config VNI %lx", NW2_VNID);
140 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
141 #add access port
142 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
143 lport=NW1_ACCESS_LPORT, phy_port=ACCESS_PORT,
144 vlan=NW1_VLAN, vnid=NW1_VNID)
145 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW1_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
146 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
147 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
148 lport=NW2_ACCESS_LPORT, phy_port=ACCESS_PORT,
149 vlan=NW2_VLAN, vnid=NW2_VNID)
150 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW2_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
151 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
152 #create next hop and network port for H1
153 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=VXLAN_TNL_H_R_NHP_ID,
154 dst_mac=VXLAN_TNL_H_R_MAC_STR,
155 phy_port=NETWORK_PORT,
156 vlan=SWITCH_VLAN)
157 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", VXLAN_TNL_H_R_NHP_ID, VXLAN_TNL_H_R_MAC_STR, NETWORK_PORT, SWITCH_VLAN);
158 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
159 #create network port
160 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
161 lport=NW1_NEWORK_LPORT,
162 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
163 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
164 vnid=NW1_VNID)
165 logging.info("config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW1_NEWORK_LPORT, NW1_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
166 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
167
168 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
169 lport=NW2_NEWORK_LPORT,
170 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
171 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
172 vnid=NW2_VNID)
173 logging.info("config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW2_NEWORK_LPORT, NW2_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
174 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
175
176
177 """add routing flow"""
178 #add port table to have vxlan ability
179 add_port_table_flow(self.controller)
180 #add l2 interface group
181 add_one_l2_interface_grouop(self.controller, NETWORK_PORT, vlan_id=SWITCH_VLAN, is_tagged=True, send_barrier=False)
182 for i in range(len(NW_VLAN)):
183 add_one_l2_interface_grouop(self.controller, LOOPBACK_PORT, vlan_id=NW_VLAN[i], is_tagged=True, send_barrier=False)
184
185 #add vlan flow table
186 add_one_vlan_table_flow(self.controller, NETWORK_PORT, SWITCH_VLAN, vrf=SWITCH_VRF, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
187
188 for i in range(len(NW_VLAN)):
189 add_one_vlan_table_flow(self.controller, LOOPBACK_PORT, NW_VLAN[i], vrf=NW_VRF[i], flag=VLAN_TABLE_FLAG_ONLY_TAG)
190 #add vxlan bridge flow
191 add_overlay_bridge_flow(self.controller, NW1_GW_MAC, NW1_VNID, NW1_ACCESS_LPORT, False, False)
192 add_overlay_bridge_flow(self.controller, NW2_GW_MAC, NW2_VNID, NW2_ACCESS_LPORT, False, False)
193 add_overlay_bridge_flow(self.controller, NW1_VM1_MAC, NW1_VNID, NW1_NEWORK_LPORT, False, False)
194 add_overlay_bridge_flow(self.controller, NW1_VM2_MAC, NW1_VNID, NW1_NEWORK_LPORT, False, False)
195 add_overlay_bridge_flow(self.controller, NW2_VM1_MAC, NW2_VNID, NW2_NEWORK_LPORT, False, False)
196 add_overlay_bridge_flow(self.controller, NW2_VM2_MAC, NW2_VNID, NW2_NEWORK_LPORT, False, False)
197
198 #add termination flow
199 add_termination_flow(self.controller, NETWORK_PORT, 0x0800, SWITCH_INTF_MAC, SWITCH_VLAN)
200 for i in range(len(NW_VLAN)):
201 add_termination_flow(self.controller, LOOPBACK_PORT, 0x0800, NW_GW_MAC[i], NW_VLAN[i])
202
203 """
204 Add Network Route, NW1
205 192.168.1.1
206 192.168.2.1
207 """
208 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=NW1_VLAN, id=0x1001, src_mac=NW1_GW_MAC, dst_mac=NW1_ROUTE1_NEXT_HOP_MAC)
209 add_unicast_routing_flow(self.controller, 0x0800, NW1_ROUTE1, 0, l3_msg.group_id, NW1_VRF)
210 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=NW1_VLAN, id=0x1002, src_mac=NW1_GW_MAC, dst_mac=NW1_ROUTE2_NEXT_HOP_MAC)
211 add_unicast_routing_flow(self.controller, 0x0800, NW1_ROUTE2, 0, l3_msg.group_id, NW1_VRF)
212 """
213 Add Network Route, NW2
214 192.168.1.1
215 192.168.2.1
216 """
217 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=NW2_VLAN, id=0x2001, src_mac=NW2_GW_MAC, dst_mac=NW2_ROUTE1_NEXT_HOP_MAC)
218 add_unicast_routing_flow(self.controller, 0x0800, NW2_ROUTE1, 0, l3_msg.group_id, NW2_VRF)
219 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=NW2_VLAN, id=0x2002, src_mac=NW2_GW_MAC, dst_mac=NW2_ROUTE2_NEXT_HOP_MAC)
220 add_unicast_routing_flow(self.controller, 0x0800, NW2_ROUTE2, 0, l3_msg.group_id, NW2_VRF)
221
222
223 """
224 Send paket to verify, NW1
225 """
226 #tx packet on network lport
227 inner_pkt = simple_udp_packet(pktlen=100
228 , eth_src = NW1_VM1_MAC_STR
229 , eth_dst=NW1_GW_MAC_STR
230 , ip_dst =NW1_VM2_IP_STR
231 , ip_src =NW1_VM1_IP_STR
232 , ip_ttl =64)
233 vxlan_pkt = simple_vxlan_packet(eth_dst=SWITCH_INTF_MAC_STR
234 ,eth_src=VXLAN_TNL_H_R_MAC_STR
235 ,vnid=NW1_VNID
236 ,ip_dst= SWITCH_IP_STR
237 ,ip_src=VXLAN_TNL_H1_IP_STR
238 ,inner_payload=inner_pkt)
239 self.dataplane.send(NETWORK_PORT, str(vxlan_pkt))
240 #verify rx on access port
241 inner_pkt = simple_udp_packet(pktlen=104
242 , eth_src= NW1_VM1_MAC_STR
243 , eth_dst=NW1_GW_MAC_STR
244 , dl_vlan_enable=True
245 , vlan_vid=NW1_VLAN
246 , ip_dst =NW1_VM2_IP_STR
247 , ip_src =NW1_VM1_IP_STR
248 , ip_ttl =64)
249 verify_packet(self, str(inner_pkt), ACCESS_PORT)
250 verify_no_other_packets(self)
251
252 #tx on loopback port
253 self.dataplane.send(LOOPBACK_PORT, str(inner_pkt))
254 #verify rx on loopback port
255 inner_pkt = simple_udp_packet(pktlen=104
256 , eth_src=NW1_GW_MAC_STR
257 , eth_dst=NW1_VM2_MAC_STR
258 , dl_vlan_enable=True
259 , vlan_vid=NW1_VLAN
260 , ip_dst =NW1_VM2_IP_STR
261 , ip_src =NW1_VM1_IP_STR
262 , ip_ttl =63)
263 verify_packet(self, str(inner_pkt), LOOPBACK_PORT)
264 verify_no_other_packets(self)
265 #tx on access port
266 self.dataplane.send(ACCESS_PORT, str(inner_pkt))
267 #verify rx on network port
268 inner_pkt = simple_udp_packet(pktlen=100
269 , eth_src=NW1_GW_MAC_STR
270 , eth_dst=NW1_VM2_MAC_STR
271 , ip_dst =NW1_VM2_IP_STR
272 , ip_src =NW1_VM1_IP_STR
273 , ip_ttl =63)
274 vxlan_pkt = simple_vxlan_packet(eth_src=SWITCH_INTF_MAC_STR
275 ,eth_dst=VXLAN_TNL_H_R_MAC_STR
276 ,vnid=NW1_VNID
277 ,ip_dst=VXLAN_TNL_H1_IP_STR
278 ,ip_src=SWITCH_IP_STR
279 ,inner_payload=inner_pkt)
280 verify_packet(self, inner_pkt, NETWORK_PORT)
281 verify_no_other_packets(self)
282
283
284 """
285 Send paket to verify, NW2
286 """
287 #tx packet on network lport
288 inner_pkt = simple_udp_packet(pktlen=100
289 , eth_src = NW2_VM1_MAC_STR
290 , eth_dst=NW2_GW_MAC_STR
291 , ip_dst =NW2_VM2_IP_STR
292 , ip_src =NW2_VM1_IP_STR
293 , ip_ttl =64)
294 vxlan_pkt = simple_vxlan_packet(eth_dst=SWITCH_INTF_MAC_STR
295 ,eth_src=VXLAN_TNL_H_R_MAC_STR
296 ,vnid=NW2_VNID
297 ,ip_dst= SWITCH_IP_STR
298 ,ip_src=VXLAN_TNL_H1_IP_STR
299 ,inner_payload=inner_pkt)
300 self.dataplane.send(NETWORK_PORT, str(vxlan_pkt))
301 #verify rx on access port
302 inner_pkt = simple_udp_packet(pktlen=104
303 , eth_src= NW2_VM1_MAC_STR
304 , eth_dst=NW2_GW_MAC_STR
305 , dl_vlan_enable=True
306 , vlan_vid=NW2_VLAN
307 , ip_dst =NW2_VM2_IP_STR
308 , ip_src =NW2_VM1_IP_STR
309 , ip_ttl =64)
310 verify_packet(self, str(inner_pkt), ACCESS_PORT)
311 verify_no_other_packets(self)
312
313 #tx on loopback port
314 self.dataplane.send(LOOPBACK_PORT, str(inner_pkt))
315 #verify rx on loopback port
316 inner_pkt = simple_udp_packet(pktlen=104
317 , eth_src=NW2_GW_MAC_STR
318 , eth_dst=NW2_VM2_MAC_STR
319 , dl_vlan_enable=True
320 , vlan_vid=NW2_VLAN
321 , ip_dst =NW2_VM2_IP_STR
322 , ip_src =NW2_VM1_IP_STR
323 , ip_ttl =63)
324 verify_packet(self, str(inner_pkt), LOOPBACK_PORT)
325 verify_no_other_packets(self)
326 #tx on access port
327 self.dataplane.send(ACCESS_PORT, str(inner_pkt))
328 #verify rx on network port
329 inner_pkt = simple_udp_packet(pktlen=100
330 , eth_src=NW2_GW_MAC_STR
331 , eth_dst=NW2_VM2_MAC_STR
332 , ip_dst =NW2_VM2_IP_STR
333 , ip_src =NW2_VM1_IP_STR
334 , ip_ttl =63)
335 vxlan_pkt = simple_vxlan_packet(eth_src=SWITCH_INTF_MAC_STR
336 ,eth_dst=VXLAN_TNL_H_R_MAC_STR
337 ,vnid=NW2_VNID
338 ,ip_dst=VXLAN_TNL_H1_IP_STR
339 ,ip_src=SWITCH_IP_STR
340 ,inner_payload=inner_pkt)
341 verify_packet(self, inner_pkt, NETWORK_PORT)
342 verify_no_other_packets(self)
343
344 """clear all flow/group and configuration
345 """
346 delete_all_flows(self.controller)
347 delete_all_groups(self.controller)
348 """ del vxlan config"""
349 #delete access port
350 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
351 lport=NW1_ACCESS_LPORT, phy_port=ACCESS_PORT,
352 vlan=NW1_VLAN, vnid=NW1_VNID, operation="delete")
353 logging.info("delete config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW1_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
354 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
355 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
356 lport=NW2_ACCESS_LPORT, phy_port=ACCESS_PORT,
357 vlan=NW2_VLAN, vnid=NW2_VNID, operation="delete")
358 logging.info("delete config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW2_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
359 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
360 #delete network port
361 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
362 lport=NW1_NEWORK_LPORT,
363 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
364 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
365 vnid=NW1_VNID, operation="delete")
366 logging.info("delete config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW1_NEWORK_LPORT, NW1_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
367 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
368
369 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
370 lport=NW2_NEWORK_LPORT,
371 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
372 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
373 vnid=NW2_VNID, operation="delete")
374 logging.info("delete config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW2_NEWORK_LPORT, NW2_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
375 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
376 #delete next hop and network port for H1
377 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=VXLAN_TNL_H_R_NHP_ID,
378 dst_mac=VXLAN_TNL_H_R_MAC_STR,
379 phy_port=NETWORK_PORT,
380 vlan=SWITCH_VLAN, operation="delete")
381 logging.info("delete config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", VXLAN_TNL_H_R_NHP_ID, VXLAN_TNL_H_R_MAC_STR, NETWORK_PORT, SWITCH_VLAN);
382 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
383 #del vni
384 vni_config_xml=get_vni_config_xml(vni_id=NW1_VNID, mcast_ipv4=None, next_hop_id=None, operation="delete")
385 logging.info("delete config VNI %lx", NW1_VNID);
386 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
387 vni_config_xml=get_vni_config_xml(vni_id=NW2_VNID, mcast_ipv4=None, next_hop_id=None, operation="delete")
388 logging.info("delete config VNI %lx", NW2_VNID);
389 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
390
391#for routing on different VNID, it can't have same subnet.
392TNW1_ACCESS_LPORT=0x10001
393TNW2_ACCESS_LPORT=0x10002
394TNW1_NEWORK_LPORT=0x10003
395TNW2_NEWORK_LPORT=0x10004
396
397TNW1_VRF=2 #all shall the same
398TNW2_VRF=2
399TNW_VRF=[TNW1_VRF, TNW2_VRF]
400TSWITCH_VRF=0 #let switch different from VM
401assert(TNW2_VRF!=TSWITCH_VRF)
402assert(TNW1_VRF!=TSWITCH_VRF)
403
404TNW1_VNID=1
405TNW2_VNID=2
406TNW_VNID=[TNW1_VNID, TNW2_VNID]
407
408TNW1_VLAN = 2
409TNW2_VLAN = 3
410TNW_VLAN=[TNW1_VLAN, TNW2_VLAN]
411assert(TNW1_VLAN!=SWITCH_VLAN)
412assert(TNW2_VLAN!=SWITCH_VLAN)
413#the subnet shall not the same, because they all NW use same VRF
414TNW1_VM1_IP = 0XC0A80101 #192.168.1.1
415TNW1_VM1_IP_STR = convertIP4toStr(TNW1_VM1_IP)
416TNW1_VM1_MAC=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
417TNW1_VM1_MAC_STR=convertMACtoStr(TNW1_VM1_MAC)
418TNW1_VM2_IP = 0XC0A80201 #192.168.2.1
419TNW1_VM2_IP_STR = convertIP4toStr(TNW1_VM2_IP)
420TNW1_VM2_MAC=[0x00, 0x12, 0x12, 0x12, 0x12, 0x12]
421TNW1_VM2_MAC_STR=convertMACtoStr(TNW1_VM2_MAC)
422TNW2_VM1_IP = 0XC0A80301 #192.168.3.1
423TNW2_VM1_IP_STR = convertIP4toStr(TNW2_VM1_IP)
424TNW2_VM1_MAC=[0x00, 0x21, 0x21, 0x21, 0x21, 0x21]
425TNW2_VM1_MAC_STR=convertMACtoStr(TNW2_VM1_MAC)
426TNW2_VM2_IP = 0XC0A80401 #192.168.4.1
427TNW2_VM2_IP_STR = convertIP4toStr(TNW2_VM2_IP)
428TNW2_VM2_MAC=[0x00, 0x22, 0x22, 0x22, 0x22, 0x22]
429TNW2_VM2_MAC_STR=convertMACtoStr(TNW2_VM2_MAC)
430
431TNW1_GW_MAC=[0x00, 0x00, 0x00, 0x00, 0x11, 0x11]
432TNW1_GW_MAC_STR=convertMACtoStr(TNW1_GW_MAC)
433TNW1_ROUTE1 =TNW1_VM1_IP
434TNW1_ROUTE1_STR =TNW1_VM1_IP_STR
435TNW1_ROUTE1_NEXT_HOP_MAC=TNW1_VM1_MAC
436TNW1_ROUTE2 =TNW1_VM2_IP
437TNW1_ROUTE2_NEXT_HOP_MAC=TNW1_VM2_MAC
438TNW1_ROUTE2_STR =TNW1_VM2_IP_STR
439TNW1_GW_ROUTE =[TNW1_ROUTE1, TNW1_ROUTE2]
440TNW1_GW_ROUTE_STR=[TNW1_ROUTE1_STR, TNW1_ROUTE2_STR]
441TNW1_GW_ROUTE_NHP=[TNW1_ROUTE1_NEXT_HOP_MAC, TNW1_ROUTE2_NEXT_HOP_MAC]
442
443TNW2_GW_MAC=[0x00, 0x00, 0x00, 0x00, 0x22, 0x22]
444TNW2_GW_MAC_STR=convertMACtoStr(TNW2_GW_MAC)
445TNW2_ROUTE1 =TNW2_VM1_IP
446TNW2_ROUTE1_STR =TNW2_VM1_IP_STR
447TNW2_ROUTE1_NEXT_HOP_MAC=TNW2_VM1_MAC
448TNW2_ROUTE2 =TNW2_VM2_IP
449TNW2_ROUTE2_STR =TNW2_VM1_IP_STR
450TNW2_ROUTE2_NEXT_HOP_MAC=TNW2_VM2_MAC
451TNW2_GW_ROUT_STR=[TNW2_ROUTE1_STR, TNW2_ROUTE2_STR]
452
453TNW_GW_MAC=[TNW1_GW_MAC, TNW2_GW_MAC]
454TNW_GW_MAC_STR=[TNW1_GW_MAC_STR, TNW2_GW_MAC_STR]
455
456
457
458class vrouterDiffVnidRouting(base_tests.SimpleDataPlane):
459 """
460 Topology:
461 === switch inner pipeline
462 --- switch forn port physical link
463 R: router
464 NP:netowrk port
465 AP:Access port
466 LP:loopback port
467 H1(VM1/VM2) -- R ----------- NP ==== AP --- LP
468 H2 --
469
470 VM1(192.168.1.1, NW1_VNID) <--> VM2(192.168.2.1, NW1_VNID)
471 VM1(192.168.1.1, NW2_VNID) <--> VM2(192.168.2.1, NW2_VNID)
472
473 Inner operation:
474 (decap/encap vxlan header)NP==(bridge inner DMAC)==AP(VNID->VLANID)----(VLANIDx->same VRF)LP
475
476 """
477 def runTest(self):
478 delete_all_flows(self.controller)
479 delete_all_groups(self.controller)
480
481 ACCESS_PORT=config["port_map"].keys()[0]
482 NETWORK_PORT=config["port_map"].keys()[1]
483 LOOPBACK_PORT=config["port_map"].keys()[2]
484 print "access %ld, network %ld, loopback %ld"%(ACCESS_PORT, NETWORK_PORT, LOOPBACK_PORT)
485 """ add vxlan config"""
486 feature_reply=get_featureReplay(self)
487 SWITCH_INTF_MAC_STR, SWITCH_INTF_MAC=getSwitchCpuMACFromDPID(feature_reply.datapath_id)
488 #add vni
489 vni_config_xml=get_vni_config_xml(vni_id=TNW1_VNID, mcast_ipv4=None, next_hop_id=None)
490 logging.info("config VNI %lx", TNW1_VNID);
491 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
492 vni_config_xml=get_vni_config_xml(vni_id=TNW2_VNID, mcast_ipv4=None, next_hop_id=None)
493 logging.info("config VNI %lx", TNW2_VNID);
494 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
495 #add access port
496 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
497 lport=TNW1_ACCESS_LPORT, phy_port=ACCESS_PORT,
498 vlan=TNW1_VLAN, vnid=TNW1_VNID)
499 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", TNW1_ACCESS_LPORT, ACCESS_PORT, TNW1_VLAN, TNW1_VNID);
500 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
501 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
502 lport=TNW2_ACCESS_LPORT, phy_port=ACCESS_PORT,
503 vlan=TNW2_VLAN, vnid=TNW2_VNID)
504 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", TNW2_ACCESS_LPORT, ACCESS_PORT, TNW1_VLAN, NW1_VNID);
505 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
506 #create next hop and network port for H1
507 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=VXLAN_TNL_H_R_NHP_ID,
508 dst_mac=VXLAN_TNL_H_R_MAC_STR,
509 phy_port=NETWORK_PORT,
510 vlan=SWITCH_VLAN)
511 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", VXLAN_TNL_H_R_NHP_ID, VXLAN_TNL_H_R_MAC_STR, NETWORK_PORT, SWITCH_VLAN);
512 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
513 #create network port
514 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
515 lport=TNW1_NEWORK_LPORT,
516 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
517 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
518 vnid=TNW1_VNID)
519 logging.info("config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", TNW1_NEWORK_LPORT, TNW1_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
520 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
521
522 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
523 lport=TNW2_NEWORK_LPORT,
524 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
525 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
526 vnid=TNW2_VNID)
527 logging.info("config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", TNW2_NEWORK_LPORT, TNW2_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
528 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
529
530
531 """add routing flow"""
532 #add port table to have vxlan ability
533 add_port_table_flow(self.controller)
534 #add l2 interface group
535 add_one_l2_interface_grouop(self.controller, NETWORK_PORT, vlan_id=SWITCH_VLAN, is_tagged=True, send_barrier=False)
536 for i in range(len(TNW_VLAN)):
537 add_one_l2_interface_grouop(self.controller, LOOPBACK_PORT, vlan_id=TNW_VLAN[i], is_tagged=True, send_barrier=False)
538
539 #add vlan flow table
540 add_one_vlan_table_flow(self.controller, NETWORK_PORT, SWITCH_VLAN, vrf=SWITCH_VRF, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
541 for i in range(len(TNW_VLAN)):
542 add_one_vlan_table_flow(self.controller, LOOPBACK_PORT, TNW_VLAN[i], vrf=TNW_VRF[i], flag=VLAN_TABLE_FLAG_ONLY_TAG)
543
544 #add vxlan bridge flow
545 add_overlay_bridge_flow(self.controller, TNW1_GW_MAC, TNW1_VNID, TNW1_ACCESS_LPORT, False, False)
546 add_overlay_bridge_flow(self.controller, TNW2_GW_MAC, TNW2_VNID, TNW2_ACCESS_LPORT, False, False)
547 add_overlay_bridge_flow(self.controller, TNW1_VM1_MAC, TNW1_VNID, TNW1_NEWORK_LPORT, False, False)
548 add_overlay_bridge_flow(self.controller, TNW1_VM2_MAC, TNW1_VNID, TNW1_NEWORK_LPORT, False, False)
549 add_overlay_bridge_flow(self.controller, TNW2_VM1_MAC, TNW2_VNID, TNW2_NEWORK_LPORT, False, False)
550 add_overlay_bridge_flow(self.controller, TNW2_VM2_MAC, TNW2_VNID, TNW2_NEWORK_LPORT, False, False)
551
552 #add termination flow
553 add_termination_flow(self.controller, NETWORK_PORT, 0x0800, SWITCH_INTF_MAC, SWITCH_VLAN)
554 for i in range(len(TNW_VLAN)):
555 add_termination_flow(self.controller, LOOPBACK_PORT, 0x0800, TNW_GW_MAC[i], TNW_VLAN[i])
556
557 """
558 Add Network Route, TNW1
559 192.168.1.1
560 192.168.2.1
561 """
562 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=TNW1_VLAN, id=0x1001, src_mac=TNW1_GW_MAC, dst_mac=TNW1_ROUTE1_NEXT_HOP_MAC)
563 add_unicast_routing_flow(self.controller, 0x0800, TNW1_ROUTE1, 0, l3_msg.group_id, TNW1_VRF)
564 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=TNW1_VLAN, id=0x1002, src_mac=TNW1_GW_MAC, dst_mac=TNW1_ROUTE2_NEXT_HOP_MAC)
565 add_unicast_routing_flow(self.controller, 0x0800, TNW1_ROUTE2, 0, l3_msg.group_id, TNW1_VRF)
566 """
567 Add Network Route, TNW2
568 192.168.1.1
569 192.168.2.1
570 """
571 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=TNW2_VLAN, id=0x2001, src_mac=TNW1_GW_MAC, dst_mac=TNW2_ROUTE1_NEXT_HOP_MAC)
572 add_unicast_routing_flow(self.controller, 0x0800, TNW2_ROUTE1, 0, l3_msg.group_id, TNW2_VRF)
573 l3_msg=add_l3_unicast_group(self.controller, LOOPBACK_PORT, vlanid=TNW2_VLAN, id=0x2002, src_mac=TNW2_GW_MAC, dst_mac=TNW2_ROUTE2_NEXT_HOP_MAC)
574 add_unicast_routing_flow(self.controller, 0x0800, TNW2_ROUTE2, 0, l3_msg.group_id, TNW2_VRF)
575
576
577 """
578 Send paket to verify, TNW1
579 """
580 #tx packet on network lport
581 inner_pkt = simple_udp_packet(pktlen=100
582 , eth_src = TNW1_VM1_MAC_STR
583 , eth_dst=TNW1_GW_MAC_STR
584 , ip_dst =TNW1_VM2_IP_STR
585 , ip_src =TNW1_VM1_IP_STR
586 , ip_ttl =64)
587 vxlan_pkt = simple_vxlan_packet(eth_dst=SWITCH_INTF_MAC_STR
588 ,eth_src=VXLAN_TNL_H_R_MAC_STR
589 ,vnid=TNW1_VNID
590 ,ip_dst= SWITCH_IP_STR
591 ,ip_src=VXLAN_TNL_H1_IP_STR
592 ,inner_payload=inner_pkt)
593 self.dataplane.send(NETWORK_PORT, str(vxlan_pkt))
594 #verify rx on access port
595 inner_pkt = simple_udp_packet(pktlen=104
596 , eth_src= TNW1_VM1_MAC_STR
597 , eth_dst=TNW1_GW_MAC_STR
598 , dl_vlan_enable=True
599 , vlan_vid=TNW1_VLAN
600 , ip_dst =TNW1_VM2_IP_STR
601 , ip_src =TNW1_VM1_IP_STR
602 , ip_ttl =64)
603 verify_packet(self, str(inner_pkt), ACCESS_PORT)
604 verify_no_other_packets(self)
605
606 #tx on loopback port
607 self.dataplane.send(LOOPBACK_PORT, str(inner_pkt))
608 #verify rx on loopback port
609 inner_pkt = simple_udp_packet(pktlen=104
610 , eth_src=TNW1_GW_MAC_STR
611 , eth_dst=TNW1_VM2_MAC_STR
612 , dl_vlan_enable=True
613 , vlan_vid=TNW1_VLAN
614 , ip_dst =TNW1_VM2_IP_STR
615 , ip_src =TNW1_VM1_IP_STR
616 , ip_ttl =63)
617 verify_packet(self, str(inner_pkt), LOOPBACK_PORT)
618 verify_no_other_packets(self)
619 #tx on access port
620 self.dataplane.send(ACCESS_PORT, str(inner_pkt))
621 #verify rx on network port
622 inner_pkt = simple_udp_packet(pktlen=100
623 , eth_src=TNW1_GW_MAC_STR
624 , eth_dst=TNW1_VM2_MAC_STR
625 , ip_dst =TNW1_VM2_IP_STR
626 , ip_src =TNW1_VM1_IP_STR
627 , ip_ttl =63)
628 vxlan_pkt = simple_vxlan_packet(eth_src=SWITCH_INTF_MAC_STR
629 ,eth_dst=VXLAN_TNL_H_R_MAC_STR
630 ,vnid=TNW1_VNID
631 ,ip_dst=VXLAN_TNL_H1_IP_STR
632 ,ip_src=SWITCH_IP_STR
633 ,inner_payload=inner_pkt)
634 verify_packet(self, inner_pkt, NETWORK_PORT)
635 verify_no_other_packets(self)
636
637
638 """
639 Send paket to verify, NW2
640 """
641 #tx packet on network lport
642 inner_pkt = simple_udp_packet(pktlen=100
643 , eth_src = TNW2_VM1_MAC_STR
644 , eth_dst=TNW2_GW_MAC_STR
645 , ip_dst =TNW2_VM2_IP_STR
646 , ip_src =TNW2_VM1_IP_STR
647 , ip_ttl =64)
648 vxlan_pkt = simple_vxlan_packet(eth_dst=SWITCH_INTF_MAC_STR
649 ,eth_src=VXLAN_TNL_H_R_MAC_STR
650 ,vnid=TNW2_VNID
651 ,ip_dst= SWITCH_IP_STR
652 ,ip_src=VXLAN_TNL_H1_IP_STR
653 ,inner_payload=inner_pkt)
654 self.dataplane.send(NETWORK_PORT, str(vxlan_pkt))
655 #verify rx on access port
656 inner_pkt = simple_udp_packet(pktlen=104
657 , eth_src= TNW2_VM1_MAC_STR
658 , eth_dst=TNW2_GW_MAC_STR
659 , dl_vlan_enable=True
660 , vlan_vid=TNW2_VLAN
661 , ip_dst =TNW2_VM2_IP_STR
662 , ip_src =TNW2_VM1_IP_STR
663 , ip_ttl =64)
664 verify_packet(self, str(inner_pkt), ACCESS_PORT)
665 verify_no_other_packets(self)
666
667 #tx on loopback port
668 self.dataplane.send(LOOPBACK_PORT, str(inner_pkt))
669 #verify rx on loopback port
670 inner_pkt = simple_udp_packet(pktlen=104
671 , eth_src=TNW2_GW_MAC_STR
672 , eth_dst=TNW2_VM2_MAC_STR
673 , dl_vlan_enable=True
674 , vlan_vid=TNW2_VLAN
675 , ip_dst =TNW2_VM2_IP_STR
676 , ip_src =TNW2_VM1_IP_STR
677 , ip_ttl =63)
678 verify_packet(self, str(inner_pkt), LOOPBACK_PORT)
679 verify_no_other_packets(self)
680 #tx on access port
681 self.dataplane.send(ACCESS_PORT, str(inner_pkt))
682 #verify rx on network port
683 inner_pkt = simple_udp_packet(pktlen=100
684 , eth_src=TNW2_GW_MAC_STR
685 , eth_dst=TNW2_VM2_MAC_STR
686 , ip_dst =TNW2_VM2_IP_STR
687 , ip_src =TNW2_VM1_IP_STR
688 , ip_ttl =63)
689 vxlan_pkt = simple_vxlan_packet(eth_src=SWITCH_INTF_MAC_STR
690 ,eth_dst=VXLAN_TNL_H_R_MAC_STR
691 ,vnid=TNW2_VNID
692 ,ip_dst=VXLAN_TNL_H1_IP_STR
693 ,ip_src=SWITCH_IP_STR
694 ,inner_payload=inner_pkt)
695 verify_packet(self, inner_pkt, NETWORK_PORT)
696 verify_no_other_packets(self)
697
698
699 """clear all flow/group and configuration
700 """
701 delete_all_flows(self.controller)
702 delete_all_groups(self.controller)
703 """ del vxlan config"""
704 #delete access port
705 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
706 lport=TNW1_ACCESS_LPORT, phy_port=ACCESS_PORT,
707 vlan=TNW1_VLAN, vnid=TNW1_VNID, operation="delete")
708 logging.info("delete config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", TNW1_ACCESS_LPORT, ACCESS_PORT, TNW1_VLAN, TNW1_VNID);
709 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
710 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
711 lport=TNW2_ACCESS_LPORT, phy_port=ACCESS_PORT,
712 vlan=TNW2_VLAN, vnid=TNW2_VNID, operation="delete")
713 logging.info("delete config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", TNW2_ACCESS_LPORT, ACCESS_PORT, TNW1_VLAN, TNW1_VNID);
714 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
715 #delete network port
716 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
717 lport=TNW1_NEWORK_LPORT,
718 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
719 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
720 vnid=TNW1_VNID, operation="delete")
721 logging.info("delete config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", TNW1_NEWORK_LPORT, TNW1_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
722 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
723
724 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
725 lport=TNW2_NEWORK_LPORT,
726 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
727 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
728 vnid=TNW2_VNID, operation="delete")
729 logging.info("delete config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", TNW2_NEWORK_LPORT, TNW2_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
730 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
731 #delete next hop and network port for H1
732 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=VXLAN_TNL_H_R_NHP_ID,
733 dst_mac=VXLAN_TNL_H_R_MAC_STR,
734 phy_port=NETWORK_PORT,
735 vlan=SWITCH_VLAN, operation="delete")
736 logging.info("delete config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", VXLAN_TNL_H_R_NHP_ID, VXLAN_TNL_H_R_MAC_STR, NETWORK_PORT, SWITCH_VLAN);
737 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
738 #del vni
739 vni_config_xml=get_vni_config_xml(vni_id=TNW1_VNID, mcast_ipv4=None, next_hop_id=None, operation="delete")
740 logging.info("delete config VNI %lx", TNW1_VNID);
741 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
742 vni_config_xml=get_vni_config_xml(vni_id=TNW2_VNID, mcast_ipv4=None, next_hop_id=None, operation="delete")
743 logging.info("delete config VNI %lx", TNW2_VNID);
744 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
745
746class vrouterNetconfSetUnset(base_tests.SimpleDataPlane):
747 def runTest(self):
748 ACCESS_PORT=config["port_map"].keys()[0]
749 NETWORK_PORT=config["port_map"].keys()[1]
750 LOOPBACK_PORT=config["port_map"].keys()[2]
751 print "access %ld, network %ld, loopback %ld"%(ACCESS_PORT, NETWORK_PORT, LOOPBACK_PORT)
752 """ add vxlan config"""
753 feature_reply=get_featureReplay(self)
754 SWITCH_INTF_MAC_STR, SWITCH_INTF_MAC=getSwitchCpuMACFromDPID(feature_reply.datapath_id)
755 #add vni
756 vni_config_xml=get_vni_config_xml(vni_id=NW1_VNID, mcast_ipv4=None, next_hop_id=None)
757 logging.info("config VNI %lx", NW1_VNID);
758 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
759 vni_config_xml=get_vni_config_xml(vni_id=NW2_VNID, mcast_ipv4=None, next_hop_id=None)
760 logging.info("config VNI %lx", NW2_VNID);
761 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
762 #add access port
763 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
764 lport=NW1_ACCESS_LPORT, phy_port=ACCESS_PORT,
765 vlan=NW1_VLAN, vnid=NW1_VNID)
766 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW1_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
767 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
768 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
769 lport=NW2_ACCESS_LPORT, phy_port=ACCESS_PORT,
770 vlan=NW2_VLAN, vnid=NW2_VNID)
771 logging.info("config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW2_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
772 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
773 #create next hop and network port for H1
774 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=VXLAN_TNL_H_R_NHP_ID,
775 dst_mac=VXLAN_TNL_H_R_MAC_STR,
776 phy_port=NETWORK_PORT,
777 vlan=SWITCH_VLAN)
778 logging.info("config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", VXLAN_TNL_H_R_NHP_ID, VXLAN_TNL_H_R_MAC_STR, NETWORK_PORT, SWITCH_VLAN);
779 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
780 #create network port
781 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
782 lport=NW1_NEWORK_LPORT,
783 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
784 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
785 vnid=NW1_VNID)
786 logging.info("config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW1_NEWORK_LPORT, NW1_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
787 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
788
789 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
790 lport=NW2_NEWORK_LPORT,
791 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
792 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
793 vnid=NW2_VNID)
794 logging.info("config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW2_NEWORK_LPORT, NW2_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
795 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
796
797 """clear all flow/group and configuration
798 """
799 """ del vxlan config"""
800 #delete access port
801 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
802 lport=NW1_ACCESS_LPORT, phy_port=ACCESS_PORT,
803 vlan=NW1_VLAN, vnid=NW1_VNID, operation="delete")
804 logging.info("delete config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW1_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
805 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
806 vtap_conf_xml=get_vtap_lport_config_xml(dp_id=feature_reply.datapath_id,
807 lport=NW2_ACCESS_LPORT, phy_port=ACCESS_PORT,
808 vlan=NW2_VLAN, vnid=NW2_VNID, operation="delete")
809 logging.info("delete config VTAP 0x%lx, PHY %d, VID %d, VNID %lx", NW2_ACCESS_LPORT, ACCESS_PORT, NW1_VLAN, NW1_VNID);
810 assert(send_edit_config(config["switch_ip"], vtap_conf_xml) == True)
811 #delete network port
812 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
813 lport=NW1_NEWORK_LPORT,
814 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
815 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
816 vnid=NW1_VNID, operation="delete")
817 logging.info("delete config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW1_NEWORK_LPORT, NW1_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
818 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
819
820 vtep_conf_xml=get_vtep_lport_config_xml(dp_id=feature_reply.datapath_id,
821 lport=NW2_NEWORK_LPORT,
822 src_ip=SWITCH_IP_STR, dst_ip=VXLAN_TNL_H1_IP_STR,
823 next_hop_id=VXLAN_TNL_H_R_NHP_ID,
824 vnid=NW2_VNID, operation="delete")
825 logging.info("delete config VTEP 0x%lx, VNID=%lu, SRC_IP %s, DST_IP %s, NEXTHOP_ID %d", NW2_NEWORK_LPORT, NW2_VNID, SWITCH_IP, VXLAN_TNL_H1_IP_STR, VXLAN_TNL_H_R_NHP_ID);
826 assert(send_edit_config(config["switch_ip"], vtep_conf_xml) == True)
827 #delete next hop and network port for H1
828 next_hop_conf_xml=get_next_hop_config_xml(next_hop_id=VXLAN_TNL_H_R_NHP_ID,
829 dst_mac=VXLAN_TNL_H_R_MAC_STR,
830 phy_port=NETWORK_PORT,
831 vlan=SWITCH_VLAN, operation="delete")
832 logging.info("delete config NextHop %d, DST_MAC %s, PHY %d, VLAN %d", VXLAN_TNL_H_R_NHP_ID, VXLAN_TNL_H_R_MAC_STR, NETWORK_PORT, SWITCH_VLAN);
833 assert(send_edit_config(config["switch_ip"], next_hop_conf_xml)==True)
834 #del vni
835 vni_config_xml=get_vni_config_xml(vni_id=NW1_VNID, mcast_ipv4=None, next_hop_id=None, operation="delete")
836 logging.info("delete config VNI %lx", NW1_VNID);
837 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)
838 vni_config_xml=get_vni_config_xml(vni_id=NW2_VNID, mcast_ipv4=None, next_hop_id=None, operation="delete")
839 logging.info("delete config VNI %lx", NW2_VNID);
840 assert(send_edit_config(config["switch_ip"], vni_config_xml) == True)