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 | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 60 | def runTest(self): |
| 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 |
| 66 | add_l2_interface_grouop(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) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 76 | do_barrier(self.controller) |
| 77 | |
| 78 | for out_port in ports: |
| 79 | # change dest based on port number |
| 80 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 81 | |
| 82 | for in_port in ports: |
| 83 | if in_port == out_port: |
| 84 | continue |
| 85 | # change source based on port number to avoid packet-ins from learning |
| 86 | mac_src= '00:12:34:56:78:%02X' % in_port |
Flavio Castro | c36621e | 2015-12-08 12:57:07 -0500 | [diff] [blame] | 87 | #sends an untagged packet |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 88 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=False, vlan_vid=4093, eth_dst=mac_dst, eth_src=mac_src) |
| 89 | pkt = str(parsed_pkt) |
| 90 | logging.info("OutputExact test, ports %d to %d", in_port, out_port) |
| 91 | self.dataplane.send(in_port, pkt) |
| 92 | |
| 93 | for ofport in ports: |
| 94 | if ofport in [out_port]: |
| 95 | verify_packet(self, pkt, ofport) |
| 96 | else: |
| 97 | verify_no_packet(self, pkt, ofport) |
| 98 | |
| 99 | verify_no_other_packets(self) |
castroflavio | 046c1fe | 2015-12-08 14:33:32 -0500 | [diff] [blame^] | 100 | # sends a double tagged packet |
| 101 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=300, |
| 102 | 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] | 103 | pkt = str(parsed_pkt) |
| 104 | logging.info("OutputExact test, ports %d to %d", in_port, out_port) |
| 105 | self.dataplane.send(in_port, pkt) |
| 106 | |
| 107 | for ofport in ports: |
| 108 | if ofport in [out_port]: |
| 109 | verify_packet(self, pkt, ofport) |
| 110 | else: |
| 111 | verify_no_packet(self, pkt, ofport) |
| 112 | |
| 113 | verify_no_other_packets(self) |
| 114 | |
| 115 | class L2FloodQinQ(base_tests.SimpleDataPlane): |
| 116 | """ |
Flavio Castro | c36621e | 2015-12-08 12:57:07 -0500 | [diff] [blame] | 117 | Test L2 flood of double tagged vlan packets (802.1Q) |
| 118 | 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] | 119 | """ |
| 120 | def runTest(self): |
| 121 | ports = sorted(config["port_map"].keys()) |
| 122 | |
| 123 | delete_all_flows(self.controller) |
| 124 | delete_all_groups(self.controller) |
| 125 | |
| 126 | # Installing flows to avoid packet-in |
| 127 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 128 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 129 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 130 | |
| 131 | group_id = encode_l2_interface_group_id(1, port) |
| 132 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 133 | msg=add_l2_flood_group(self.controller, ports, 1, 1) |
| 134 | add_bridge_flow(self.controller, None, 1, msg.group_id, True) |
| 135 | do_barrier(self.controller) |
| 136 | |
| 137 | #verify flood |
| 138 | for ofport in ports: |
| 139 | # change dest based on port number |
| 140 | mac_src= '00:12:34:56:78:%02X' % ofport |
| 141 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=1, |
| 142 | in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 143 | pkt = str(parsed_pkt) |
| 144 | self.dataplane.send(ofport, pkt) |
| 145 | #self won't rx packet |
| 146 | verify_no_packet(self, pkt, ofport) |
| 147 | #others will rx packet |
| 148 | tmp_ports=list(ports) |
| 149 | tmp_ports.remove(ofport) |
| 150 | verify_packets(self, pkt, tmp_ports) |
| 151 | |
| 152 | verify_no_other_packets(self) |
| 153 | |
| 154 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 155 | class L2FloodTagged(base_tests.SimpleDataPlane): |
| 156 | """ |
| 157 | Test L2 flood to a vlan |
| 158 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
| 159 | #todo take in account unknown src |
| 160 | """ |
| 161 | def runTest(self): |
| 162 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 163 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 164 | delete_all_flows(self.controller) |
| 165 | delete_all_groups(self.controller) |
| 166 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 167 | # Installing flows to avoid packet-in |
| 168 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 169 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 170 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 171 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 172 | group_id = encode_l2_interface_group_id(1, port) |
| 173 | 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] | 174 | msg=add_l2_flood_group(self.controller, ports, 1, 1) |
| 175 | add_bridge_flow(self.controller, None, 1, msg.group_id, True) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 176 | do_barrier(self.controller) |
| 177 | |
| 178 | #verify flood |
| 179 | for ofport in ports: |
| 180 | # change dest based on port number |
| 181 | mac_src= '00:12:34:56:78:%02X' % ofport |
| 182 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 183 | pkt = str(parsed_pkt) |
| 184 | self.dataplane.send(ofport, pkt) |
| 185 | #self won't rx packet |
| 186 | verify_no_packet(self, pkt, ofport) |
| 187 | #others will rx packet |
| 188 | tmp_ports=list(ports) |
| 189 | tmp_ports.remove(ofport) |
| 190 | verify_packets(self, pkt, tmp_ports) |
| 191 | |
| 192 | verify_no_other_packets(self) |
| 193 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 194 | class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane): |
| 195 | """ |
| 196 | Test L2 flood to a vlan |
| 197 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
| 198 | #todo take in account unknown src |
| 199 | """ |
| 200 | def runTest(self): |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 201 | delete_all_flows(self.controller) |
| 202 | delete_all_groups(self.controller) |
| 203 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 204 | ports = sorted(config["port_map"].keys()) |
| 205 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 206 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 207 | 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] | 208 | |
| 209 | msg=add_l2_flood_group(self.controller, ports, 1, 1) |
| 210 | add_bridge_flow(self.controller, None, 1, msg.group_id, True) |
| 211 | |
| 212 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a') |
| 213 | pkt = str(parsed_pkt) |
| 214 | #verify flood |
| 215 | for ofport in ports: |
| 216 | self.dataplane.send(ofport, pkt) |
| 217 | #self won't rx packet |
| 218 | verify_no_packet(self, pkt, ofport) |
| 219 | #others will rx packet |
| 220 | tmp_ports=list(ports) |
| 221 | tmp_ports.remove(ofport) |
| 222 | verify_packets(self, pkt, tmp_ports) |
| 223 | |
| 224 | verify_no_other_packets(self) |
| 225 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 226 | class L2UnicastTagged(base_tests.SimpleDataPlane): |
| 227 | """ |
| 228 | Test output function for an exact-match flow |
| 229 | |
| 230 | For each port A, adds a flow directing matching packets to that port. |
| 231 | Then, for all other ports B != A, verifies that sending a matching packet |
| 232 | to B results in an output to A. |
| 233 | """ |
| 234 | def runTest(self): |
| 235 | ports = sorted(config["port_map"].keys()) |
| 236 | |
| 237 | delete_all_flows(self.controller) |
| 238 | delete_all_groups(self.controller) |
| 239 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 240 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 241 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 242 | 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] | 243 | group_id = encode_l2_interface_group_id(1, port) |
| 244 | 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] | 245 | do_barrier(self.controller) |
| 246 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 247 | for out_port in ports: |
| 248 | # change dest based on port number |
| 249 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 250 | for in_port in ports: |
| 251 | if in_port == out_port: |
| 252 | continue |
| 253 | # change source based on port number to avoid packet-ins from learning |
| 254 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 255 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 256 | pkt = str(parsed_pkt) |
| 257 | self.dataplane.send(in_port, pkt) |
| 258 | |
| 259 | for ofport in ports: |
| 260 | if ofport in [out_port]: |
| 261 | verify_packet(self, pkt, ofport) |
| 262 | else: |
| 263 | verify_no_packet(self, pkt, ofport) |
| 264 | |
| 265 | verify_no_other_packets(self) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 266 | |
| 267 | |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 268 | class Mtu4500(base_tests.SimpleDataPlane): |
| 269 | |
| 270 | def runTest(self): |
| 271 | ports = sorted(config["port_map"].keys()) |
| 272 | |
| 273 | delete_all_flows(self.controller) |
| 274 | delete_all_groups(self.controller) |
| 275 | |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 276 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 277 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 278 | 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] | 279 | group_id = encode_l2_interface_group_id(1, port) |
| 280 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 281 | do_barrier(self.controller) |
| 282 | |
| 283 | for out_port in ports: |
| 284 | # change dest based on port number |
| 285 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 286 | for in_port in ports: |
| 287 | if in_port == out_port: |
| 288 | continue |
| 289 | # change source based on port number to avoid packet-ins from learning |
| 290 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 291 | parsed_pkt = simple_tcp_packet(pktlen=4500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 292 | pkt = str(parsed_pkt) |
| 293 | self.dataplane.send(in_port, pkt) |
| 294 | |
| 295 | for ofport in ports: |
| 296 | if ofport in [out_port]: |
| 297 | verify_packet(self, pkt, ofport) |
| 298 | else: |
| 299 | verify_no_packet(self, pkt, ofport) |
| 300 | |
| 301 | verify_no_other_packets(self) |
| 302 | |
| 303 | |
| 304 | class Mtu1500(base_tests.SimpleDataPlane): |
| 305 | |
| 306 | def runTest(self): |
| 307 | ports = sorted(config["port_map"].keys()) |
| 308 | |
| 309 | delete_all_flows(self.controller) |
| 310 | delete_all_groups(self.controller) |
| 311 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 312 | # set up tag groups for each port |
| 313 | add_l2_interface_grouop(self.controller, ports, 1, True, 1) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 314 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 315 | add_vlan_table_flow(self.controller, ports) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 316 | |
| 317 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 318 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 319 | 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] | 320 | group_id = encode_l2_interface_group_id(1, port) |
| 321 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 322 | do_barrier(self.controller) |
| 323 | |
| 324 | for out_port in ports: |
| 325 | # change dest based on port number |
| 326 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 327 | for in_port in ports: |
| 328 | if in_port == out_port: |
| 329 | continue |
| 330 | # change source based on port number to avoid packet-ins from learning |
| 331 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 332 | parsed_pkt = simple_tcp_packet(pktlen=1500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 333 | pkt = str(parsed_pkt) |
| 334 | self.dataplane.send(in_port, pkt) |
| 335 | |
| 336 | for ofport in ports: |
| 337 | if ofport in [out_port]: |
| 338 | verify_packet(self, pkt, ofport) |
| 339 | else: |
| 340 | verify_no_packet(self, pkt, ofport) |
| 341 | |
| 342 | verify_no_other_packets(self) |
| 343 | |
| 344 | |
| 345 | class Mtu4000(base_tests.SimpleDataPlane): |
| 346 | """ |
| 347 | Test output function for an exact-match flow |
| 348 | For each port A, adds a flow directing matching packets to that port. |
| 349 | Then, for all other ports B != A, verifies that sending a matching packet |
| 350 | to B results in an output to A. |
| 351 | """ |
| 352 | def runTest(self): |
| 353 | ports = sorted(config["port_map"].keys()) |
| 354 | |
| 355 | delete_all_flows(self.controller) |
| 356 | delete_all_groups(self.controller) |
| 357 | |
| 358 | add_vlan_table_flow(self.controller, config["port_map"].keys()) |
| 359 | |
| 360 | # set up tag groups for each port |
| 361 | add_l2_interface_grouop(self.controller, config["port_map"].keys(), 1, True, 1) |
| 362 | |
| 363 | for port in ports: |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 364 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 365 | 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] | 366 | group_id = encode_l2_interface_group_id(1, port) |
| 367 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 368 | do_barrier(self.controller) |
| 369 | |
| 370 | for out_port in ports: |
| 371 | # change dest based on port number |
| 372 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 373 | for in_port in ports: |
| 374 | if in_port == out_port: |
| 375 | continue |
| 376 | # change source based on port number to avoid packet-ins from learning |
| 377 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 378 | parsed_pkt = simple_tcp_packet(pktlen=4000,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 379 | pkt = str(parsed_pkt) |
| 380 | self.dataplane.send(in_port, pkt) |
| 381 | |
| 382 | for ofport in ports: |
| 383 | if ofport in [out_port]: |
| 384 | verify_packet(self, pkt, ofport) |
| 385 | else: |
| 386 | verify_no_packet(self, pkt, ofport) |
| 387 | |
| 388 | verify_no_other_packets(self) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 389 | |
| 390 | class L3UcastTagged(base_tests.SimpleDataPlane): |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 391 | """ |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 392 | Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) , |
| 393 | 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] | 394 | """ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 395 | def runTest(self): |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 396 | delete_all_flows(self.controller) |
| 397 | delete_all_groups(self.controller) |
| 398 | |
| 399 | if len(config["port_map"]) <2: |
| 400 | logging.info("Port count less than 2, can't run this case") |
| 401 | return |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 402 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 403 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 404 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 405 | dip=0xc0a80001 |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 406 | ports = config["port_map"].keys() |
| 407 | for port in ports: |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 408 | #add l2 interface group |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 409 | vlan_id=port |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 410 | 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] | 411 | dst_mac[5]=vlan_id |
| 412 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 413 | #add vlan flow table |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 414 | 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] | 415 | #add termination flow |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 416 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 417 | #add unicast routing flow |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 418 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 419 | 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] | 420 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 421 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 422 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 423 | |
| 424 | do_barrier(self.controller) |
| 425 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 426 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 427 | for in_port in ports: |
| 428 | mac_src='00:00:00:22:22:%02X' % in_port |
| 429 | ip_src='192.168.%02d.1' % in_port |
| 430 | for out_port in ports: |
| 431 | if in_port == out_port: |
| 432 | continue |
| 433 | ip_dst='192.168.%02d.1' % out_port |
| 434 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 435 | 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] | 436 | ip_dst=ip_dst) |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 437 | pkt=str(parsed_pkt) |
| 438 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 439 | #build expected packet |
Flavio Castro | a823386 | 2015-12-02 14:41:11 -0500 | [diff] [blame] | 440 | mac_dst='00:00:00:22:22:%02X' % out_port |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 441 | 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] | 442 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 443 | ip_src=ip_src, ip_dst=ip_dst) |
| 444 | pkt=str(exp_pkt) |
| 445 | verify_packet(self, pkt, out_port) |
| 446 | verify_no_other_packets(self) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 447 | |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 448 | class L3VPNMPLS(base_tests.SimpleDataPlane): |
| 449 | """ |
| 450 | Insert IP packet |
| 451 | Receive MPLS packet |
| 452 | """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 453 | def runTest(self): |
| 454 | delete_all_flows(self.controller) |
| 455 | delete_all_groups(self.controller) |
| 456 | |
| 457 | if len(config["port_map"]) <2: |
| 458 | logging.info("Port count less than 2, can't run this case") |
| 459 | return |
| 460 | |
| 461 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 462 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 463 | dip=0xc0a80001 |
| 464 | index=1 |
| 465 | ports = config["port_map"].keys() |
| 466 | for port in ports: |
| 467 | #add l2 interface group |
| 468 | vlan_id=port |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 469 | 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] | 470 | dst_mac[5]=vlan_id |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 471 | #add MPLS interface group |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 472 | 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] | 473 | #add MPLS L3 VPN group |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 474 | 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] | 475 | index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32) |
| 476 | #add vlan flow table |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 477 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 478 | #add termination flow |
| 479 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
Flavio Castro | 35e6439 | 2015-12-02 16:53:14 -0500 | [diff] [blame] | 480 | #add routing flow |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 481 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 482 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 483 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 484 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 485 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 486 | |
| 487 | do_barrier(self.controller) |
| 488 | |
| 489 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 490 | for in_port in ports: |
| 491 | mac_src='00:00:00:22:22:%02X' % in_port |
| 492 | ip_src='192.168.%02d.1' % in_port |
| 493 | for out_port in ports: |
| 494 | if in_port == out_port: |
| 495 | continue |
| 496 | ip_dst='192.168.%02d.1' % out_port |
| 497 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 498 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 499 | ip_dst=ip_dst) |
| 500 | pkt=str(parsed_pkt) |
| 501 | self.dataplane.send(in_port, pkt) |
| 502 | #build expect packet |
| 503 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 504 | label = (out_port, 0, 1, 32) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 505 | 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] | 506 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 507 | pkt=str(exp_pkt) |
| 508 | verify_packet(self, pkt, out_port) |
| 509 | verify_no_other_packets(self) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 510 | |
| 511 | class MplsTermination(base_tests.SimpleDataPlane): |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 512 | """ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 513 | Insert IP packet |
| 514 | Receive MPLS packet |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 515 | """ |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 516 | def runTest(self): |
| 517 | delete_all_flows(self.controller) |
| 518 | delete_all_groups(self.controller) |
| 519 | |
| 520 | if len(config["port_map"]) <2: |
| 521 | logging.info("Port count less than 2, can't run this case") |
| 522 | return |
| 523 | |
| 524 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 525 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 526 | dip=0xc0a80001 |
| 527 | index=1 |
| 528 | ports = config["port_map"].keys() |
| 529 | for port in ports: |
| 530 | #add l2 interface group |
| 531 | vlan_id=port |
castroflavio | dd17147 | 2015-12-08 13:55:58 -0500 | [diff] [blame] | 532 | 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] | 533 | dst_mac[5]=vlan_id |
| 534 | #add L3 Unicast group |
| 535 | 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] | 536 | #add L3 ecmp group |
| 537 | 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] | 538 | #add vlan flow table |
| 539 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 540 | #add termination flow |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 541 | 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] | 542 | #add routing flow |
| 543 | dst_ip = dip + (vlan_id<<8) |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 544 | add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 545 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 546 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 547 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 548 | |
| 549 | do_barrier(self.controller) |
| 550 | |
| 551 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 552 | for in_port in ports: |
| 553 | mac_src='00:00:00:22:22:%02X' % in_port |
| 554 | ip_src='192.168.%02d.1' % in_port |
| 555 | for out_port in ports: |
| 556 | if in_port == out_port: |
| 557 | continue |
| 558 | ip_dst='192.168.%02d.1' % out_port |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 559 | |
| 560 | label = (out_port, 0, 1, 32) |
| 561 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 562 | 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] | 563 | pkt=str(parsed_pkt) |
| 564 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 565 | |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 566 | #build expect packet |
| 567 | mac_dst='00:00:00:22:22:%02X' % out_port |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 568 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 569 | 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] | 570 | pkt=str(exp_pkt) |
| 571 | verify_packet(self, pkt, out_port) |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 572 | verify_no_other_packets(self) |
| 573 | |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 574 | |