Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 1 | """ |
Flavio Castro | c36621e | 2015-12-08 12:57:07 -0500 | [diff] [blame] | 2 | The following tests are being done here |
Flavio Castro | 3aec890 | 2015-11-20 10:51:38 -0500 | [diff] [blame] | 3 | 1) PacketInSrcMacMiss |
castroflavio | 9e715f3 | 2015-12-08 14:04:12 -0500 | [diff] [blame] | 4 | 2) VlanSupport |
| 5 | 3) L2FloodQinQ |
| 6 | 4) L2FloodTagged |
| 7 | 5) L2Flood Tagged Unknown Src |
| 8 | 6) L2 Unicast Tagged |
| 9 | 7) MTU 1500 |
| 10 | 8) MTU 4100 |
| 11 | 9) MTU 4500 |
| 12 | 10) L3UnicastTagged |
| 13 | 11) L3VPNMPLS |
| 14 | 12) MPLS Termination |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 15 | """ |
| 16 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 17 | from oftest import config |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 18 | import logging |
| 19 | import oftest.base_tests as base_tests |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 20 | import ofp |
| 21 | from oftest.testutils import * |
| 22 | from accton_util import * |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 23 | |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 24 | @disabled |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 25 | class PacketInSrcMacMiss(base_tests.SimpleDataPlane): |
| 26 | """ |
| 27 | Test packet in function on a src-mac miss |
| 28 | Send a packet to each dataplane port and verify that a packet |
| 29 | in message is received from the controller for each |
| 30 | #todo verify you stop receiving after adding rule |
| 31 | """ |
| 32 | |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 33 | def runTest(self): |
| 34 | delete_all_flows(self.controller) |
| 35 | delete_all_groups(self.controller) |
| 36 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 37 | ports = sorted(config["port_map"].keys()) |
| 38 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 39 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 40 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 41 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 42 | parsed_vlan_pkt = simple_tcp_packet(pktlen=104, |
| 43 | vlan_vid=0x1001, dl_vlan_enable=True) |
| 44 | vlan_pkt = str(parsed_vlan_pkt) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 45 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 46 | for of_port in config["port_map"].keys(): |
| 47 | logging.info("PacketInMiss test, port %d", of_port) |
| 48 | self.dataplane.send(of_port, vlan_pkt) |
| 49 | |
| 50 | verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH) |
| 51 | |
| 52 | verify_no_other_packets(self) |
| 53 | |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 54 | class PacketInUDP(base_tests.SimpleDataPlane): |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 55 | """ |
| 56 | Test packet in function for a table-miss flow |
| 57 | Send a packet to each dataplane port and verify that a packet |
| 58 | in message is received from the controller for each |
| 59 | |
| 60 | NOTE: Verify This case the oft option shall not use --switch-ip |
| 61 | """ |
| 62 | |
| 63 | def runTest(self): |
| 64 | delete_all_flows(self.controller) |
| 65 | delete_all_groups(self.controller) |
| 66 | |
| 67 | parsed_vlan_pkt = simple_udp_packet(pktlen=104, |
| 68 | vlan_vid=0x1001, dl_vlan_enable=True) |
| 69 | vlan_pkt = str(parsed_vlan_pkt) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 70 | # create match |
| 71 | match = ofp.match() |
| 72 | match.oxm_list.append(ofp.oxm.eth_type(0x0800)) |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 73 | match.oxm_list.append(ofp.oxm.ip_proto(17)) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 74 | request = ofp.message.flow_add( |
| 75 | table_id=60, |
| 76 | cookie=42, |
| 77 | match=match, |
| 78 | instructions=[ |
| 79 | ofp.instruction.apply_actions( |
| 80 | actions=[ |
| 81 | ofp.action.output( |
| 82 | port=ofp.OFPP_CONTROLLER, |
| 83 | max_len=ofp.OFPCML_NO_BUFFER)]), |
| 84 | ], |
| 85 | buffer_id=ofp.OFP_NO_BUFFER, |
| 86 | priority=1) |
| 87 | |
| 88 | logging.info("Inserting packet in flow to controller") |
| 89 | self.controller.message_send(request) |
| 90 | do_barrier(self.controller) |
| 91 | |
| 92 | for of_port in config["port_map"].keys(): |
| 93 | logging.info("PacketInMiss test, port %d", of_port) |
| 94 | self.dataplane.send(of_port, vlan_pkt) |
| 95 | |
| 96 | verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION) |
| 97 | |
| 98 | verify_no_other_packets(self) |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 99 | @disabled |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 100 | class PacketInIPTable(base_tests.SimpleDataPlane): |
| 101 | """ |
| 102 | Test packet in function on IPTABLE |
| 103 | Send a packet to each dataplane port and verify that a packet |
| 104 | in message is received from the controller for each |
| 105 | #todo verify you stop receiving after adding rule |
| 106 | """ |
| 107 | |
| 108 | def runTest(self): |
| 109 | delete_all_flows(self.controller) |
| 110 | delete_all_groups(self.controller) |
| 111 | |
| 112 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 113 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 114 | dip=0xc0a80001 |
| 115 | ports = sorted(config["port_map"].keys()) |
| 116 | for port in ports: |
| 117 | #add l2 interface group |
| 118 | vlan_id=port |
| 119 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False) |
| 120 | dst_mac[5]=vlan_id |
| 121 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 122 | #add vlan flow table |
| 123 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 124 | #add termination flow |
| 125 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 126 | #add unicast routing flow |
| 127 | dst_ip = dip + (vlan_id<<8) |
| 128 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xfffffff0, l3_msg.group_id, send_ctrl=True) |
| 129 | |
| 130 | do_barrier(self.controller) |
| 131 | |
| 132 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 133 | for in_port in ports: |
| 134 | mac_src='00:00:00:22:22:%02X' % in_port |
| 135 | ip_src='192.168.%02d.1' % in_port |
| 136 | for out_port in ports: |
| 137 | if in_port == out_port: |
| 138 | continue |
| 139 | ip_dst='192.168.%02d.1' % out_port |
| 140 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 141 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 142 | ip_dst=ip_dst) |
| 143 | pkt=str(parsed_pkt) |
| 144 | self.dataplane.send(in_port, pkt) |
| 145 | verify_packet_in(self, pkt, in_port, ofp.OFPR_ACTION) |
| 146 | #verify_no_other_packets(self) |
| 147 | |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 148 | @disabled |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 149 | class ArpNL2(base_tests.SimpleDataPlane): |
| 150 | def runTest(self): |
| 151 | delete_all_flows(self.controller) |
| 152 | delete_all_groups(self.controller) |
| 153 | |
| 154 | ports = sorted(config["port_map"].keys()) |
| 155 | match = ofp.match() |
| 156 | match.oxm_list.append(ofp.oxm.eth_type(0x0806)) |
| 157 | request = ofp.message.flow_add( |
| 158 | table_id=60, |
| 159 | cookie=42, |
| 160 | match=match, |
| 161 | instructions=[ |
| 162 | ofp.instruction.apply_actions( |
| 163 | actions=[ |
| 164 | ofp.action.output( |
| 165 | port=ofp.OFPP_CONTROLLER, |
| 166 | max_len=ofp.OFPCML_NO_BUFFER)]), |
| 167 | ], |
| 168 | buffer_id=ofp.OFP_NO_BUFFER, |
| 169 | priority=40000) |
| 170 | self.controller.message_send(request) |
| 171 | for port in ports: |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 172 | add_one_l2_interface_group(self.controller, port, 1, False, False) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 173 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 174 | group_id = encode_l2_interface_group_id(1, port) |
| 175 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 176 | do_barrier(self.controller) |
| 177 | parsed_arp_pkt = simple_arp_packet() |
| 178 | arp_pkt = str(parsed_arp_pkt) |
| 179 | |
| 180 | for out_port in ports: |
| 181 | self.dataplane.send(out_port, arp_pkt) |
| 182 | verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION) |
| 183 | # change dest based on port number |
| 184 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 185 | for in_port in ports: |
| 186 | if in_port == out_port: |
| 187 | continue |
| 188 | # change source based on port number to avoid packet-ins from learning |
| 189 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 190 | parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src) |
| 191 | pkt = str(parsed_pkt) |
| 192 | self.dataplane.send(in_port, pkt) |
| 193 | |
| 194 | for ofport in ports: |
| 195 | if ofport in [out_port]: |
| 196 | verify_packet(self, pkt, ofport) |
| 197 | else: |
| 198 | verify_no_packet(self, pkt, ofport) |
| 199 | |
| 200 | verify_no_other_packets(self) |
| 201 | |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 202 | class PacketInArp(base_tests.SimpleDataPlane): |
| 203 | """ |
| 204 | Test packet in function for a table-miss flow |
| 205 | Send a packet to each dataplane port and verify that a packet |
| 206 | in message is received from the controller for each |
| 207 | |
| 208 | NOTE: Verify This case the oft option shall not use --switch-ip |
| 209 | """ |
| 210 | |
| 211 | def runTest(self): |
| 212 | delete_all_flows(self.controller) |
| 213 | delete_all_groups(self.controller) |
| 214 | |
| 215 | parsed_arp_pkt = simple_arp_packet() |
| 216 | arp_pkt = str(parsed_arp_pkt) |
| 217 | ports = sorted(config["port_map"].keys()) |
| 218 | #for port in ports: |
| 219 | # add_one_l2_interface_group(self.controller, port, 1, True, False) |
| 220 | # add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 221 | |
| 222 | # create match |
| 223 | match = ofp.match() |
| 224 | match.oxm_list.append(ofp.oxm.eth_type(0x0806)) |
| 225 | request = ofp.message.flow_add( |
| 226 | table_id=60, |
| 227 | cookie=42, |
| 228 | match=match, |
| 229 | instructions=[ |
| 230 | ofp.instruction.apply_actions( |
| 231 | actions=[ |
| 232 | ofp.action.output( |
| 233 | port=ofp.OFPP_CONTROLLER, |
| 234 | max_len=ofp.OFPCML_NO_BUFFER)]), |
| 235 | ], |
| 236 | buffer_id=ofp.OFP_NO_BUFFER, |
| 237 | priority=1) |
| 238 | |
| 239 | logging.info("Inserting packet in flow to controller") |
| 240 | self.controller.message_send(request) |
| 241 | do_barrier(self.controller) |
| 242 | |
| 243 | for of_port in config["port_map"].keys(): |
| 244 | logging.info("PacketInMiss test, port %d", of_port) |
| 245 | self.dataplane.send(of_port, arp_pkt) |
| 246 | |
| 247 | verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION) |
| 248 | |
| 249 | verify_no_other_packets(self) |
| 250 | |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 251 | class L2FloodQinQ(base_tests.SimpleDataPlane): |
| 252 | """ |
Flavio Castro | c36621e | 2015-12-08 12:57:07 -0500 | [diff] [blame] | 253 | Test L2 flood of double tagged vlan packets (802.1Q) |
| 254 | Sends a double tagged packet and verifies flooding behavior according to outer vlan |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 255 | """ |
| 256 | def runTest(self): |
| 257 | ports = sorted(config["port_map"].keys()) |
| 258 | |
| 259 | delete_all_flows(self.controller) |
| 260 | delete_all_groups(self.controller) |
| 261 | |
| 262 | # Installing flows to avoid packet-in |
| 263 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 264 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 265 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 266 | |
| 267 | group_id = encode_l2_interface_group_id(1, port) |
| 268 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 269 | msg=add_l2_flood_group(self.controller, ports, 1, 1) |
| 270 | add_bridge_flow(self.controller, None, 1, msg.group_id, True) |
| 271 | do_barrier(self.controller) |
| 272 | |
| 273 | #verify flood |
| 274 | for ofport in ports: |
| 275 | # change dest based on port number |
| 276 | mac_src= '00:12:34:56:78:%02X' % ofport |
| 277 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=1, |
| 278 | in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 279 | pkt = str(parsed_pkt) |
| 280 | self.dataplane.send(ofport, pkt) |
| 281 | #self won't rx packet |
| 282 | verify_no_packet(self, pkt, ofport) |
| 283 | #others will rx packet |
| 284 | tmp_ports=list(ports) |
| 285 | tmp_ports.remove(ofport) |
| 286 | verify_packets(self, pkt, tmp_ports) |
| 287 | |
| 288 | verify_no_other_packets(self) |
| 289 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 290 | class L2FloodTagged(base_tests.SimpleDataPlane): |
| 291 | """ |
| 292 | Test L2 flood to a vlan |
| 293 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
| 294 | #todo take in account unknown src |
| 295 | """ |
| 296 | def runTest(self): |
| 297 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 298 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 299 | delete_all_flows(self.controller) |
| 300 | delete_all_groups(self.controller) |
| 301 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 302 | # Installing flows to avoid packet-in |
| 303 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 304 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 305 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 306 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 307 | group_id = encode_l2_interface_group_id(1, port) |
| 308 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 309 | msg=add_l2_flood_group(self.controller, ports, 1, 1) |
| 310 | add_bridge_flow(self.controller, None, 1, msg.group_id, True) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 311 | do_barrier(self.controller) |
| 312 | |
| 313 | #verify flood |
| 314 | for ofport in ports: |
| 315 | # change dest based on port number |
| 316 | mac_src= '00:12:34:56:78:%02X' % ofport |
| 317 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 318 | pkt = str(parsed_pkt) |
| 319 | self.dataplane.send(ofport, pkt) |
| 320 | #self won't rx packet |
| 321 | verify_no_packet(self, pkt, ofport) |
| 322 | #others will rx packet |
| 323 | tmp_ports=list(ports) |
| 324 | tmp_ports.remove(ofport) |
| 325 | verify_packets(self, pkt, tmp_ports) |
| 326 | |
| 327 | verify_no_other_packets(self) |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 328 | @disabled |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 329 | class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane): |
| 330 | """ |
| 331 | Test L2 flood to a vlan |
| 332 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
| 333 | #todo take in account unknown src |
| 334 | """ |
| 335 | def runTest(self): |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 336 | delete_all_flows(self.controller) |
| 337 | delete_all_groups(self.controller) |
| 338 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 339 | ports = sorted(config["port_map"].keys()) |
| 340 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 341 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 342 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 343 | |
| 344 | msg=add_l2_flood_group(self.controller, ports, 1, 1) |
| 345 | add_bridge_flow(self.controller, None, 1, msg.group_id, True) |
| 346 | |
| 347 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a') |
| 348 | pkt = str(parsed_pkt) |
| 349 | #verify flood |
| 350 | for ofport in ports: |
| 351 | self.dataplane.send(ofport, pkt) |
| 352 | #self won't rx packet |
| 353 | verify_no_packet(self, pkt, ofport) |
| 354 | #others will rx packet |
| 355 | tmp_ports=list(ports) |
| 356 | tmp_ports.remove(ofport) |
| 357 | verify_packets(self, pkt, tmp_ports) |
| 358 | |
| 359 | verify_no_other_packets(self) |
| 360 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 361 | class L2UnicastTagged(base_tests.SimpleDataPlane): |
| 362 | """ |
| 363 | Test output function for an exact-match flow |
| 364 | |
| 365 | For each port A, adds a flow directing matching packets to that port. |
| 366 | Then, for all other ports B != A, verifies that sending a matching packet |
| 367 | to B results in an output to A. |
| 368 | """ |
| 369 | def runTest(self): |
| 370 | ports = sorted(config["port_map"].keys()) |
| 371 | |
| 372 | delete_all_flows(self.controller) |
| 373 | delete_all_groups(self.controller) |
| 374 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 375 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 376 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 377 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 378 | group_id = encode_l2_interface_group_id(1, port) |
| 379 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 380 | do_barrier(self.controller) |
| 381 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 382 | for out_port in ports: |
| 383 | # change dest based on port number |
| 384 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 385 | for in_port in ports: |
| 386 | if in_port == out_port: |
| 387 | continue |
| 388 | # change source based on port number to avoid packet-ins from learning |
| 389 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 390 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 391 | pkt = str(parsed_pkt) |
| 392 | self.dataplane.send(in_port, pkt) |
| 393 | |
| 394 | for ofport in ports: |
| 395 | if ofport in [out_port]: |
| 396 | verify_packet(self, pkt, ofport) |
| 397 | else: |
| 398 | verify_no_packet(self, pkt, ofport) |
| 399 | |
| 400 | verify_no_other_packets(self) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 401 | |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 402 | class Mtu1500(base_tests.SimpleDataPlane): |
| 403 | |
| 404 | def runTest(self): |
| 405 | ports = sorted(config["port_map"].keys()) |
| 406 | |
| 407 | delete_all_flows(self.controller) |
| 408 | delete_all_groups(self.controller) |
| 409 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 410 | # set up tag groups for each port |
Flavio Castro | d4c44d1 | 2015-12-08 14:44:18 -0500 | [diff] [blame] | 411 | add_l2_interface_group(self.controller, ports, 1, True, 1) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 412 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 413 | add_vlan_table_flow(self.controller, ports) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 414 | |
| 415 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 416 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 417 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 418 | group_id = encode_l2_interface_group_id(1, port) |
| 419 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 420 | do_barrier(self.controller) |
| 421 | |
| 422 | for out_port in ports: |
| 423 | # change dest based on port number |
| 424 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 425 | for in_port in ports: |
| 426 | if in_port == out_port: |
| 427 | continue |
| 428 | # change source based on port number to avoid packet-ins from learning |
| 429 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 430 | parsed_pkt = simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 431 | pkt = str(parsed_pkt) |
| 432 | self.dataplane.send(in_port, pkt) |
| 433 | |
| 434 | for ofport in ports: |
| 435 | if ofport in [out_port]: |
| 436 | verify_packet(self, pkt, ofport) |
| 437 | else: |
| 438 | verify_no_packet(self, pkt, ofport) |
| 439 | |
| 440 | verify_no_other_packets(self) |
| 441 | |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 442 | @disabled |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 443 | class Mtu4000(base_tests.SimpleDataPlane): |
| 444 | """ |
| 445 | Test output function for an exact-match flow |
| 446 | For each port A, adds a flow directing matching packets to that port. |
| 447 | Then, for all other ports B != A, verifies that sending a matching packet |
| 448 | to B results in an output to A. |
| 449 | """ |
| 450 | def runTest(self): |
| 451 | ports = sorted(config["port_map"].keys()) |
| 452 | |
| 453 | delete_all_flows(self.controller) |
| 454 | delete_all_groups(self.controller) |
| 455 | |
| 456 | add_vlan_table_flow(self.controller, config["port_map"].keys()) |
| 457 | |
| 458 | # set up tag groups for each port |
Flavio Castro | d4c44d1 | 2015-12-08 14:44:18 -0500 | [diff] [blame] | 459 | add_l2_interface_group(self.controller, config["port_map"].keys(), 1, True, 1) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 460 | |
| 461 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 462 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 463 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 464 | group_id = encode_l2_interface_group_id(1, port) |
| 465 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 466 | do_barrier(self.controller) |
| 467 | |
| 468 | for out_port in ports: |
| 469 | # change dest based on port number |
| 470 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 471 | for in_port in ports: |
| 472 | if in_port == out_port: |
| 473 | continue |
| 474 | # change source based on port number to avoid packet-ins from learning |
| 475 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 476 | parsed_pkt = simple_tcp_packet(pktlen=4000,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 477 | pkt = str(parsed_pkt) |
| 478 | self.dataplane.send(in_port, pkt) |
| 479 | |
| 480 | for ofport in ports: |
| 481 | if ofport in [out_port]: |
| 482 | verify_packet(self, pkt, ofport) |
| 483 | else: |
| 484 | verify_no_packet(self, pkt, ofport) |
| 485 | |
| 486 | verify_no_other_packets(self) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 487 | |
| 488 | class L3UcastTagged(base_tests.SimpleDataPlane): |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 489 | """ |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 490 | Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) , |
| 491 | Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 492 | """ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 493 | def runTest(self): |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 494 | delete_all_flows(self.controller) |
| 495 | delete_all_groups(self.controller) |
| 496 | |
| 497 | if len(config["port_map"]) <2: |
| 498 | logging.info("Port count less than 2, can't run this case") |
| 499 | return |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 500 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 501 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 502 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 503 | dip=0xc0a80001 |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 504 | ports = config["port_map"].keys() |
| 505 | for port in ports: |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 506 | #add l2 interface group |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 507 | vlan_id=port |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 508 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 509 | dst_mac[5]=vlan_id |
| 510 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 511 | #add vlan flow table |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 512 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 513 | #add termination flow |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 514 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 515 | #add unicast routing flow |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 516 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 517 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 518 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 519 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 520 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 521 | |
| 522 | do_barrier(self.controller) |
| 523 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 524 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 525 | for in_port in ports: |
| 526 | mac_src='00:00:00:22:22:%02X' % in_port |
| 527 | ip_src='192.168.%02d.1' % in_port |
| 528 | for out_port in ports: |
| 529 | if in_port == out_port: |
| 530 | continue |
| 531 | ip_dst='192.168.%02d.1' % out_port |
| 532 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 533 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 534 | ip_dst=ip_dst) |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 535 | pkt=str(parsed_pkt) |
| 536 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 537 | #build expected packet |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 538 | mac_dst='00:00:00:22:22:%02X' % out_port |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 539 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 540 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 541 | ip_src=ip_src, ip_dst=ip_dst) |
| 542 | pkt=str(exp_pkt) |
| 543 | verify_packet(self, pkt, out_port) |
| 544 | verify_no_other_packets(self) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 545 | |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 546 | class L3VPNMPLS(base_tests.SimpleDataPlane): |
| 547 | """ |
| 548 | Insert IP packet |
| 549 | Receive MPLS packet |
| 550 | """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 551 | def runTest(self): |
| 552 | delete_all_flows(self.controller) |
| 553 | delete_all_groups(self.controller) |
| 554 | |
| 555 | if len(config["port_map"]) <2: |
| 556 | logging.info("Port count less than 2, can't run this case") |
| 557 | return |
| 558 | |
| 559 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 560 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 561 | dip=0xc0a80001 |
| 562 | index=1 |
| 563 | ports = config["port_map"].keys() |
| 564 | for port in ports: |
| 565 | #add l2 interface group |
| 566 | vlan_id=port |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 567 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 568 | dst_mac[5]=vlan_id |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 569 | #add MPLS interface group |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 570 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port) |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 571 | #add MPLS L3 VPN group |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 572 | mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 573 | index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32) |
Flavio Castro | 5edf313 | 2016-01-27 15:45:08 -0500 | [diff] [blame] | 574 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 575 | do_barrier(self.controller) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 576 | #add vlan flow table |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 577 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 578 | #add termination flow |
| 579 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 580 | #add routing flow |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 581 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 5edf313 | 2016-01-27 15:45:08 -0500 | [diff] [blame] | 582 | #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 583 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, vrf=2) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 584 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 585 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 586 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 587 | |
| 588 | do_barrier(self.controller) |
| 589 | |
| 590 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 591 | for in_port in ports: |
| 592 | mac_src='00:00:00:22:22:%02X' % in_port |
| 593 | ip_src='192.168.%02d.1' % in_port |
| 594 | for out_port in ports: |
| 595 | if in_port == out_port: |
| 596 | continue |
| 597 | ip_dst='192.168.%02d.1' % out_port |
| 598 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 599 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 600 | ip_dst=ip_dst) |
| 601 | pkt=str(parsed_pkt) |
| 602 | self.dataplane.send(in_port, pkt) |
| 603 | #build expect packet |
| 604 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 605 | label = (out_port, 0, 1, 32) |
| 606 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src, |
| 607 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 608 | pkt=str(exp_pkt) |
| 609 | verify_packet(self, pkt, out_port) |
| 610 | verify_no_other_packets(self) |
castroflavio | ee29484 | 2016-01-06 15:54:28 -0800 | [diff] [blame] | 611 | |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 612 | |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 613 | class _32VPN(base_tests.SimpleDataPlane): |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 614 | """ |
| 615 | Insert IP packet |
| 616 | Receive MPLS packet |
| 617 | """ |
| 618 | def runTest(self): |
| 619 | delete_all_flows(self.controller) |
| 620 | delete_all_groups(self.controller) |
| 621 | |
| 622 | if len(config["port_map"]) <2: |
| 623 | logging.info("Port count less than 2, can't run this case") |
| 624 | return |
| 625 | |
| 626 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 627 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 628 | dip=0xc0a80001 |
| 629 | index=1 |
| 630 | ports = config["port_map"].keys() |
| 631 | for port in ports: |
| 632 | #add l2 interface group |
| 633 | vlan_id=port |
| 634 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True) |
| 635 | dst_mac[5]=vlan_id |
| 636 | #add MPLS interface group |
| 637 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port) |
| 638 | #add MPLS L3 VPN group |
| 639 | mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 640 | index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32) |
| 641 | #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 642 | do_barrier(self.controller) |
| 643 | #add vlan flow table |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 644 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 645 | #add termination flow |
| 646 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 647 | #add routing flow |
| 648 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 649 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 650 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 651 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 652 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 653 | |
| 654 | do_barrier(self.controller) |
| 655 | |
| 656 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 657 | for in_port in ports: |
| 658 | mac_src='00:00:00:22:22:%02X' % in_port |
| 659 | ip_src='192.168.%02d.1' % in_port |
| 660 | for out_port in ports: |
| 661 | if in_port == out_port: |
| 662 | continue |
| 663 | ip_dst='192.168.%02d.1' % out_port |
| 664 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 665 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 666 | ip_dst=ip_dst) |
| 667 | pkt=str(parsed_pkt) |
| 668 | self.dataplane.send(in_port, pkt) |
| 669 | #build expect packet |
| 670 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 671 | label = (out_port, 0, 1, 32) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 672 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src, |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 673 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 674 | pkt=str(exp_pkt) |
| 675 | verify_packet(self, pkt, out_port) |
| 676 | verify_no_other_packets(self) |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 677 | @disabled |
| 678 | class UniqueMplsTermination(base_tests.SimpleDataPlane): |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 679 | """ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 680 | Insert IP packet |
| 681 | Receive MPLS packet |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 682 | """ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 683 | def runTest(self): |
| 684 | delete_all_flows(self.controller) |
| 685 | delete_all_groups(self.controller) |
| 686 | |
| 687 | if len(config["port_map"]) <2: |
| 688 | logging.info("Port count less than 2, can't run this case") |
| 689 | return |
| 690 | |
| 691 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 692 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 693 | mcast_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x01] |
| 694 | |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 695 | dip=0xc0a80001 |
| 696 | index=1 |
| 697 | ports = config["port_map"].keys() |
| 698 | for port in ports: |
| 699 | #add l2 interface group |
| 700 | vlan_id=port |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 701 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 702 | dst_mac[5]=vlan_id |
| 703 | #add L3 Unicast group |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 704 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 705 | #add L3 ecmp group |
| 706 | ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id]) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 707 | #add vlan flow table |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 708 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 709 | #add termination flow |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 710 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 711 | #add routing flow |
| 712 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 713 | add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 714 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 715 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 716 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 717 | |
| 718 | do_barrier(self.controller) |
| 719 | |
| 720 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 721 | for in_port in ports: |
| 722 | mac_src='00:00:00:22:22:%02X' % in_port |
| 723 | ip_src='192.168.%02d.1' % in_port |
| 724 | for out_port in ports: |
| 725 | if in_port == out_port: |
| 726 | continue |
| 727 | ip_dst='192.168.%02d.1' % out_port |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 728 | |
| 729 | label = (out_port, 0, 1, 32) |
| 730 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 731 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label]) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 732 | pkt=str(parsed_pkt) |
| 733 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 734 | |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 735 | #build expect packet |
| 736 | mac_dst='00:00:00:22:22:%02X' % out_port |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 737 | mcast='01:00:5e:00:00:01' |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 738 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 739 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 740 | pkt=str(exp_pkt) |
| 741 | verify_packet(self, pkt, out_port) |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 742 | verify_no_other_packets(self) |
| 743 | |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 744 | class MPLSBUG(base_tests.SimpleDataPlane): |
| 745 | |
| 746 | def runTest(self): |
| 747 | delete_all_flows(self.controller) |
| 748 | delete_all_groups(self.controller) |
| 749 | |
| 750 | if len(config["port_map"]) <2: |
| 751 | logging.info("Port count less than 2, can't run this case") |
| 752 | return |
| 753 | |
| 754 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 755 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 756 | dip=0xc0a80001 |
| 757 | index=1 |
| 758 | ports = config["port_map"].keys() |
| 759 | for port in ports: |
| 760 | #add l2 interface group |
| 761 | vlan_id=port |
| 762 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 763 | dst_mac[5]=vlan_id |
| 764 | #add L3 Unicast group |
| 765 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 766 | #add vlan flow table |
| 767 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 768 | #add termination flow |
| 769 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24) |
| 770 | #add mpls flow |
| 771 | add_mpls_flow(self.controller, l3_msg.group_id, port) |
| 772 | #add termination flow |
| 773 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 774 | #add unicast routing flow |
| 775 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 776 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 777 | |
| 778 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 779 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 780 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 781 | |
| 782 | do_barrier(self.controller) |
| 783 | |
| 784 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 785 | for in_port in ports: |
| 786 | mac_src='00:00:00:22:22:%02X' % in_port |
| 787 | ip_src='192.168.%02d.1' % in_port |
| 788 | for out_port in ports: |
| 789 | if in_port == out_port: |
| 790 | continue |
| 791 | ip_dst='192.168.%02d.1' % out_port |
| 792 | switch_mac = "00:00:00:cc:cc:cc" |
| 793 | label = (out_port, 0, 1, 32) |
| 794 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 795 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label]) |
| 796 | pkt=str(parsed_pkt) |
| 797 | self.dataplane.send(in_port, pkt) |
| 798 | |
| 799 | #build expect packet |
| 800 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 801 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 802 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst) |
| 803 | pkt=str(exp_pkt) |
| 804 | verify_packet(self, pkt, out_port) |
| 805 | verify_no_other_packets(self) |
| 806 | |
| 807 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 808 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 809 | ip_dst=ip_dst) |
| 810 | pkt=str(parsed_pkt) |
| 811 | self.dataplane.send(in_port, pkt) |
| 812 | #build expected packet |
| 813 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 814 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 815 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 816 | ip_src=ip_src, ip_dst=ip_dst) |
| 817 | pkt=str(exp_pkt) |
| 818 | verify_packet(self, pkt, out_port) |
| 819 | verify_no_other_packets(self) |
| 820 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 821 | class L3McastToL2(base_tests.SimpleDataPlane): |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 822 | """ |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 823 | Mcast routing to L2 |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 824 | """ |
| 825 | def runTest(self): |
| 826 | """ |
| 827 | port1 (vlan 300)-> All Ports (vlan 300) |
| 828 | """ |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 829 | #delete_all_flows(self.controller) |
| 830 | #delete_all_groups(self.controller) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 831 | |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 832 | if len(config["port_map"]) <3: |
| 833 | logging.info("Port count less than 3, can't run this case") |
| 834 | assert(False) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 835 | return |
| 836 | |
| 837 | vlan_id =300 |
| 838 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 839 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 840 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 841 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 842 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 843 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 844 | src_ip=0xc0a80101 |
| 845 | src_ip_str="192.168.1.1" |
| 846 | dst_ip=0xe0010101 |
| 847 | dst_ip_str="224.1.1.1" |
| 848 | |
| 849 | port1=config["port_map"].keys()[0] |
| 850 | port2=config["port_map"].keys()[1] |
| 851 | |
| 852 | switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00] |
| 853 | |
| 854 | |
| 855 | #add l2 interface group |
| 856 | l2_intf_group_list=[] |
| 857 | for port in config["port_map"].keys(): |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 858 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=4) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 859 | if port == port2: |
| 860 | continue |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 861 | l2_intf_gid, msg=add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 862 | l2_intf_group_list.append(l2_intf_gid) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 863 | |
| 864 | #add termination flow |
| 865 | add_termination_flow(self.controller, port1, 0x0800, switch_mac, vlan_id) |
| 866 | |
| 867 | #add l3 interface group |
| 868 | mcat_group_msg=add_l3_mcast_group(self.controller, vlan_id, 2, l2_intf_group_list) |
| 869 | add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
| 870 | |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 871 | parsed_pkt = simple_udp_packet(pktlen=100, |
| 872 | dl_vlan_enable=True, |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 873 | eth_dst=dst_mac_str, |
| 874 | eth_src=port1_mac_str, |
| 875 | ip_ttl=64, |
| 876 | ip_src=src_ip_str, |
| 877 | ip_dst=dst_ip_str) |
| 878 | pkt=str(parsed_pkt) |
| 879 | self.dataplane.send(port1, pkt) |
| 880 | for port in config["port_map"].keys(): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 881 | if port == port2 or port == port1: |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 882 | verify_no_packet(self, pkt, port) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 883 | continue |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 884 | verify_packet(self, pkt, port) |
| 885 | verify_no_other_packets(self) |
| 886 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 887 | class L3McastToL3(base_tests.SimpleDataPlane): |
| 888 | """ |
| 889 | Mcast routing |
| 890 | """ |
| 891 | def runTest(self): |
| 892 | """ |
| 893 | port1 (vlan 1)-> port 2 (vlan 2) |
| 894 | """ |
| 895 | delete_all_flows(self.controller) |
| 896 | delete_all_groups(self.controller) |
| 897 | |
| 898 | if len(config["port_map"]) <3: |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 899 | logging.info("Port count less than 3, can't run this case") |
| 900 | assert(False) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 901 | return |
| 902 | |
| 903 | vlan_id =1 |
| 904 | port2_out_vlan=2 |
| 905 | port3_out_vlan=3 |
| 906 | in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 907 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 908 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 909 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 910 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 911 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 912 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 913 | src_ip=0xc0a80101 |
| 914 | src_ip_str="192.168.1.1" |
| 915 | dst_ip=0xe0010101 |
| 916 | dst_ip_str="224.1.1.1" |
| 917 | |
| 918 | port1=config["port_map"].keys()[0] |
| 919 | port2=config["port_map"].keys()[1] |
| 920 | port3=config["port_map"].keys()[2] |
| 921 | |
| 922 | #add l2 interface group |
| 923 | for port in config["port_map"].keys(): |
| 924 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False) |
| 925 | #add vlan flow table |
| 926 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 927 | vlan_id +=1 |
| 928 | |
| 929 | #add termination flow |
| 930 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
| 931 | |
| 932 | #add l3 interface group |
| 933 | port2_ucast_msg=add_l3_interface_group(self.controller, port2, port2_out_vlan, 2, intf_src_mac) |
| 934 | port3_ucast_msg=add_l3_interface_group(self.controller, port3, port3_out_vlan, 3, intf_src_mac) |
| 935 | mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [port2_ucast_msg.group_id, port3_ucast_msg.group_id]) |
| 936 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
| 937 | |
| 938 | parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1, |
| 939 | eth_dst=dst_mac_str, |
| 940 | eth_src=port1_mac_str, |
| 941 | ip_ttl=64, |
| 942 | ip_src=src_ip_str, |
| 943 | ip_dst=dst_ip_str) |
| 944 | pkt=str(parsed_pkt) |
| 945 | self.dataplane.send(port1, pkt) |
| 946 | parsed_pkt = simple_udp_packet(pktlen=96, |
| 947 | eth_dst=dst_mac_str, |
| 948 | eth_src=intf_src_mac_str, |
| 949 | ip_ttl=63, |
| 950 | ip_src=src_ip_str, |
| 951 | ip_dst=dst_ip_str) |
| 952 | pkt=str(parsed_pkt) |
| 953 | verify_packet(self, pkt, port2) |
| 954 | verify_packet(self, pkt, port3) |
| 955 | verify_no_other_packets(self) |
| 956 | |
| 957 | class L3McastToVPN(base_tests.SimpleDataPlane): |
| 958 | """ |
| 959 | Mcast routing |
| 960 | """ |
| 961 | def runTest(self): |
| 962 | """ |
| 963 | port1 (vlan 1)-> port 2 (vlan 2) |
| 964 | """ |
| 965 | #delete_all_flows(self.controller) |
| 966 | #delete_all_groups(self.controller) |
| 967 | |
| 968 | if len(config["port_map"]) <3: |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 969 | logging.info("Port count less than 3, can't run this case") |
| 970 | assert(False) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 971 | return |
| 972 | |
| 973 | vlan_id =1 |
| 974 | port2_out_vlan=2 |
| 975 | port3_out_vlan=3 |
| 976 | in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 977 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 978 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 979 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 980 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 981 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 982 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 983 | src_ip=0xc0a80101 |
| 984 | src_ip_str="192.168.1.1" |
| 985 | dst_ip=0xe0010101 |
| 986 | dst_ip_str="224.1.1.1" |
| 987 | |
| 988 | port1=config["port_map"].keys()[0] |
| 989 | port2=config["port_map"].keys()[1] |
| 990 | port3=config["port_map"].keys()[2] |
| 991 | |
| 992 | #add l2 interface group |
| 993 | for port in config["port_map"].keys(): |
| 994 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False) |
| 995 | #add vlan flow table |
| 996 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 997 | vlan_id +=1 |
| 998 | |
| 999 | #add termination flow |
| 1000 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
| 1001 | |
| 1002 | #add MPLS interface group |
| 1003 | l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2) |
| 1004 | mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2) |
| 1005 | l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 1006 | mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 1007 | #add L3VPN groups |
| 1008 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 1009 | index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True) |
| 1010 | mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 1011 | index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
| 1012 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1013 | mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023]) |
| 1014 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
| 1015 | |
| 1016 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1, |
| 1017 | eth_dst=dst_mac_str, |
| 1018 | eth_src=port1_mac_str, |
| 1019 | ip_ttl=64, |
| 1020 | ip_src=src_ip_str, |
| 1021 | ip_dst=dst_ip_str) |
| 1022 | pkt=str(parsed_pkt) |
| 1023 | self.dataplane.send(port1, pkt) |
| 1024 | label = (in_vlan, 0, 1, 63) |
| 1025 | parsed_pkt = mpls_packet(pktlen=100, |
| 1026 | eth_dst=dst_mac_str, |
| 1027 | eth_src=intf_src_mac_str, |
| 1028 | ip_ttl=63, |
| 1029 | ip_src=src_ip_str, label= [label], |
| 1030 | ip_dst=dst_ip_str) |
| 1031 | pkt=str(parsed_pkt) |
| 1032 | verify_packet(self, pkt, port2) |
| 1033 | verify_packet(self, pkt, port3) |
| 1034 | verify_no_other_packets(self) |
Flavio Castro | f2ff2d3 | 2016-02-03 14:22:14 -0500 | [diff] [blame^] | 1035 | @disabled |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1036 | class LPM(base_tests.SimpleDataPlane): |
| 1037 | """ |
| 1038 | Insert IP packet |
| 1039 | Receive MPLS packet |
| 1040 | """ |
| 1041 | def runTest(self): |
| 1042 | delete_all_flows(self.controller) |
| 1043 | delete_all_groups(self.controller) |
| 1044 | |
| 1045 | if len(config["port_map"]) <2: |
| 1046 | logging.info("Port count less than 2, can't run this case") |
| 1047 | return |
| 1048 | |
| 1049 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1050 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1051 | dip=0xc0a80001 |
| 1052 | index=1 |
| 1053 | ports = config["port_map"].keys() |
| 1054 | for port in ports: |
| 1055 | #add l2 interface group |
| 1056 | vlan_id=port |
| 1057 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True) |
| 1058 | dst_mac[5]=vlan_id |
| 1059 | #add MPLS interface group |
| 1060 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port) |
| 1061 | #add MPLS L3 VPN group |
| 1062 | mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 1063 | index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32) |
Flavio Castro | 5edf313 | 2016-01-27 15:45:08 -0500 | [diff] [blame] | 1064 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1065 | do_barrier(self.controller) |
| 1066 | #add vlan flow table |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1067 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1068 | #add termination flow |
| 1069 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 1070 | #add routing flow |
| 1071 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 5edf313 | 2016-01-27 15:45:08 -0500 | [diff] [blame] | 1072 | #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid, vrf=2) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1073 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1074 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 1075 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 1076 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 1077 | port = ports[0] |
| 1078 | #add l2 interface group |
| 1079 | vlan_id=port |
| 1080 | l2_gid = encode_l2_interface_group_id(vlan_id, port) |
| 1081 | dst_mac[5]=vlan_id |
| 1082 | #add MPLS interface group |
| 1083 | mpls_gid = encode_mpls_interface_group_id(0, port) |
| 1084 | #add MPLS L3 VPN group |
| 1085 | mpls_label_gid = encode_mpls_label_group_id(OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=port) |
Flavio Castro | 5edf313 | 2016-01-27 15:45:08 -0500 | [diff] [blame] | 1086 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1087 | do_barrier(self.controller) |
| 1088 | #add routing flow |
| 1089 | dst_ip = 0x0 |
Flavio Castro | 5edf313 | 2016-01-27 15:45:08 -0500 | [diff] [blame] | 1090 | #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, mpls_label_gid, vrf=2) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1091 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, ecmp_msg.group_id) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1092 | |
| 1093 | do_barrier(self.controller) |
| 1094 | |
| 1095 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1096 | for in_port in ports: |
| 1097 | mac_src='00:00:00:22:22:%02X' % in_port |
| 1098 | ip_src='192.168.%02d.1' % in_port |
| 1099 | for out_port in ports: |
| 1100 | if in_port == out_port: |
| 1101 | continue |
| 1102 | ip_dst='192.168.%02d.1' % out_port |
| 1103 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1104 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 1105 | ip_dst=ip_dst) |
| 1106 | pkt=str(parsed_pkt) |
| 1107 | self.dataplane.send(in_port, pkt) |
| 1108 | #build expect packet |
| 1109 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 1110 | label = (out_port, 0, 1, 32) |
| 1111 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src, |
| 1112 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 1113 | pkt=str(exp_pkt) |
| 1114 | verify_packet(self, pkt, out_port) |
| 1115 | verify_no_other_packets(self) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1116 | ip_dst='1.168.%02d.1' % ports[0] |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1117 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1118 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst) |
| 1119 | pkt=str(parsed_pkt) |
| 1120 | self.dataplane.send(in_port, pkt) |
| 1121 | #build expect packet |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1122 | mac_dst='00:00:00:22:22:%02X' % ports[0] |
| 1123 | label = (ports[0], 0, 1, 32) |
| 1124 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=ports[0], ip_ttl=63, ip_src=ip_src, |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1125 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 1126 | pkt=str(exp_pkt) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 1127 | verify_packet(self, pkt, ports[0]) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1128 | verify_no_other_packets(self) |