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