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 VlanSupport(base_tests.SimpleDataPlane): |
| 25 | """ |
| 26 | Test L2 forwarding of both, untagged and double-tagged packets |
| 27 | Sends a packet and expects the same packet on the other port |
| 28 | Repeats for double tagged |
| 29 | """ |
| 30 | def runTest(self): |
| 31 | delete_all_flows(self.controller) |
| 32 | delete_all_groups(self.controller) |
| 33 | ports = sorted(config["port_map"].keys()) |
| 34 | # group table |
| 35 | # set up untag groups for each port |
| 36 | add_l2_interface_group(self.controller, config["port_map"].keys(), 4093, False, 1) |
| 37 | for port in ports: |
| 38 | add_one_vlan_table_flow(self.controller, port, 4093, flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 39 | group_id = encode_l2_interface_group_id(4093, port) |
| 40 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 4093, group_id, True) |
| 41 | #add flow match for vlan 300 |
| 42 | add_one_l2_interface_group(self.controller, port, 300, True, False) |
| 43 | add_one_vlan_table_flow(self.controller, port, 300, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 44 | msg=add_l2_flood_group(self.controller, ports, 300, 1) |
| 45 | add_bridge_flow(self.controller, None, 300, msg.group_id, True) |
| 46 | msg=add_l2_flood_group(self.controller, ports, 4093, 1) |
| 47 | add_bridge_flow(self.controller, None, 4093, msg.group_id, True) |
| 48 | do_barrier(self.controller) |
| 49 | |
| 50 | for out_port in ports: |
| 51 | # change dest based on port number |
| 52 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 53 | |
| 54 | for in_port in ports: |
| 55 | if in_port == out_port: |
| 56 | continue |
| 57 | # change source based on port number to avoid packet-ins from learning |
| 58 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 59 | #sends an untagged packet |
| 60 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=False, vlan_vid=4093, eth_dst=mac_dst, eth_src=mac_src) |
| 61 | pkt = str(parsed_pkt) |
| 62 | logging.info("OutputExact test, ports %d to %d", in_port, out_port) |
| 63 | self.dataplane.send(in_port, pkt) |
| 64 | |
| 65 | for ofport in ports: |
Flavio Castro | cca0d98 | 2016-01-26 17:55:55 -0500 | [diff] [blame] | 66 | if ofport is out_port: |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 67 | verify_packet(self, pkt, ofport) |
| 68 | else: |
| 69 | verify_no_packet(self, pkt, ofport) |
| 70 | |
| 71 | verify_no_other_packets(self) |
| 72 | # sends a double tagged packet |
| 73 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=300, |
| 74 | in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 75 | pkt = str(parsed_pkt) |
| 76 | logging.info("OutputExact test, ports %d to %d", in_port, out_port) |
| 77 | self.dataplane.send(in_port, pkt) |
| 78 | |
| 79 | for ofport in ports: |
Flavio Castro | cca0d98 | 2016-01-26 17:55:55 -0500 | [diff] [blame] | 80 | if ofport is in_port: |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 81 | verify_no_packet(self, pkt, ofport) |
Flavio Castro | cca0d98 | 2016-01-26 17:55:55 -0500 | [diff] [blame] | 82 | else: |
| 83 | verify_packet(self, pkt, ofport) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 84 | |
| 85 | verify_no_other_packets(self) |
| 86 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 87 | class UniqueMplsTermination(base_tests.SimpleDataPlane): |
| 88 | """ |
| 89 | Insert IP packet |
| 90 | Receive MPLS packet |
| 91 | """ |
| 92 | def runTest(self): |
| 93 | delete_all_flows(self.controller) |
| 94 | delete_all_groups(self.controller) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 95 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 96 | if len(config["port_map"]) <2: |
| 97 | logging.info("Port count less than 2, can't run this case") |
| 98 | return |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 99 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 100 | intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc] |
| 101 | dst_mac=[0x00, 0x00, 0x00, 0x22, 0x22, 0x00] |
| 102 | mcast_mac = [0x01, 0x00, 0x5e, 0x00, 0x00, 0x01] |
| 103 | |
| 104 | dip=0xc0a80001 |
| 105 | index=1 |
| 106 | ports = config["port_map"].keys() |
| 107 | for port in ports: |
| 108 | #add l2 interface group |
| 109 | vlan_id=port |
| 110 | l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id, True, False) |
| 111 | dst_mac[5]=vlan_id |
| 112 | #add L3 Unicast group |
| 113 | l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=vlan_id, src_mac=intf_src_mac, dst_mac=dst_mac) |
| 114 | #add L3 ecmp group |
| 115 | ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id]) |
| 116 | #add vlan flow table |
| 117 | add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 118 | #add termination flow |
| 119 | add_termination_flow(self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24) |
| 120 | #add routing flow |
| 121 | dst_ip = dip + (vlan_id<<8) |
| 122 | add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
| 123 | #add entries in the Bridging table to avoid packet-in from mac learning |
| 124 | group_id = encode_l2_interface_group_id(vlan_id, port) |
| 125 | add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True) |
| 126 | |
| 127 | do_barrier(self.controller) |
| 128 | |
| 129 | switch_mac = ':'.join(['%02X' % x for x in intf_src_mac]) |
| 130 | for in_port in ports: |
| 131 | mac_src='00:00:00:22:22:%02X' % in_port |
| 132 | ip_src='192.168.%02d.1' % in_port |
| 133 | for out_port in ports: |
| 134 | if in_port == out_port: |
| 135 | continue |
| 136 | ip_dst='192.168.%02d.1' % out_port |
| 137 | |
| 138 | label = (out_port, 0, 1, 32) |
| 139 | parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 140 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[label]) |
| 141 | pkt=str(parsed_pkt) |
| 142 | self.dataplane.send(in_port, pkt) |
| 143 | |
| 144 | #build expect packet |
| 145 | mac_dst='00:00:00:22:22:%02X' % out_port |
| 146 | mcast='01:00:5e:00:00:01' |
| 147 | exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 148 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst) |
| 149 | pkt=str(exp_pkt) |
| 150 | verify_packet(self, pkt, out_port) |
| 151 | verify_no_other_packets(self) |