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