castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame^] | 1 | """ |
| 2 | The following tests are being done here |
| 3 | 1) PacketInSrcMacMiss |
| 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 |
| 15 | """ |
| 16 | |
| 17 | from oftest import config |
| 18 | import logging |
| 19 | import oftest.base_tests as base_tests |
| 20 | import ofp |
| 21 | from oftest.testutils import * |
| 22 | from accton_util import * |
| 23 | |
| 24 | class Mtu4500(base_tests.SimpleDataPlane): |
| 25 | |
| 26 | def runTest(self): |
| 27 | ports = sorted(config["port_map"].keys()) |
| 28 | |
| 29 | delete_all_flows(self.controller) |
| 30 | delete_all_groups(self.controller) |
| 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=4500,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) |
| 58 | |
| 59 | class L3McastToVPN(base_tests.SimpleDataPlane): |
| 60 | """ |
| 61 | Mcast routing |
| 62 | """ |
| 63 | def runTest(self): |
| 64 | """ |
| 65 | port1 (vlan 1)-> port 2 (vlan 2) |
| 66 | """ |
| 67 | #delete_all_flows(self.controller) |
| 68 | #delete_all_groups(self.controller) |
| 69 | |
| 70 | if len(config["port_map"]) <3: |
| 71 | logging.info("Port count less than 2, can't run this case") |
| 72 | return |
| 73 | |
| 74 | vlan_id =1 |
| 75 | port2_out_vlan=2 |
| 76 | port3_out_vlan=3 |
| 77 | in_vlan=1 #macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 78 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 79 | intf_src_mac_str=':'.join(['%02X' % x for x in intf_src_mac]) |
| 80 | dst_mac=[0x01, 0x00, 0x5e, 0x01, 0x01, 0x01] |
| 81 | dst_mac_str=':'.join(['%02X' % x for x in dst_mac]) |
| 82 | port1_mac=[0x00, 0x11, 0x11, 0x11, 0x11, 0x11] |
| 83 | port1_mac_str=':'.join(['%02X' % x for x in port1_mac]) |
| 84 | src_ip=0xc0a80101 |
| 85 | src_ip_str="192.168.1.1" |
| 86 | dst_ip=0xe0010101 |
| 87 | dst_ip_str="224.1.1.1" |
| 88 | |
| 89 | port1=config["port_map"].keys()[0] |
| 90 | port2=config["port_map"].keys()[1] |
| 91 | port3=config["port_map"].keys()[2] |
| 92 | |
| 93 | #add l2 interface group |
| 94 | for port in config["port_map"].keys(): |
| 95 | add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False) |
| 96 | #add vlan flow table |
| 97 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 98 | vlan_id +=1 |
| 99 | |
| 100 | #add termination flow |
| 101 | add_termination_flow(self.controller, port1, 0x0800, [0x01, 0x00, 0x5e, 0x00, 0x00, 0x00], vlan_id) |
| 102 | |
| 103 | #add MPLS interface group |
| 104 | l2_gid = encode_l2_interface_group_id(port2_out_vlan, port2) |
| 105 | mpls_gid2, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, port2_out_vlan, port2) |
| 106 | l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 107 | mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 108 | #add L3VPN groups |
| 109 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 110 | index=(0x20000+port2), ref_gid= mpls_gid2, push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True) |
| 111 | mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
| 112 | index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
| 113 | |
| 114 | |
| 115 | |
| 116 | mcat_group_msg=add_l3_mcast_group(self.controller, in_vlan, 2, [0x92020022 , 0x92010023]) |
| 117 | add_mcast4_routing_flow(self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id) |
| 118 | |
| 119 | parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=1, |
| 120 | eth_dst=dst_mac_str, |
| 121 | eth_src=port1_mac_str, |
| 122 | ip_ttl=64, |
| 123 | ip_src=src_ip_str, |
| 124 | ip_dst=dst_ip_str) |
| 125 | pkt=str(parsed_pkt) |
| 126 | self.dataplane.send(port1, pkt) |
| 127 | label = (in_vlan, 0, 1, 63) |
| 128 | parsed_pkt = mpls_packet(pktlen=100, |
| 129 | eth_dst=dst_mac_str, |
| 130 | eth_src=intf_src_mac_str, |
| 131 | ip_ttl=63, |
| 132 | ip_src=src_ip_str, label= [label], |
| 133 | ip_dst=dst_ip_str) |
| 134 | pkt=str(parsed_pkt) |
| 135 | verify_packet(self, pkt, port2) |
| 136 | verify_packet(self, pkt, port3) |
| 137 | verify_no_other_packets(self) |
| 138 | |
| 139 | |