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