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()) |
Flavio Castro | 8628adb | 2016-02-03 17:30:57 -0500 | [diff] [blame^] | 181 | #Hashes Test Name and uses it as id for installing unique groups |
| 182 | vlan_id=abs(hash(inspect.stack()[0][3])) % (256) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 183 | delete_all_flows(self.controller) |
| 184 | delete_all_groups(self.controller) |
| 185 | |
| 186 | # Installing flows to avoid packet-in |
| 187 | for port in ports: |
Flavio Castro | 8628adb | 2016-02-03 17:30:57 -0500 | [diff] [blame^] | 188 | add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 189 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 190 | |
Flavio Castro | 8628adb | 2016-02-03 17:30:57 -0500 | [diff] [blame^] | 191 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 192 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id, group_id, True) |
| 193 | msg=add_l2_flood_group(self.controller, ports, vlan_id, 2) |
| 194 | add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 195 | do_barrier(self.controller) |
| 196 | |
| 197 | #verify flood |
| 198 | for ofport in ports: |
| 199 | # change dest based on port number |
| 200 | mac_src= '00:12:34:56:78:%02X' % ofport |
Flavio Castro | 8628adb | 2016-02-03 17:30:57 -0500 | [diff] [blame^] | 201 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=vlan_id, |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 202 | in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 203 | pkt = str(parsed_pkt) |
| 204 | self.dataplane.send(ofport, pkt) |
| 205 | #self won't rx packet |
| 206 | verify_no_packet(self, pkt, ofport) |
| 207 | #others will rx packet |
| 208 | tmp_ports=list(ports) |
| 209 | tmp_ports.remove(ofport) |
| 210 | verify_packets(self, pkt, tmp_ports) |
| 211 | |
| 212 | verify_no_other_packets(self) |
| 213 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 214 | class L2FloodTagged(base_tests.SimpleDataPlane): |
| 215 | """ |
| 216 | Test L2 flood to a vlan |
| 217 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 218 | """ |
| 219 | def runTest(self): |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 220 | #Hashes Test Name and uses it as id for installing unique groups |
| 221 | vlan_id=abs(hash(inspect.stack()[0][3])) % (256) |
| 222 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 223 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 224 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 225 | delete_all_flows(self.controller) |
| 226 | delete_all_groups(self.controller) |
| 227 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 228 | # Installing flows to avoid packet-in |
| 229 | for port in ports: |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 230 | add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 231 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 232 | msg=add_l2_flood_group(self.controller, ports, vlan_id, 1) |
| 233 | add_bridge_flow(self.controller, None, vlan_id, 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 |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 239 | pkt = str( simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a') ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 240 | self.dataplane.send(ofport, pkt) |
| 241 | #self won't rx packet |
| 242 | verify_no_packet(self, pkt, ofport) |
| 243 | #others will rx packet |
| 244 | tmp_ports=list(ports) |
| 245 | tmp_ports.remove(ofport) |
| 246 | verify_packets(self, pkt, tmp_ports) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 247 | verify_no_other_packets(self) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 248 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 249 | class L2UnicastTagged(base_tests.SimpleDataPlane): |
| 250 | """ |
| 251 | Test output function for an exact-match flow |
| 252 | |
| 253 | For each port A, adds a flow directing matching packets to that port. |
| 254 | Then, for all other ports B != A, verifies that sending a matching packet |
| 255 | to B results in an output to A. |
| 256 | """ |
| 257 | def runTest(self): |
| 258 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 259 | #Hashes Test Name and uses it as id for installing unique groups |
| 260 | vlan_id=abs(hash(inspect.stack()[0][3])) % (256) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 261 | delete_all_flows(self.controller) |
| 262 | delete_all_groups(self.controller) |
| 263 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 264 | for port in ports: |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 265 | add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 266 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 267 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 268 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id, group_id, True) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 269 | do_barrier(self.controller) |
| 270 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 271 | for out_port in ports: |
| 272 | # change dest based on port number |
| 273 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 274 | for in_port in ports: |
| 275 | if in_port == out_port: |
| 276 | continue |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 277 | pkt = str( simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst)) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 278 | self.dataplane.send(in_port, pkt) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 279 | for ofport in ports: |
| 280 | if ofport in [out_port]: |
| 281 | verify_packet(self, pkt, ofport) |
| 282 | else: |
| 283 | verify_no_packet(self, pkt, ofport) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 284 | verify_no_other_packets(self) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 285 | |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 286 | class Mtu1500(base_tests.SimpleDataPlane): |
| 287 | |
| 288 | def runTest(self): |
| 289 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 290 | #Hashes Test Name and uses it as id for installing unique groups |
| 291 | vlan_id=abs(hash(inspect.stack()[0][3])) % (256) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 292 | delete_all_flows(self.controller) |
| 293 | delete_all_groups(self.controller) |
| 294 | |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 295 | for port in ports: |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 296 | add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 297 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 298 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 299 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id, group_id, True) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 300 | do_barrier(self.controller) |
| 301 | |
| 302 | for out_port in ports: |
| 303 | # change dest based on port number |
| 304 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 305 | for in_port in ports: |
| 306 | if in_port == out_port: |
| 307 | continue |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 308 | pkt = str(simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst)) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 309 | self.dataplane.send(in_port, pkt) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 310 | for ofport in ports: |
| 311 | if ofport in [out_port]: |
| 312 | verify_packet(self, pkt, ofport) |
| 313 | else: |
| 314 | verify_no_packet(self, pkt, ofport) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 315 | verify_no_other_packets(self) |
| 316 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 317 | class L3UcastTagged(base_tests.SimpleDataPlane): |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 318 | """ |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 319 | Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) , |
| 320 | 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] | 321 | """ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 322 | def runTest(self): |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 323 | delete_all_flows(self.controller) |
| 324 | delete_all_groups(self.controller) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 325 | #Hashes Test Name and uses it as id for installing unique groups |
| 326 | class_id=abs(hash(inspect.stack()[0][3])) % (256) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 327 | if len(config["port_map"]) <2: |
| 328 | logging.info("Port count less than 2, can't run this case") |
| 329 | return |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 330 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 331 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 332 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 333 | dip=0xc0a80001 |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 334 | ports = config["port_map"].keys() |
| 335 | for port in ports: |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 336 | #add l2 interface group |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 337 | vlan_id=port+class_id |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 338 | 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] | 339 | dst_mac[5]=vlan_id |
| 340 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 341 | #add vlan flow table |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 342 | 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] | 343 | #add termination flow |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 344 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 345 | #add unicast routing flow |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 346 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 347 | 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] | 348 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 349 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 350 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 351 | |
| 352 | do_barrier(self.controller) |
| 353 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 354 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 355 | for in_port in ports: |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 356 | mac_src='00:00:00:22:22:%02X' % (class_id+in_port) |
| 357 | ip_src='192.168.%02d.1' % (class_id+in_port) |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 358 | for out_port in ports: |
| 359 | if in_port == out_port: |
| 360 | continue |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 361 | ip_dst='192.168.%02d.1' % (class_id+out_port) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 362 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=(class_id+in_port), |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 363 | 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] | 364 | ip_dst=ip_dst) |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 365 | pkt=str(parsed_pkt) |
| 366 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 367 | #build expected packet |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 368 | mac_dst='00:00:00:22:22:%02X' % (class_id+out_port) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 369 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=(class_id+out_port), |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 370 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 371 | ip_src=ip_src, ip_dst=ip_dst) |
| 372 | pkt=str(exp_pkt) |
| 373 | verify_packet(self, pkt, out_port) |
| 374 | verify_no_other_packets(self) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 375 | |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 376 | class L3VPNMPLS(base_tests.SimpleDataPlane): |
| 377 | """ |
| 378 | Insert IP packet |
| 379 | Receive MPLS packet |
| 380 | """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 381 | def runTest(self): |
| 382 | delete_all_flows(self.controller) |
| 383 | delete_all_groups(self.controller) |
| 384 | |
| 385 | if len(config["port_map"]) <2: |
| 386 | logging.info("Port count less than 2, can't run this case") |
| 387 | return |
| 388 | |
| 389 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 390 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 391 | dip=0xc0a80001 |
Flavio Castro | 1732778 | 2016-02-03 15:20:15 -0500 | [diff] [blame] | 392 | #Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 393 | class_id=abs(hash(inspect.stack()[0][3])) % (200) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 394 | ports = config["port_map"].keys() |
| 395 | for port in ports: |
| 396 | #add l2 interface group |
Flavio Castro | 1732778 | 2016-02-03 15:20:15 -0500 | [diff] [blame] | 397 | id=port+class_id<<8 |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 398 | vlan_id=port+class_id |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 399 | 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] | 400 | dst_mac[5]=vlan_id |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 401 | #add MPLS interface group |
Flavio Castro | 1732778 | 2016-02-03 15:20:15 -0500 | [diff] [blame] | 402 | 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] | 403 | #add MPLS L3 VPN group |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 404 | 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] | 405 | index=id, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32) |
| 406 | ecmp_msg=add_l3_ecmp_group(self.controller, id, [mpls_label_gid]) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 407 | do_barrier(self.controller) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 408 | #add vlan flow table |
Flavio Castro | 1732778 | 2016-02-03 15:20:15 -0500 | [diff] [blame] | 409 | 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] | 410 | #add termination flow |
| 411 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 412 | #add routing flow |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 413 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 5edf313 | 2016-01-27 15:45:08 -0500 | [diff] [blame] | 414 | #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] | 415 | 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] | 416 | |
| 417 | do_barrier(self.controller) |
| 418 | |
| 419 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 420 | for in_port in ports: |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 421 | mac_src='00:00:00:22:22:%02X' % (class_id+in_port) |
| 422 | ip_src='192.168.%02d.1' (class_id+in_port) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 423 | for out_port in ports: |
| 424 | if in_port == out_port: |
| 425 | continue |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 426 | ip_dst='192.168.%02d.1' % (class_id+out_port) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 427 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=(class_id+in_port), |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 428 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 429 | ip_dst=ip_dst) |
| 430 | pkt=str(parsed_pkt) |
| 431 | self.dataplane.send(in_port, pkt) |
| 432 | #build expect packet |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 433 | mac_dst='00:00:00:22:22:%02X' % (class_id+out_port) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 434 | label = (out_port, 0, 1, 32) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 435 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port+class_id), ip_ttl=63, ip_src=ip_src, |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 436 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 437 | pkt=str(exp_pkt) |
| 438 | verify_packet(self, pkt, out_port) |
| 439 | verify_no_other_packets(self) |
castroflavio | ee29484 | 2016-01-06 15:54:28 -0800 | [diff] [blame] | 440 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 441 | class _32VPN(base_tests.SimpleDataPlane): |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 442 | """ |
| 443 | Insert IP packet |
| 444 | Receive MPLS packet |
| 445 | """ |
| 446 | def runTest(self): |
| 447 | delete_all_flows(self.controller) |
| 448 | delete_all_groups(self.controller) |
| 449 | |
| 450 | if len(config["port_map"]) <2: |
| 451 | logging.info("Port count less than 2, can't run this case") |
| 452 | return |
| 453 | |
| 454 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 455 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 456 | dip=0xc0a80001 |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 457 | #Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | 443c95e | 2016-02-03 15:05:28 -0500 | [diff] [blame] | 458 | class_id=abs(hash(inspect.stack()[0][3])) % (256) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 459 | ports = config["port_map"].keys() |
| 460 | for port in ports: |
| 461 | #add l2 interface group |
Flavio Castro | 443c95e | 2016-02-03 15:05:28 -0500 | [diff] [blame] | 462 | id=port+class_id<<8 |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 463 | vlan_id=port+class_id |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 464 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True) |
| 465 | dst_mac[5]=vlan_id |
| 466 | #add MPLS interface group |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 467 | 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] | 468 | #add MPLS L3 VPN group |
| 469 | 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] | 470 | 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] | 471 | #ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 472 | do_barrier(self.controller) |
| 473 | #add vlan flow table |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 474 | 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] | 475 | #add termination flow |
| 476 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 477 | #add routing flow |
| 478 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 479 | 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] | 480 | |
| 481 | do_barrier(self.controller) |
| 482 | |
| 483 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 484 | for in_port in ports: |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 485 | ip_src='192.168.%02d.1' % (class_id+in_port) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 486 | for out_port in ports: |
| 487 | if in_port == out_port: |
| 488 | continue |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 489 | ip_dst='192.168.%02d.1' % (class_id+out_port) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 490 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=(class_id+in_port), |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 491 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 492 | ip_dst=ip_dst) |
| 493 | pkt=str(parsed_pkt) |
| 494 | self.dataplane.send(in_port, pkt) |
| 495 | #build expect packet |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 496 | mac_dst='00:00:00:22:22:%02X' % (class_id+out_port) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 497 | label = (out_port, 0, 1, 32) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 498 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=(class_id+out_port), ip_ttl=63, ip_src=ip_src, |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 499 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 500 | pkt=str(exp_pkt) |
| 501 | verify_packet(self, pkt, out_port) |
| 502 | verify_no_other_packets(self) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 503 | @disabled |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 504 | class MPLSBUG(base_tests.SimpleDataPlane): |
| 505 | |
| 506 | def runTest(self): |
| 507 | delete_all_flows(self.controller) |
| 508 | delete_all_groups(self.controller) |
| 509 | |
| 510 | if len(config["port_map"]) <2: |
| 511 | logging.info("Port count less than 2, can't run this case") |
| 512 | return |
| 513 | |
| 514 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 515 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 516 | dip=0xc0a80001 |
| 517 | index=1 |
| 518 | ports = config["port_map"].keys() |
| 519 | for port in ports: |
| 520 | #add l2 interface group |
| 521 | vlan_id=port |
| 522 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 523 | dst_mac[5]=vlan_id |
| 524 | #add L3 Unicast group |
| 525 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 526 | #add vlan flow table |
| 527 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 528 | #add termination flow |
| 529 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24) |
| 530 | #add mpls flow |
| 531 | add_mpls_flow(self.controller, l3_msg.group_id, port) |
| 532 | #add termination flow |
| 533 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 534 | #add unicast routing flow |
| 535 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 536 | 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] | 537 | |
| 538 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 539 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 540 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 541 | |
| 542 | do_barrier(self.controller) |
| 543 | |
| 544 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 545 | for in_port in ports: |
| 546 | mac_src='00:00:00:22:22:%02X' % in_port |
| 547 | ip_src='192.168.%02d.1' % in_port |
| 548 | for out_port in ports: |
| 549 | if in_port == out_port: |
| 550 | continue |
| 551 | ip_dst='192.168.%02d.1' % out_port |
| 552 | switch_mac = "00:00:00:cc:cc:cc" |
| 553 | label = (out_port, 0, 1, 32) |
| 554 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 555 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label]) |
| 556 | pkt=str(parsed_pkt) |
| 557 | self.dataplane.send(in_port, pkt) |
| 558 | |
| 559 | #build expect packet |
| 560 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 561 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 562 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst) |
| 563 | pkt=str(exp_pkt) |
| 564 | verify_packet(self, pkt, out_port) |
| 565 | verify_no_other_packets(self) |
| 566 | |
| 567 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 568 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 569 | ip_dst=ip_dst) |
| 570 | pkt=str(parsed_pkt) |
| 571 | self.dataplane.send(in_port, pkt) |
| 572 | #build expected packet |
| 573 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 574 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 575 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 576 | ip_src=ip_src, ip_dst=ip_dst) |
| 577 | pkt=str(exp_pkt) |
| 578 | verify_packet(self, pkt, out_port) |
| 579 | verify_no_other_packets(self) |
| 580 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 581 | class L3McastToL2(base_tests.SimpleDataPlane): |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 582 | """ |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 583 | Mcast routing to L2 |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 584 | """ |
| 585 | def runTest(self): |
| 586 | """ |
| 587 | port1 (vlan 300)-> All Ports (vlan 300) |
| 588 | """ |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 589 | #delete_all_flows(self.controller) |
| 590 | #delete_all_groups(self.controller) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 591 | |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 592 | if len(config["port_map"]) <3: |
| 593 | logging.info("Port count less than 3, can't run this case") |
| 594 | assert(False) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 595 | return |
| 596 | |
| 597 | vlan_id =300 |
| 598 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 599 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 600 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 601 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 602 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 603 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 604 | src_ip=0xc0a80101 |
| 605 | src_ip_str="192.168.1.1" |
| 606 | dst_ip=0xe0010101 |
| 607 | dst_ip_str="224.1.1.1" |
| 608 | |
| 609 | port1=config["port_map"].keys()[0] |
| 610 | port2=config["port_map"].keys()[1] |
| 611 | |
| 612 | switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00] |
| 613 | |
| 614 | |
| 615 | #add l2 interface group |
| 616 | l2_intf_group_list=[] |
| 617 | for port in config["port_map"].keys(): |
Flavio Castro | 89933f2 | 2016-02-03 15:53:16 -0500 | [diff] [blame] | 618 | 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] | 619 | if port == port2: |
| 620 | continue |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 621 | 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] | 622 | l2_intf_group_list.append(l2_intf_gid) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 623 | |
| 624 | #add termination flow |
| 625 | add_termination_flow(self.controller, port1, 0x0800, switch_mac, vlan_id) |
| 626 | |
| 627 | #add l3 interface group |
| 628 | mcat_group_msg=add_l3_mcast_group(self.controller, vlan_id, 2, l2_intf_group_list) |
| 629 | add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
| 630 | |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 631 | parsed_pkt = simple_udp_packet(pktlen=100, |
Flavio Castro | 89933f2 | 2016-02-03 15:53:16 -0500 | [diff] [blame] | 632 | dl_vlan_enable=True, |
| 633 | vlan_vid=vlan_id, |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 634 | eth_dst=dst_mac_str, |
| 635 | eth_src=port1_mac_str, |
| 636 | ip_ttl=64, |
| 637 | ip_src=src_ip_str, |
| 638 | ip_dst=dst_ip_str) |
| 639 | pkt=str(parsed_pkt) |
| 640 | self.dataplane.send(port1, pkt) |
| 641 | for port in config["port_map"].keys(): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 642 | if port == port2 or port == port1: |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 643 | verify_no_packet(self, pkt, port) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 644 | continue |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 645 | verify_packet(self, pkt, port) |
| 646 | verify_no_other_packets(self) |
| 647 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 648 | class L3McastToL3(base_tests.SimpleDataPlane): |
| 649 | """ |
| 650 | Mcast routing |
| 651 | """ |
| 652 | def runTest(self): |
| 653 | """ |
| 654 | port1 (vlan 1)-> port 2 (vlan 2) |
| 655 | """ |
| 656 | delete_all_flows(self.controller) |
| 657 | delete_all_groups(self.controller) |
| 658 | |
| 659 | if len(config["port_map"]) <3: |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 660 | logging.info("Port count less than 3, can't run this case") |
| 661 | assert(False) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 662 | return |
| 663 | |
| 664 | vlan_id =1 |
| 665 | port2_out_vlan=2 |
| 666 | port3_out_vlan=3 |
| 667 | in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 668 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 669 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 670 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 671 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 672 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 673 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 674 | src_ip=0xc0a80101 |
| 675 | src_ip_str="192.168.1.1" |
| 676 | dst_ip=0xe0010101 |
| 677 | dst_ip_str="224.1.1.1" |
| 678 | |
| 679 | port1=config["port_map"].keys()[0] |
| 680 | port2=config["port_map"].keys()[1] |
| 681 | port3=config["port_map"].keys()[2] |
| 682 | |
| 683 | #add l2 interface group |
| 684 | for port in config["port_map"].keys(): |
| 685 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False) |
| 686 | #add vlan flow table |
| 687 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 688 | vlan_id +=1 |
| 689 | |
| 690 | #add termination flow |
| 691 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
| 692 | |
| 693 | #add l3 interface group |
| 694 | port2_ucast_msg=add_l3_interface_group(self.controller, port2, port2_out_vlan, 2, intf_src_mac) |
| 695 | port3_ucast_msg=add_l3_interface_group(self.controller, port3, port3_out_vlan, 3, intf_src_mac) |
| 696 | mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [port2_ucast_msg.group_id, port3_ucast_msg.group_id]) |
| 697 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
| 698 | |
| 699 | parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1, |
| 700 | eth_dst=dst_mac_str, |
| 701 | eth_src=port1_mac_str, |
| 702 | ip_ttl=64, |
| 703 | ip_src=src_ip_str, |
| 704 | ip_dst=dst_ip_str) |
| 705 | pkt=str(parsed_pkt) |
| 706 | self.dataplane.send(port1, pkt) |
| 707 | parsed_pkt = simple_udp_packet(pktlen=96, |
| 708 | eth_dst=dst_mac_str, |
| 709 | eth_src=intf_src_mac_str, |
| 710 | ip_ttl=63, |
| 711 | ip_src=src_ip_str, |
| 712 | ip_dst=dst_ip_str) |
| 713 | pkt=str(parsed_pkt) |
| 714 | verify_packet(self, pkt, port2) |
| 715 | verify_packet(self, pkt, port3) |
| 716 | verify_no_other_packets(self) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 717 | |
| 718 | |
| 719 | |
Flavio Castro | f54be49 | 2016-02-03 16:26:22 -0500 | [diff] [blame] | 720 | class _MplsTermination(base_tests.SimpleDataPlane): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 721 | """ |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 722 | Insert IP packet |
| 723 | Receive MPLS packet |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 724 | """ |
| 725 | def runTest(self): |
| 726 | delete_all_flows(self.controller) |
| 727 | delete_all_groups(self.controller) |
| 728 | |
| 729 | if len(config["port_map"]) <2: |
| 730 | logging.info("Port count less than 2, can't run this case") |
| 731 | return |
| 732 | |
| 733 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 734 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 735 | #Hashes Test Name and uses it as id for installing unique groups |
| 736 | class_id=abs(hash(inspect.stack()[0][3])) % (256) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 737 | ports = config["port_map"].keys() |
| 738 | for port in ports: |
| 739 | #add l2 interface group |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 740 | id = port + class_id<<8 |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 741 | vlan_id=port+class_id |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 742 | 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] | 743 | dst_mac[5]=vlan_id |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 744 | #add L3 Unicast group |
| 745 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 746 | #add L3 ecmp group |
| 747 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id]) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 748 | #add vlan flow table |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 749 | 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] | 750 | #add termination flow |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 751 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24) |
| 752 | add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 753 | |
| 754 | do_barrier(self.controller) |
| 755 | |
| 756 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 757 | for in_port in ports: |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 758 | ip_src='192.168.%02d.1' % (class_id+in_port) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 759 | for out_port in ports: |
| 760 | if in_port == out_port: |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 761 | continue |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 762 | ip_dst='192.168.%02d.1' % (class_id+out_port) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 763 | |
| 764 | label = (out_port, 0, 1, 32) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 765 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port+class_id), ip_src=ip_src, |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 766 | ip_dst=ip_dst, eth_dst=switch_mac, label=[label]) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 767 | pkt=str(parsed_pkt) |
| 768 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 769 | |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 770 | #build expect packet |
Flavio Castro | 5cc3ef0 | 2016-02-03 17:03:31 -0500 | [diff] [blame] | 771 | mac_dst='00:00:00:22:22:%02X' % (class_id+out_port) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 772 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=(class_id+out_port), |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 773 | 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] | 774 | pkt=str(exp_pkt) |
| 775 | verify_packet(self, pkt, out_port) |
| 776 | verify_no_other_packets(self) |