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