blob: 024b3067988d233f29b6ba8c48251cecf3ef23bd [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
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
castroflaviobd48e302015-12-15 17:57:38 -050017"""
18The following tests are being done here
191) PacketInSrcMacMiss
202) VlanSupport
213) L2FloodQinQ
224) L2FloodTagged
235) L2Flood Tagged Unknown Src
246) L2 Unicast Tagged
257) MTU 1500
268) MTU 4100
279) MTU 4500
2810) L3UnicastTagged
2911) L3VPNMPLS
3012) MPLS Termination
31"""
32
33from oftest import config
34import logging
35import oftest.base_tests as base_tests
36import ofp
37from oftest.testutils import *
38from accton_util import *
39
40class 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 Castrocca0d982016-01-26 17:55:55 -050082 if ofport is out_port:
castroflaviobd48e302015-12-15 17:57:38 -050083 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 Castrocca0d982016-01-26 17:55:55 -050096 if ofport is in_port:
castroflaviobd48e302015-12-15 17:57:38 -050097 verify_no_packet(self, pkt, ofport)
Flavio Castrocca0d982016-01-26 17:55:55 -050098 else:
99 verify_packet(self, pkt, ofport)
castroflaviobd48e302015-12-15 17:57:38 -0500100
101 verify_no_other_packets(self)