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