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