blob: 653bbadcbb05952bbaa8a232fe8acf9268904a96 [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_cheng4bb7ffc2015-10-26 15:30:26 +080017import logging
18import oftest.base_tests as base_tests
19from oftest import config
20from oftest.testutils import *
21from util import *
22from accton_util import convertIP4toStr as toIpV4Str
23from accton_util import convertMACtoStr as toMacStr
24
25
26class single_tag_to_double_tag(base_tests.SimpleDataPlane):
27 """
28 [Single tag to double tag]
29 Add a specified outer tag to incoming tagged packet
30
31 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
32 Output eth 1/1 Outter Tag 5, inner Tag 3, others not change
33
34 dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff apply:push_vlan=0x8100,set_field=vlan_vid=5 goto:20
35 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
36 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1
37 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x50001
38 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output=3
39 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60
40 """
41 def runTest(self):
42 delete_all_flows(self.controller)
43 delete_all_groups(self.controller)
44
45 test_ports = sorted(config["port_map"].keys())
46 input_port = test_ports[0]
47 output_port = test_ports[1]
48
macauley_cheng77205a42015-11-06 15:24:21 +080049 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080050 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff apply:push_vlan=0x8100,set_field=vlan_vid=5 goto:20")
51 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080052 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x5000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
53 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x5000"+str(output_port))
54 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(input_port)+" group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
55 apply_dpctl_mod(self, config, " flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x3000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080056
macauley_cheng0a0a7f62015-11-06 11:36:50 +080057 input_pkt = simple_packet(
58 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
59 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
60 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
61 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080062
macauley_cheng0a0a7f62015-11-06 11:36:50 +080063 output_pkt = simple_packet(
64 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
65 '81 00 00 03 08 00 45 00 00 2e 04 d2 00 00 7f 00 '
66 'b2 47 c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
67 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
68 '00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080069
70 self.dataplane.send(input_port, str(input_pkt))
71 verify_packet(self, str(output_pkt), output_port)
72
73
74
75
76class double_tag_to_single_tag(base_tests.SimpleDataPlane):
77 """
78 [Double tag to single tag]
79 Pop outter tag of incoming double tagged packet
80
81 Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
82 Output eth 1/1 Tag 3, others not change
83
84 dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11
85 dpctl tcp:192.168.1.1:6633 flow-mod table=11,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 goto:20
86 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
87 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30001 group=any,port=any,weight=0 output=1
88 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x30001
89 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
90 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60
91
92 """
93 def runTest(self):
94 delete_all_flows(self.controller)
95 delete_all_groups(self.controller)
96
97 test_ports = sorted(config["port_map"].keys())
98 input_port = test_ports[0]
99 output_port = test_ports[1]
100
macauley_cheng77205a42015-11-06 15:24:21 +0800101 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800102 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800103 apply_dpctl_mod(self, config, "flow-mod table=11,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 goto:20")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800104 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800105 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
106 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x3000"+str(output_port))
107 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x6000"+str(input_port)+" group=any,port=any,weight=0 output="+str(input_port))
108 apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x6000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800109
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800110 input_pkt = simple_packet(
111 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 06 '
112 '81 00 00 03 08 00 45 00 00 2a 04 d2 00 00 7f 00 '
113 'b2 4b c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
114 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800115
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800116 output_pkt = simple_packet(
117 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
118 '08 00 45 00 00 2a 04 d2 00 00 7f 00 b2 4b c0 a8 '
119 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
120 '00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800121
122 self.dataplane.send(input_port, str(input_pkt))
123 verify_packet(self, str(output_pkt), output_port)
124
125
126
127
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800128class double2single_vlan_translate(base_tests.SimpleDataPlane):
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800129 """
130 [Double tag to single tag and modify inner tag]
131 Pop outter tag of incoming double tagged packet and modify inner tag
132
133 Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
134 Output eth 1/1 Tag 4, others not change
135
136 dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11
137 dpctl tcp:192.168.1.1:6633 flow-mod table=11,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 apply:set_field=vlan_vid=4 goto:20
138 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
139 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x40001 group=any,port=any,weight=0 output=1
140 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x40001
141 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
142 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60
143
144 """
145 def runTest(self):
146 delete_all_flows(self.controller)
147 delete_all_groups(self.controller)
148
149 test_ports = sorted(config["port_map"].keys())
150 input_port = test_ports[0]
151 output_port = test_ports[1]
152
macauley_cheng77205a42015-11-06 15:24:21 +0800153 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800154 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11")
155 apply_dpctl_mod(self, config, "flow-mod table=11,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 apply:set_field=vlan_vid=4 goto:20")
156 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800157 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x4000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
158 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x4000"+str(output_port))
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800159 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output="+str(input_port))
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800160 apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x6000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800161
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800162 input_pkt = simple_packet(
163 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 06 '
164 '81 00 00 03 08 00 45 00 00 2a 04 d2 00 00 7f 00 '
165 'b2 4b c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
166 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800167
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800168 output_pkt = simple_packet(
169 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 04 '
170 '08 00 45 00 00 2a 04 d2 00 00 7f 00 b2 4b c0 a8 '
171 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
172 '00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800173
174 self.dataplane.send(input_port, str(input_pkt))
175 verify_packet(self, str(output_pkt), output_port)
176
177
178
179class vlan_translate(base_tests.SimpleDataPlane):
180 """
181 [VLAN tanslate]
182 Swap incoming tagged packet to a specified VLAN tag
183
184 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
185 Output eth 1/1 Tag 5, others not change
186
187 dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff apply:set_field=vlan_vid=5 goto:20
188 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
189 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1
190 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x50001
191 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output=3
192 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60
193
194 """
195 def runTest(self):
196 delete_all_flows(self.controller)
197 delete_all_groups(self.controller)
198
199 test_ports = sorted(config["port_map"].keys())
200 input_port = test_ports[0]
201 output_port = test_ports[1]
202
macauley_cheng77205a42015-11-06 15:24:21 +0800203 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800204 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff apply:set_field=vlan_vid=5 goto:20")
205 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800206 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x5000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
207 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x5000"+str(output_port))
208 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(input_port)+" group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
209 apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x3000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800210
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800211 input_pkt = simple_packet(
212 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
213 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
214 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
215 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800216
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800217 output_pkt = simple_packet(
218 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
219 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
220 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
221 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
222
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800223 self.dataplane.send(input_port, str(input_pkt))
224 verify_packet(self, str(output_pkt), output_port)