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