macauley | 1e26c5b | 2015-07-16 17:27:32 +0800 | [diff] [blame] | 1 | """
|
| 2 | Flow Test
|
| 3 |
|
| 4 | Test each flow table can set entry, and packet rx correctly.
|
| 5 | """
|
| 6 |
|
| 7 | import logging
|
| 8 |
|
| 9 | from oftest import config
|
| 10 | import oftest.base_tests as base_tests
|
| 11 | import ofp
|
| 12 | from oftest.testutils import *
|
| 13 | from accton_util import *
|
| 14 |
|
| 15 | class L2McastFlow(base_tests.SimpleDataPlane):
|
| 16 | """
|
| 17 | Test output function for an exact-match flow
|
| 18 |
|
| 19 | Add some multicast flows
|
| 20 | Then, for all ports, verifies that sending a matching packet
|
| 21 | to a multicast match results in an output to all ports.
|
| 22 | """
|
| 23 | def runTest(self):
|
| 24 | ports = sorted(config["port_map"].keys())
|
| 25 |
|
| 26 | delete_all_flows(self.controller)
|
| 27 | delete_all_groups(self.controller)
|
| 28 |
|
| 29 | # table 10: vlan
|
| 30 | # send to table 20
|
| 31 | add_vlan_table_flow(self.controller, config["port_map"].keys(), 1)
|
| 32 |
|
| 33 | # group table
|
| 34 | # set up untag groups for each port
|
| 35 | add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, False)
|
| 36 |
|
| 37 | # set up multicast group
|
| 38 | add_l2_mcast_group(self.controller, config["port_map"].keys(), 1, 1)
|
| 39 |
|
macauley | 53e64c4 | 2015-07-30 14:07:45 +0800 | [diff] [blame] | 40 | test_macs = [[0x01, 0x00, 0x5e, 0x0f, 0xff, 0xff]]
|
macauley | 1e26c5b | 2015-07-16 17:27:32 +0800 | [diff] [blame] | 41 |
|
| 42 | for test_mac in test_macs:
|
| 43 | group_id = encode_l2_mcast_group_id(1, 1)
|
| 44 | add_bridge_flow(self.controller, test_mac, 1, group_id, True)
|
| 45 |
|
| 46 | for test_mac in test_macs:
|
| 47 | mactest = ':'.join(['%02X' % x for x in test_mac])
|
| 48 |
|
| 49 | for in_port in ports:
|
| 50 | # change dest based on port number
|
| 51 | parsed_pkt = simple_tcp_packet(eth_dst=mactest)
|
| 52 | pkt = str(parsed_pkt)
|
| 53 | logging.info("OutputExact test, from port %d to mac %s", in_port, mactest)
|
| 54 | self.dataplane.send(in_port, pkt)
|
| 55 |
|
| 56 | for ofport in ports:
|
| 57 | if ofport == in_port: #tx port won't rx packet, unless L3 mcast routing
|
| 58 | continue
|
| 59 | verify_packet(self, pkt, ofport)
|
| 60 | verify_no_other_packets(self)
|
| 61 |
|
| 62 | class L2UnicastFlow(base_tests.SimpleDataPlane):
|
| 63 | """
|
| 64 | Test output function for an exact-match flow
|
| 65 |
|
| 66 | For each port A, adds a flow directing matching packets to that port.
|
| 67 | Then, for all other ports B != A, verifies that sending a matching packet
|
| 68 | to B results in an output to A.
|
| 69 | """
|
| 70 | def runTest(self):
|
| 71 | ports = sorted(config["port_map"].keys())
|
| 72 |
|
| 73 | delete_all_flows(self.controller)
|
| 74 | delete_all_groups(self.controller)
|
| 75 | # table 10: vlan
|
| 76 | # send to table 20
|
| 77 | add_vlan_table_flow(self.controller, config["port_map"].keys(), 1)
|
| 78 |
|
| 79 | # group table
|
| 80 | # set up untag groups for each port
|
| 81 | add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, 1)
|
| 82 |
|
| 83 | for out_port in ports:
|
| 84 | group_id = encode_l2_interface_group_id(1, out_port)
|
| 85 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, out_port], 1, group_id, True)
|
| 86 |
|
| 87 | for in_port in ports:
|
| 88 | if in_port == out_port:
|
| 89 | continue
|
| 90 | # change dest based on port number
|
| 91 | parsed_pkt = simple_tcp_packet(eth_dst='00:12:34:56:78:%02X' % out_port)
|
| 92 | pkt = str(parsed_pkt)
|
| 93 | logging.info("OutputExact test, ports %d to %d", in_port, out_port)
|
| 94 | self.dataplane.send(in_port, pkt)
|
| 95 |
|
| 96 | for ofport in ports:
|
| 97 | if ofport in [out_port]:
|
| 98 | verify_packet(self, pkt, ofport)
|
| 99 | else:
|
| 100 | verify_no_packet(self, pkt, ofport)
|
| 101 |
|
| 102 | verify_no_other_packets(self)
|
| 103 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 104 | class L2Flood(base_tests.SimpleDataPlane):
|
| 105 | """
|
| 106 | Test L2 unknown unicast flooding and broadcast flood
|
| 107 | """
|
| 108 | def runTest(self):
|
| 109 | ports = sorted(config["port_map"].keys())
|
| 110 |
|
| 111 | delete_all_flows(self.controller)
|
| 112 | delete_all_groups(self.controller)
|
| 113 | # table 10: vlan
|
| 114 | # send to table 20
|
| 115 | add_vlan_table_flow(self.controller, ports, 1)
|
| 116 |
|
| 117 | # group table
|
| 118 | # set up untag groups for each port
|
| 119 | add_l2_interface_grouop(self.controller, ports, 1, False, 1)
|
| 120 |
|
| 121 | input_port = ports.pop()
|
| 122 | flood_ports= ports
|
macauley | 53e64c4 | 2015-07-30 14:07:45 +0800 | [diff] [blame] | 123 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 124 | #no fllod group create, veriy all drop
|
| 125 | parsed_pkt = simple_tcp_packet(eth_dst='00:12:34:56:78:9a')
|
| 126 | pkt = str(parsed_pkt)
|
| 127 | self.dataplane.send(input_port, pkt)
|
| 128 | verify_no_other_packets(self)
|
| 129 | parsed_pkt = simple_tcp_packet(eth_dst='FF:FF:FF:FF:FF:FF')
|
| 130 | pkt = str(parsed_pkt)
|
| 131 | self.dataplane.send(input_port, pkt)
|
| 132 | verify_no_other_packets(self)
|
| 133 | #add flood groupo
|
| 134 | msg=add_l2_flood_group(self.controller, flood_ports, 1, 1)
|
| 135 | add_bridge_flow(self.controller, None, 1, msg.group_id, True)
|
| 136 | #verify flood
|
| 137 | parsed_pkt = simple_tcp_packet(eth_dst='00:12:34:56:78:9a')
|
| 138 | pkt = str(parsed_pkt)
|
| 139 | self.dataplane.send(input_port, pkt)
|
| 140 | for ofport in flood_ports:
|
| 141 | verify_packet(self, pkt, ofport)
|
| 142 |
|
| 143 | verify_no_other_packets(self)
|
| 144 |
|
| 145 | for ofport in flood_ports:
|
| 146 | self.dataplane.send(ofport, pkt)
|
macauley | 53e64c4 | 2015-07-30 14:07:45 +0800 | [diff] [blame] | 147 | #self won't rx packet
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 148 | verify_no_packet(self, pkt, ofport)
|
macauley | 53e64c4 | 2015-07-30 14:07:45 +0800 | [diff] [blame] | 149 | #others will rx packet
|
| 150 | tmp_ports=[]
|
| 151 | for tmp in flood_ports:
|
| 152 | if tmp != ofport:
|
| 153 | tmp_ports.append(tmp)
|
| 154 | verify_packets(self, pkt, tmp_ports)
|
| 155 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 156 | verify_no_other_packets(self)
|
| 157 |
|
| 158 | parsed_pkt = simple_tcp_packet(eth_dst='FF:FF:FF:FF:FF:FF')
|
| 159 | pkt = str(parsed_pkt)
|
| 160 | self.dataplane.send(input_port, pkt)
|
| 161 | for ofport in flood_ports:
|
| 162 | verify_packet(self, pkt, ofport)
|
| 163 |
|
macauley | 1e26c5b | 2015-07-16 17:27:32 +0800 | [diff] [blame] | 164 | class PacketInMiss(base_tests.SimpleDataPlane):
|
| 165 | """
|
| 166 | Test packet in function for a table-miss flow
|
| 167 |
|
| 168 | Send a packet to each dataplane port and verify that a packet
|
| 169 | in message is received from the controller for each
|
macauley | 5295038 | 2015-07-17 15:59:01 +0800 | [diff] [blame] | 170 |
|
| 171 | NOTE: Verify This case the oft option shall not use --switch-ip
|
macauley | 1e26c5b | 2015-07-16 17:27:32 +0800 | [diff] [blame] | 172 | """
|
| 173 |
|
| 174 | def runTest(self):
|
| 175 | delete_all_flows(self.controller)
|
| 176 | delete_all_groups(self.controller)
|
| 177 |
|
| 178 | parsed_pkt = simple_tcp_packet(pktlen=100)
|
| 179 | parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
|
| 180 | vlan_vid=0x1001, dl_vlan_enable=True)
|
| 181 | pkt = str(parsed_pkt)
|
| 182 | vlan_pkt = str(parsed_vlan_pkt)
|
| 183 | # table 10: vlan
|
| 184 | # send to table 20
|
| 185 | add_vlan_table_flow(self.controller, config["port_map"].keys(), 1)
|
| 186 |
|
| 187 | # group table
|
| 188 | # set up untag groups for each port
|
| 189 | add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, False, 1)
|
| 190 |
|
| 191 | # create match
|
| 192 | match = ofp.match()
|
| 193 | match.oxm_list.append(ofp.oxm.vlan_vid(0x1001))
|
| 194 | request = ofp.message.flow_add(
|
| 195 | table_id=60,
|
| 196 | cookie=42,
|
| 197 | match=match,
|
| 198 | instructions=[
|
| 199 | ofp.instruction.apply_actions(
|
| 200 | actions=[
|
| 201 | ofp.action.output(
|
| 202 | port=ofp.OFPP_CONTROLLER,
|
| 203 | max_len=ofp.OFPCML_NO_BUFFER)]),
|
| 204 | ],
|
| 205 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 206 | priority=1)
|
| 207 |
|
| 208 | logging.info("Inserting packet in flow to controller")
|
| 209 | self.controller.message_send(request)
|
| 210 | do_barrier(self.controller)
|
| 211 |
|
| 212 | for of_port in config["port_map"].keys():
|
| 213 | logging.info("PacketInMiss test, port %d", of_port)
|
| 214 | self.dataplane.send(of_port, pkt)
|
| 215 |
|
| 216 | #AOS current packet in will not have vlan tag
|
macauley | 5295038 | 2015-07-17 15:59:01 +0800 | [diff] [blame] | 217 | if config["cicada_poject"]:
|
| 218 | verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
|
| 219 | else:
|
| 220 | verify_packet_in(self, pkt, of_port, ofp.OFPR_ACTION)
|
| 221 |
|
macauley | 1e26c5b | 2015-07-16 17:27:32 +0800 | [diff] [blame] | 222 | verify_no_other_packets(self)
|
| 223 |
|
macauley | 5295038 | 2015-07-17 15:59:01 +0800 | [diff] [blame] | 224 | class PacketOut(base_tests.SimpleDataPlane):
|
| 225 | """
|
| 226 | Verify action Flood, ALL, in port
|
| 227 | """
|
| 228 |
|
| 229 | def runTest(self):
|
| 230 | if config["cicada_poject"]:
|
| 231 | pass
|
| 232 |
|
| 233 | delete_all_flows(self.controller)
|
| 234 | delete_all_groups(self.controller)
|
| 235 |
|
| 236 | parsed_pkt = simple_tcp_packet(pktlen=100)
|
| 237 | parsed_vlan_pkt = simple_tcp_packet(pktlen=104,
|
| 238 | vlan_vid=0x1002, dl_vlan_enable=True)
|
| 239 |
|
| 240 | pkt = str(parsed_pkt)
|
| 241 | vlan_pkt = str(parsed_vlan_pkt)
|
| 242 |
|
| 243 |
|
| 244 | #packet out flood, untag packet
|
| 245 | self.controller.message_send(ofp.message.packet_out(in_port=ofp.OFPP_CONTROLLER,
|
| 246 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 247 | actions=[ofp.action.output(
|
| 248 | port=ofp.OFPP_FLOOD)],
|
| 249 | data=pkt))
|
| 250 |
|
| 251 | for of_port in config["port_map"].keys():
|
| 252 | verify_packet(self, pkt, of_port)
|
| 253 |
|
| 254 | verify_no_other_packets(self)
|
| 255 |
|
| 256 | #packet out flood, tag packet, because it can't identify vlan has which port
|
| 257 | #so we do as all action.
|
| 258 | self.controller.message_send(ofp.message.packet_out(in_port=ofp.OFPP_CONTROLLER,
|
| 259 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 260 | actions=[ofp.action.output(
|
| 261 | port=ofp.OFPP_FLOOD)],
|
| 262 | data=vlan_pkt))
|
| 263 |
|
| 264 | for of_port in config["port_map"].keys():
|
| 265 | verify_packet(self, vlan_pkt, of_port)
|
| 266 |
|
| 267 | verify_no_other_packets(self)
|
| 268 |
|
| 269 | #packet out all
|
| 270 | self.controller.message_send(ofp.message.packet_out(in_port=ofp.OFPP_CONTROLLER,
|
| 271 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 272 | actions=[ofp.action.output(
|
| 273 | port=ofp.OFPP_FLOOD)],
|
| 274 | data=pkt))
|
| 275 |
|
| 276 | for of_port in config["port_map"].keys():
|
| 277 | verify_packet(self, pkt, of_port)
|
| 278 |
|
| 279 | verify_no_other_packets(self)
|
| 280 |
|
| 281 | #packet out to in port
|
| 282 | in_port = config["port_map"].keys()[0]
|
| 283 | self.controller.message_send(ofp.message.packet_out(in_port=in_port,
|
| 284 | buffer_id=ofp.OFP_NO_BUFFER,
|
| 285 | actions=[ofp.action.output(
|
| 286 | port=in_port)],
|
| 287 | data=pkt))
|
| 288 |
|
| 289 | verify_packet(self, pkt, in_port)
|
| 290 | verify_no_other_packets(self)
|
| 291 |
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 292 | class L3UcastRoute(base_tests.SimpleDataPlane):
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 293 | """
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 294 | Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
|
| 295 | Port2(vlan2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 296 | """
|
| 297 | def runTest(self):
|
| 298 | delete_all_flows(self.controller)
|
| 299 | delete_all_groups(self.controller)
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 300 |
|
| 301 | if len(config["port_map"]) <2:
|
| 302 | logging.info("Port count less than 2, can't run this case")
|
| 303 | return
|
| 304 |
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 305 | vlan_id=1
|
| 306 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 307 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
|
| 308 | dip=0xc0a80001
|
| 309 | for port in config["port_map"].keys():
|
| 310 | #add l2 interface group
|
| 311 | add_one_l2_interface_grouop(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
| 312 | dst_mac[5]=vlan_id
|
| 313 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
|
| 314 | #add vlan flow table
|
| 315 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 316 | #add termination flow
|
| 317 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
|
| 318 | #add unicast routing flow
|
| 319 | dst_ip = dip + (vlan_id<<8)
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 320 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, l3_msg.group_id)
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 321 | vlan_id += 1
|
| 322 |
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 323 | do_barrier(self.controller)
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 324 |
|
| 325 | port1=config["port_map"].keys()[0]
|
| 326 | port2=config["port_map"].keys()[1]
|
| 327 | #port 1 to port 2
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 328 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 329 | dst_mac[5]=1
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 330 | port1_mac=':'.join(['%02X' % x for x in dst_mac])
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 331 |
|
| 332 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 333 | eth_dst=switch_mac,
|
| 334 | eth_src=port1_mac,
|
| 335 | ip_ttl=64,
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 336 | ip_src="192.168.1.1",
|
| 337 | ip_dst='192.168.2.1')
|
| 338 | pkt=str(parsed_pkt)
|
| 339 | self.dataplane.send(port1, pkt)
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 340 | #build expect packet
|
| 341 | dst_mac[5]=2
|
| 342 | port2_mac=':'.join(['%02X' % x for x in dst_mac])
|
| 343 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 344 | eth_dst=port2_mac,
|
| 345 | eth_src=switch_mac,
|
| 346 | ip_ttl=63,
|
| 347 | ip_src="192.168.1.1",
|
| 348 | ip_dst='192.168.2.1')
|
| 349 | pkt=str(exp_pkt)
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 350 | verify_packet(self, pkt, port2)
|
| 351 | verify_no_other_packets(self)
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 352 |
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 353 | #port 2 to port 1
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 354 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 355 | dst_mac[5]=2
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 356 | port2_mac=':'.join(['%02X' % x for x in dst_mac])
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 357 |
|
| 358 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 359 | eth_dst=switch_mac,
|
| 360 | eth_src=port2_mac,
|
| 361 | ip_ttl=64,
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 362 | ip_src="192.168.2.1",
|
| 363 | ip_dst='192.168.1.1')
|
| 364 | pkt=str(parsed_pkt)
|
| 365 | self.dataplane.send(port2, pkt)
|
macauley | fa788eb | 2015-07-23 15:13:54 +0800 | [diff] [blame] | 366 | #build expect packet
|
| 367 | dst_mac[5]=1
|
| 368 | port1_mac=':'.join(['%02X' % x for x in dst_mac])
|
| 369 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 370 | eth_dst=port1_mac,
|
| 371 | eth_src=switch_mac,
|
| 372 | ip_ttl=63,
|
| 373 | ip_src="192.168.2.1",
|
| 374 | ip_dst='192.168.1.1')
|
| 375 | pkt=str(exp_pkt)
|
| 376 | verify_packet(self, pkt, port1)
|
| 377 | verify_no_other_packets(self)
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 378 |
|
macauley | 9a53bf9 | 2015-08-03 13:36:00 +0800 | [diff] [blame] | 379 | class L3UcastRouteOnSamVLANSamPort(base_tests.SimpleDataPlane):
|
| 380 | """
|
| 381 | Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
|
| 382 | Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
|
| 383 | """
|
| 384 | def runTest(self):
|
| 385 | delete_all_flows(self.controller)
|
| 386 | delete_all_groups(self.controller)
|
| 387 | port = config["port_map"].keys()[0]
|
| 388 |
|
| 389 | vlan_id=1
|
| 390 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 391 | port_mac1=[0x00, 0x00, 0x00, 0x22, 0x22, 0x01]
|
| 392 | port_mac2=[0x00, 0x00, 0x00, 0x22, 0x22, 0x02]
|
| 393 | port_ip1=0xc0a80101
|
| 394 | port_ip1_str=convertIP4toStr(port_ip1)
|
| 395 | port_ip2=0xc0a80201
|
| 396 | port_ip2_str=convertIP4toStr(port_ip2)
|
| 397 | #add l2 interface group
|
| 398 | add_one_l2_interface_grouop(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
| 399 | #add vlan flow table
|
| 400 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 401 | #add termination flow
|
| 402 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
|
| 403 |
|
| 404 | """192.168.1.1->192.168.2.1"""
|
| 405 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=1, src_mac=intf_src_mac, dst_mac=port_mac2)
|
| 406 | add_unicast_routing_flow(self.controller, 0x0800, port_ip2, 0, l3_msg.group_id)
|
| 407 | """192.168.1.1->192.168.2.1"""
|
| 408 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=2, src_mac=intf_src_mac, dst_mac=port_mac1)
|
| 409 | add_unicast_routing_flow(self.controller, 0x0800, port_ip1, 0, l3_msg.group_id)
|
| 410 |
|
| 411 | do_barrier(self.controller)
|
| 412 |
|
| 413 | """send packet to verify"""
|
| 414 | """192.168.1.1->192.168.2.1"""
|
| 415 | switch_mac_str = convertMACtoStr(intf_src_mac)
|
| 416 | port_mac1_str = convertMACtoStr(port_mac1)
|
| 417 | port_mac2_str = convertMACtoStr(port_mac2)
|
| 418 | ttl=64
|
| 419 | #send packet
|
| 420 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 421 | eth_dst=switch_mac_str,
|
| 422 | eth_src=port_mac1_str,
|
| 423 | ip_ttl=ttl,
|
| 424 | ip_src=port_ip1_str,
|
| 425 | ip_dst=port_ip2_str)
|
| 426 | pkt=str(parsed_pkt)
|
| 427 | self.dataplane.send(port, pkt)
|
| 428 | #build expect packet
|
| 429 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 430 | eth_dst=port_mac2_str,
|
| 431 | eth_src=switch_mac_str,
|
| 432 | ip_ttl=(ttl-1),
|
| 433 | ip_src=port_ip1_str,
|
| 434 | ip_dst=port_ip2_str)
|
| 435 | pkt=str(exp_pkt)
|
| 436 | verify_packet(self, pkt, port)
|
| 437 | verify_no_other_packets(self)
|
| 438 |
|
| 439 | """192.168.2.1->192.168.1.1"""
|
| 440 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 441 | eth_dst=switch_mac_str,
|
| 442 | eth_src=port_mac2_str,
|
| 443 | ip_ttl=ttl,
|
| 444 | ip_src=port_ip2_str,
|
| 445 | ip_dst=port_ip1_str)
|
| 446 | pkt=str(parsed_pkt)
|
| 447 | self.dataplane.send(port, pkt)
|
| 448 | #build expect packet
|
| 449 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 450 | eth_dst=port_mac1_str,
|
| 451 | eth_src=switch_mac_str,
|
| 452 | ip_ttl=(ttl-1),
|
| 453 | ip_src=port_ip2_str,
|
| 454 | ip_dst=port_ip1_str)
|
| 455 | pkt=str(exp_pkt)
|
| 456 | verify_packet(self, pkt, port)
|
| 457 | verify_no_other_packets(self)
|
| 458 |
|
| 459 | class L3UcastRouteOnDiffVLANSamPort(base_tests.SimpleDataPlane):
|
| 460 | """
|
| 461 | Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
|
| 462 | Port1(vlan2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
|
| 463 | """
|
| 464 | def runTest(self):
|
| 465 | delete_all_flows(self.controller)
|
| 466 | delete_all_groups(self.controller)
|
| 467 | port = config["port_map"].keys()[0]
|
| 468 |
|
| 469 | port_vlan_id1=1
|
| 470 | port_vlan_id2=2
|
| 471 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 472 | port_mac1=[0x00, 0x00, 0x00, 0x22, 0x22, 0x01]
|
| 473 | port_mac2=[0x00, 0x00, 0x00, 0x22, 0x22, 0x02]
|
| 474 | port_ip1=0xc0a80101
|
| 475 | port_ip1_str=convertIP4toStr(port_ip1)
|
| 476 | port_ip2=0xc0a80201
|
| 477 | port_ip2_str=convertIP4toStr(port_ip2)
|
| 478 | #add l2 interface group
|
| 479 | add_one_l2_interface_grouop(self.controller, port, vlan_id=port_vlan_id1, is_tagged=True, send_barrier=False)
|
| 480 | add_one_l2_interface_grouop(self.controller, port, vlan_id=port_vlan_id2, is_tagged=True, send_barrier=False)
|
| 481 | #add vlan flow table
|
| 482 | add_one_vlan_table_flow(self.controller, port, port_vlan_id1, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 483 | add_one_vlan_table_flow(self.controller, port, port_vlan_id2, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 484 | #add termination flow
|
| 485 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, port_vlan_id1)
|
| 486 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, port_vlan_id2)
|
| 487 |
|
| 488 | """192.168.1.1->192.168.2.1"""
|
| 489 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=port_vlan_id2, id=1, src_mac=intf_src_mac, dst_mac=port_mac2)
|
| 490 | add_unicast_routing_flow(self.controller, 0x0800, port_ip2, 0, l3_msg.group_id)
|
| 491 | """192.168.1.1->192.168.2.1"""
|
| 492 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=port_vlan_id1, id=2, src_mac=intf_src_mac, dst_mac=port_mac1)
|
| 493 | add_unicast_routing_flow(self.controller, 0x0800, port_ip1, 0, l3_msg.group_id)
|
| 494 |
|
| 495 | do_barrier(self.controller)
|
| 496 |
|
| 497 | """send packet to verify"""
|
| 498 | """192.168.1.1->192.168.2.1"""
|
| 499 | switch_mac_str =convertMACtoStr(intf_src_mac)
|
| 500 | port_mac1_str= convertMACtoStr(port_mac1)
|
| 501 | port_mac2_str= convertMACtoStr(port_mac2)
|
| 502 | ttl=64
|
| 503 | #send packet
|
| 504 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 505 | eth_dst=switch_mac_str,
|
| 506 | eth_src=port_mac1_str,
|
| 507 | dl_vlan_enable=True,
|
| 508 | vlan_vid=port_vlan_id1,
|
| 509 | ip_ttl=ttl,
|
| 510 | ip_src=port_ip1_str,
|
| 511 | ip_dst=port_ip2_str)
|
| 512 | pkt=str(parsed_pkt)
|
| 513 | self.dataplane.send(port, pkt)
|
| 514 | #build expect packet
|
| 515 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 516 | eth_dst=port_mac2_str,
|
| 517 | eth_src=switch_mac_str,
|
| 518 | dl_vlan_enable=True,
|
| 519 | vlan_vid=port_vlan_id2,
|
| 520 | ip_ttl=(ttl-1),
|
| 521 | ip_src=port_ip1_str,
|
| 522 | ip_dst=port_ip2_str)
|
| 523 | pkt=str(exp_pkt)
|
| 524 | verify_packet(self, pkt, port)
|
| 525 | verify_no_other_packets(self)
|
| 526 |
|
| 527 | """192.168.2.1->192.168.1.1"""
|
| 528 | switch_mac = convertMACtoStr(intf_src_mac)
|
| 529 | port_mac2_str=convertMACtoStr(port_mac2)
|
| 530 |
|
| 531 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 532 | eth_dst=switch_mac_str,
|
| 533 | eth_src=port_mac2_str,
|
| 534 | dl_vlan_enable=True,
|
| 535 | vlan_vid=port_vlan_id2,
|
| 536 | ip_ttl=ttl,
|
| 537 | ip_src=port_ip2_str,
|
| 538 | ip_dst=port_ip1_str)
|
| 539 | pkt=str(parsed_pkt)
|
| 540 | self.dataplane.send(port, pkt)
|
| 541 | #build expect packet
|
| 542 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 543 | eth_dst=port_mac1_str,
|
| 544 | eth_src=switch_mac_str,
|
| 545 | dl_vlan_enable=True,
|
| 546 | vlan_vid=port_vlan_id1,
|
| 547 | ip_ttl=(ttl-1),
|
| 548 | ip_src=port_ip2_str,
|
| 549 | ip_dst=port_ip1_str)
|
| 550 | pkt=str(exp_pkt)
|
| 551 | verify_packet(self, pkt, port)
|
| 552 | verify_no_other_packets(self)
|
| 553 |
|
macauley | 53d90fe | 2015-08-04 17:34:22 +0800 | [diff] [blame] | 554 | class L3UcastVrfRouteOnSamVLANSamPort(base_tests.SimpleDataPlane):
|
| 555 | """
|
| 556 | Port1(vlan1, VRF1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
|
| 557 | Port1(vlan1, VRF1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
|
| 558 | Port1(vlan2, VRF2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
|
| 559 | Port1(vlan2, VRF2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
|
| 560 |
|
| 561 | """
|
| 562 | def runTest(self):
|
| 563 | delete_all_flows(self.controller)
|
| 564 | delete_all_groups(self.controller)
|
| 565 | port = config["port_map"].keys()[0]
|
| 566 |
|
| 567 | vrf1=1
|
| 568 | vrf2=2
|
| 569 | vrf1_vlan_id=1
|
| 570 | vrf2_vlan_id=2
|
| 571 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 572 | port_mac1=[0x00, 0x00, 0x00, 0x22, 0x22, 0x01]
|
| 573 | port_mac2=[0x00, 0x00, 0x00, 0x22, 0x22, 0x02]
|
| 574 | port_ip1=0xc0a80101
|
| 575 | port_ip1_str=convertIP4toStr(port_ip1)
|
| 576 | port_ip2=0xc0a80201
|
| 577 | port_ip2_str=convertIP4toStr(port_ip2)
|
| 578 | #add l2 interface group
|
| 579 | add_one_l2_interface_grouop(self.controller, port, vlan_id=vrf1_vlan_id, is_tagged=True, send_barrier=False)
|
| 580 | add_one_l2_interface_grouop(self.controller, port, vlan_id=vrf2_vlan_id, is_tagged=True, send_barrier=False)
|
| 581 | #add vlan flow table
|
| 582 | add_one_vlan_table_flow(self.controller, port, vrf1_vlan_id, vrf=vrf1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
|
| 583 | add_one_vlan_table_flow(self.controller, port, vrf2_vlan_id, vrf=vrf2, flag=VLAN_TABLE_FLAG_ONLY_TAG)
|
| 584 |
|
| 585 | #add termination flow
|
| 586 | add_termination_flow(self.controller, 0, 0x0800, intf_src_mac, vrf1_vlan_id)
|
| 587 | add_termination_flow(self.controller, 0, 0x0800, intf_src_mac, vrf2_vlan_id)
|
| 588 |
|
| 589 | """192.168.1.1->192.168.2.1"""
|
| 590 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf1_vlan_id, id=1, src_mac=intf_src_mac, dst_mac=port_mac2)
|
| 591 | add_unicast_routing_flow(self.controller, 0x0800, port_ip2, 0, l3_msg.group_id, vrf1)
|
| 592 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf2_vlan_id, id=2, src_mac=intf_src_mac, dst_mac=port_mac2)
|
| 593 | add_unicast_routing_flow(self.controller, 0x0800, port_ip2, 0, l3_msg.group_id, vrf2)
|
| 594 |
|
| 595 | """192.168.1.1->192.168.2.1"""
|
| 596 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf1_vlan_id, id=3, src_mac=intf_src_mac, dst_mac=port_mac1)
|
| 597 | add_unicast_routing_flow(self.controller, 0x0800, port_ip1, 0, l3_msg.group_id, vrf1)
|
| 598 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf2_vlan_id, id=4, src_mac=intf_src_mac, dst_mac=port_mac1)
|
| 599 | add_unicast_routing_flow(self.controller, 0x0800, port_ip1, 0, l3_msg.group_id, vrf2)
|
| 600 |
|
| 601 | do_barrier(self.controller)
|
| 602 |
|
| 603 | """send packet to verify on VRF vrf1"""
|
| 604 | """192.168.1.1->192.168.2.1"""
|
| 605 | switch_mac_str = convertMACtoStr(intf_src_mac)
|
| 606 | port_mac1_str = convertMACtoStr(port_mac1)
|
| 607 | port_mac2_str = convertMACtoStr(port_mac2)
|
| 608 | ttl=64
|
| 609 | #send packet
|
| 610 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 611 | eth_dst=switch_mac_str,
|
| 612 | eth_src=port_mac1_str,
|
| 613 | dl_vlan_enable=True,
|
| 614 | vlan_vid=vrf1_vlan_id,
|
| 615 | ip_ttl=ttl,
|
| 616 | ip_src=port_ip1_str,
|
| 617 | ip_dst=port_ip2_str)
|
| 618 | pkt=str(parsed_pkt)
|
| 619 | self.dataplane.send(port, pkt)
|
| 620 | #build expect packet
|
| 621 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 622 | eth_dst=port_mac2_str,
|
| 623 | eth_src=switch_mac_str,
|
| 624 | dl_vlan_enable=True,
|
| 625 | vlan_vid=vrf1_vlan_id,
|
| 626 | ip_ttl=(ttl-1),
|
| 627 | ip_src=port_ip1_str,
|
| 628 | ip_dst=port_ip2_str)
|
| 629 | pkt=str(exp_pkt)
|
| 630 | verify_packet(self, pkt, port)
|
| 631 | verify_no_other_packets(self)
|
| 632 |
|
| 633 | """192.168.2.1->192.168.1.1"""
|
| 634 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 635 | eth_dst=switch_mac_str,
|
| 636 | eth_src=port_mac2_str,
|
| 637 | dl_vlan_enable=True,
|
| 638 | vlan_vid=vrf1_vlan_id,
|
| 639 | ip_ttl=ttl,
|
| 640 | ip_src=port_ip2_str,
|
| 641 | ip_dst=port_ip1_str)
|
| 642 | pkt=str(parsed_pkt)
|
| 643 | self.dataplane.send(port, pkt)
|
| 644 | #build expect packet
|
| 645 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 646 | eth_dst=port_mac1_str,
|
| 647 | eth_src=switch_mac_str,
|
| 648 | dl_vlan_enable=True,
|
| 649 | vlan_vid=vrf1_vlan_id,
|
| 650 | ip_ttl=(ttl-1),
|
| 651 | ip_src=port_ip2_str,
|
| 652 | ip_dst=port_ip1_str)
|
| 653 | pkt=str(exp_pkt)
|
| 654 | verify_packet(self, pkt, port)
|
| 655 | verify_no_other_packets(self)
|
| 656 |
|
| 657 |
|
| 658 | """send packet to verify on VRF vrf2"""
|
| 659 | """192.168.1.1->192.168.2.1"""
|
| 660 | switch_mac_str = convertMACtoStr(intf_src_mac)
|
| 661 | port_mac1_str = convertMACtoStr(port_mac1)
|
| 662 | port_mac2_str = convertMACtoStr(port_mac2)
|
| 663 | ttl=64
|
| 664 | #send packet
|
| 665 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 666 | eth_dst=switch_mac_str,
|
| 667 | eth_src=port_mac1_str,
|
| 668 | dl_vlan_enable=True,
|
| 669 | vlan_vid=vrf2_vlan_id,
|
| 670 | ip_ttl=ttl,
|
| 671 | ip_src=port_ip1_str,
|
| 672 | ip_dst=port_ip2_str)
|
| 673 | pkt=str(parsed_pkt)
|
| 674 | self.dataplane.send(port, pkt)
|
| 675 | #build expect packet
|
| 676 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 677 | eth_dst=port_mac2_str,
|
| 678 | eth_src=switch_mac_str,
|
| 679 | dl_vlan_enable=True,
|
| 680 | vlan_vid=vrf2_vlan_id,
|
| 681 | ip_ttl=(ttl-1),
|
| 682 | ip_src=port_ip1_str,
|
| 683 | ip_dst=port_ip2_str)
|
| 684 | pkt=str(exp_pkt)
|
| 685 | verify_packet(self, pkt, port)
|
| 686 | verify_no_other_packets(self)
|
| 687 |
|
| 688 | """192.168.2.1->192.168.1.1"""
|
| 689 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 690 | eth_dst=switch_mac_str,
|
| 691 | eth_src=port_mac2_str,
|
| 692 | dl_vlan_enable=True,
|
| 693 | vlan_vid=vrf2_vlan_id,
|
| 694 | ip_ttl=ttl,
|
| 695 | ip_src=port_ip2_str,
|
| 696 | ip_dst=port_ip1_str)
|
| 697 | pkt=str(parsed_pkt)
|
| 698 | self.dataplane.send(port, pkt)
|
| 699 | #build expect packet
|
| 700 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 701 | eth_dst=port_mac1_str,
|
| 702 | eth_src=switch_mac_str,
|
| 703 | dl_vlan_enable=True,
|
| 704 | vlan_vid=vrf2_vlan_id,
|
| 705 | ip_ttl=(ttl-1),
|
| 706 | ip_src=port_ip2_str,
|
| 707 | ip_dst=port_ip1_str)
|
| 708 | pkt=str(exp_pkt)
|
| 709 | verify_packet(self, pkt, port)
|
| 710 | verify_no_other_packets(self)
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 715 | class L3UcastECMP(base_tests.SimpleDataPlane):
|
| 716 | """
|
| 717 | Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
|
| 718 | Port2(vlan2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
|
| 719 | """
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 720 | def runTest(self):
|
| 721 | delete_all_flows(self.controller)
|
| 722 | delete_all_groups(self.controller)
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 723 |
|
| 724 | if len(config["port_map"]) <2:
|
| 725 | logging.info("Port count less than 2, can't run this case")
|
| 726 | return
|
macauley | 0c54d3f | 2015-07-17 18:10:03 +0800 | [diff] [blame] | 727 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 728 | vlan_id=1
|
| 729 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 730 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00]
|
| 731 | dip=0xc0a80001
|
| 732 | for port in config["port_map"].keys():
|
| 733 | #add l2 interface group
|
| 734 | add_one_l2_interface_grouop(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
| 735 | dst_mac[5]=vlan_id
|
| 736 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac)
|
| 737 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [l3_msg.group_id])
|
| 738 | #add vlan flow table
|
| 739 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 740 | #add termination flow
|
| 741 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
|
| 742 | #add unicast routing flow
|
| 743 | dst_ip = dip + (vlan_id<<8)
|
| 744 | #ECMP shall have prefix not 32
|
| 745 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id)
|
| 746 | vlan_id += 1
|
| 747 |
|
| 748 | do_barrier(self.controller)
|
| 749 |
|
| 750 | port1=config["port_map"].keys()[0]
|
| 751 | port2=config["port_map"].keys()[1]
|
| 752 | #port 1 to port 2
|
| 753 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
|
| 754 | dst_mac[5]=1
|
| 755 | port1_mac=':'.join(['%02X' % x for x in dst_mac])
|
macauley | 5295038 | 2015-07-17 15:59:01 +0800 | [diff] [blame] | 756 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 757 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 758 | eth_dst=switch_mac,
|
| 759 | eth_src=port1_mac,
|
| 760 | ip_ttl=64,
|
| 761 | ip_src="192.168.1.1",
|
| 762 | ip_dst='192.168.2.1')
|
| 763 | pkt=str(parsed_pkt)
|
| 764 | self.dataplane.send(port1, pkt)
|
| 765 | #build expect packet
|
| 766 | dst_mac[5]=2
|
| 767 | port2_mac=':'.join(['%02X' % x for x in dst_mac])
|
| 768 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 769 | eth_dst=port2_mac,
|
| 770 | eth_src=switch_mac,
|
| 771 | ip_ttl=63,
|
| 772 | ip_src="192.168.1.1",
|
| 773 | ip_dst='192.168.2.1')
|
| 774 | pkt=str(exp_pkt)
|
| 775 | verify_packet(self, pkt, port2)
|
| 776 | verify_no_other_packets(self)
|
macauley | 5295038 | 2015-07-17 15:59:01 +0800 | [diff] [blame] | 777 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 778 | #port 2 to port 1
|
| 779 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
|
| 780 | dst_mac[5]=2
|
| 781 | port2_mac=':'.join(['%02X' % x for x in dst_mac])
|
| 782 |
|
| 783 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 784 | eth_dst=switch_mac,
|
| 785 | eth_src=port2_mac,
|
| 786 | ip_ttl=64,
|
| 787 | ip_src="192.168.2.1",
|
| 788 | ip_dst='192.168.1.1')
|
| 789 | pkt=str(parsed_pkt)
|
| 790 | self.dataplane.send(port2, pkt)
|
| 791 | #build expect packet
|
| 792 | dst_mac[5]=1
|
| 793 | port1_mac=':'.join(['%02X' % x for x in dst_mac])
|
| 794 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 795 | eth_dst=port1_mac,
|
| 796 | eth_src=switch_mac,
|
| 797 | ip_ttl=63,
|
| 798 | ip_src="192.168.2.1",
|
| 799 | ip_dst='192.168.1.1')
|
| 800 | pkt=str(exp_pkt)
|
| 801 | verify_packet(self, pkt, port1)
|
| 802 | verify_no_other_packets(self)
|
macauley_cheng | 1db6a36 | 2015-09-01 13:39:40 +0800 | [diff] [blame^] | 803 |
|
| 804 |
|
| 805 | class L3UcastECMP2(base_tests.SimpleDataPlane):
|
| 806 | """
|
| 807 | Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
|
| 808 | Port2(vlan2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
|
| 809 | Portn(vlann, 0x00, 0x00, 0x00, 0x22, 0x22, 0x0n, 19.168.n.1)
|
| 810 | """
|
| 811 |
|
| 812 | def runTest(self):
|
| 813 | delete_all_flows(self.controller)
|
| 814 | delete_all_groups(self.controller)
|
| 815 |
|
| 816 | if len(config["port_map"]) <3:
|
| 817 | logging.info("Port count less than 3, can't run this case")
|
| 818 | return
|
| 819 |
|
| 820 | vlan_id=1
|
| 821 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 822 | same_dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x22]
|
| 823 |
|
| 824 | l3_ucast_gips=[]
|
| 825 | tx_port = config["port_map"].keys()[0]
|
| 826 | for port in config["port_map"].keys():
|
| 827 | #add l2 interface group
|
| 828 | add_one_l2_interface_grouop(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
| 829 | if tx_port != port:
|
| 830 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=same_dst_mac)
|
| 831 | l3_ucast_gips.append(l3_msg.group_id)
|
| 832 | #add vlan flow table
|
| 833 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 834 | #add termination flow
|
| 835 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
|
| 836 | vlan_id += 1
|
| 837 |
|
| 838 | tx_dip=0x0a0a0a0a
|
| 839 | tx_sip=0x0b0a0a0a
|
| 840 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, l3_ucast_gips)
|
| 841 | #ECMP shall have prefix not 32
|
| 842 | add_unicast_routing_flow(self.controller, 0x0800, tx_dip, 0xffffff00, ecmp_msg.group_id)
|
| 843 |
|
| 844 | do_barrier(self.controller)
|
| 845 |
|
| 846 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac])
|
| 847 | packet_src_mac="00:00:33:44:55:66"
|
| 848 | #from unknown src ip to unknown dst ip, to verify ecmp
|
| 849 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 850 | eth_dst=switch_mac,
|
| 851 | eth_src=packet_src_mac,
|
| 852 | ip_ttl=64,
|
| 853 | ip_src=convertIP4toStr(tx_sip),
|
| 854 | ip_dst=convertIP4toStr(tx_dip))
|
| 855 | self.dataplane.send(tx_port, str(parsed_pkt))
|
| 856 | #build expect packet
|
| 857 | dst_mac=':'.join(['%02X' % x for x in same_dst_mac])
|
| 858 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 859 | eth_dst=dst_mac,
|
| 860 | eth_src=switch_mac,
|
| 861 | ip_ttl=63,
|
| 862 | ip_src=convertIP4toStr(tx_sip),
|
| 863 | ip_dst=convertIP4toStr(tx_dip))
|
| 864 |
|
| 865 | verify_packet(self, exp_pkt, config["port_map"].keys()[2])
|
| 866 | verify_no_other_packets(self)
|
| 867 | tx_sip=tx_sip+0x01000000
|
| 868 | #from unknown scr ip to unknown dst ip, to verify ecmp
|
| 869 | parsed_pkt = simple_tcp_packet(pktlen=100,
|
| 870 | eth_dst=switch_mac,
|
| 871 | eth_src=packet_src_mac,
|
| 872 | ip_ttl=64,
|
| 873 | ip_src=convertIP4toStr(tx_sip),
|
| 874 | ip_dst=convertIP4toStr(tx_dip))
|
| 875 | self.dataplane.send(tx_port, str(parsed_pkt))
|
| 876 | #build expect packet
|
| 877 | dst_mac=':'.join(['%02X' % x for x in same_dst_mac])
|
| 878 | exp_pkt = simple_tcp_packet(pktlen=100,
|
| 879 | eth_dst=dst_mac,
|
| 880 | eth_src=switch_mac,
|
| 881 | ip_ttl=63,
|
| 882 | ip_src=convertIP4toStr(tx_sip),
|
| 883 | ip_dst=convertIP4toStr(tx_dip))
|
| 884 |
|
| 885 | verify_packet(self, exp_pkt, config["port_map"].keys()[1])
|
| 886 | verify_no_other_packets(self)
|
| 887 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 888 | class L3McastRoute1(base_tests.SimpleDataPlane):
|
| 889 | """
|
| 890 | Mcast routing, From VLAN 1 to VLAN 2
|
| 891 | """
|
| 892 | def runTest(self):
|
| 893 | """
|
| 894 | port1 (vlan 1)-> port 2 (vlan 2)
|
| 895 | """
|
| 896 | delete_all_flows(self.controller)
|
| 897 | delete_all_groups(self.controller)
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 898 |
|
| 899 | if len(config["port_map"]) <3:
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 900 | logging.info("Port count less than 2, can't run this case")
|
| 901 | return
|
| 902 |
|
| 903 | vlan_id =1
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 904 | port2_out_vlan=2
|
| 905 | port3_out_vlan=3
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 906 | in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan
|
| 907 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 908 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
|
| 909 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
|
| 910 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
|
| 911 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
|
| 912 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
|
| 913 | src_ip=0xc0a80101
|
| 914 | src_ip_str="192.168.1.1"
|
| 915 | dst_ip=0xe0010101
|
| 916 | dst_ip_str="224.1.1.1"
|
| 917 |
|
| 918 | port1=config["port_map"].keys()[0]
|
| 919 | port2=config["port_map"].keys()[1]
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 920 | port3=config["port_map"].keys()[2]
|
| 921 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 922 | #add l2 interface group
|
| 923 | for port in config["port_map"].keys():
|
| 924 | add_one_l2_interface_grouop(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
| 925 | #add vlan flow table
|
| 926 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 927 | vlan_id +=1
|
| 928 |
|
| 929 | #add termination flow
|
| 930 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
|
| 931 |
|
| 932 | #add l3 interface group
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 933 | port2_ucast_msg=add_l3_interface_group(self.controller, port2, port2_out_vlan, 2, intf_src_mac)
|
| 934 | port3_ucast_msg=add_l3_interface_group(self.controller, port3, port3_out_vlan, 3, intf_src_mac)
|
| 935 | mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [port2_ucast_msg.group_id, port3_ucast_msg.group_id])
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 936 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id)
|
| 937 |
|
| 938 | parsed_pkt = simple_udp_packet(pktlen=100,
|
| 939 | eth_dst=dst_mac_str,
|
| 940 | eth_src=port1_mac_str,
|
| 941 | ip_ttl=64,
|
| 942 | ip_src=src_ip_str,
|
| 943 | ip_dst=dst_ip_str)
|
| 944 | pkt=str(parsed_pkt)
|
| 945 | self.dataplane.send(port1, pkt)
|
| 946 | parsed_pkt = simple_udp_packet(pktlen=100,
|
| 947 | eth_dst=dst_mac_str,
|
| 948 | eth_src=intf_src_mac_str,
|
| 949 | ip_ttl=63,
|
| 950 | ip_src=src_ip_str,
|
| 951 | ip_dst=dst_ip_str)
|
| 952 | pkt=str(parsed_pkt)
|
| 953 | verify_packet(self, pkt, port2)
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 954 | verify_packet(self, pkt, port3)
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 955 | verify_no_other_packets(self)
|
| 956 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 957 | class L3McastRoute2(base_tests.SimpleDataPlane):
|
| 958 | """
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 959 | Mcast routing, but on same vlan (l2mcast)
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 960 | """
|
| 961 | def runTest(self):
|
| 962 | """
|
| 963 | port1 (vlan 1)-> port 2 (vlan 1)
|
| 964 | """
|
| 965 | delete_all_flows(self.controller)
|
| 966 | delete_all_groups(self.controller)
|
| 967 |
|
| 968 | if len(config["port_map"]) <2:
|
| 969 | logging.info("Port count less than 2, can't run this case")
|
| 970 | return
|
| 971 |
|
| 972 | vlan_id =1
|
| 973 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
|
| 974 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac])
|
| 975 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01]
|
| 976 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac])
|
| 977 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11]
|
| 978 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac])
|
| 979 | src_ip=0xc0a80101
|
| 980 | src_ip_str="192.168.1.1"
|
| 981 | dst_ip=0xe0010101
|
| 982 | dst_ip_str="224.1.1.1"
|
| 983 |
|
| 984 | port1=config["port_map"].keys()[0]
|
| 985 | port2=config["port_map"].keys()[1]
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 986 |
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 987 |
|
| 988 | #add l2 interface group
|
| 989 | l2_intf_group_list=[]
|
macauley | c8edafa | 2015-07-30 14:26:18 +0800 | [diff] [blame] | 990 | for port in config["port_map"].keys():
|
| 991 | if port != port1 and port !=port2:
|
| 992 | continue
|
macauley | 76cc8d2 | 2015-07-27 17:40:36 +0800 | [diff] [blame] | 993 | l2_intf_gid, msg=add_one_l2_interface_grouop(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
|
| 994 | l2_intf_group_list.append(l2_intf_gid)
|
| 995 | #add vlan flow table
|
| 996 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
|
| 997 |
|
| 998 | #add termination flow
|
| 999 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id)
|
| 1000 |
|
| 1001 | #add l3 interface group
|
| 1002 | mcat_group_msg=add_l3_mcast_group(self.controller, vlan_id, 2, l2_intf_group_list)
|
| 1003 | add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id)
|
| 1004 |
|
| 1005 | parsed_pkt = simple_udp_packet(pktlen=100,
|
| 1006 | eth_dst=dst_mac_str,
|
| 1007 | eth_src=port1_mac_str,
|
| 1008 | ip_ttl=64,
|
| 1009 | ip_src=src_ip_str,
|
| 1010 | ip_dst=dst_ip_str)
|
| 1011 | pkt=str(parsed_pkt)
|
| 1012 | self.dataplane.send(port1, pkt)
|
| 1013 | verify_packet(self, pkt, port2)
|
| 1014 | verify_no_other_packets(self)
|
| 1015 |
|
| 1016 |
|
| 1017 | |