blob: cfe12961a549f584f457bf70d15314bc5eb6c207 [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
macauley_cheng6b311612015-09-04 11:32:27 +080017"""
18Flow Test
19
20Test each flow table can set entry, and packet rx correctly.
21"""
22
23import logging
24
25from oftest import config
26import oftest.base_tests as base_tests
27import ofp
28from oftest.testutils import *
29from accton_util import *
30
31class qinq(base_tests.SimpleDataPlane):
32 def runTest(self):
33 delete_all_flows(self.controller)
34 delete_all_groups(self.controller)
35
36 in_port = config["port_map"].keys()[0]
37 out_port=config["port_map"].keys()[1]
38 out_vlan=10
39 add_vlan_table_flow_pvid(self.controller, in_port, None, out_vlan, False)
40 add_vlan_table_flow_pvid(self.controller, in_port, 1,out_vlan, False)
castroflaviodd171472015-12-08 13:55:58 -050041 group_id, msg=add_one_l2_interface_group(self.controller, out_port, out_vlan, True, False)
macauley_cheng6b311612015-09-04 11:32:27 +080042 #add acl
43 match = ofp.match()
44 match.oxm_list.append(ofp.oxm.in_port(in_port))
45 request = ofp.message.flow_add(
46 table_id=60,
47 cookie=42,
48 match=match,
49 instructions=[
50 ofp.instruction.write_actions(
51 actions=[
52 ofp.action.group(msg.group_id)])
53 ],
54 buffer_id=ofp.OFP_NO_BUFFER,
55 priority=1000)
56 self.controller.message_send(request)
57
58 #input untag packet
59
60 parsed_pkt = simple_tcp_packet(pktlen=100)
61 pkt = str(parsed_pkt)
62 self.dataplane.send(in_port, pkt)
63
64 parsed_pkt = simple_tcp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=10)
65 verify_packet(self, str(parsed_pkt), out_port)
66
67 #input tag packet
68 parsed_pkt = simple_tcp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=1)
69 pkt = str(parsed_pkt)
70 self.dataplane.send(in_port, pkt)
71
72 parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=10,
73 in_dl_vlan_enable=True, in_vlan_vid=1)
74 verify_packet(self, str(parsed_pkt), out_port)