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