blob: c13a3d7349b1d1d387fb3ce0f898b066780d7ec7 [file] [log] [blame]
Sreeju Sreedhare3fefd92019-04-02 15:57:15 -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
17import logging
18
19from oftest import config
20import oftest.base_tests as base_tests
21import ofp
22from oftest.testutils import *
23from accton_util import *
24
25"""
26This file test case is copied from NTC EPR bug
27"""
28
29class pvidClear(base_tests.SimpleDataPlane):
30 """
31 AOS5700-54X-00620
32 """
33 def runTest(self):
34 ports = sorted(config["port_map"].keys())
35 delete_all_flows(self.controller)
36 delete_all_groups(self.controller)
37 port1=ports[0]
38 port2=ports[1]
39
40 vlan_id = 10
41
42 gid_p1, req_msg_p1 = add_one_l2_interface_group(self.controller, port=port1, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
43 gid_p2, req_msg_p2 = add_one_l2_interface_group(self.controller, port=port2, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
44 #add ACL flow, in port1 out port2
45 match = ofp.match()
46 match.oxm_list.append(ofp.oxm.in_port(port1))
47 request = ofp.message.flow_add(
48 table_id=60,
49 cookie=42,
50 match=match,
51 instructions=[
52 ofp.instruction.write_actions(
53 actions=[
54 ofp.action.group(gid_p2)]
55 )
56 ],
57 priority=1)
58 #install flow
59 self.controller.message_send(request)
60 #add ACL flow, in port2 out port1
61 match = ofp.match()
62 match.oxm_list.append(ofp.oxm.in_port(port2))
63 request = ofp.message.flow_add(
64 table_id=60,
65 cookie=42,
66 match=match,
67 instructions=[
68 ofp.instruction.write_actions(
69 actions=[
70 ofp.action.group(gid_p1)]
71 )
72 ],
73 priority=1)
74 #install flow
75 self.controller.message_send(request)
76
77 #send packet and verify packet
78 parsed_pkt = simple_tcp_packet()
79 self.dataplane.send(port1, str(parsed_pkt))
80 verify_no_packet(self, str(parsed_pkt), port2)
81 self.dataplane.send(port2, str(parsed_pkt))
82 verify_no_packet(self, str(parsed_pkt), port1)
83
84
85 #add vlan flow table
86 add_vlan_table_flow(self.controller, [port1, port2], vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG)
87 #send packet and verify packet
88 parsed_pkt = simple_tcp_packet()
89 self.dataplane.send(port1, str(parsed_pkt))
90 verify_packet(self, str(parsed_pkt), port2)
91 self.dataplane.send(port2, str(parsed_pkt))
92 verify_packet(self, str(parsed_pkt), port1)
93
94 #remove vlan table flow
95 del_vlan_table_flow(self.controller, [port1, port2], vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG)
96 #send packet and verify packet
97 parsed_pkt = simple_tcp_packet()
98 self.dataplane.send(port1, str(parsed_pkt))
99 verify_no_packet(self, str(parsed_pkt), port2)
100 self.dataplane.send(port2, str(parsed_pkt))
101 verify_no_packet(self, str(parsed_pkt), port1)
102
103
104
105