castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 1 | """ |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 2 | """ |
| 3 | |
| 4 | from oftest import config |
| 5 | import logging |
| 6 | import oftest.base_tests as base_tests |
| 7 | import ofp |
| 8 | from oftest.testutils import * |
| 9 | from accton_util import * |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 10 | import inspect |
| 11 | |
| 12 | @disabled |
| 13 | class Mtu4000(base_tests.SimpleDataPlane): |
| 14 | """ |
| 15 | Test output function for an exact-match flow |
| 16 | For each port A, adds a flow directing matching packets to that port. |
| 17 | Then, for all other ports B != A, verifies that sending a matching packet |
| 18 | to B results in an output to A. |
| 19 | """ |
| 20 | def runTest(self): |
| 21 | ports = sorted(config["port_map"].keys()) |
| 22 | |
| 23 | delete_all_flows(self.controller) |
| 24 | delete_all_groups(self.controller) |
| 25 | |
| 26 | add_vlan_table_flow(self.controller, config["port_map"].keys()) |
| 27 | |
| 28 | # set up tag groups for each port |
| 29 | add_l2_interface_group(self.controller, config["port_map"].keys(), 1, True, 1) |
| 30 | |
| 31 | for port in ports: |
| 32 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
| 33 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 34 | group_id = encode_l2_interface_group_id(1, port) |
| 35 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 36 | do_barrier(self.controller) |
| 37 | |
| 38 | for out_port in ports: |
| 39 | # change dest based on port number |
| 40 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 41 | for in_port in ports: |
| 42 | if in_port == out_port: |
| 43 | continue |
| 44 | # change source based on port number to avoid packet-ins from learning |
| 45 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 46 | parsed_pkt = simple_tcp_packet(pktlen=4000,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 47 | pkt = str(parsed_pkt) |
| 48 | self.dataplane.send(in_port, pkt) |
| 49 | |
| 50 | for ofport in ports: |
| 51 | if ofport in [out_port]: |
| 52 | verify_packet(self, pkt, ofport) |
| 53 | else: |
| 54 | verify_no_packet(self, pkt, ofport) |
| 55 | |
| 56 | verify_no_other_packets(self) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 57 | |
| 58 | class Mtu4500(base_tests.SimpleDataPlane): |
| 59 | |
| 60 | def runTest(self): |
| 61 | ports = sorted(config["port_map"].keys()) |
| 62 | |
| 63 | delete_all_flows(self.controller) |
| 64 | delete_all_groups(self.controller) |
| 65 | |
| 66 | for port in ports: |
| 67 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
| 68 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 69 | group_id = encode_l2_interface_group_id(1, port) |
| 70 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 1, group_id, True) |
| 71 | do_barrier(self.controller) |
| 72 | |
| 73 | for out_port in ports: |
| 74 | # change dest based on port number |
| 75 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 76 | for in_port in ports: |
| 77 | if in_port == out_port: |
| 78 | continue |
| 79 | # change source based on port number to avoid packet-ins from learning |
| 80 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 81 | parsed_pkt = simple_tcp_packet(pktlen=4500,dl_vlan_enable=True, vlan_vid=1, eth_dst=mac_dst, eth_src=mac_src) |
| 82 | pkt = str(parsed_pkt) |
| 83 | self.dataplane.send(in_port, pkt) |
| 84 | |
| 85 | for ofport in ports: |
| 86 | if ofport in [out_port]: |
| 87 | verify_packet(self, pkt, ofport) |
| 88 | else: |
| 89 | verify_no_packet(self, pkt, ofport) |
| 90 | |
| 91 | verify_no_other_packets(self) |
| 92 | |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 93 | |
| 94 | @disabled |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 95 | class L3McastToVPN(base_tests.SimpleDataPlane): |
| 96 | """ |
| 97 | Mcast routing |
| 98 | """ |
| 99 | def runTest(self): |
| 100 | """ |
| 101 | port1 (vlan 1)-> port 2 (vlan 2) |
| 102 | """ |
| 103 | #delete_all_flows(self.controller) |
| 104 | #delete_all_groups(self.controller) |
| 105 | |
| 106 | if len(config["port_map"]) <3: |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 107 | logging.info("Port count less than 3, can't run this case") |
| 108 | assert(False) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 109 | return |
| 110 | |
| 111 | vlan_id =1 |
| 112 | port2_out_vlan=2 |
| 113 | port3_out_vlan=3 |
| 114 | in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 115 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 116 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 117 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 118 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 119 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 120 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 121 | src_ip=0xc0a80101 |
| 122 | src_ip_str="192.168.1.1" |
| 123 | dst_ip=0xe0010101 |
| 124 | dst_ip_str="224.1.1.1" |
| 125 | |
| 126 | port1=config["port_map"].keys()[0] |
| 127 | port2=config["port_map"].keys()[1] |
| 128 | port3=config["port_map"].keys()[2] |
| 129 | |
| 130 | #add l2 interface group |
| 131 | for port in config["port_map"].keys(): |
| 132 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False) |
| 133 | #add vlan flow table |
| 134 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 135 | vlan_id +=1 |
| 136 | |
| 137 | #add termination flow |
| 138 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
| 139 | |
| 140 | #add MPLS interface group |
| 141 | l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2) |
| 142 | mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2) |
| 143 | l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 144 | mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 145 | #add L3VPN groups |
| 146 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 147 | index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 148 | mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 149 | index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 150 | |
| 151 | mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023]) |
| 152 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
| 153 | |
| 154 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1, |
| 155 | eth_dst=dst_mac_str, |
| 156 | eth_src=port1_mac_str, |
| 157 | ip_ttl=64, |
| 158 | ip_src=src_ip_str, |
| 159 | ip_dst=dst_ip_str) |
| 160 | pkt=str(parsed_pkt) |
| 161 | self.dataplane.send(port1, pkt) |
| 162 | label = (in_vlan, 0, 1, 63) |
| 163 | parsed_pkt = mpls_packet(pktlen=100, |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 164 | eth_dst=dst_mac_str, |
| 165 | eth_src=intf_src_mac_str, |
| 166 | ip_ttl=63, |
| 167 | ip_src=src_ip_str, label= [label], |
| 168 | ip_dst=dst_ip_str) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 169 | pkt=str(parsed_pkt) |
| 170 | verify_packet(self, pkt, port2) |
| 171 | verify_packet(self, pkt, port3) |
| 172 | verify_no_other_packets(self) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 173 | @disabled |
| 174 | class LPM(base_tests.SimpleDataPlane): |
| 175 | """ |
| 176 | Insert IP packet |
| 177 | Receive MPLS packet |
| 178 | """ |
| 179 | def runTest(self): |
| 180 | delete_all_flows(self.controller) |
| 181 | delete_all_groups(self.controller) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 182 | |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 183 | if len(config["port_map"]) <2: |
| 184 | logging.info("Port count less than 2, can't run this case") |
| 185 | return |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 186 | |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame^] | 187 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 188 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 189 | dip=0xc0a80001 |
| 190 | index=1 |
| 191 | ports = config["port_map"].keys() |
| 192 | for port in ports: |
| 193 | #add l2 interface group |
| 194 | vlan_id=port |
| 195 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, True) |
| 196 | dst_mac[5]=vlan_id |
| 197 | #add MPLS interface group |
| 198 | mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port) |
| 199 | #add MPLS L3 VPN group |
| 200 | mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 201 | index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32) |
| 202 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 203 | do_barrier(self.controller) |
| 204 | #add vlan flow table |
| 205 | add_one_vlan_table_flow(self.controller, port, vlan_id, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 206 | #add termination flow |
| 207 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 208 | #add routing flow |
| 209 | dst_ip = dip + (vlan_id<<8) |
| 210 | #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid, vrf=2) |
| 211 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id) |
| 212 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 213 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 214 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 215 | port = ports[0] |
| 216 | #add l2 interface group |
| 217 | vlan_id=port |
| 218 | l2_gid = encode_l2_interface_group_id(vlan_id, port) |
| 219 | dst_mac[5]=vlan_id |
| 220 | #add MPLS interface group |
| 221 | mpls_gid = encode_mpls_interface_group_id(0, port) |
| 222 | #add MPLS L3 VPN group |
| 223 | mpls_label_gid = encode_mpls_label_group_id(OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=port) |
| 224 | ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
| 225 | do_barrier(self.controller) |
| 226 | #add routing flow |
| 227 | dst_ip = 0x0 |
| 228 | #add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, mpls_label_gid, vrf=2) |
| 229 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0x0, ecmp_msg.group_id) |
| 230 | |
| 231 | do_barrier(self.controller) |
| 232 | |
| 233 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 234 | for in_port in ports: |
| 235 | mac_src='00:00:00:22:22:%02X' % in_port |
| 236 | ip_src='192.168.%02d.1' % in_port |
| 237 | for out_port in ports: |
| 238 | if in_port == out_port: |
| 239 | continue |
| 240 | ip_dst='192.168.%02d.1' % out_port |
| 241 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 242 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 243 | ip_dst=ip_dst) |
| 244 | pkt=str(parsed_pkt) |
| 245 | self.dataplane.send(in_port, pkt) |
| 246 | #build expect packet |
| 247 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 248 | label = (out_port, 0, 1, 32) |
| 249 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=63, ip_src=ip_src, |
| 250 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 251 | pkt=str(exp_pkt) |
| 252 | verify_packet(self, pkt, out_port) |
| 253 | verify_no_other_packets(self) |
| 254 | ip_dst='1.168.%02d.1' % ports[0] |
| 255 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 256 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst) |
| 257 | pkt=str(parsed_pkt) |
| 258 | self.dataplane.send(in_port, pkt) |
| 259 | #build expect packet |
| 260 | mac_dst='00:00:00:22:22:%02X' % ports[0] |
| 261 | label = (ports[0], 0, 1, 32) |
| 262 | exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=ports[0], ip_ttl=63, ip_src=ip_src, |
| 263 | ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label]) |
| 264 | pkt=str(exp_pkt) |
| 265 | verify_packet(self, pkt, ports[0]) |
| 266 | verify_no_other_packets(self) |
| 267 | |
| 268 | @disabled |
| 269 | class L2FloodTaggedUnknownSrc(base_tests.SimpleDataPlane): |
| 270 | """ |
| 271 | Test L2 flood to a vlan |
| 272 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
| 273 | #todo take in account unknown src |
| 274 | """ |
| 275 | def runTest(self): |
| 276 | delete_all_flows(self.controller) |
| 277 | delete_all_groups(self.controller) |
| 278 | |
| 279 | ports = sorted(config["port_map"].keys()) |
| 280 | for port in ports: |
| 281 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
| 282 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 283 | |
| 284 | msg=add_l2_flood_group(self.controller, ports, 1, 1) |
| 285 | add_bridge_flow(self.controller, None, 1, msg.group_id, True) |
| 286 | |
| 287 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=True, vlan_vid=1, eth_dst='00:12:34:56:78:9a') |
| 288 | pkt = str(parsed_pkt) |
| 289 | #verify flood |
| 290 | for ofport in ports: |
| 291 | self.dataplane.send(ofport, pkt) |
| 292 | #self won't rx packet |
| 293 | verify_no_packet(self, pkt, ofport) |
| 294 | #others will rx packet |
| 295 | tmp_ports=list(ports) |
| 296 | tmp_ports.remove(ofport) |
| 297 | verify_packets(self, pkt, tmp_ports) |
| 298 | |
| 299 | verify_no_other_packets(self) |
| 300 | |
| 301 | @disabled |
| 302 | class PacketInIPTable(base_tests.SimpleDataPlane): |
| 303 | """ |
| 304 | Test packet in function on IPTABLE |
| 305 | Send a packet to each dataplane port and verify that a packet |
| 306 | in message is received from the controller for each |
| 307 | #todo verify you stop receiving after adding rule |
| 308 | """ |
| 309 | |
| 310 | def runTest(self): |
| 311 | delete_all_flows(self.controller) |
| 312 | delete_all_groups(self.controller) |
| 313 | |
| 314 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 315 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 316 | dip=0xc0a80001 |
| 317 | ports = sorted(config["port_map"].keys()) |
| 318 | for port in ports: |
| 319 | #add l2 interface group |
| 320 | vlan_id=port |
| 321 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False) |
| 322 | dst_mac[5]=vlan_id |
| 323 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 324 | #add vlan flow table |
| 325 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 326 | #add termination flow |
| 327 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 328 | #add unicast routing flow |
| 329 | dst_ip = dip + (vlan_id<<8) |
| 330 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xfffffff0, l3_msg.group_id, send_ctrl=True) |
| 331 | |
| 332 | do_barrier(self.controller) |
| 333 | |
| 334 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 335 | for in_port in ports: |
| 336 | mac_src='00:00:00:22:22:%02X' % in_port |
| 337 | ip_src='192.168.%02d.1' % in_port |
| 338 | for out_port in ports: |
| 339 | if in_port == out_port: |
| 340 | continue |
| 341 | ip_dst='192.168.%02d.1' % out_port |
| 342 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 343 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 344 | ip_dst=ip_dst) |
| 345 | pkt=str(parsed_pkt) |
| 346 | self.dataplane.send(in_port, pkt) |
| 347 | verify_packet_in(self, pkt, in_port, ofp.OFPR_ACTION) |
| 348 | #verify_no_other_packets(self) |
| 349 | |
| 350 | @disabled |
| 351 | class PacketInSrcMacMiss(base_tests.SimpleDataPlane): |
| 352 | """ |
| 353 | Test packet in function on a src-mac miss |
| 354 | Send a packet to each dataplane port and verify that a packet |
| 355 | in message is received from the controller for each |
| 356 | #todo verify you stop receiving after adding rule |
| 357 | """ |
| 358 | |
| 359 | def runTest(self): |
| 360 | delete_all_flows(self.controller) |
| 361 | delete_all_groups(self.controller) |
| 362 | |
| 363 | ports = sorted(config["port_map"].keys()) |
| 364 | for port in ports: |
| 365 | add_one_l2_interface_group(self.controller, port, 1, True, False) |
| 366 | add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 367 | |
| 368 | parsed_vlan_pkt = simple_tcp_packet(pktlen=104, |
| 369 | vlan_vid=0x1001, dl_vlan_enable=True) |
| 370 | vlan_pkt = str(parsed_vlan_pkt) |
| 371 | |
| 372 | for of_port in config["port_map"].keys(): |
| 373 | logging.info("PacketInMiss test, port %d", of_port) |
| 374 | self.dataplane.send(of_port, vlan_pkt) |
| 375 | |
| 376 | verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH) |
| 377 | |
| 378 | verify_no_other_packets(self) |
| 379 | |
| 380 | class _32ECMPL3(base_tests.SimpleDataPlane): |
| 381 | """ |
| 382 | Port1(vid=in_port, src=00:00:00:22:22:in_port, 192.168.outport.1) , |
| 383 | Port2(vid=outport, dst=00:00:00:22:22:outport, 192.168.outport.1) |
| 384 | """ |
| 385 | def runTest(self): |
| 386 | delete_all_flows(self.controller) |
| 387 | delete_all_groups(self.controller) |
| 388 | |
| 389 | if len(config["port_map"]) <2: |
| 390 | logging.info("Port count less than 2, can't run this case") |
| 391 | return |
| 392 | |
| 393 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 394 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 395 | dip=0xc0a80001 |
| 396 | #Hashes Test Name and uses it as id for installing unique groups |
| 397 | class_id=abs(hash(inspect.stack()[0][3])) % (256) |
| 398 | ports = config["port_map"].keys() |
| 399 | for port in ports: |
| 400 | vlan_id=port |
| 401 | id=port+class_id<<8 |
| 402 | #add l2 interface group |
| 403 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=True, send_barrier=False) |
| 404 | dst_mac[5]=vlan_id |
| 405 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 406 | ecmp_msg=add_l3_ecmp_group(self.controller, id, [l3_msg.group_id]) |
| 407 | #add vlan flow table |
| 408 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 409 | #add termination flow |
| 410 | add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id) |
| 411 | #add unicast routing flow |
| 412 | dst_ip = dip + (vlan_id<<8) |
| 413 | add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id) |
| 414 | |
| 415 | do_barrier(self.controller) |
| 416 | |
| 417 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 418 | for in_port in ports: |
| 419 | mac_src='00:00:00:22:22:%02X' % in_port |
| 420 | ip_src='192.168.%02d.1' % in_port |
| 421 | for out_port in ports: |
| 422 | if in_port == out_port: |
| 423 | continue |
| 424 | ip_dst='192.168.%02d.1' % out_port |
| 425 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 426 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 427 | ip_dst=ip_dst) |
| 428 | pkt=str(parsed_pkt) |
| 429 | self.dataplane.send(in_port, pkt) |
| 430 | #build expected packet |
| 431 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 432 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 433 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 434 | ip_src=ip_src, ip_dst=ip_dst) |
| 435 | pkt=str(exp_pkt) |
| 436 | verify_packet(self, pkt, out_port) |
| 437 | verify_no_other_packets(self) |