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