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 | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 427 | class _32VPN(base_tests.SimpleDataPlane): |
| 428 | """ |
| 429 | Insert IP packet |
| 430 | Receive MPLS packet |
| 431 | """ |
| 432 | |
| 433 | def runTest(self): |
| 434 | if len(config["port_map"]) < 2: |
| 435 | logging.info("Port count less than 2, can't run this case") |
| 436 | return |
| 437 | |
| 438 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 439 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 440 | dip = 0xc0a80001 |
| 441 | ports = config["port_map"].keys() |
| 442 | Groups = Queue.LifoQueue() |
| 443 | for port in ports: |
| 444 | # add l2 interface group |
| 445 | id = port |
| 446 | vlan_id = port |
| 447 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 448 | vlan_id, True, True) |
| 449 | dst_mac[5] = vlan_id |
| 450 | # add MPLS interface group |
| 451 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 452 | dst_mac, intf_src_mac, |
| 453 | vlan_id, id) |
| 454 | # add MPLS L3 VPN group |
| 455 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 456 | self.controller, |
| 457 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 458 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 459 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 460 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 461 | do_barrier(self.controller) |
| 462 | # add vlan flow table |
Flavio Castro | bcc3dbc | 2016-04-06 11:05:03 -0400 | [diff] [blame^] | 463 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 464 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 465 | # add termination flow |
| 466 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 467 | vlan_id) |
| 468 | # add routing flow |
| 469 | dst_ip = dip + (vlan_id << 8) |
| 470 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
Flavio Castro | bcc3dbc | 2016-04-06 11:05:03 -0400 | [diff] [blame^] | 471 | 0xffffffff, mpls_label_gid,vrf=2) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 472 | Groups._put(l2_gid) |
| 473 | Groups._put(mpls_gid) |
| 474 | Groups._put(mpls_label_gid) |
| 475 | do_barrier(self.controller) |
| 476 | |
| 477 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 478 | for in_port in ports: |
| 479 | ip_src = '192.168.%02d.1' % (in_port) |
| 480 | for out_port in ports: |
| 481 | if in_port == out_port: |
| 482 | continue |
| 483 | ip_dst = '192.168.%02d.1' % (out_port) |
| 484 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 485 | vlan_vid=(in_port), |
| 486 | eth_dst=switch_mac, ip_ttl=64, |
| 487 | ip_src=ip_src, |
| 488 | ip_dst=ip_dst) |
| 489 | pkt = str(parsed_pkt) |
| 490 | self.dataplane.send(in_port, pkt) |
| 491 | # build expect packet |
| 492 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 493 | label = (out_port, 0, 1, 32) |
| 494 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 495 | vlan_vid=(out_port), ip_ttl=63, |
| 496 | ip_src=ip_src, |
| 497 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 498 | eth_src=switch_mac, label=[label]) |
| 499 | pkt = str(exp_pkt) |
| 500 | verify_packet(self, pkt, out_port) |
| 501 | verify_no_other_packets(self) |
| 502 | delete_all_flows(self.controller) |
| 503 | delete_groups(self.controller, Groups) |
| 504 | |
| 505 | class _32EcmpVpn(base_tests.SimpleDataPlane): |
| 506 | """ |
| 507 | Insert IP packet |
| 508 | Receive MPLS packet |
| 509 | """ |
| 510 | |
| 511 | def runTest(self): |
| 512 | if len(config["port_map"]) < 2: |
| 513 | logging.info("Port count less than 2, can't run this case") |
| 514 | return |
| 515 | |
| 516 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 517 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 518 | dip = 0xc0a80001 |
| 519 | ports = config["port_map"].keys() |
| 520 | Groups = Queue.LifoQueue() |
| 521 | for port in ports: |
| 522 | # add l2 interface group |
| 523 | id = port |
| 524 | vlan_id = port |
| 525 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 526 | vlan_id, True, True) |
| 527 | dst_mac[5] = vlan_id |
| 528 | # add MPLS interface group |
| 529 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 530 | dst_mac, intf_src_mac, |
| 531 | vlan_id, id) |
| 532 | # add MPLS L3 VPN group |
| 533 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 534 | self.controller, |
| 535 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 536 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 537 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 538 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 539 | do_barrier(self.controller) |
| 540 | # add vlan flow table |
| 541 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, |
| 542 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 543 | # add termination flow |
| 544 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 545 | vlan_id) |
| 546 | # add routing flow |
| 547 | dst_ip = dip + (vlan_id << 8) |
| 548 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 549 | 0xffffffff, ecmp_msg.group_id) |
| 550 | Groups._put(l2_gid) |
| 551 | Groups._put(mpls_gid) |
| 552 | Groups._put(mpls_label_gid) |
| 553 | Groups._put(ecmp_msg.group_id) |
| 554 | do_barrier(self.controller) |
| 555 | |
| 556 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 557 | for in_port in ports: |
| 558 | ip_src = '192.168.%02d.1' % (in_port) |
| 559 | for out_port in ports: |
| 560 | if in_port == out_port: |
| 561 | continue |
| 562 | ip_dst = '192.168.%02d.1' % (out_port) |
| 563 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 564 | vlan_vid=(in_port), |
| 565 | eth_dst=switch_mac, ip_ttl=64, |
| 566 | ip_src=ip_src, |
| 567 | ip_dst=ip_dst) |
| 568 | pkt = str(parsed_pkt) |
| 569 | self.dataplane.send(in_port, pkt) |
| 570 | # build expect packet |
| 571 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 572 | label = (out_port, 0, 1, 32) |
| 573 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 574 | vlan_vid=(out_port), ip_ttl=63, |
| 575 | ip_src=ip_src, |
| 576 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 577 | eth_src=switch_mac, label=[label]) |
| 578 | pkt = str(exp_pkt) |
| 579 | verify_packet(self, pkt, out_port) |
| 580 | verify_no_other_packets(self) |
| 581 | delete_all_flows(self.controller) |
| 582 | delete_groups(self.controller, Groups) |
| 583 | |
| 584 | class _32ECMPL3(base_tests.SimpleDataPlane): |
| 585 | """ |
| 586 | Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) , |
| 587 | Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1) |
| 588 | """ |
| 589 | |
| 590 | def runTest(self): |
| 591 | Groups = Queue.LifoQueue() |
| 592 | if len(config["port_map"]) < 2: |
| 593 | logging.info("Port count less than 2, can't run this case") |
| 594 | return |
| 595 | |
| 596 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 597 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 598 | dip = 0xc0a80001 |
| 599 | # Hashes Test Name and uses it as id for installing unique groups |
| 600 | ports = config["port_map"].keys() |
| 601 | for port in ports: |
| 602 | vlan_id = port |
| 603 | id = port |
| 604 | # add l2 interface group |
| 605 | l2_gid, msg = add_one_l2_interface_group(self.controller, port, |
| 606 | vlan_id=vlan_id, |
| 607 | is_tagged=True, |
| 608 | send_barrier=False) |
| 609 | dst_mac[5] = vlan_id |
| 610 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 611 | id=id, src_mac=intf_src_mac, |
| 612 | dst_mac=dst_mac) |
| 613 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id]) |
| 614 | # add vlan flow table |
| 615 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 616 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 617 | # add termination flow |
| 618 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 619 | vlan_id) |
| 620 | # add unicast routing flow |
| 621 | dst_ip = dip + (vlan_id << 8) |
| 622 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 623 | 0xffffffff, ecmp_msg.group_id) |
| 624 | Groups._put(l2_gid) |
| 625 | Groups._put(l3_msg.group_id) |
| 626 | Groups._put(ecmp_msg.group_id) |
| 627 | do_barrier(self.controller) |
| 628 | |
| 629 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 630 | for in_port in ports: |
| 631 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 632 | ip_src = '192.168.%02d.1' % in_port |
| 633 | for out_port in ports: |
| 634 | if in_port == out_port: |
| 635 | continue |
| 636 | ip_dst = '192.168.%02d.1' % out_port |
| 637 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 638 | vlan_vid=in_port, |
| 639 | eth_dst=switch_mac, |
| 640 | eth_src=mac_src, ip_ttl=64, |
| 641 | ip_src=ip_src, |
| 642 | ip_dst=ip_dst) |
| 643 | pkt = str(parsed_pkt) |
| 644 | self.dataplane.send(in_port, pkt) |
| 645 | # build expected packet |
| 646 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 647 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 648 | vlan_vid=out_port, |
| 649 | eth_dst=mac_dst, eth_src=switch_mac, |
| 650 | ip_ttl=63, |
| 651 | ip_src=ip_src, ip_dst=ip_dst) |
| 652 | pkt = str(exp_pkt) |
| 653 | verify_packet(self, pkt, out_port) |
| 654 | verify_no_other_packets(self) |
| 655 | delete_all_flows(self.controller) |
| 656 | delete_groups(self.controller, Groups) |
| 657 | |
| 658 | |
| 659 | class _24VPN(base_tests.SimpleDataPlane): |
| 660 | """ |
| 661 | Insert IP packet |
| 662 | Receive MPLS packet |
| 663 | """ |
| 664 | |
| 665 | def runTest(self): |
| 666 | if len(config["port_map"]) < 2: |
| 667 | logging.info("Port count less than 2, can't run this case") |
| 668 | return |
| 669 | |
| 670 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 671 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 672 | dip = 0xc0a80001 |
| 673 | ports = config["port_map"].keys() |
| 674 | Groups = Queue.LifoQueue() |
| 675 | for port in ports: |
| 676 | # add l2 interface group |
| 677 | id = port |
| 678 | vlan_id = port |
| 679 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 680 | vlan_id, True, True) |
| 681 | dst_mac[5] = vlan_id |
| 682 | # add MPLS interface group |
| 683 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 684 | dst_mac, intf_src_mac, |
| 685 | vlan_id, id) |
| 686 | # add MPLS L3 VPN group |
| 687 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 688 | self.controller, |
| 689 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 690 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 691 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 692 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 693 | do_barrier(self.controller) |
| 694 | # add vlan flow table |
| 695 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, |
| 696 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 697 | # add termination flow |
| 698 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 699 | vlan_id) |
| 700 | # add routing flow |
| 701 | dst_ip = dip + (vlan_id << 8) |
| 702 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 703 | 0xffffff00, mpls_label_gid) |
| 704 | Groups._put(l2_gid) |
| 705 | Groups._put(mpls_gid) |
| 706 | Groups._put(mpls_label_gid) |
| 707 | do_barrier(self.controller) |
| 708 | |
| 709 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 710 | for in_port in ports: |
| 711 | ip_src = '192.168.%02d.1' % (in_port) |
| 712 | for out_port in ports: |
| 713 | if in_port == out_port: |
| 714 | continue |
| 715 | ip_dst = '192.168.%02d.1' % (out_port) |
| 716 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 717 | vlan_vid=(in_port), |
| 718 | eth_dst=switch_mac, ip_ttl=64, |
| 719 | ip_src=ip_src, |
| 720 | ip_dst=ip_dst) |
| 721 | pkt = str(parsed_pkt) |
| 722 | self.dataplane.send(in_port, pkt) |
| 723 | # build expect packet |
| 724 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 725 | label = (out_port, 0, 1, 32) |
| 726 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 727 | vlan_vid=(out_port), ip_ttl=63, |
| 728 | ip_src=ip_src, |
| 729 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 730 | eth_src=switch_mac, label=[label]) |
| 731 | pkt = str(exp_pkt) |
| 732 | verify_packet(self, pkt, out_port) |
| 733 | verify_no_other_packets(self) |
| 734 | delete_all_flows(self.controller) |
| 735 | delete_groups(self.controller, Groups) |
| 736 | |
| 737 | |
| 738 | class _24EcmpVpn(base_tests.SimpleDataPlane): |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 739 | """ |
| 740 | Insert IP packet |
| 741 | Receive MPLS packet |
| 742 | """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 743 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 744 | def runTest(self): |
| 745 | if len(config["port_map"]) < 2: |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 746 | logging.info("Port count less than 2, can't run this case") |
| 747 | return |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 748 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 749 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 750 | dip = 0xc0a80001 |
| 751 | Groups = Queue.LifoQueue() |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 752 | ports = config["port_map"].keys() |
| 753 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 754 | # add l2 interface group |
| 755 | id = port |
| 756 | vlan_id = id |
| 757 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 758 | vlan_id, True, True) |
| 759 | dst_mac[5] = vlan_id |
| 760 | # add MPLS interface group |
| 761 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 762 | dst_mac, intf_src_mac, |
| 763 | vlan_id, id) |
| 764 | # add MPLS L3 VPN group |
| 765 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 766 | self.controller, |
| 767 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 768 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 769 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 770 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [mpls_label_gid]) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 771 | do_barrier(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 772 | # add vlan flow table |
| 773 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, |
| 774 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 775 | # add termination flow |
| 776 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 777 | vlan_id) |
| 778 | # add routing flow |
| 779 | dst_ip = dip + (vlan_id << 8) |
| 780 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 781 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 782 | 0xffffff00, ecmp_msg.group_id, vrf=0) |
| 783 | Groups._put(l2_gid) |
| 784 | Groups._put(mpls_gid) |
| 785 | Groups._put(mpls_label_gid) |
| 786 | Groups._put(ecmp_msg.group_id) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 787 | |
| 788 | do_barrier(self.controller) |
| 789 | |
| 790 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 791 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 792 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 793 | ip_src = '192.168.%02d.1' % (in_port) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 794 | for out_port in ports: |
| 795 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 796 | continue |
| 797 | ip_dst = '192.168.%02d.1' % (out_port) |
| 798 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 799 | vlan_vid=(in_port), |
| 800 | eth_dst=switch_mac, |
| 801 | eth_src=mac_src, ip_ttl=64, |
| 802 | ip_src=ip_src, |
| 803 | ip_dst=ip_dst) |
| 804 | pkt = str(parsed_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 805 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 806 | # build expect packet |
| 807 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 808 | label = (out_port, 0, 1, 32) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 809 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 810 | vlan_vid=(out_port), ip_ttl=63, |
| 811 | ip_src=ip_src, |
| 812 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 813 | eth_src=switch_mac, label=[label]) |
| 814 | pkt = str(exp_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 815 | verify_packet(self, pkt, out_port) |
| 816 | verify_no_other_packets(self) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 817 | delete_all_flows(self.controller) |
| 818 | delete_groups(self.controller, Groups) |
| 819 | |
castroflavio | ee29484 | 2016-01-06 15:54:28 -0800 | [diff] [blame] | 820 | |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 821 | |
| 822 | class _24ECMPL3(base_tests.SimpleDataPlane): |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 823 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 824 | Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) , |
| 825 | Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 826 | """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 827 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 828 | def runTest(self): |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 829 | Groups = Queue.LifoQueue() |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 830 | if len(config["port_map"]) < 2: |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 831 | logging.info("Port count less than 2, can't run this case") |
| 832 | return |
| 833 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 834 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 835 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 836 | dip = 0xc0a80001 |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 837 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 838 | ports = config["port_map"].keys() |
| 839 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 840 | vlan_id = port |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 841 | id = port |
| 842 | # add l2 interface group |
| 843 | l2_gid, msg = add_one_l2_interface_group(self.controller, port, |
| 844 | vlan_id=vlan_id, |
| 845 | is_tagged=True, |
| 846 | send_barrier=False) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 847 | dst_mac[5] = vlan_id |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 848 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 849 | id=id, src_mac=intf_src_mac, |
| 850 | dst_mac=dst_mac) |
| 851 | 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] | 852 | # add vlan flow table |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 853 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 854 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 855 | # add termination flow |
| 856 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 857 | vlan_id) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 858 | # add unicast routing flow |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 859 | dst_ip = dip + (vlan_id << 8) |
| 860 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 861 | 0xffffff00, ecmp_msg.group_id) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 862 | Groups._put(l2_gid) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 863 | Groups._put(l3_msg.group_id) |
| 864 | Groups._put(ecmp_msg.group_id) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 865 | do_barrier(self.controller) |
| 866 | |
| 867 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 868 | for in_port in ports: |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 869 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 870 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 871 | for out_port in ports: |
| 872 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 873 | continue |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 874 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 875 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 876 | vlan_vid=in_port, |
| 877 | eth_dst=switch_mac, |
| 878 | eth_src=mac_src, ip_ttl=64, |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 879 | ip_src=ip_src, |
| 880 | ip_dst=ip_dst) |
| 881 | pkt = str(parsed_pkt) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 882 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 883 | # build expected packet |
| 884 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 885 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 886 | vlan_vid=out_port, |
| 887 | eth_dst=mac_dst, eth_src=switch_mac, |
| 888 | ip_ttl=63, |
| 889 | ip_src=ip_src, ip_dst=ip_dst) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 890 | pkt = str(exp_pkt) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 891 | verify_packet(self, pkt, out_port) |
| 892 | verify_no_other_packets(self) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 893 | delete_all_flows(self.controller) |
| 894 | delete_groups(self.controller, Groups) |
| 895 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 896 | @disabled |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 897 | class MPLSBUG(base_tests.SimpleDataPlane): |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 898 | def runTest(self): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 899 | if len(config["port_map"]) < 2: |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 900 | logging.info("Port count less than 2, can't run this case") |
| 901 | return |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 902 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 903 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 904 | dip = 0xc0a80001 |
| 905 | Groups = Queue.LifoQueue() |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 906 | ports = config["port_map"].keys() |
| 907 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 908 | # add l2 interface group |
| 909 | vlan_id = port |
| 910 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 911 | vlan_id, True, False) |
| 912 | dst_mac[5] = vlan_id |
| 913 | # add L3 Unicast group |
| 914 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 915 | id=vlan_id, src_mac=intf_src_mac, |
| 916 | dst_mac=dst_mac) |
| 917 | # add vlan flow table |
| 918 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 919 | flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 920 | # add termination flow |
| 921 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, |
| 922 | vlan_id, goto_table=24) |
| 923 | # add mpls flow |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 924 | add_mpls_flow(self.controller, l3_msg.group_id, port) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 925 | # add termination flow |
| 926 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 927 | vlan_id) |
| 928 | # add unicast routing flow |
| 929 | dst_ip = dip + (vlan_id << 8) |
| 930 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 931 | 0xffffffff, l3_msg.group_id) |
| 932 | Groups._put(l2_gid) |
| 933 | Groups._put(l3_msg.group_id) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 934 | do_barrier(self.controller) |
| 935 | |
| 936 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 937 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 938 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 939 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 940 | for out_port in ports: |
| 941 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 942 | continue |
| 943 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 944 | switch_mac = "00:00:00:cc:cc:cc" |
| 945 | label = (out_port, 0, 1, 32) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 946 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 947 | vlan_vid=in_port, ip_src=ip_src, |
| 948 | ip_dst=ip_dst, eth_dst=switch_mac, |
| 949 | eth_src=mac_src, label=[label]) |
| 950 | pkt = str(parsed_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 951 | self.dataplane.send(in_port, pkt) |
| 952 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 953 | # build expect packet |
| 954 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 955 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 956 | vlan_vid=out_port, |
| 957 | eth_dst=mac_dst, eth_src=switch_mac, |
| 958 | ip_ttl=31, ip_src=ip_src, |
| 959 | ip_dst=ip_dst) |
| 960 | pkt = str(exp_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 961 | verify_packet(self, pkt, out_port) |
| 962 | verify_no_other_packets(self) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 963 | |
| 964 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 965 | vlan_vid=in_port, |
| 966 | eth_dst=switch_mac, |
| 967 | eth_src=mac_src, ip_ttl=64, |
| 968 | ip_src=ip_src, |
| 969 | ip_dst=ip_dst) |
| 970 | pkt = str(parsed_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 971 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 972 | # build expected packet |
| 973 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 974 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 975 | vlan_vid=out_port, |
| 976 | eth_dst=mac_dst, eth_src=switch_mac, |
| 977 | ip_ttl=63, |
| 978 | ip_src=ip_src, ip_dst=ip_dst) |
| 979 | pkt = str(exp_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 980 | verify_packet(self, pkt, out_port) |
| 981 | verify_no_other_packets(self) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 982 | delete_all_flows(self.controller) |
| 983 | delete_groups(self.controller, Groups) |
| 984 | |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 985 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 986 | class L3McastToL2(base_tests.SimpleDataPlane): |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 987 | """ |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 988 | Mcast routing to L2 |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 989 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 990 | |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 991 | def runTest(self): |
| 992 | """ |
| 993 | port1 (vlan 300)-> All Ports (vlan 300) |
| 994 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 995 | if len(config["port_map"]) < 3: |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 996 | logging.info("Port count less than 3, can't run this case") |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 997 | assert (False) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 998 | return |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 999 | Groups = Queue.LifoQueue() |
| 1000 | vlan_id = 300 |
| 1001 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1002 | intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1003 | dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 1004 | dst_mac_str = ':'.join(['%02X' % x for x in dst_mac]) |
| 1005 | port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 1006 | port1_mac_str = ':'.join(['%02X' % x for x in port1_mac]) |
| 1007 | src_ip = 0xc0a80101 |
| 1008 | src_ip_str = "192.168.1.1" |
| 1009 | dst_ip = 0xe0010101 |
| 1010 | dst_ip_str = "224.1.1.1" |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1011 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1012 | port1 = config["port_map"].keys()[0] |
| 1013 | port2 = config["port_map"].keys()[1] |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1014 | |
| 1015 | switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00] |
| 1016 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1017 | # add l2 interface group |
| 1018 | l2_intf_group_list = [] |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1019 | for port in config["port_map"].keys(): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1020 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1021 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1022 | if port == port2: |
| 1023 | continue |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1024 | l2_intf_gid, msg = add_one_l2_interface_group(self.controller, port, |
| 1025 | vlan_id=vlan_id, |
| 1026 | is_tagged=True, |
| 1027 | send_barrier=False) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1028 | l2_intf_group_list.append(l2_intf_gid) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1029 | Groups.put(l2_intf_gid) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1030 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1031 | # add termination flow |
| 1032 | add_termination_flow(self.controller, port1, 0x0800, switch_mac, |
| 1033 | vlan_id) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1034 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1035 | # add l3 interface group |
| 1036 | mcat_group_msg = add_l3_mcast_group(self.controller, vlan_id, 2, |
| 1037 | l2_intf_group_list) |
| 1038 | add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, |
| 1039 | mcat_group_msg.group_id) |
| 1040 | Groups._put(mcat_group_msg.group_id) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1041 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1042 | parsed_pkt = simple_udp_packet(pktlen=100, |
Flavio Castro | 89933f2 | 2016-02-03 15:53:16 -0500 | [diff] [blame] | 1043 | dl_vlan_enable=True, |
| 1044 | vlan_vid=vlan_id, |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1045 | eth_dst=dst_mac_str, |
| 1046 | eth_src=port1_mac_str, |
| 1047 | ip_ttl=64, |
| 1048 | ip_src=src_ip_str, |
| 1049 | ip_dst=dst_ip_str) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1050 | pkt = str(parsed_pkt) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1051 | self.dataplane.send(port1, pkt) |
| 1052 | for port in config["port_map"].keys(): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1053 | if port == port2 or port == port1: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1054 | verify_no_packet(self, pkt, port) |
| 1055 | continue |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1056 | verify_packet(self, pkt, port) |
| 1057 | verify_no_other_packets(self) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1058 | delete_all_flows(self.controller) |
| 1059 | delete_groups(self.controller, Groups) |
| 1060 | |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1061 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1062 | class L3McastToL3(base_tests.SimpleDataPlane): |
| 1063 | """ |
| 1064 | Mcast routing |
| 1065 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1066 | |
| 1067 | def runTest(self): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1068 | """ |
| 1069 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1070 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1071 | Groups = Queue.LifoQueue() |
| 1072 | if len(config["port_map"]) < 3: |
castroflavio | 4a09c96 | 2016-01-05 13:13:41 -0800 | [diff] [blame] | 1073 | logging.info("Port count less than 3, can't run this case") |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1074 | assert (False) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1075 | return |
| 1076 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1077 | vlan_id = 1 |
| 1078 | port2_out_vlan = 2 |
| 1079 | port3_out_vlan = 3 |
| 1080 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1081 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1082 | intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1083 | dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 1084 | dst_mac_str = ':'.join(['%02X' % x for x in dst_mac]) |
| 1085 | port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 1086 | port1_mac_str = ':'.join(['%02X' % x for x in port1_mac]) |
| 1087 | src_ip = 0xc0a80101 |
| 1088 | src_ip_str = "192.168.1.1" |
| 1089 | dst_ip = 0xe0010101 |
| 1090 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1091 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1092 | port1 = config["port_map"].keys()[0] |
| 1093 | port2 = config["port_map"].keys()[1] |
| 1094 | port3 = config["port_map"].keys()[2] |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1095 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1096 | # add l2 interface group |
| 1097 | for port in config["port_map"].keys(): |
| 1098 | l2gid, msg = add_one_l2_interface_group(self.controller, port, |
| 1099 | vlan_id=vlan_id, |
| 1100 | is_tagged=False, |
| 1101 | send_barrier=False) |
| 1102 | # add vlan flow table |
| 1103 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1104 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1105 | vlan_id += 1 |
| 1106 | Groups._put(l2gid) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1107 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1108 | # add termination flow |
| 1109 | add_termination_flow(self.controller, port1, 0x0800, |
| 1110 | [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
| 1111 | |
| 1112 | # add l3 interface group |
| 1113 | port2_ucast_msg = add_l3_interface_group(self.controller, port2, |
| 1114 | port2_out_vlan, 2, |
| 1115 | intf_src_mac) |
| 1116 | port3_ucast_msg = add_l3_interface_group(self.controller, port3, |
| 1117 | port3_out_vlan, 3, |
| 1118 | intf_src_mac) |
| 1119 | mcat_group_msg = add_l3_mcast_group(self.controller, in_vlan, 2, |
| 1120 | [port2_ucast_msg.group_id, |
| 1121 | port3_ucast_msg.group_id]) |
| 1122 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, |
| 1123 | mcat_group_msg.group_id) |
| 1124 | Groups._put(port2_ucast_msg.group_id) |
| 1125 | Groups._put(port3_ucast_msg.group_id) |
| 1126 | Groups._put(mcat_group_msg.group_id) |
| 1127 | parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, |
| 1128 | vlan_vid=1, |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1129 | eth_dst=dst_mac_str, |
| 1130 | eth_src=port1_mac_str, |
| 1131 | ip_ttl=64, |
| 1132 | ip_src=src_ip_str, |
| 1133 | ip_dst=dst_ip_str) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1134 | pkt = str(parsed_pkt) |
| 1135 | self.dataplane.send(port1, pkt) |
| 1136 | parsed_pkt = simple_udp_packet(pktlen=96, |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1137 | eth_dst=dst_mac_str, |
| 1138 | eth_src=intf_src_mac_str, |
| 1139 | ip_ttl=63, |
| 1140 | ip_src=src_ip_str, |
| 1141 | ip_dst=dst_ip_str) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1142 | pkt = str(parsed_pkt) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1143 | verify_packet(self, pkt, port2) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1144 | verify_packet(self, pkt, port3) |
| 1145 | verify_no_other_packets(self) |
| 1146 | delete_all_flows(self.controller) |
| 1147 | delete_groups(self.controller, Groups) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1148 | |
| 1149 | |
Flavio Castro | f54be49 | 2016-02-03 16:26:22 -0500 | [diff] [blame] | 1150 | class _MplsTermination(base_tests.SimpleDataPlane): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1151 | """ |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1152 | Insert IP packet |
| 1153 | Receive MPLS packet |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1154 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1155 | def runTest(self): |
| 1156 | Groups = Queue.LifoQueue() |
| 1157 | if len(config["port_map"]) < 2: |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1158 | logging.info("Port count less than 2, can't run this case") |
| 1159 | return |
Flavio Castro | bcc3dbc | 2016-04-06 11:05:03 -0400 | [diff] [blame^] | 1160 | dip = 0xc0a80001 |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1161 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1162 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1163 | # 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] | 1164 | ports = config["port_map"].keys() |
| 1165 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1166 | # add l2 interface group |
| 1167 | id = port |
| 1168 | vlan_id = id |
| 1169 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 1170 | vlan_id, True, False) |
| 1171 | dst_mac[5] = vlan_id |
| 1172 | # add L3 Unicast group |
| 1173 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 1174 | id=id, src_mac=intf_src_mac, |
| 1175 | dst_mac=dst_mac) |
| 1176 | # add L3 ecmp group |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1177 | 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] | 1178 | # add vlan flow table |
| 1179 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1180 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1181 | # add termination flow |
| 1182 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, |
| 1183 | vlan_id, goto_table=24) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1184 | add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
Flavio Castro | bcc3dbc | 2016-04-06 11:05:03 -0400 | [diff] [blame^] | 1185 | dst_ip = dip + (vlan_id << 8) |
| 1186 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
| 1187 | ecmp_msg.group_id, 1) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1188 | Groups._put(l2_gid) |
| 1189 | Groups._put(l3_msg.group_id) |
| 1190 | Groups._put(ecmp_msg.group_id) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1191 | do_barrier(self.controller) |
| 1192 | |
| 1193 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1194 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1195 | ip_src = '192.168.%02d.1' % (in_port) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1196 | for out_port in ports: |
| 1197 | if in_port == out_port: |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1198 | continue |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1199 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1200 | |
| 1201 | label = (out_port, 0, 1, 32) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1202 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 1203 | vlan_vid=(in_port), ip_src=ip_src, |
| 1204 | ip_dst=ip_dst, eth_dst=switch_mac, |
| 1205 | label=[label]) |
| 1206 | pkt = str(parsed_pkt) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1207 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1208 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1209 | # build expect packet |
| 1210 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1211 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1212 | vlan_vid=(out_port), |
| 1213 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1214 | ip_ttl=31, ip_src=ip_src, |
| 1215 | ip_dst=ip_dst) |
| 1216 | pkt = str(exp_pkt) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1217 | verify_packet(self, pkt, out_port) |
| 1218 | verify_no_other_packets(self) |
Flavio Castro | bcc3dbc | 2016-04-06 11:05:03 -0400 | [diff] [blame^] | 1219 | #delete_all_flows(self.controller) |
| 1220 | #delete_groups(self.controller, Groups) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1221 | |
| 1222 | |
| 1223 | class _24UcastTagged(base_tests.SimpleDataPlane): |
| 1224 | """ |
| 1225 | Verify a IP forwarding works for a /32 rule to L3 Unicast Interface |
| 1226 | """ |
| 1227 | |
| 1228 | def runTest(self): |
| 1229 | test_id = 26 |
| 1230 | if len(config["port_map"]) < 2: |
| 1231 | logging.info("Port count less than 2, can't run this case") |
| 1232 | return |
| 1233 | |
| 1234 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1235 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1236 | dip = 0xc0a80001 |
| 1237 | ports = config["port_map"].keys() |
| 1238 | Groups = Queue.LifoQueue() |
| 1239 | for port in ports: |
| 1240 | # add l2 interface group |
| 1241 | vlan_id = port + test_id |
| 1242 | l2gid, msg = add_one_l2_interface_group(self.controller, port, |
| 1243 | vlan_id=vlan_id, |
| 1244 | is_tagged=True, |
| 1245 | send_barrier=False) |
| 1246 | dst_mac[5] = vlan_id |
| 1247 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 1248 | id=vlan_id, src_mac=intf_src_mac, |
| 1249 | dst_mac=dst_mac) |
| 1250 | # add vlan flow table |
| 1251 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1252 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1253 | # add termination flow |
| 1254 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 1255 | vlan_id) |
| 1256 | # add unicast routing flow |
| 1257 | dst_ip = dip + (vlan_id << 8) |
| 1258 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 1259 | 0xffffff00, l3_msg.group_id) |
| 1260 | Groups.put(l2gid) |
| 1261 | Groups.put(l3_msg.group_id) |
| 1262 | do_barrier(self.controller) |
| 1263 | |
| 1264 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1265 | for in_port in ports: |
| 1266 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1267 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1268 | for out_port in ports: |
| 1269 | if in_port == out_port: |
| 1270 | continue |
| 1271 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 1272 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1273 | vlan_vid=(test_id + in_port), |
| 1274 | eth_dst=switch_mac, |
| 1275 | eth_src=mac_src, ip_ttl=64, |
| 1276 | ip_src=ip_src, |
| 1277 | ip_dst=ip_dst) |
| 1278 | pkt = str(parsed_pkt) |
| 1279 | self.dataplane.send(in_port, pkt) |
| 1280 | # build expected packet |
| 1281 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 1282 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1283 | vlan_vid=(test_id + out_port), |
| 1284 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1285 | ip_ttl=63, |
| 1286 | ip_src=ip_src, ip_dst=ip_dst) |
| 1287 | pkt = str(exp_pkt) |
| 1288 | verify_packet(self, pkt, out_port) |
| 1289 | verify_no_other_packets(self) |
| 1290 | delete_all_flows(self.controller) |
| 1291 | delete_groups(self.controller, Groups) |