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