Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 17 | """ |
| 18 | The following tests are being done here |
| 19 | 1) PacketInSrcMacMiss |
| 20 | 2) VlanSupport |
| 21 | 3) L2FloodQinQ |
| 22 | 4) L2FloodTagged |
| 23 | 5) L2Flood Tagged Unknown Src |
| 24 | 6) L2 Unicast Tagged |
| 25 | 7) MTU 1500 |
| 26 | 8) MTU 4100 |
| 27 | 9) MTU 4500 |
| 28 | 10) L3UnicastTagged |
| 29 | 11) L3VPNMPLS |
| 30 | 12) MPLS Termination |
| 31 | """ |
| 32 | |
| 33 | from oftest import config |
| 34 | import logging |
| 35 | import oftest.base_tests as base_tests |
| 36 | import ofp |
| 37 | from oftest.testutils import * |
| 38 | from accton_util import * |
| 39 | |
| 40 | class VlanSupport(base_tests.SimpleDataPlane): |
| 41 | """ |
| 42 | Test L2 forwarding of both, untagged and double-tagged packets |
| 43 | Sends a packet and expects the same packet on the other port |
| 44 | Repeats for double tagged |
| 45 | """ |
| 46 | def runTest(self): |
| 47 | delete_all_flows(self.controller) |
| 48 | delete_all_groups(self.controller) |
| 49 | ports = sorted(config["port_map"].keys()) |
| 50 | # group table |
| 51 | # set up untag groups for each port |
| 52 | add_l2_interface_group(self.controller, config["port_map"].keys(), 4093, False, 1) |
| 53 | for port in ports: |
| 54 | add_one_vlan_table_flow(self.controller, port, 4093, flag=VLAN_TABLE_FLAG_ONLY_BOTH) |
| 55 | group_id = encode_l2_interface_group_id(4093, port) |
| 56 | add_bridge_flow(self.controller, [0x00, 0x12, 0x34, 0x56, 0x78, port], 4093, group_id, True) |
| 57 | #add flow match for vlan 300 |
| 58 | add_one_l2_interface_group(self.controller, port, 300, True, False) |
| 59 | add_one_vlan_table_flow(self.controller, port, 300, flag=VLAN_TABLE_FLAG_ONLY_TAG) |
| 60 | msg=add_l2_flood_group(self.controller, ports, 300, 1) |
| 61 | add_bridge_flow(self.controller, None, 300, msg.group_id, True) |
| 62 | msg=add_l2_flood_group(self.controller, ports, 4093, 1) |
| 63 | add_bridge_flow(self.controller, None, 4093, msg.group_id, True) |
| 64 | do_barrier(self.controller) |
| 65 | |
| 66 | for out_port in ports: |
| 67 | # change dest based on port number |
| 68 | mac_dst= '00:12:34:56:78:%02X' % out_port |
| 69 | |
| 70 | for in_port in ports: |
| 71 | if in_port == out_port: |
| 72 | continue |
| 73 | # change source based on port number to avoid packet-ins from learning |
| 74 | mac_src= '00:12:34:56:78:%02X' % in_port |
| 75 | #sends an untagged packet |
| 76 | parsed_pkt = simple_tcp_packet(dl_vlan_enable=False, vlan_vid=4093, eth_dst=mac_dst, eth_src=mac_src) |
| 77 | pkt = str(parsed_pkt) |
| 78 | logging.info("OutputExact test, ports %d to %d", in_port, out_port) |
| 79 | self.dataplane.send(in_port, pkt) |
| 80 | |
| 81 | for ofport in ports: |
Flavio Castro | cca0d98 | 2016-01-26 17:55:55 -0500 | [diff] [blame] | 82 | if ofport is out_port: |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 83 | verify_packet(self, pkt, ofport) |
| 84 | else: |
| 85 | verify_no_packet(self, pkt, ofport) |
| 86 | |
| 87 | verify_no_other_packets(self) |
| 88 | # sends a double tagged packet |
| 89 | parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=300, |
| 90 | in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', eth_src=mac_src) |
| 91 | pkt = str(parsed_pkt) |
| 92 | logging.info("OutputExact test, ports %d to %d", in_port, out_port) |
| 93 | self.dataplane.send(in_port, pkt) |
| 94 | |
| 95 | for ofport in ports: |
Flavio Castro | cca0d98 | 2016-01-26 17:55:55 -0500 | [diff] [blame] | 96 | if ofport is in_port: |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 97 | verify_no_packet(self, pkt, ofport) |
Flavio Castro | cca0d98 | 2016-01-26 17:55:55 -0500 | [diff] [blame] | 98 | else: |
| 99 | verify_packet(self, pkt, ofport) |
castroflavio | bd48e30 | 2015-12-15 17:57:38 -0500 | [diff] [blame] | 100 | |
| 101 | verify_no_other_packets(self) |