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