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