Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 1 | """ |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2 | Check README file |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 3 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 4 | import Queue |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 5 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 6 | from oftest import config |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 7 | import inspect |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 8 | import logging |
| 9 | import oftest.base_tests as base_tests |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 10 | import ofp |
| 11 | from oftest.testutils import * |
| 12 | from accton_util import * |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 13 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 14 | |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 15 | class PacketInUDP(base_tests.SimpleDataPlane): |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 16 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 17 | Verify a ACL rule that matches on IP_PROTO 2 will not match a UDP packet. |
| 18 | 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] | 19 | """ |
| 20 | |
| 21 | def runTest(self): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 22 | try: |
| 23 | parsed_vlan_pkt = simple_udp_packet(pktlen=104, |
| 24 | vlan_vid=0x1001, |
| 25 | dl_vlan_enable=True) |
| 26 | vlan_pkt = str(parsed_vlan_pkt) |
| 27 | # create match |
| 28 | match = ofp.match() |
| 29 | match.oxm_list.append(ofp.oxm.eth_type(0x0800)) |
| 30 | match.oxm_list.append(ofp.oxm.ip_proto(2)) |
| 31 | request = ofp.message.flow_add( |
| 32 | table_id=60, |
| 33 | cookie=42, |
| 34 | match=match, |
| 35 | instructions=[ |
| 36 | ofp.instruction.apply_actions( |
| 37 | actions=[ |
| 38 | ofp.action.output( |
| 39 | port=ofp.OFPP_CONTROLLER, |
| 40 | max_len=ofp.OFPCML_NO_BUFFER)]), ], |
| 41 | buffer_id=ofp.OFP_NO_BUFFER, |
| 42 | priority=1) |
| 43 | logging.info("Inserting packet in flow to controller") |
| 44 | self.controller.message_send(request) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 45 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 46 | for of_port in config["port_map"].keys(): |
| 47 | logging.info("PacketInMiss test, port %d", of_port) |
| 48 | self.dataplane.send(of_port, vlan_pkt) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 49 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 50 | verify_no_packet_in(self, vlan_pkt, of_port) |
| 51 | delete_all_flows(self.controller) |
| 52 | do_barrier(self.controller) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 53 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 54 | match = ofp.match() |
| 55 | match.oxm_list.append(ofp.oxm.eth_type(0x0800)) |
| 56 | match.oxm_list.append(ofp.oxm.ip_proto(17)) |
| 57 | request = ofp.message.flow_add( |
| 58 | table_id=60, |
| 59 | cookie=42, |
| 60 | match=match, |
| 61 | instructions=[ |
| 62 | ofp.instruction.apply_actions( |
| 63 | actions=[ |
| 64 | ofp.action.output( |
| 65 | port=ofp.OFPP_CONTROLLER, |
| 66 | max_len=ofp.OFPCML_NO_BUFFER)]), ], |
| 67 | buffer_id=ofp.OFP_NO_BUFFER, |
| 68 | priority=1) |
| 69 | logging.info("Inserting packet in flow to controller") |
| 70 | self.controller.message_send(request) |
| 71 | do_barrier(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 72 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 73 | for of_port in config["port_map"].keys(): |
| 74 | logging.info("PacketInMiss test, port %d", of_port) |
| 75 | self.dataplane.send(of_port, vlan_pkt) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 76 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 77 | verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 78 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 79 | verify_no_other_packets(self) |
| 80 | finally: |
| 81 | delete_all_flows(self.controller) |
| 82 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 83 | |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 84 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 85 | @disabled |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 86 | class ArpNL2(base_tests.SimpleDataPlane): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 87 | def runTest(self): |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 88 | delete_all_flows(self.controller) |
| 89 | delete_all_groups(self.controller) |
| 90 | |
| 91 | ports = sorted(config["port_map"].keys()) |
| 92 | match = ofp.match() |
| 93 | match.oxm_list.append(ofp.oxm.eth_type(0x0806)) |
| 94 | request = ofp.message.flow_add( |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 95 | table_id=60, |
| 96 | cookie=42, |
| 97 | match=match, |
| 98 | instructions=[ |
| 99 | ofp.instruction.apply_actions( |
| 100 | actions=[ |
| 101 | ofp.action.output( |
| 102 | port=ofp.OFPP_CONTROLLER, |
| 103 | max_len=ofp.OFPCML_NO_BUFFER)]), |
| 104 | ], |
| 105 | buffer_id=ofp.OFP_NO_BUFFER, |
| 106 | priority=40000) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 107 | self.controller.message_send(request) |
| 108 | for port in ports: |
Flavio Castro | 932014b | 2016-01-05 18:29:15 -0500 | [diff] [blame] | 109 | add_one_l2_interface_group(self.controller, port, 1, False, False) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 110 | add_one_vlan_table_flow(self.controller, port, 1, |
| 111 | flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 112 | group_id = encode_l2_interface_group_id(1, port) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 113 | add_bridge_flow(self.controller, |
| 114 | [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, |
| 115 | True) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 116 | do_barrier(self.controller) |
| 117 | parsed_arp_pkt = simple_arp_packet() |
| 118 | arp_pkt = str(parsed_arp_pkt) |
| 119 | |
| 120 | for out_port in ports: |
| 121 | self.dataplane.send(out_port, arp_pkt) |
| 122 | verify_packet_in(self, arp_pkt, out_port, ofp.OFPR_ACTION) |
| 123 | # change dest based on port number |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 124 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 125 | for in_port in ports: |
| 126 | if in_port == out_port: |
| 127 | continue |
| 128 | # change source based on port number to avoid packet-ins from learning |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 129 | mac_src = '00:12:34:56:78:%02X' % in_port |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 130 | parsed_pkt = simple_tcp_packet(eth_dst=mac_dst, eth_src=mac_src) |
| 131 | pkt = str(parsed_pkt) |
| 132 | self.dataplane.send(in_port, pkt) |
| 133 | |
| 134 | for ofport in ports: |
| 135 | if ofport in [out_port]: |
| 136 | verify_packet(self, pkt, ofport) |
| 137 | else: |
| 138 | verify_no_packet(self, pkt, ofport) |
| 139 | |
| 140 | verify_no_other_packets(self) |
| 141 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 142 | |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 143 | class PacketInArp(base_tests.SimpleDataPlane): |
| 144 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 145 | 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] | 146 | """ |
| 147 | |
| 148 | def runTest(self): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 149 | try: |
| 150 | parsed_arp_pkt = simple_arp_packet() |
| 151 | arp_pkt = str(parsed_arp_pkt) |
| 152 | # create match |
| 153 | match = ofp.match() |
| 154 | match.oxm_list.append(ofp.oxm.eth_type(0x0806)) |
| 155 | request = ofp.message.flow_add( |
| 156 | table_id=60, |
| 157 | cookie=42, |
| 158 | match=match, |
| 159 | instructions=[ |
| 160 | ofp.instruction.apply_actions( |
| 161 | actions=[ |
| 162 | ofp.action.output( |
| 163 | port=ofp.OFPP_CONTROLLER, |
| 164 | max_len=ofp.OFPCML_NO_BUFFER)]), |
| 165 | ], |
| 166 | buffer_id=ofp.OFP_NO_BUFFER, |
| 167 | priority=1) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 168 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 169 | logging.info("Inserting packet in flow to controller") |
| 170 | self.controller.message_send(request) |
| 171 | do_barrier(self.controller) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 172 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 173 | for of_port in config["port_map"].keys(): |
| 174 | logging.info("PacketInMiss test, port %d", of_port) |
| 175 | self.dataplane.send(of_port, arp_pkt) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 176 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 177 | verify_packet_in(self, arp_pkt, of_port, ofp.OFPR_ACTION) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 178 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 179 | verify_no_other_packets(self) |
| 180 | finally: |
| 181 | delete_all_flows(self.controller) |
| 182 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 183 | |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 184 | class PacketInIPTable(base_tests.SimpleDataPlane): |
| 185 | """ |
| 186 | Test packet in function on IPTABLE |
| 187 | Send a packet to each dataplane port and verify that a packet |
| 188 | in message is received from the controller for each |
| 189 | #todo verify you stop receiving after adding rule |
| 190 | """ |
| 191 | |
| 192 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 193 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 194 | try: |
| 195 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 196 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 197 | dip=0xc0a80001 |
| 198 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 199 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 200 | for port in ports: |
| 201 | #add l2 interface group |
| 202 | vlan_id=port |
| 203 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False) |
| 204 | dst_mac[5]=vlan_id |
| 205 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 206 | #add vlan flow table |
| 207 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 208 | #add termination flow |
| 209 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 210 | #add unicast routing flow |
| 211 | dst_ip = dip + (vlan_id<<8) |
| 212 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, send_ctrl=True) |
| 213 | Groups.put(l3_msg.group_id) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 214 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 215 | do_barrier(self.controller) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 216 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 217 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 218 | for in_port in ports: |
| 219 | mac_src='00:00:00:22:22:%02X' % in_port |
| 220 | ip_src='192.168.%02d.1' % in_port |
| 221 | for out_port in ports: |
| 222 | if in_port == out_port: |
| 223 | continue |
| 224 | ip_dst='192.168.%02d.1' % out_port |
| 225 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 226 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 227 | ip_dst=ip_dst) |
| 228 | pkt=str(parsed_pkt) |
| 229 | self.dataplane.send(in_port, pkt) |
| 230 | verify_packet_in(self, pkt, in_port, ofp.OFPR_ACTION) |
| 231 | #verify_no_other_packets(self) |
| 232 | finally: |
| 233 | delete_all_flows(self.controller) |
| 234 | delete_groups(self.controller, Groups) |
| 235 | delete_all_groups(self.controller) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 236 | |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 237 | class L2FloodQinQ(base_tests.SimpleDataPlane): |
| 238 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 239 | Verify a tagged frame can be flooded based on its outer vlan |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 240 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 241 | |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 242 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 243 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 244 | try: |
| 245 | ports = sorted(config["port_map"].keys()) |
| 246 | vlan_id = 1 |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 247 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 248 | for port in ports: |
| 249 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, |
| 250 | vlan_id, True, False) |
| 251 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 252 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 253 | Groups.put(L2gid) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 254 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 255 | msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id) |
| 256 | Groups.put(msg.group_id) |
| 257 | add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True) |
| 258 | do_barrier(self.controller) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 259 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 260 | # verify flood |
| 261 | for ofport in ports: |
| 262 | # change dest based on port number |
| 263 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 264 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, |
| 265 | out_dl_vlan_enable=True, |
| 266 | out_vlan_vid=vlan_id, |
| 267 | in_dl_vlan_enable=True, |
| 268 | in_vlan_vid=10, |
| 269 | eth_dst='00:12:34:56:78:9a', |
| 270 | eth_src=mac_src) |
| 271 | pkt = str(parsed_pkt) |
| 272 | self.dataplane.send(ofport, pkt) |
| 273 | # self won't rx packet |
| 274 | verify_no_packet(self, pkt, ofport) |
| 275 | # others will rx packet |
| 276 | tmp_ports = list(ports) |
| 277 | tmp_ports.remove(ofport) |
| 278 | verify_packets(self, pkt, tmp_ports) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 279 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 280 | verify_no_other_packets(self) |
| 281 | finally: |
| 282 | delete_all_flows(self.controller) |
| 283 | delete_groups(self.controller, Groups) |
| 284 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 285 | |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 286 | @disabled |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 287 | class L2FloodTagged(base_tests.SimpleDataPlane): |
| 288 | """ |
| 289 | Test L2 flood to a vlan |
| 290 | 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] | 291 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 292 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 293 | def runTest(self): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 294 | # Hashes Test Name and uses it as id for installing unique groups |
| 295 | vlan_id = abs(hash(inspect.stack()[0][3])) % (256) |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 296 | print vlan_id |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 297 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 298 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 299 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 300 | delete_all_flows(self.controller) |
| 301 | delete_all_groups(self.controller) |
| 302 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 303 | # Installing flows to avoid packet-in |
| 304 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 305 | add_one_l2_interface_group(self.controller, port, vlan_id, True, |
| 306 | False) |
| 307 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 308 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 309 | msg = add_l2_flood_group(self.controller, ports, vlan_id, vlan_id) |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 310 | add_bridge_flow(self.controller, None, vlan_id, msg.group_id, True) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 311 | do_barrier(self.controller) |
| 312 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 313 | # verify flood |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 314 | for ofport in ports: |
| 315 | # change dest based on port number |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 316 | pkt = str(simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, |
| 317 | eth_dst='00:12:34:56:78:9a')) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 318 | self.dataplane.send(ofport, pkt) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 319 | # self won't rx packet |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 320 | verify_no_packet(self, pkt, ofport) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 321 | # others will rx packet |
| 322 | tmp_ports = list(ports) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 323 | tmp_ports.remove(ofport) |
| 324 | verify_packets(self, pkt, tmp_ports) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 325 | verify_no_other_packets(self) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 326 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 327 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 328 | class L2UnicastTagged(base_tests.SimpleDataPlane): |
| 329 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 330 | Verify L2 forwarding works |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 331 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 332 | |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 333 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 334 | |
| 335 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 336 | try: |
| 337 | ports = sorted(config["port_map"].keys()) |
| 338 | vlan_id = 1; |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 339 | for port in ports: |
| 340 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, |
| 341 | vlan_id, True, False) |
| 342 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 343 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 344 | Groups.put(L2gid) |
| 345 | add_bridge_flow(self.controller, |
| 346 | [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id, |
| 347 | L2gid, True) |
| 348 | do_barrier(self.controller) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 349 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 350 | for out_port in ports: |
| 351 | # change dest based on port number |
| 352 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 353 | for in_port in ports: |
| 354 | if in_port == out_port: |
| 355 | continue |
| 356 | pkt = str( |
| 357 | simple_tcp_packet(dl_vlan_enable=True, vlan_vid=vlan_id, |
| 358 | eth_dst=mac_dst)) |
| 359 | self.dataplane.send(in_port, pkt) |
| 360 | for ofport in ports: |
| 361 | if ofport in [out_port]: |
| 362 | verify_packet(self, pkt, ofport) |
| 363 | else: |
| 364 | verify_no_packet(self, pkt, ofport) |
| 365 | verify_no_other_packets(self) |
| 366 | finally: |
| 367 | delete_all_flows(self.controller) |
| 368 | delete_groups(self.controller, Groups) |
| 369 | delete_all_groups(self.controller) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 370 | |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 371 | class Mtu1500(base_tests.SimpleDataPlane): |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 372 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 373 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 374 | try: |
| 375 | ports = sorted(config["port_map"].keys()) |
| 376 | vlan_id = 18 |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 377 | for port in ports: |
| 378 | L2gid, msg = add_one_l2_interface_group(self.controller, port, |
| 379 | vlan_id, True, False) |
| 380 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 381 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 382 | Groups.put(L2gid) |
| 383 | add_bridge_flow(self.controller, |
| 384 | [0x00, 0x12, 0x34, 0x56, 0x78, port], vlan_id, |
| 385 | L2gid, True) |
| 386 | do_barrier(self.controller) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 387 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 388 | for out_port in ports: |
| 389 | # change dest based on port number |
| 390 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 391 | for in_port in ports: |
| 392 | if in_port == out_port: |
| 393 | continue |
| 394 | pkt = str(simple_tcp_packet(pktlen=1500, dl_vlan_enable=True, |
| 395 | vlan_vid=vlan_id, eth_dst=mac_dst)) |
| 396 | self.dataplane.send(in_port, pkt) |
| 397 | for ofport in ports: |
| 398 | if ofport in [out_port]: |
| 399 | verify_packet(self, pkt, ofport) |
| 400 | else: |
| 401 | verify_no_packet(self, pkt, ofport) |
| 402 | verify_no_other_packets(self) |
| 403 | finally: |
| 404 | delete_all_flows(self.controller) |
| 405 | delete_groups(self.controller, Groups) |
| 406 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 407 | |
| 408 | class _32UcastTagged(base_tests.SimpleDataPlane): |
| 409 | """ |
| 410 | Verify a IP forwarding works for a /32 rule to L3 Unicast Interface |
| 411 | """ |
| 412 | |
| 413 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 414 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 415 | try: |
| 416 | test_id = 26 |
| 417 | if len(config["port_map"]) < 2: |
| 418 | logging.info("Port count less than 2, can't run this case") |
| 419 | return |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 420 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 421 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 422 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 423 | dip = 0xc0a80001 |
| 424 | ports = config["port_map"].keys() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 425 | for port in ports: |
| 426 | # add l2 interface group |
| 427 | vlan_id = port + test_id |
| 428 | l2gid, msg = add_one_l2_interface_group(self.controller, port, |
| 429 | vlan_id=vlan_id, |
| 430 | is_tagged=True, |
| 431 | send_barrier=False) |
| 432 | dst_mac[5] = vlan_id |
| 433 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 434 | id=vlan_id, src_mac=intf_src_mac, |
| 435 | dst_mac=dst_mac) |
| 436 | # add vlan flow table |
| 437 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 438 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 439 | # add termination flow |
| 440 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 441 | vlan_id) |
| 442 | # add unicast routing flow |
| 443 | dst_ip = dip + (vlan_id << 8) |
| 444 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 445 | 0xffffffff, l3_msg.group_id) |
| 446 | Groups.put(l2gid) |
| 447 | Groups.put(l3_msg.group_id) |
| 448 | do_barrier(self.controller) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 449 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 450 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 451 | for in_port in ports: |
| 452 | mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| 453 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 454 | for out_port in ports: |
| 455 | if in_port == out_port: |
| 456 | continue |
| 457 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 458 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 459 | vlan_vid=(test_id + in_port), |
| 460 | eth_dst=switch_mac, |
| 461 | eth_src=mac_src, ip_ttl=64, |
| 462 | ip_src=ip_src, |
| 463 | ip_dst=ip_dst) |
| 464 | pkt = str(parsed_pkt) |
| 465 | self.dataplane.send(in_port, pkt) |
| 466 | # build expected packet |
| 467 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 468 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 469 | vlan_vid=(test_id + out_port), |
| 470 | eth_dst=mac_dst, eth_src=switch_mac, |
| 471 | ip_ttl=63, |
| 472 | ip_src=ip_src, ip_dst=ip_dst) |
| 473 | pkt = str(exp_pkt) |
| 474 | verify_packet(self, pkt, out_port) |
| 475 | verify_no_other_packets(self) |
| 476 | finally: |
| 477 | delete_all_flows(self.controller) |
| 478 | delete_groups(self.controller, Groups) |
| 479 | delete_all_groups(self.controller) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 480 | |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 481 | class _32VPN(base_tests.SimpleDataPlane): |
| 482 | """ |
| 483 | Insert IP packet |
| 484 | Receive MPLS packet |
| 485 | """ |
| 486 | |
| 487 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 488 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 489 | try: |
| 490 | if len(config["port_map"]) < 2: |
| 491 | logging.info("Port count less than 2, can't run this case") |
| 492 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 493 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 494 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 495 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 496 | dip = 0xc0a80001 |
| 497 | ports = config["port_map"].keys() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 498 | for port in ports: |
| 499 | # add l2 interface group |
| 500 | id = port |
| 501 | vlan_id = port |
| 502 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 503 | vlan_id, True, True) |
| 504 | dst_mac[5] = vlan_id |
| 505 | # add MPLS interface group |
| 506 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 507 | dst_mac, intf_src_mac, |
| 508 | vlan_id, id) |
| 509 | # add MPLS L3 VPN group |
| 510 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 511 | self.controller, |
| 512 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 513 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 514 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 515 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 516 | do_barrier(self.controller) |
| 517 | # add vlan flow table |
| 518 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=2, |
| 519 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 520 | # add termination flow |
| 521 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 522 | vlan_id) |
| 523 | # add routing flow |
| 524 | dst_ip = dip + (vlan_id << 8) |
| 525 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 526 | 0xffffffff, mpls_label_gid,vrf=2) |
| 527 | Groups._put(l2_gid) |
| 528 | Groups._put(mpls_gid) |
| 529 | Groups._put(mpls_label_gid) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 530 | do_barrier(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 531 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 532 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 533 | for in_port in ports: |
| 534 | ip_src = '192.168.%02d.1' % (in_port) |
| 535 | for out_port in ports: |
| 536 | if in_port == out_port: |
| 537 | continue |
| 538 | ip_dst = '192.168.%02d.1' % (out_port) |
| 539 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 540 | vlan_vid=(in_port), |
| 541 | eth_dst=switch_mac, ip_ttl=64, |
| 542 | ip_src=ip_src, |
| 543 | ip_dst=ip_dst) |
| 544 | pkt = str(parsed_pkt) |
| 545 | self.dataplane.send(in_port, pkt) |
| 546 | # build expect packet |
| 547 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 548 | label = (out_port, 0, 1, 32) |
| 549 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 550 | vlan_vid=(out_port), ip_ttl=63, |
| 551 | ip_src=ip_src, |
| 552 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 553 | eth_src=switch_mac, label=[label]) |
| 554 | pkt = str(exp_pkt) |
| 555 | verify_packet(self, pkt, out_port) |
| 556 | verify_no_other_packets(self) |
| 557 | finally: |
| 558 | delete_all_flows(self.controller) |
| 559 | delete_groups(self.controller, Groups) |
| 560 | delete_all_groups(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 561 | |
| 562 | class _32EcmpVpn(base_tests.SimpleDataPlane): |
| 563 | """ |
| 564 | Insert IP packet |
| 565 | Receive MPLS packet |
| 566 | """ |
| 567 | |
| 568 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 569 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 570 | try: |
| 571 | if len(config["port_map"]) < 2: |
| 572 | logging.info("Port count less than 2, can't run this case") |
| 573 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 574 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 575 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 576 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 577 | dip = 0xc0a80001 |
| 578 | ports = config["port_map"].keys() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 579 | for port in ports: |
| 580 | # add l2 interface group |
| 581 | id = port |
| 582 | vlan_id = port |
| 583 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 584 | vlan_id, True, True) |
| 585 | dst_mac[5] = vlan_id |
| 586 | # add MPLS interface group |
| 587 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 588 | dst_mac, intf_src_mac, |
| 589 | vlan_id, id) |
| 590 | # add MPLS L3 VPN group |
| 591 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 592 | self.controller, |
| 593 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 594 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 595 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 596 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 597 | do_barrier(self.controller) |
| 598 | # add vlan flow table |
| 599 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, |
| 600 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 601 | # add termination flow |
| 602 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 603 | vlan_id) |
| 604 | # add routing flow |
| 605 | dst_ip = dip + (vlan_id << 8) |
| 606 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 607 | 0xffffffff, ecmp_msg.group_id) |
| 608 | Groups._put(l2_gid) |
| 609 | Groups._put(mpls_gid) |
| 610 | Groups._put(mpls_label_gid) |
| 611 | Groups._put(ecmp_msg.group_id) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 612 | do_barrier(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 613 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 614 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 615 | for in_port in ports: |
| 616 | ip_src = '192.168.%02d.1' % (in_port) |
| 617 | for out_port in ports: |
| 618 | if in_port == out_port: |
| 619 | continue |
| 620 | ip_dst = '192.168.%02d.1' % (out_port) |
| 621 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 622 | vlan_vid=(in_port), |
| 623 | eth_dst=switch_mac, ip_ttl=64, |
| 624 | ip_src=ip_src, |
| 625 | ip_dst=ip_dst) |
| 626 | pkt = str(parsed_pkt) |
| 627 | self.dataplane.send(in_port, pkt) |
| 628 | # build expect packet |
| 629 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 630 | label = (out_port, 0, 1, 32) |
| 631 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 632 | vlan_vid=(out_port), ip_ttl=63, |
| 633 | ip_src=ip_src, |
| 634 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 635 | eth_src=switch_mac, label=[label]) |
| 636 | pkt = str(exp_pkt) |
| 637 | verify_packet(self, pkt, out_port) |
| 638 | verify_no_other_packets(self) |
| 639 | finally: |
| 640 | delete_all_flows(self.controller) |
| 641 | delete_groups(self.controller, Groups) |
| 642 | delete_all_groups(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 643 | |
| 644 | class _32ECMPL3(base_tests.SimpleDataPlane): |
| 645 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 646 | Insert IP packet |
| 647 | Receive IP packet |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 648 | """ |
| 649 | |
| 650 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 651 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 652 | try: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 653 | if len(config["port_map"]) < 2: |
| 654 | logging.info("Port count less than 2, can't run this case") |
| 655 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 656 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 657 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 658 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 659 | dip = 0xc0a80001 |
| 660 | # Hashes Test Name and uses it as id for installing unique groups |
| 661 | ports = config["port_map"].keys() |
| 662 | for port in ports: |
| 663 | vlan_id = port |
| 664 | id = port |
| 665 | # add l2 interface group |
| 666 | l2_gid, msg = add_one_l2_interface_group(self.controller, port, |
| 667 | vlan_id=vlan_id, |
| 668 | is_tagged=True, |
| 669 | send_barrier=False) |
| 670 | dst_mac[5] = vlan_id |
| 671 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 672 | id=id, src_mac=intf_src_mac, |
| 673 | dst_mac=dst_mac) |
| 674 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id]) |
| 675 | # add vlan flow table |
| 676 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 677 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 678 | # add termination flow |
| 679 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 680 | vlan_id) |
| 681 | # add unicast routing flow |
| 682 | dst_ip = dip + (vlan_id << 8) |
| 683 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 684 | 0xffffffff, ecmp_msg.group_id) |
| 685 | Groups._put(l2_gid) |
| 686 | Groups._put(l3_msg.group_id) |
| 687 | Groups._put(ecmp_msg.group_id) |
| 688 | do_barrier(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 689 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 690 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 691 | for in_port in ports: |
| 692 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 693 | ip_src = '192.168.%02d.1' % in_port |
| 694 | for out_port in ports: |
| 695 | if in_port == out_port: |
| 696 | continue |
| 697 | ip_dst = '192.168.%02d.1' % out_port |
| 698 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 699 | vlan_vid=in_port, |
| 700 | eth_dst=switch_mac, |
| 701 | eth_src=mac_src, ip_ttl=64, |
| 702 | ip_src=ip_src, |
| 703 | ip_dst=ip_dst) |
| 704 | pkt = str(parsed_pkt) |
| 705 | self.dataplane.send(in_port, pkt) |
| 706 | # build expected packet |
| 707 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 708 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 709 | vlan_vid=out_port, |
| 710 | eth_dst=mac_dst, eth_src=switch_mac, |
| 711 | ip_ttl=63, |
| 712 | ip_src=ip_src, ip_dst=ip_dst) |
| 713 | pkt = str(exp_pkt) |
| 714 | verify_packet(self, pkt, out_port) |
| 715 | verify_no_other_packets(self) |
| 716 | finally: |
| 717 | delete_all_flows(self.controller) |
| 718 | delete_groups(self.controller, Groups) |
| 719 | delete_all_groups(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 720 | |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 721 | class _24VPN(base_tests.SimpleDataPlane): |
| 722 | """ |
| 723 | Insert IP packet |
| 724 | Receive MPLS packet |
| 725 | """ |
| 726 | |
| 727 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 728 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 729 | try: |
| 730 | if len(config["port_map"]) < 2: |
| 731 | logging.info("Port count less than 2, can't run this case") |
| 732 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 733 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 734 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 735 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 736 | dip = 0xc0a80001 |
| 737 | ports = config["port_map"].keys() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 738 | for port in ports: |
| 739 | # add l2 interface group |
| 740 | id = port |
| 741 | vlan_id = port |
| 742 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True) |
| 743 | dst_mac[5] = vlan_id |
| 744 | # add MPLS interface group |
| 745 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, id) |
| 746 | # add MPLS L3 VPN group |
| 747 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 748 | self.controller, |
| 749 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 750 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 751 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 752 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 753 | do_barrier(self.controller) |
| 754 | # add vlan flow table |
| 755 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, |
| 756 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 757 | # add termination flow |
| 758 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 759 | vlan_id) |
| 760 | # add routing flow |
| 761 | dst_ip = dip + (vlan_id << 8) |
| 762 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 763 | 0xffffff00, mpls_label_gid) |
| 764 | Groups._put(l2_gid) |
| 765 | Groups._put(mpls_gid) |
| 766 | Groups._put(mpls_label_gid) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 767 | do_barrier(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 768 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 769 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 770 | for in_port in ports: |
| 771 | ip_src = '192.168.%02d.1' % (in_port) |
| 772 | for out_port in ports: |
| 773 | if in_port == out_port: |
| 774 | continue |
| 775 | ip_dst = '192.168.%02d.1' % (out_port) |
| 776 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 777 | vlan_vid=(in_port), |
| 778 | eth_dst=switch_mac, ip_ttl=64, |
| 779 | ip_src=ip_src, |
| 780 | ip_dst=ip_dst) |
| 781 | pkt = str(parsed_pkt) |
| 782 | self.dataplane.send(in_port, pkt) |
| 783 | # build expect packet |
| 784 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 785 | label = (out_port, 0, 1, 32) |
| 786 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 787 | vlan_vid=(out_port), ip_ttl=63, |
| 788 | ip_src=ip_src, |
| 789 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 790 | eth_src=switch_mac, label=[label]) |
| 791 | pkt = str(exp_pkt) |
| 792 | verify_packet(self, pkt, out_port) |
| 793 | verify_no_other_packets(self) |
| 794 | finally: |
| 795 | delete_all_flows(self.controller) |
| 796 | delete_groups(self.controller, Groups) |
| 797 | delete_all_groups(self.controller) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 798 | |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 799 | class _24EcmpVpn(base_tests.SimpleDataPlane): |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 800 | """ |
| 801 | Insert IP packet |
| 802 | Receive MPLS packet |
| 803 | """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 804 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 805 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 806 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 807 | try: |
| 808 | if len(config["port_map"]) < 2: |
| 809 | logging.info("Port count less than 2, can't run this case") |
| 810 | return |
| 811 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 812 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 813 | dip = 0xc0a80001 |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 814 | ports = config["port_map"].keys() |
| 815 | for port in ports: |
| 816 | # add l2 interface group |
| 817 | id = port |
| 818 | vlan_id = id |
| 819 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 820 | vlan_id, True, True) |
| 821 | dst_mac[5] = vlan_id |
| 822 | # add MPLS interface group |
| 823 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 824 | dst_mac, intf_src_mac, |
| 825 | vlan_id, id) |
| 826 | # add MPLS L3 VPN group |
| 827 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 828 | self.controller, |
| 829 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 830 | index=id, ref_gid=mpls_gid, push_mpls_header=True, |
| 831 | set_mpls_label=port, set_bos=1, set_ttl=32) |
| 832 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [mpls_label_gid]) |
| 833 | do_barrier(self.controller) |
| 834 | # add vlan flow table |
| 835 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, |
| 836 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 837 | # add termination flow |
| 838 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 839 | vlan_id) |
| 840 | # add routing flow |
| 841 | dst_ip = dip + (vlan_id << 8) |
| 842 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
| 843 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 844 | 0xffffff00, ecmp_msg.group_id, vrf=0) |
| 845 | Groups._put(l2_gid) |
| 846 | Groups._put(mpls_gid) |
| 847 | Groups._put(mpls_label_gid) |
| 848 | Groups._put(ecmp_msg.group_id) |
| 849 | |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 850 | do_barrier(self.controller) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 851 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 852 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 853 | for in_port in ports: |
| 854 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 855 | ip_src = '192.168.%02d.1' % (in_port) |
| 856 | for out_port in ports: |
| 857 | if in_port == out_port: |
| 858 | continue |
| 859 | ip_dst = '192.168.%02d.1' % (out_port) |
| 860 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 861 | vlan_vid=(in_port), |
| 862 | eth_dst=switch_mac, |
| 863 | eth_src=mac_src, ip_ttl=64, |
| 864 | ip_src=ip_src, |
| 865 | ip_dst=ip_dst) |
| 866 | pkt = str(parsed_pkt) |
| 867 | self.dataplane.send(in_port, pkt) |
| 868 | # build expect packet |
| 869 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 870 | label = (out_port, 0, 1, 32) |
| 871 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 872 | vlan_vid=(out_port), ip_ttl=63, |
| 873 | ip_src=ip_src, |
| 874 | ip_dst=ip_dst, eth_dst=mac_dst, |
| 875 | eth_src=switch_mac, label=[label]) |
| 876 | pkt = str(exp_pkt) |
| 877 | verify_packet(self, pkt, out_port) |
| 878 | verify_no_other_packets(self) |
| 879 | finally: |
| 880 | delete_all_flows(self.controller) |
| 881 | delete_groups(self.controller, Groups) |
| 882 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 883 | |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 884 | class _24ECMPL3(base_tests.SimpleDataPlane): |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 885 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 886 | Insert IP packet |
| 887 | Receive IP packet |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 888 | """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 889 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 890 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 891 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 892 | try: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 893 | if len(config["port_map"]) < 2: |
| 894 | logging.info("Port count less than 2, can't run this case") |
| 895 | return |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 896 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 897 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 898 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 899 | dip = 0xc0a80001 |
| 900 | # Hashes Test Name and uses it as id for installing unique groups |
| 901 | ports = config["port_map"].keys() |
| 902 | for port in ports: |
| 903 | vlan_id = port |
| 904 | id = port |
| 905 | # add l2 interface group |
| 906 | l2_gid, msg = add_one_l2_interface_group(self.controller, port, |
| 907 | vlan_id=vlan_id, |
| 908 | is_tagged=True, |
| 909 | send_barrier=False) |
| 910 | dst_mac[5] = vlan_id |
| 911 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 912 | id=id, src_mac=intf_src_mac, |
| 913 | dst_mac=dst_mac) |
| 914 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id]) |
| 915 | # add vlan flow table |
| 916 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 917 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 918 | # add termination flow |
| 919 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 920 | vlan_id) |
| 921 | # add unicast routing flow |
| 922 | dst_ip = dip + (vlan_id << 8) |
| 923 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 924 | 0xffffff00, ecmp_msg.group_id) |
| 925 | Groups._put(l2_gid) |
| 926 | Groups._put(l3_msg.group_id) |
| 927 | Groups._put(ecmp_msg.group_id) |
| 928 | do_barrier(self.controller) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 929 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 930 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 931 | for in_port in ports: |
| 932 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 933 | ip_src = '192.168.%02d.1' % in_port |
| 934 | for out_port in ports: |
| 935 | if in_port == out_port: |
| 936 | continue |
| 937 | ip_dst = '192.168.%02d.1' % out_port |
| 938 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 939 | vlan_vid=in_port, |
| 940 | eth_dst=switch_mac, |
| 941 | eth_src=mac_src, ip_ttl=64, |
| 942 | ip_src=ip_src, |
| 943 | ip_dst=ip_dst) |
| 944 | pkt = str(parsed_pkt) |
| 945 | self.dataplane.send(in_port, pkt) |
| 946 | # build expected packet |
| 947 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 948 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 949 | vlan_vid=out_port, |
| 950 | eth_dst=mac_dst, eth_src=switch_mac, |
| 951 | ip_ttl=63, |
| 952 | ip_src=ip_src, ip_dst=ip_dst) |
| 953 | pkt = str(exp_pkt) |
| 954 | verify_packet(self, pkt, out_port) |
| 955 | verify_no_other_packets(self) |
| 956 | finally: |
| 957 | delete_all_flows(self.controller) |
| 958 | delete_groups(self.controller, Groups) |
| 959 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 960 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 961 | @disabled |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 962 | class MPLSBUG(base_tests.SimpleDataPlane): |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 963 | def runTest(self): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 964 | if len(config["port_map"]) < 2: |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 965 | logging.info("Port count less than 2, can't run this case") |
| 966 | return |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 967 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 968 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 969 | dip = 0xc0a80001 |
| 970 | Groups = Queue.LifoQueue() |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 971 | ports = config["port_map"].keys() |
| 972 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 973 | # add l2 interface group |
| 974 | vlan_id = port |
| 975 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 976 | vlan_id, True, False) |
| 977 | dst_mac[5] = vlan_id |
| 978 | # add L3 Unicast group |
| 979 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 980 | id=vlan_id, src_mac=intf_src_mac, |
| 981 | dst_mac=dst_mac) |
| 982 | # add vlan flow table |
| 983 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 984 | flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 985 | # add termination flow |
| 986 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, |
| 987 | vlan_id, goto_table=24) |
| 988 | # add mpls flow |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 989 | add_mpls_flow(self.controller, l3_msg.group_id, port) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 990 | # add termination flow |
| 991 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 992 | vlan_id) |
| 993 | # add unicast routing flow |
| 994 | dst_ip = dip + (vlan_id << 8) |
| 995 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 996 | 0xffffffff, l3_msg.group_id) |
| 997 | Groups._put(l2_gid) |
| 998 | Groups._put(l3_msg.group_id) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 999 | do_barrier(self.controller) |
| 1000 | |
| 1001 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1002 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1003 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1004 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1005 | for out_port in ports: |
| 1006 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1007 | continue |
| 1008 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1009 | switch_mac = "00:00:00:cc:cc:cc" |
| 1010 | label = (out_port, 0, 1, 32) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1011 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 1012 | vlan_vid=in_port, ip_src=ip_src, |
| 1013 | ip_dst=ip_dst, eth_dst=switch_mac, |
| 1014 | eth_src=mac_src, label=[label]) |
| 1015 | pkt = str(parsed_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1016 | self.dataplane.send(in_port, pkt) |
| 1017 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1018 | # build expect packet |
| 1019 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1020 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1021 | vlan_vid=out_port, |
| 1022 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1023 | ip_ttl=31, ip_src=ip_src, |
| 1024 | ip_dst=ip_dst) |
| 1025 | pkt = str(exp_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1026 | verify_packet(self, pkt, out_port) |
| 1027 | verify_no_other_packets(self) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1028 | |
| 1029 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1030 | vlan_vid=in_port, |
| 1031 | eth_dst=switch_mac, |
| 1032 | eth_src=mac_src, ip_ttl=64, |
| 1033 | ip_src=ip_src, |
| 1034 | ip_dst=ip_dst) |
| 1035 | pkt = str(parsed_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1036 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1037 | # build expected packet |
| 1038 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1039 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1040 | vlan_vid=out_port, |
| 1041 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1042 | ip_ttl=63, |
| 1043 | ip_src=ip_src, ip_dst=ip_dst) |
| 1044 | pkt = str(exp_pkt) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1045 | verify_packet(self, pkt, out_port) |
| 1046 | verify_no_other_packets(self) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1047 | delete_all_flows(self.controller) |
| 1048 | delete_groups(self.controller, Groups) |
| 1049 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1050 | class L3McastToL2(base_tests.SimpleDataPlane): |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1051 | """ |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1052 | Mcast routing to L2 |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1053 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1054 | |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1055 | def runTest(self): |
| 1056 | """ |
| 1057 | port1 (vlan 300)-> All Ports (vlan 300) |
| 1058 | """ |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 1059 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1060 | try: |
| 1061 | if len(config["port_map"]) < 3: |
| 1062 | logging.info("Port count less than 3, can't run this case") |
| 1063 | assert (False) |
| 1064 | return |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1065 | vlan_id = 300 |
| 1066 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1067 | intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1068 | dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 1069 | dst_mac_str = ':'.join(['%02X' % x for x in dst_mac]) |
| 1070 | port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 1071 | port1_mac_str = ':'.join(['%02X' % x for x in port1_mac]) |
| 1072 | src_ip = 0xc0a80101 |
| 1073 | src_ip_str = "192.168.1.1" |
| 1074 | dst_ip = 0xe0010101 |
| 1075 | dst_ip_str = "224.1.1.1" |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1076 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1077 | port1 = config["port_map"].keys()[0] |
| 1078 | port2 = config["port_map"].keys()[1] |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1079 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1080 | switch_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00] |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1081 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1082 | # add l2 interface group |
| 1083 | l2_intf_group_list = [] |
| 1084 | for port in config["port_map"].keys(): |
| 1085 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1086 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1087 | if port == port2: |
| 1088 | continue |
| 1089 | l2_intf_gid, msg = add_one_l2_interface_group(self.controller, port, |
| 1090 | vlan_id=vlan_id, |
| 1091 | is_tagged=True, |
| 1092 | send_barrier=False) |
| 1093 | l2_intf_group_list.append(l2_intf_gid) |
| 1094 | Groups.put(l2_intf_gid) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1095 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1096 | # add termination flow |
| 1097 | add_termination_flow(self.controller, port1, 0x0800, switch_mac, |
| 1098 | vlan_id) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1099 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1100 | # add l3 interface group |
| 1101 | mcat_group_msg = add_l3_mcast_group(self.controller, vlan_id, 2, |
| 1102 | l2_intf_group_list) |
| 1103 | add_mcast4_routing_flow(self.controller, vlan_id, src_ip, 0, dst_ip, |
| 1104 | mcat_group_msg.group_id) |
| 1105 | Groups._put(mcat_group_msg.group_id) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1106 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1107 | parsed_pkt = simple_udp_packet(pktlen=100, |
| 1108 | dl_vlan_enable=True, |
| 1109 | vlan_vid=vlan_id, |
| 1110 | eth_dst=dst_mac_str, |
| 1111 | eth_src=port1_mac_str, |
| 1112 | ip_ttl=64, |
| 1113 | ip_src=src_ip_str, |
| 1114 | ip_dst=dst_ip_str) |
| 1115 | pkt = str(parsed_pkt) |
| 1116 | self.dataplane.send(port1, pkt) |
| 1117 | for port in config["port_map"].keys(): |
| 1118 | if port == port2 or port == port1: |
| 1119 | verify_no_packet(self, pkt, port) |
| 1120 | continue |
| 1121 | verify_packet(self, pkt, port) |
| 1122 | verify_no_other_packets(self) |
| 1123 | finally: |
| 1124 | delete_all_flows(self.controller) |
| 1125 | delete_groups(self.controller, Groups) |
| 1126 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1127 | |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1128 | class L3McastToL3(base_tests.SimpleDataPlane): |
| 1129 | """ |
| 1130 | Mcast routing |
| 1131 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1132 | |
| 1133 | def runTest(self): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1134 | """ |
| 1135 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1136 | """ |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 1137 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1138 | try: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1139 | if len(config["port_map"]) < 3: |
| 1140 | logging.info("Port count less than 3, can't run this case") |
| 1141 | assert (False) |
| 1142 | return |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1143 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1144 | vlan_id = 1 |
| 1145 | port2_out_vlan = 2 |
| 1146 | port3_out_vlan = 3 |
| 1147 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1148 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1149 | intf_src_mac_str = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1150 | dst_mac = [0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 1151 | dst_mac_str = ':'.join(['%02X' % x for x in dst_mac]) |
| 1152 | port1_mac = [0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 1153 | port1_mac_str = ':'.join(['%02X' % x for x in port1_mac]) |
| 1154 | src_ip = 0xc0a80101 |
| 1155 | src_ip_str = "192.168.1.1" |
| 1156 | dst_ip = 0xe0010101 |
| 1157 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1158 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1159 | port1 = config["port_map"].keys()[0] |
| 1160 | port2 = config["port_map"].keys()[1] |
| 1161 | port3 = config["port_map"].keys()[2] |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1162 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1163 | # add l2 interface group |
| 1164 | for port in config["port_map"].keys(): |
| 1165 | l2gid, msg = add_one_l2_interface_group(self.controller, port, |
| 1166 | vlan_id=vlan_id, |
| 1167 | is_tagged=False, |
| 1168 | send_barrier=False) |
| 1169 | # add vlan flow table |
| 1170 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1171 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1172 | vlan_id += 1 |
| 1173 | Groups._put(l2gid) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1174 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1175 | # add termination flow |
| 1176 | add_termination_flow(self.controller, port1, 0x0800, |
| 1177 | [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1178 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1179 | # add l3 interface group |
| 1180 | port2_ucast_msg = add_l3_interface_group(self.controller, port2, |
| 1181 | port2_out_vlan, 2, |
| 1182 | intf_src_mac) |
| 1183 | port3_ucast_msg = add_l3_interface_group(self.controller, port3, |
| 1184 | port3_out_vlan, 3, |
| 1185 | intf_src_mac) |
| 1186 | mcat_group_msg = add_l3_mcast_group(self.controller, in_vlan, 2, |
| 1187 | [port2_ucast_msg.group_id, |
| 1188 | port3_ucast_msg.group_id]) |
| 1189 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, |
| 1190 | mcat_group_msg.group_id) |
| 1191 | Groups._put(port2_ucast_msg.group_id) |
| 1192 | Groups._put(port3_ucast_msg.group_id) |
| 1193 | Groups._put(mcat_group_msg.group_id) |
| 1194 | parsed_pkt = simple_udp_packet(pktlen=100, dl_vlan_enable=True, |
| 1195 | vlan_vid=1, |
| 1196 | eth_dst=dst_mac_str, |
| 1197 | eth_src=port1_mac_str, |
| 1198 | ip_ttl=64, |
| 1199 | ip_src=src_ip_str, |
| 1200 | ip_dst=dst_ip_str) |
| 1201 | pkt = str(parsed_pkt) |
| 1202 | self.dataplane.send(port1, pkt) |
| 1203 | parsed_pkt = simple_udp_packet(pktlen=96, |
| 1204 | eth_dst=dst_mac_str, |
| 1205 | eth_src=intf_src_mac_str, |
| 1206 | ip_ttl=63, |
| 1207 | ip_src=src_ip_str, |
| 1208 | ip_dst=dst_ip_str) |
| 1209 | pkt = str(parsed_pkt) |
| 1210 | verify_packet(self, pkt, port2) |
| 1211 | verify_packet(self, pkt, port3) |
| 1212 | verify_no_other_packets(self) |
| 1213 | finally: |
| 1214 | delete_all_flows(self.controller) |
| 1215 | delete_groups(self.controller, Groups) |
| 1216 | delete_all_groups(self.controller) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 1217 | @disabled |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1218 | class _MplsFwd(base_tests.SimpleDataPlane): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1219 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 1220 | Insert MPLS packet |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1221 | Receive MPLS packet |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1222 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1223 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 1224 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1225 | try: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1226 | if len(config["port_map"]) < 2: |
| 1227 | logging.info("Port count less than 2, can't run this case") |
| 1228 | return |
| 1229 | dip = 0xc0a80001 |
| 1230 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1231 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1232 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1233 | ports = config["port_map"].keys() |
| 1234 | for port in ports: |
| 1235 | # add l2 interface group |
| 1236 | id = port |
| 1237 | vlan_id = id |
| 1238 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 1239 | vlan_id, True, False) |
| 1240 | dst_mac[5] = vlan_id |
| 1241 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, |
| 1242 | dst_mac, intf_src_mac, |
| 1243 | vlan_id, id) |
| 1244 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( |
| 1245 | self.controller, |
| 1246 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, |
| 1247 | index=id, ref_gid=mpls_gid, push_mpls_header=False, |
| 1248 | set_mpls_label=port, set_bos=1) |
| 1249 | # add vlan flow table |
| 1250 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1251 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1252 | # add termination flow |
| 1253 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, |
| 1254 | vlan_id, goto_table=24) |
| 1255 | add_mpls_flow(self.controller, mpls_label_gid, port, goto_table=29) |
| 1256 | dst_ip = dip + (vlan_id << 8) |
| 1257 | Groups._put(l2_gid) |
| 1258 | Groups._put(mpls_gid) |
| 1259 | Groups._put(mpls_label_gid) |
| 1260 | do_barrier(self.controller) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1261 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1262 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1263 | for in_port in ports: |
| 1264 | ip_src = '192.168.%02d.1' % (in_port) |
| 1265 | for out_port in ports: |
| 1266 | if in_port == out_port: |
| 1267 | continue |
| 1268 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1269 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1270 | label = (out_port, 0, 1, 32) |
| 1271 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 1272 | vlan_vid=(in_port), ip_src=ip_src, |
| 1273 | ip_dst=ip_dst, eth_dst=switch_mac, |
| 1274 | label=[label]) |
| 1275 | pkt = str(parsed_pkt) |
| 1276 | self.dataplane.send(in_port, pkt) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1277 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1278 | # build expect packet |
| 1279 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1280 | label = (out_port, 0, 1, 31) |
| 1281 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, |
| 1282 | vlan_vid=(out_port), ip_src=ip_src, |
| 1283 | ip_dst=ip_dst, eth_src=switch_mac, |
| 1284 | eth_dst=mac_dst,label=[label]) |
| 1285 | pkt = str(exp_pkt) |
| 1286 | verify_packet(self, pkt, out_port) |
| 1287 | verify_no_other_packets(self) |
| 1288 | finally: |
| 1289 | delete_all_flows(self.controller) |
| 1290 | delete_groups(self.controller, Groups) |
| 1291 | delete_all_groups(self.controller) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1292 | |
| 1293 | class _MplsTermination(base_tests.SimpleDataPlane): |
| 1294 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 1295 | Insert MPLS packet |
| 1296 | Receive IP packet |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1297 | """ |
| 1298 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 1299 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1300 | try: |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1301 | if len(config["port_map"]) < 2: |
| 1302 | logging.info("Port count less than 2, can't run this case") |
| 1303 | return |
| 1304 | dip = 0xc0a80001 |
| 1305 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1306 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1307 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1308 | ports = config["port_map"].keys() |
| 1309 | for port in ports: |
| 1310 | # add l2 interface group |
| 1311 | vlan_id, id, dst_mac[5] = port, port, port |
| 1312 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 1313 | vlan_id, True, False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1314 | # add L3 Unicast group |
| 1315 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 1316 | id=id, src_mac=intf_src_mac,dst_mac=dst_mac) |
| 1317 | # add L3 ecmp group |
| 1318 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id]) |
| 1319 | # add vlan flow table |
| 1320 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1321 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1322 | # add termination flow |
| 1323 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, |
| 1324 | vlan_id, goto_table=24) |
| 1325 | #add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
| 1326 | add_mpls_flow(self.controller, label=port) |
| 1327 | dst_ip = dip + (vlan_id << 8) |
| 1328 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 1329 | ecmp_msg.group_id, 1) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1330 | Groups._put(l2_gid) |
| 1331 | Groups._put(l3_msg.group_id) |
| 1332 | Groups._put(ecmp_msg.group_id) |
| 1333 | do_barrier(self.controller) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1334 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1335 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1336 | for in_port in ports: |
| 1337 | ip_src = '192.168.%02d.1' % (in_port) |
| 1338 | for out_port in ports: |
| 1339 | if in_port == out_port: |
| 1340 | continue |
| 1341 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1342 | label = (out_port, 0, 1, 32) |
| 1343 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,vlan_vid=(in_port), |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 1344 | ip_src=ip_src,ip_dst=ip_dst, eth_dst=switch_mac,label=[label]) |
| 1345 | pkt = str(parsed_pkt) |
| 1346 | self.dataplane.send(in_port, pkt) |
| 1347 | # build expect packet |
| 1348 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1349 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1350 | vlan_vid=(out_port), |
| 1351 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1352 | ip_ttl=31, ip_src=ip_src, |
| 1353 | ip_dst=ip_dst) |
| 1354 | pkt = str(exp_pkt) |
| 1355 | verify_packet(self, pkt, out_port) |
| 1356 | verify_no_other_packets(self) |
| 1357 | finally: |
| 1358 | delete_all_flows(self.controller) |
| 1359 | delete_groups(self.controller, Groups) |
| 1360 | delete_all_groups(self.controller) |
| 1361 | |
| 1362 | class _MplsVpnFwd(base_tests.SimpleDataPlane): |
| 1363 | """ |
| 1364 | Insert MPLS packet |
| 1365 | Receive IP packet |
| 1366 | """ |
| 1367 | def runTest(self): |
| 1368 | Groups = Queue.LifoQueue() |
| 1369 | try: |
| 1370 | if len(config["port_map"]) < 2: |
| 1371 | logging.info("Port count less than 2, can't run this case") |
| 1372 | return |
| 1373 | dip = 0xc0a80001 |
| 1374 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1375 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1376 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1377 | ports = config["port_map"].keys() |
| 1378 | for port in ports: |
| 1379 | # add l2 interface group |
| 1380 | vlan_id, id, dst_mac[5] = port, port, port |
| 1381 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, |
| 1382 | vlan_id, True, False) |
| 1383 | # add L3 Unicast group |
| 1384 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 1385 | id=id, src_mac=intf_src_mac,dst_mac=dst_mac) |
| 1386 | # add L3 ecmp group |
| 1387 | ecmp_msg = add_l3_ecmp_group(self.controller, id, [l3_msg.group_id]) |
| 1388 | # add vlan flow table |
| 1389 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1390 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1391 | # add termination flow |
| 1392 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, |
| 1393 | vlan_id, goto_table=24) |
| 1394 | add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
| 1395 | #add_mpls_flow(self.controller, label=port) |
| 1396 | dst_ip = dip + (vlan_id << 8) |
| 1397 | #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
| 1398 | # ecmp_msg.group_id, 1) |
| 1399 | Groups._put(l2_gid) |
| 1400 | Groups._put(l3_msg.group_id) |
| 1401 | Groups._put(ecmp_msg.group_id) |
| 1402 | do_barrier(self.controller) |
| 1403 | |
| 1404 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1405 | for in_port in ports: |
| 1406 | ip_src = '192.168.%02d.1' % (in_port) |
| 1407 | for out_port in ports: |
| 1408 | if in_port == out_port: |
| 1409 | continue |
| 1410 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1411 | label = (out_port, 0, 1, 32) |
| 1412 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True,vlan_vid=(in_port), |
| 1413 | ip_src=ip_src,ip_dst=ip_dst, eth_dst=switch_mac,label=[label]) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1414 | pkt = str(parsed_pkt) |
| 1415 | self.dataplane.send(in_port, pkt) |
| 1416 | # build expect packet |
| 1417 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1418 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1419 | vlan_vid=(out_port), |
| 1420 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1421 | ip_ttl=31, ip_src=ip_src, |
| 1422 | ip_dst=ip_dst) |
| 1423 | pkt = str(exp_pkt) |
| 1424 | verify_packet(self, pkt, out_port) |
| 1425 | verify_no_other_packets(self) |
| 1426 | finally: |
| 1427 | delete_all_flows(self.controller) |
| 1428 | delete_groups(self.controller, Groups) |
| 1429 | delete_all_groups(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1430 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1431 | class _24UcastTagged(base_tests.SimpleDataPlane): |
| 1432 | """ |
| 1433 | Verify a IP forwarding works for a /32 rule to L3 Unicast Interface |
| 1434 | """ |
| 1435 | |
| 1436 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 1437 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1438 | try: |
| 1439 | test_id = 26 |
| 1440 | if len(config["port_map"]) < 2: |
| 1441 | logging.info("Port count less than 2, can't run this case") |
| 1442 | return |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1443 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1444 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1445 | dip = 0xc0a80001 |
| 1446 | ports = config["port_map"].keys() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1447 | for port in ports: |
| 1448 | # add l2 interface group |
| 1449 | vlan_id = port + test_id |
| 1450 | l2gid, msg = add_one_l2_interface_group(self.controller, port, |
| 1451 | vlan_id=vlan_id, |
| 1452 | is_tagged=True, |
| 1453 | send_barrier=False) |
| 1454 | dst_mac[5] = vlan_id |
| 1455 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id, |
| 1456 | id=vlan_id, src_mac=intf_src_mac, |
| 1457 | dst_mac=dst_mac) |
| 1458 | # add vlan flow table |
| 1459 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1460 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1461 | # add termination flow |
| 1462 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 1463 | vlan_id) |
| 1464 | # add unicast routing flow |
| 1465 | dst_ip = dip + (vlan_id << 8) |
| 1466 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 1467 | 0xffffff00, l3_msg.group_id) |
| 1468 | Groups.put(l2gid) |
| 1469 | Groups.put(l3_msg.group_id) |
| 1470 | do_barrier(self.controller) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1471 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1472 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1473 | for in_port in ports: |
| 1474 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1475 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1476 | for out_port in ports: |
| 1477 | if in_port == out_port: |
| 1478 | continue |
| 1479 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
| 1480 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1481 | vlan_vid=(test_id + in_port), |
| 1482 | eth_dst=switch_mac, |
| 1483 | eth_src=mac_src, ip_ttl=64, |
| 1484 | ip_src=ip_src, |
| 1485 | ip_dst=ip_dst) |
| 1486 | pkt = str(parsed_pkt) |
| 1487 | self.dataplane.send(in_port, pkt) |
| 1488 | # build expected packet |
| 1489 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
| 1490 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1491 | vlan_vid=(test_id + out_port), |
| 1492 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1493 | ip_ttl=63, |
| 1494 | ip_src=ip_src, ip_dst=ip_dst) |
| 1495 | pkt = str(exp_pkt) |
| 1496 | verify_packet(self, pkt, out_port) |
| 1497 | verify_no_other_packets(self) |
| 1498 | finally: |
| 1499 | delete_all_flows(self.controller) |
| 1500 | delete_groups(self.controller, Groups) |
| 1501 | delete_all_groups(self.controller) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1502 | |
| 1503 | class _0Ucast(base_tests.SimpleDataPlane): |
| 1504 | """ |
| 1505 | Verify a IP forwarding works for a /0 rule to L3 Unicast Interface |
| 1506 | """ |
| 1507 | |
| 1508 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 1509 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1510 | try: |
| 1511 | if len(config["port_map"]) < 2: |
| 1512 | logging.info("Port count less than 2, can't run this case") |
| 1513 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1514 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1515 | intf_src_mac = [0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1516 | dst_mac = [0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 1517 | dip = 0xc0a80001 |
| 1518 | ports = config["port_map"].keys() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1519 | for port in ports: |
| 1520 | # add l2 interface group |
| 1521 | vlan_id = port |
| 1522 | l2gid, msg = add_one_l2_interface_group(self.controller, port, |
| 1523 | vlan_id=vlan_id+1, |
| 1524 | is_tagged=True, |
| 1525 | send_barrier=False) |
| 1526 | dst_mac[5] = vlan_id |
| 1527 | l3_msg = add_l3_unicast_group(self.controller, port, vlanid=vlan_id+1, |
| 1528 | id=vlan_id, src_mac=intf_src_mac, |
| 1529 | dst_mac=dst_mac) |
| 1530 | # add vlan flow table |
| 1531 | add_one_vlan_table_flow(self.controller, port, vlan_id, |
| 1532 | flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1533 | # add termination flow |
| 1534 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, |
| 1535 | vlan_id) |
| 1536 | # add unicast routing flow |
| 1537 | dst_ip = dip + (vlan_id << 8) |
| 1538 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, |
| 1539 | 0xffffffff, l3_msg.group_id) |
| 1540 | Groups.put(l2gid) |
| 1541 | Groups.put(l3_msg.group_id) |
| 1542 | l3_gid = encode_l3_unicast_group_id(ports[0]) |
| 1543 | dst_ip = 0x0 |
| 1544 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, l3_gid) |
| 1545 | do_barrier(self.controller) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1546 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1547 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 1548 | for in_port in ports: |
| 1549 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1550 | ip_src = '192.168.%02d.1' % (in_port) |
| 1551 | for out_port in ports: |
| 1552 | if in_port == out_port: |
| 1553 | continue |
| 1554 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1555 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1556 | vlan_vid=(in_port), |
| 1557 | eth_dst=switch_mac, |
| 1558 | eth_src=mac_src, ip_ttl=64, |
| 1559 | ip_src=ip_src, |
| 1560 | ip_dst=ip_dst) |
| 1561 | pkt = str(parsed_pkt) |
| 1562 | self.dataplane.send(in_port, pkt) |
| 1563 | # build expected packet |
| 1564 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1565 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, |
| 1566 | vlan_vid=(out_port+1), |
| 1567 | eth_dst=mac_dst, eth_src=switch_mac, |
| 1568 | ip_ttl=63, |
| 1569 | ip_src=ip_src, ip_dst=ip_dst) |
| 1570 | pkt = str(exp_pkt) |
| 1571 | verify_packet(self, pkt, out_port) |
| 1572 | verify_no_other_packets(self) |
| 1573 | ip_dst='1.168.%02d.1' % ports[0] |
| 1574 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1575 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst) |
| 1576 | pkt=str(parsed_pkt) |
| 1577 | self.dataplane.send(in_port, pkt) |
| 1578 | #build expect packet |
| 1579 | mac_dst='00:00:00:22:22:%02X' % ports[0] |
| 1580 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0]+1, ip_ttl=63, ip_src=ip_src, |
| 1581 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac) |
| 1582 | pkt=str(exp_pkt) |
| 1583 | verify_packet(self, pkt, ports[0]) |
| 1584 | verify_no_other_packets(self) |
| 1585 | finally: |
| 1586 | delete_all_flows(self.controller) |
| 1587 | delete_groups(self.controller, Groups) |
| 1588 | delete_all_groups(self.controller) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1589 | |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1590 | class Unfiltered(base_tests.SimpleDataPlane): |
| 1591 | """ |
| 1592 | Testing addition of unfiltered groups |
| 1593 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1594 | |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1595 | def runTest(self): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1596 | try: |
| 1597 | ports = sorted(config["port_map"].keys()) |
| 1598 | vlan_id = 1; |
| 1599 | for port in ports: |
| 1600 | add_l2_unfiltered_group(self.controller, [port], False) |
| 1601 | do_barrier(self.controller) |
| 1602 | finally: |
| 1603 | delete_all_flows(self.controller) |
| 1604 | delete_all_groups(self.controller) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1605 | |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1606 | class L3McastToVPN(base_tests.SimpleDataPlane): |
| 1607 | """ |
| 1608 | Mcast routing |
| 1609 | """ |
| 1610 | def runTest(self): |
| 1611 | """ |
| 1612 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1613 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1614 | try: |
| 1615 | delete_all_flows(self.controller) |
| 1616 | delete_all_groups(self.controller) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1617 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1618 | if len(config["port_map"]) <3: |
| 1619 | logging.info("Port count less than 3, can't run this case") |
| 1620 | assert(False) |
| 1621 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1622 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1623 | vlan_id =1 |
| 1624 | port2_out_vlan=2 |
| 1625 | port3_out_vlan=3 |
| 1626 | in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1627 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 1628 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 1629 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 1630 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 1631 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 1632 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 1633 | src_ip=0xc0a80101 |
| 1634 | src_ip_str="192.168.1.1" |
| 1635 | dst_ip=0xe0010101 |
| 1636 | dst_ip_str="224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1637 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1638 | port1=config["port_map"].keys()[0] |
| 1639 | port2=config["port_map"].keys()[1] |
| 1640 | #port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1641 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1642 | #add l2 interface group |
| 1643 | for port in config["port_map"].keys(): |
| 1644 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False) |
| 1645 | #add vlan flow table |
| 1646 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1647 | vlan_id +=1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1648 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1649 | #add termination flow |
| 1650 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1651 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1652 | #add MPLS interface group |
| 1653 | l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2) |
| 1654 | mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2) |
| 1655 | #l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 1656 | #mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 1657 | #add L3VPN groups |
| 1658 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 1659 | index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True) |
| 1660 | #mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 1661 | # index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1662 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1663 | mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [mpls_label_gid2]) |
| 1664 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1665 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1666 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1, |
| 1667 | eth_dst=dst_mac_str, |
| 1668 | eth_src=port1_mac_str, |
| 1669 | ip_ttl=64, |
| 1670 | ip_src=src_ip_str, |
| 1671 | ip_dst=dst_ip_str) |
| 1672 | pkt=str(parsed_pkt) |
| 1673 | self.dataplane.send(port1, pkt) |
| 1674 | label = (12, 0, 1, 63) |
| 1675 | exp_pkt = mpls_packet(pktlen=100, |
| 1676 | eth_dst=dst_mac_str, |
| 1677 | eth_src=intf_src_mac_str, |
| 1678 | ip_ttl=64, |
| 1679 | ip_src=src_ip_str, label= [label], |
| 1680 | ip_dst=dst_ip_str) |
| 1681 | pkt=str(exp_pkt) |
| 1682 | verify_packet(self, pkt, port2) |
| 1683 | #verify_packet(self, pkt, port3) |
| 1684 | verify_no_other_packets(self) |
| 1685 | delete_all_groups(self.controller) |
| 1686 | finally: |
| 1687 | delete_all_flows(self.controller) |
| 1688 | delete_all_groups(self.controller) |
| 1689 | |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1690 | |
| 1691 | class PacketInSrcMacMiss(base_tests.SimpleDataPlane): |
| 1692 | """ |
| 1693 | Test packet in function on a src-mac miss |
| 1694 | Send a packet to each dataplane port and verify that a packet |
| 1695 | in message is received from the controller for each |
| 1696 | #todo verify you stop receiving after adding rule |
| 1697 | """ |
| 1698 | |
| 1699 | def runTest(self): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 1700 | Groups = Queue.LifoQueue() |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1701 | try: |
| 1702 | ports = sorted(config["port_map"].keys()) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1703 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1704 | Groups = Queue.LifoQueue() |
| 1705 | for port in ports: |
| 1706 | L2gid, l2msg = add_one_l2_interface_group(self.controller, port, 1, True, False) |
| 1707 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 1708 | Groups.put(L2gid) |
| 1709 | parsed_vlan_pkt = simple_tcp_packet(pktlen=104, |
| 1710 | vlan_vid=0x1001, dl_vlan_enable=True) |
| 1711 | vlan_pkt = str(parsed_vlan_pkt) |
| 1712 | for of_port in config["port_map"].keys(): |
| 1713 | logging.info("PacketInMiss test, port %d", of_port) |
| 1714 | self.dataplane.send(of_port, vlan_pkt) |
| 1715 | verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH) |
| 1716 | verify_no_other_packets(self) |
| 1717 | finally: |
| 1718 | delete_all_flows(self.controller) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame^] | 1719 | delete_all_groups(self.controller) |