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