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