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) |