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