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