blob: a4399d739bc6870ec626b80c505552f883fcf2a5 [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_cheng0a0a7f62015-11-06 11:36:50 +080017import logging
18import oftest.base_tests as base_tests
19import time
20from oftest import config
21from oftest.testutils import *
22from util import *
23from accton_util import convertIP4toStr as toIpV4Str
24from accton_util import convertMACtoStr as toMacStr
25
26class encap_mpls(base_tests.SimpleDataPlane):
27 """
28 [Encap one MPLS label]
29 Encap a MPLS label
30
31 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
32 Output eth 1/1 Tag 2, SA000004223355, DA000004224466, MPLS label 2305, EXP7, BoS1, TTL250, CW
33
34 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
35 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x20001 goto:60
36 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
37 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001
38 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
39 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3 apply:set_field=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13
40 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
41 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
42 """
43 def runTest(self):
44 delete_all_flows(self.controller)
45 delete_all_groups(self.controller)
46
47 test_ports = sorted(config["port_map"].keys())
48
49 input_port = test_ports[0]
50 output_port = test_ports[1]
51
macauley_cheng77205a42015-11-06 15:24:21 +080052 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080053 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
54 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x2000"+str(output_port)+" goto:60")
55 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
56 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001")
57 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
58 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+" apply:set_field=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13")
59 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1002/0x1fff goto:20")
60 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(output_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
61
62 input_pkt = simple_packet(
63 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
64 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
65 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
66 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
67
68 output_pkt = simple_packet(
69 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
70 '88 47 00 90 1f fa 00 00 00 00 00 00 00 11 33 55 '
71 '00 00 00 11 22 33 81 00 00 03 08 00 45 00 00 2e '
72 '04 d2 00 00 7f 00 b2 47 c0 a8 01 64 c0 a8 02 02 '
73 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
74 '00 00 00 00 00 00 00 00 00 00')
75
76 self.dataplane.send(input_port, str(input_pkt))
77 verify_packet(self, str(output_pkt), output_port)
78
79
80class decap_mpls(base_tests.SimpleDataPlane):
81 """
82 [Decap one MPLS label]
83 Decap the MPLS label
84
85 Inject eth 1/1 Tag 2, SA000004223355, DA000004224466, MPLS label 2305, EXP7, BoS1, TTL250, CW, InSA000000112233, InDA000000113355
86 Output eth 1/3 SA000000112233, DA000000113355
87
88 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
89 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x20001 goto:60
90 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
91 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001
92 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
93 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3 apply:set_field=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13
94 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
95 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
96 """
97 def runTest(self):
98 delete_all_flows(self.controller)
99 delete_all_groups(self.controller)
100
101 test_ports = sorted(config["port_map"].keys())
102
103 input_port = test_ports[0]
104 output_port = test_ports[1]
105
macauley_cheng77205a42015-11-06 15:24:21 +0800106 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800107 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(input_port)+" group=any,port=any,weight=0 output="+str(input_port))
108 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x2000"+str(input_port)+" goto:60")
109 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(input_port))
110 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001")
111 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
112 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+" apply:set_field=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13")
113 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
114 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
115
116 input_pkt = simple_packet(
117 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
118 '88 47 00 90 1f fa 00 00 00 00 00 00 00 11 33 55 '
119 '00 00 00 11 22 33 81 00 00 05 08 00 45 00 00 2e '
120 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
121 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
122 '10 11 12 13 14 15 16 17 18 19 00 00 00 00')
123
124 output_pkt = simple_packet(
125 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
126 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 '
127 '02 01 c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 '
128 '0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 '
129 '00 00 00 00')
130
131 self.dataplane.send(input_port, str(input_pkt))
132 verify_packet(self, str(output_pkt), output_port)
133
134
135class encap_2mpls(base_tests.SimpleDataPlane):
136 """
137 [Encap two MPLS labels]
138 Encap two MPLS labels
139
140 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355
141 Output eth 1/1 Tag 2, Outer label 0x903, TTL 250, InLabel 0x901, TTL 250, SA000004223355, DA000004224466
142
143 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
144 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x20001 goto:60
145 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
146 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x903,group=0x90000001
147 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x93000001
148 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
149 ./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=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13
150 """
151 def runTest(self):
152 delete_all_flows(self.controller)
153 delete_all_groups(self.controller)
154
155 test_ports = sorted(config["port_map"].keys())
156
157 input_port = test_ports[0]
158 output_port = test_ports[1]
159
macauley_cheng77205a42015-11-06 15:24:21 +0800160 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800161 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
162 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x2000"+str(output_port)+" goto:60")
163 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
164 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x903,group=0x90000001")
165 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x93000001")
166 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
167 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=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13")
168
169 input_pkt = simple_packet(
170 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
171 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
172 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
173 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
174
175 output_pkt = simple_packet(
176 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
177 '88 47 00 90 3e fa 00 90 1f fa 00 00 00 00 00 00 '
178 '00 11 33 55 00 00 00 11 22 33 81 00 00 03 08 00 '
179 '45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 01 64 '
180 'c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 00 00 '
181 '00 00 00 00 00 00 00 00 00 00 00 00 00 00')
182
183 self.dataplane.send(input_port, str(input_pkt))
184 verify_packet(self, str(output_pkt), output_port)
185
186
187class encap_3mpls(base_tests.SimpleDataPlane):
188 """
189 [Encap 3 MPLS labels]
190 Encap 3 MPLS labels
191
192 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355
193 Output eth 1/1 Tag 2, Outest label 0x904, TTL 250, Middle label 0x903, InLabel 0x901, SA000004223355, DA000004224466
194
195 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
196 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x20001 goto:60
197 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
198 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x94000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x904,group=0x90000001
199 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x903,group=0x94000001
200 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x93000001
201 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
202 ./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=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13
203 """
204 def runTest(self):
205 delete_all_flows(self.controller)
206 delete_all_groups(self.controller)
207
208 test_ports = sorted(config["port_map"].keys())
209
210 input_port = test_ports[0]
211 output_port = test_ports[1]
212
macauley_cheng77205a42015-11-06 15:24:21 +0800213 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800214 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
215 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x2000"+str(output_port)+" goto:60")
216 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
217 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x94000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x904,group=0x90000001")
218 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x903,group=0x94000001")
219 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x93000001")
220 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
221 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=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13")
222
223 input_pkt = simple_packet(
224 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
225 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
226 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
227 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
228
229 output_pkt = simple_packet(
230 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
231 '88 47 00 90 4e fa 00 90 3e fa 00 90 1f fa 00 00 '
232 '00 00 00 00 00 11 33 55 00 00 00 11 22 33 81 00 '
233 '00 03 08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 '
234 'c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 '
235 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
236 '00 00')
237
238 self.dataplane.send(input_port, str(input_pkt))
239 verify_packet(self, str(output_pkt), output_port)
240
241
242class decap_penultimate_mpls(base_tests.SimpleDataPlane):
243 """
244 [Penultimate Hop Pop]
245 Pop outermost tunnel label
246
247 Inject eth 1/1 Tag 2, Outer label 0x901, InLabel 0xF, SA000004223355, DA000004224466
248 Output eth 1/3 Tag 2, label 0xF, SA000004223355, DA000004224466
249
250 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
251 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20003
252 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901 apply:pop_mpls=0x8847,mpls_dec write:group=0x90000001 goto:60
253 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
254 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
255 """
256 def runTest(self):
257 delete_all_flows(self.controller)
258 delete_all_groups(self.controller)
259
260 test_ports = sorted(config["port_map"].keys())
261
262 input_port = test_ports[0]
263 output_port = test_ports[1]
264
macauley_cheng77205a42015-11-06 15:24:21 +0800265 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800266 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
267 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
268 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901 apply:pop_mpls=0x8847,mpls_dec write:group=0x90000001 goto:60")
269 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
270 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
271
272 input_pkt = simple_packet(
273 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
274 '88 47 00 90 1e fa 00 01 0b ff 00 00 00 00 00 00 '
275 '00 11 33 55 00 00 00 11 22 33 81 00 00 05 08 00 '
276 '45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 02 01 '
277 'c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 0a 0b '
278 '0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
279
280 output_pkt = simple_packet(
281 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
282 '88 47 00 01 0f f9 00 00 00 00 00 00 00 11 33 55 '
283 '00 00 00 11 22 33 81 00 00 05 08 00 45 00 00 2e '
284 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
285 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
286 '10 11 12 13 14 15 16 17 18 19')
287
288 self.dataplane.send(input_port, str(input_pkt))
289 verify_packet(self, str(output_pkt), output_port)
290
291
292class decap_2mpls(base_tests.SimpleDataPlane):
293 """
294 [Pop, decap, and L2 forward]
295 Pop outermost tunnel label and pop outer L2 header (L2 Switch VPWS )
296
297 Inject eth 1/1 Tag 2, Outer label 0x903, InLabel 0x901, SA000004223355, DA000004224466; InTag 5, InSA000000112233, InDA000000113355
298 Output eth 1/3 Tag 5, SA000000112233, DA000000113355
299
300 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
301 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
302 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 set_field=mpls_label:0x903,push_mpls=0x8847,group=0x90000001
303 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x93000001
304 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
305 ./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=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13
306 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
307 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x00008847 goto:24
308 ./dpctl tcp:192.168.1.1:6633 flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec goto:24
309 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x20001 goto:60
310 """
311 def runTest(self):
312 delete_all_flows(self.controller)
313 delete_all_groups(self.controller)
314
315 test_ports = sorted(config["port_map"].keys())
316
317 input_port = test_ports[0]
318 output_port = test_ports[1]
319
macauley_cheng77205a42015-11-06 15:24:21 +0800320 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800321 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(input_port)+" group=any,port=any,weight=0 output="+str(input_port))
322 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(input_port))
323 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 set_field=mpls_label:0x903,push_mpls=0x8847,group=0x90000001")
324 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x93000001")
325 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
326 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1003/0x1fff apply:set_field=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13")
327 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
328 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x00008847 goto:24")
329 apply_dpctl_mod(self, config, "flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec goto:24")
330 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x2000"+str(input_port)+" goto:60")
331
332 input_pkt = simple_packet(
333 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
334 '88 47 00 90 3e fa 00 90 1b ff 00 00 00 00 00 00 '
335 '00 11 33 55 00 00 00 11 22 33 81 00 00 05 08 00 '
336 '45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 02 01 '
337 'c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 0a 0b '
338 '0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
339
340 output_pkt = simple_packet(
341 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
342 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 '
343 '02 01 c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 '
344 '0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
345
346 self.dataplane.send(input_port, str(input_pkt))
347 verify_packet(self, str(output_pkt), output_port)
348
349
350class decap_penultimate_swap_mpls(base_tests.SimpleDataPlane):
351 """
352 [Penultimate Hop Pop and swap inner MPLS label]
353 Pop outermost tunnel label and swap inner MPLS label (MS-PW, LSR)
354
355 Inject eth 1/1 Tag 2, Outer label 0x903, InLabel 0x901, SA000004223355, DA000004224466; InTag 5, InSA000000112233, InDA000000113355
356 Output eth 1/3 Tag 2, Label 0x905, TTL 249, SA000004223355, DA000004224466
357
358 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
359 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20003
360 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001
361 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
362 ./dpctl tcp:192.168.1.1:6633 flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec goto:24
363 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x905,group=0x90000001
364 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:mpls_dec write:group=0x95000001 goto:60
365 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
366 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
367 """
368 def runTest(self):
369 delete_all_flows(self.controller)
370 delete_all_groups(self.controller)
371
372 test_ports = sorted(config["port_map"].keys())
373
374 input_port = test_ports[0]
375 output_port = test_ports[1]
376
macauley_cheng77205a42015-11-06 15:24:21 +0800377 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800378 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
379 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
380 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001")
381 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
382 apply_dpctl_mod(self, config, "flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec goto:24")
383 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x905,group=0x90000001")
384 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:mpls_dec write:group=0x95000001 goto:60")
385 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
386 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
387
388 input_pkt = simple_packet(
389 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
390 '88 47 00 90 3e fa 00 90 1b ff 00 00 00 00 00 00 '
391 '00 11 33 55 00 00 00 11 22 33 81 00 00 05 08 00 '
392 '45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 02 01 '
393 'c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 0a 0b '
394 '0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
395
396 output_pkt = simple_packet(
397 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
398 '88 47 00 90 51 f9 00 00 00 00 00 00 00 11 33 55 '
399 '00 00 00 11 22 33 81 00 00 05 08 00 45 00 00 2e '
400 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
401 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
402 '10 11 12 13 14 15 16 17 18 19')
403
404 self.dataplane.send(input_port, str(input_pkt))
405 verify_packet(self, str(output_pkt), output_port)
406
407
408
409class swap_out_mpls(base_tests.SimpleDataPlane):
410 """
411 [Swap outermost MPLS label]
412 Swap outermost MPLS label (LSR)
413
414 Inject eth 1/1 Tag 2, Outer label 0x901, TTL 250, InLabel 0xF, DA000004223355, SA000004224466
415 Output eth 1/3 Tag 2, Outer label 0x9051, TTL 249, InLabel 0xF, SA000004223357, DA000004224467
416
417 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
418 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:57,set_field=eth_dst=00:00:04:22:44:67,set_field=vlan_vid=2,group=0x20003
419 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x9051,group=0x90000001
420 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901 apply:mpls_dec write:group=0x95000001 goto:60
421 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
422 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
423 """
424 def runTest(self):
425 delete_all_flows(self.controller)
426 delete_all_groups(self.controller)
427
428 test_ports = sorted(config["port_map"].keys())
429
430 input_port = test_ports[0]
431 output_port = test_ports[1]
432
macauley_cheng77205a42015-11-06 15:24:21 +0800433 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800434 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
435 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:57,set_field=eth_dst=00:00:04:22:44:67,set_field=vlan_vid=2,group=0x2000"+str(output_port))
436 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x9051,group=0x90000001")
437 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901 apply:mpls_dec write:group=0x95000001 goto:60")
438 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
439 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
440
441 input_pkt = simple_packet(
442 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
443 '88 47 00 90 1e fa 00 01 0b ff 00 00 00 00 00 00 '
444 '00 11 33 55 00 00 00 11 22 33 81 00 00 05 08 00 '
445 '45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 02 01 '
446 'c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 0a 0b '
447 '0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
448
449 output_pkt = simple_packet(
450 '00 00 04 22 44 67 00 00 04 22 33 57 81 00 00 02 '
451 '88 47 09 05 10 f9 00 01 0b ff 00 00 00 00 00 00 '
452 '00 11 33 55 00 00 00 11 22 33 81 00 00 05 08 00 '
453 '45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 02 01 '
454 'c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 0a 0b '
455 '0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
456
457 self.dataplane.send(input_port, str(input_pkt))
458 verify_packet(self, str(output_pkt), output_port)
459
460
461
462class swap_encap_mpls(base_tests.SimpleDataPlane):
463 """
464 [Swap and encap a MPLS label]
465 Swap and encap a MPLS label
466
467 Inject eth 1/1 Tag 2, MPLS label 0x901, TTL 250, DA000004223355, SA000004224466
468 Output eth 1/3 Tag 2, Outer label 0x9052, TTL 249, InLabel 0xF, SA000004223358, DA000004224468
469
470 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
471 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:58,set_field=eth_dst=00:00:04:22:44:68,set_field=vlan_vid=2,group=0x20003
472 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x9052,group=0x90000001
473 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:mpls_dec write:group=0x95000001 goto:60
474 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
475 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
476 """
477 def runTest(self):
478 delete_all_flows(self.controller)
479 delete_all_groups(self.controller)
480
481 test_ports = sorted(config["port_map"].keys())
482
483 input_port = test_ports[0]
484 output_port = test_ports[1]
485
macauley_cheng77205a42015-11-06 15:24:21 +0800486 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800487 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
488 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:58,set_field=eth_dst=00:00:04:22:44:68,set_field=vlan_vid=2,group=0x2000"+str(output_port))
489 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x9052,group=0x90000001")
490 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:mpls_dec write:group=0x95000001 goto:60")
491 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
492 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
493
494 input_pkt = simple_packet(
495 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
496 '88 47 00 90 1f fa 00 00 00 00 00 00 00 11 33 55 '
497 '00 00 00 11 22 33 81 00 00 05 08 00 45 00 00 2e '
498 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
499 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
500 '10 11 12 13 14 15 16 17 18 19 00 00 00 00')
501
502 output_pkt = simple_packet(
503 '00 00 04 22 44 68 00 00 04 22 33 58 81 00 00 02 '
504 '88 47 09 05 21 f9 00 00 00 00 00 00 00 11 33 55 '
505 '00 00 00 11 22 33 81 00 00 05 08 00 45 00 00 2e '
506 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
507 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
508 '10 11 12 13 14 15 16 17 18 19 00 00 00 00')
509
510 self.dataplane.send(input_port, str(input_pkt))
511 verify_packet(self, str(output_pkt), output_port)
512
513
514class swap_encap_2mpls(base_tests.SimpleDataPlane):
515 """
516 [Swap and encap 2 MPLS labels]
517 Swap and encap 2 MPLS labels
518
519 Inject eth 1/1 Tag 2, MPLS label 0x901, TTL 250, DA000004223355, SA000004224466
520 Output eth 1/3 Tag 2, Outest label 0x904, TTL 249, Middle label 0x903, InLabel 0x9052, SA000004223358, DA000004224468
521
522 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
523 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:58,set_field=eth_dst=00:00:04:22:44:68,set_field=vlan_vid=2,group=0x20003
524 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x94000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x904,group=0x90000001
525 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x903,group=0x94000001
526 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x9052,group=0x93000001
527 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:mpls_dec write:group=0x95000001 goto:60
528 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
529 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
530 """
531 def runTest(self):
532 delete_all_flows(self.controller)
533 delete_all_groups(self.controller)
534
535 test_ports = sorted(config["port_map"].keys())
536
537 input_port = test_ports[0]
538 output_port = test_ports[1]
539
macauley_cheng77205a42015-11-06 15:24:21 +0800540 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800541 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
542 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:58,set_field=eth_dst=00:00:04:22:44:68,set_field=vlan_vid=2,group=0x2000"+str(output_port))
543 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x94000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x904,group=0x90000001")
544 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x903,group=0x94000001")
545 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x95000001 group=any,port=any,weight=0 set_field=mpls_label:0x9052,group=0x93000001")
546 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:mpls_dec write:group=0x95000001 goto:60")
547 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
548 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
549
550 input_pkt = simple_packet(
551 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
552 '88 47 00 90 1f fa 00 00 00 00 00 00 00 11 33 55 '
553 '00 00 00 11 22 33 81 00 00 05 08 00 45 00 00 2e '
554 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
555 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
556 '10 11 12 13 14 15 16 17 18 19 00 00 00 00')
557
558 output_pkt = simple_packet(
559 '00 00 04 22 44 68 00 00 04 22 33 58 81 00 00 02 '
560 '88 47 00 90 40 f9 00 90 30 f9 09 05 21 f9 00 00 '
561 '00 00 00 00 00 11 33 55 00 00 00 11 22 33 81 00 '
562 '00 05 08 00 45 00 00 2e 04 d2 00 00 7f 00 b1 aa '
563 'c0 a8 02 01 c0 a8 02 02 00 01 02 03 04 05 06 07 '
564 '08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 '
565 '18 19 00 00 00 00')
566
567 self.dataplane.send(input_port, str(input_pkt))
568 verify_packet(self, str(output_pkt), output_port)
569
570
571class decap_1mpls_of3(base_tests.SimpleDataPlane):
572 """
573 [Decap outermost MPLS label of 3 MPLS labels]
574 Decap outermost one MPLS of 3 MPLS labels
575
576 Inject eth 1/1 Tag 2, Outest label 0x904, TTL 250, Middle label 0x903/250, InLabel 0x901/250, SA000004224466, DA000004223355
577 Output eth 1/3 Tag 2, Outer label 0x903/249, InLabel 0x901/250, SA000004223355, DA000004224466
578
579 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
580 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20003
581 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x904 apply:pop_mpls=0x8847,mpls_dec write:group=0x90000001 goto:60
582 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
583 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
584 """
585 def runTest(self):
586 delete_all_flows(self.controller)
587 delete_all_groups(self.controller)
588
589 test_ports = sorted(config["port_map"].keys())
590
591 input_port = test_ports[0]
592 output_port = test_ports[1]
593
macauley_cheng77205a42015-11-06 15:24:21 +0800594 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800595 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
596 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
597 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x904 apply:pop_mpls=0x8847,mpls_dec write:group=0x90000001 goto:60")
598 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
599 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
600
601 input_pkt = simple_packet(
602 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
603 '88 47 00 90 4e fa 00 90 3e fa 00 90 1f fa 00 00 '
604 '00 00 00 00 00 11 33 55 00 00 00 11 22 33 00 00 '
605 '00 03 08 00 45 00 00 2e 04 d2 00 00 7f 00 b1 aa '
606 'c0 a8 02 01 c0 a8 02 02 00 01 02 03 04 05 06 07 '
607 '08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 '
608 '18 19')
609
610 output_pkt = simple_packet(
611 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
612 '88 47 00 90 3e f9 00 90 1f fa 00 00 00 00 00 00 '
613 '00 11 33 55 00 00 00 11 22 33 00 00 00 03 08 00 '
614 '45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 02 01 '
615 'c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 0a 0b '
616 '0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
617
618 self.dataplane.send(input_port, str(input_pkt))
619 verify_packet(self, str(output_pkt), output_port)
620
621
622class decap_2mpls_of3(base_tests.SimpleDataPlane):
623 """
624 [Decap outermost 2 MPLS labels of 3 MPLS labels]
625 Decap outermost two MPLS of 3 MPLS labels
626
627 Inject eth 1/1 Tag 2, Outest label 0x904, TTL 250, Middle label 0x903/250, InLabel 0x901/250, SA000004224466, DA000004223355
628 Output eth 1/3 Tag 2, MPLS Label 0x901/249, SA000004223355, DA000004224466
629
630 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
631 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20003
632 ./dpctl tcp:192.168.1.1:6633 flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x904 apply:pop_mpls=0x8847,mpls_dec goto:24
633 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec write:group=0x90000001 goto:60
634 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
635 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
636 """
637 def runTest(self):
638 delete_all_flows(self.controller)
639 delete_all_groups(self.controller)
640
641 test_ports = sorted(config["port_map"].keys())
642
643 input_port = test_ports[0]
644 output_port = test_ports[1]
645
macauley_cheng77205a42015-11-06 15:24:21 +0800646 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800647 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
648 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
649 apply_dpctl_mod(self, config, "flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x904 apply:pop_mpls=0x8847,mpls_dec goto:24")
650 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec write:group=0x90000001 goto:60")
651 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
652 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
653
654 input_pkt = simple_packet(
655 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
656 '88 47 00 90 4e fa 00 90 3e fa 00 90 1f fa 00 00 '
657 '00 00 00 00 00 11 33 55 00 00 00 11 22 33 00 00 '
658 '00 03 08 00 45 00 00 2e 04 d2 00 00 7f 00 b1 aa '
659 'c0 a8 02 01 c0 a8 02 02 00 01 02 03 04 05 06 07 '
660 '08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 '
661 '18 19')
662
663 output_pkt = simple_packet(
664 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
665 '88 47 00 90 1f f9 00 00 00 00 00 00 00 11 33 55 '
666 '00 00 00 11 22 33 00 00 00 03 08 00 45 00 00 2e '
667 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
668 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
669 '10 11 12 13 14 15 16 17 18 19')
670
671 self.dataplane.send(input_port, str(input_pkt))
672 verify_packet(self, str(output_pkt), output_port)
673
674
675class encap_2mpls_ff(base_tests.SimpleDataPlane):
676 """
677 [Encap two MPLS labels with FF]
678 Encap two MPLS labels with fast failover group
679
680 Env eth 1/1 link up; eth 1/5 link down
681 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355
682 Output eth 1/1 Tag 2, Outest label 0x931, TTL 250, InLabel 0x901, SA000004223351, DA000004224461
683
684 Env eth 1/1 link down; eth 1/5 link up
685 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355
686 Output eth 1/5 Tag 2, Outest label 0x935, TTL 250, InLabel 0x901, SA000004223355, DA000004224465
687
688 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
689 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:51,set_field=eth_dst=00:00:04:22:44:61,set_field=vlan_vid=2,group=0x20001
690 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x931,group=0x90000001
691 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20005 group=any,port=any,weight=0 output=5
692 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000005 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:65,set_field=vlan_vid=2,group=0x20005
693 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000005 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x935,group=0x90000005
694 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ff,group=0xA6000001 group=any,port=1,weight=0 group=0x93000001 group=any,port=5,weight=0 group=0x93000005
695 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0xA6000001
696 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
697 ./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=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13
698 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x20001 goto:60
699 """
700 def runTest(self):
701 delete_all_flows(self.controller)
702 delete_all_groups(self.controller)
703
704 test_ports = sorted(config["port_map"].keys())
705
706 input_port = test_ports[0]
707 output_port = test_ports[1]
708 output_port2 = test_ports[2]
709
macauley_cheng77205a42015-11-06 15:24:21 +0800710 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800711 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
712 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:51,set_field=eth_dst=00:00:04:22:44:61,set_field=vlan_vid=2,group=0x2000"+str(output_port))
713 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x931,group=0x90000001")
714 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port2)+" group=any,port=any,weight=0 output="+str(output_port2))
715 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000005 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:65,set_field=vlan_vid=2,group=0x2000"+str(output_port2))
716 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000005 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x935,group=0x90000005")
717 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ff,group=0xA6000001 group=any,port="+str(output_port)+",weight=0 group=0x93000001 group=any,port="+str(output_port2)+",weight=0 group=0x93000005")
718 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0xA6000001")
719 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
720 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=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13")
721 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x2000"+str(output_port)+" goto:60")
722
723 input_pkt = simple_packet(
724 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
725 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
726 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
727 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
728
729 output_pkt = simple_packet(
730 '00 00 04 22 44 61 00 00 04 22 33 51 81 00 00 02 '
731 '88 47 00 93 1e fa 00 90 1f fa 00 00 00 00 00 00 '
732 '00 11 33 55 00 00 00 11 22 33 81 00 00 03 08 00 '
733 '45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 01 64 '
734 'c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 00 00 '
735 '00 00 00 00 00 00 00 00 00 00 00 00 00 00')
736
737 output_pkt2 = simple_packet(
738 '00 00 04 22 44 65 00 00 04 22 33 55 81 00 00 02 '
739 '88 47 00 93 5e fa 00 90 1f fa 00 00 00 00 00 00 '
740 '00 11 33 55 00 00 00 11 22 33 81 00 00 03 08 00 '
741 '45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 01 64 '
742 'c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 00 00 '
743 '00 00 00 00 00 00 00 00 00 00 00 00 00 00')
744
745 self.dataplane.send(input_port, str(input_pkt))
746 verify_packet(self, str(output_pkt), output_port)
747
748 #if output_port link down
749 apply_dpctl_mod(self, config, "port-mod port="+str(output_port)+",conf=0x1,mask=0x1")
750 time.sleep(1)
751 self.dataplane.send(input_port, str(input_pkt))
752 verify_packet(self, str(output_pkt2), output_port2)
753 apply_dpctl_mod(self, config, "port-mod port="+str(output_port)+",conf=0x0,mask=0x1")
macauley_cheng29e4f3b2015-11-09 13:54:29 +0800754 #make sure port link up
macauley_chengcc04e2f2015-11-06 15:07:51 +0800755 port_up = 0
756 while port_up == 0:
macauley_cheng29e4f3b2015-11-09 13:54:29 +0800757 time.sleep(1)
758 #apply_dpctl_mod(self, config, "port-mod port="+str(output_port)+",conf=0x0,mask=0x1")
759 json_result = apply_dpctl_get_cmd(self, config, "port-desc")
760 result=json_result["RECEIVED"][1]
macauley_chengcc04e2f2015-11-06 15:07:51 +0800761 for p_desc in result["port"]:
762 if p_desc["no"] == output_port:
macauley_cheng29e4f3b2015-11-09 13:54:29 +0800763 if p_desc["config"] != 0x01 : #up
764 port_up = 1
765
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800766
767
768class decap_mpls_acl(base_tests.SimpleDataPlane):
769 """
770 [Decap a MPLS label with ACL]
771 Decap a MPLS label with ACL
772
773 Inject eth 1/1 Tag 2, SA000004223355, DA000004224466, MPLS label 2305, EXP7, BoS1, TTL250, CW, InSA000000112233, InDA000000113355
774 Output eth 1/5 SA000000112233, DA000000113355
775
776 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
777 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x20001 goto:60
778 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
779 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001
780 ./dpctl tcp:192.168.1.1:6633 flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60
781 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3 apply:set_field=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13
782 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
783 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=1,vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
784 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20005 group=any,port=any,weight=0 output=5
785 ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 tunn_id=0x10001,ofdpa_mpls_l2_port=131328 write:group=0x20005
786 """
787 def runTest(self):
788 delete_all_flows(self.controller)
789 delete_all_groups(self.controller)
790
791 test_ports = sorted(config["port_map"].keys())
792
793 input_port = test_ports[0]
794 output_port = test_ports[1]
795
macauley_cheng77205a42015-11-06 15:24:21 +0800796 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800797 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(input_port)+" group=any,port=any,weight=0 output="+str(input_port))
798 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1 apply:pop_mpls=0x8847,mpls_dec,ofdpa_pop_l2hdr,ofdpa_pop_cw,set_field=ofdpa_mpls_l2_port:0x20100,set_field=tunn_id:0x10001 write:group=0x2000"+str(input_port)+" goto:60")
799 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(input_port))
800 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x91000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ofdpa_push_l2hdr,push_vlan=0x8100,push_mpls=0x8847,ofdpa_push_cw,group=0x90000001")
801 apply_dpctl_mod(self, config, "flow-mod table=13,cmd=add,prio=113 tunn_id=0x10001,ofdpa_mpls_l2_port=100 write:group=0x91000001 goto:60")
802 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+" apply:set_field=ofdpa_mpls_l2_port:100,set_field=tunn_id:0x10001 goto:13")
803 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
804 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
805 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
806 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 tunn_id=0x10001,ofdpa_mpls_l2_port=131328 write:group=0x2000"+str(output_port))
807
808 input_pkt = simple_packet(
809 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
810 '88 47 00 90 1f fa 00 00 00 00 00 00 00 11 33 55 '
811 '00 00 00 11 22 33 81 00 00 05 08 00 45 00 00 2e '
812 '04 d2 00 00 7f 00 b1 aa c0 a8 02 01 c0 a8 02 02 '
813 '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f '
814 '10 11 12 13 14 15 16 17 18 19 00 00 00 00')
815
816 output_pkt = simple_packet(
817 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
818 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b1 aa c0 a8 '
819 '02 01 c0 a8 02 02 00 01 02 03 04 05 06 07 08 09 '
820 '0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 '
821 '00 00 00 00')
822
823 self.dataplane.send(input_port, str(input_pkt))
824 verify_packet(self, str(output_pkt), output_port)
825
826
827class encap_mpls_l3(base_tests.SimpleDataPlane):
828 """
829 [Encap a MPLS label with L3]
830 Encap a MPLS label with L3 routing
831
832 Inject eth 1/3 Tag 2, SA000000112233, DA000000113355, SIP 192.168.1.10, DIP 192.168.2.2
833 Output eth 1/1 SA000004223355, DA000004224466, Tag2, MPLS label 0x901; IP the same as original
834
835 ./dpctl tcp:192.168.1.1:6633 flow-mod table=0,cmd=add,prio=1 in_port=0/0xffff0000 goto:10
836 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
837 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=2/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
838 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
839 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
840 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x92000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ttl_out,group=0x90000001
841 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x92000001 goto:60
842 """
843 def runTest(self):
844 delete_all_flows(self.controller)
845 delete_all_groups(self.controller)
846
847 test_ports = sorted(config["port_map"].keys())
848
849 input_port = test_ports[0]
850 output_port = test_ports[1]
851
macauley_cheng77205a42015-11-06 15:24:21 +0800852 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800853 apply_dpctl_mod(self, config, "flow-mod table=0,cmd=add,prio=1 in_port=0/0xffff0000 goto:10")
854 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
855 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
856 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
857 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
858 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x92000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ttl_out,group=0x90000001")
859 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x92000001 goto:60")
860
861 input_pkt = simple_packet(
862 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 02 '
863 '08 00 45 00 00 4e 04 d2 00 00 7f 00 b0 81 c0 a8 '
864 '03 0a c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
865 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
866 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
867 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
868
869 output_pkt = simple_packet(
870 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
871 '88 47 00 90 1f fa 45 00 00 4e 04 d2 00 00 7e 00 '
872 'b1 81 c0 a8 03 0a c0 a8 02 02 00 00 00 00 00 00 '
873 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
874 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
875 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
876 '00 00 00 00')
877
878 self.dataplane.send(input_port, str(input_pkt))
879 verify_packet(self, str(output_pkt), output_port)
880
881
882class decap_mpls_l3(base_tests.SimpleDataPlane):
883 """
884 [Decap a MPLS label with L3]
885 Decap a MPLS label with L3 routing
886
887 Inject eth 1/3 Tag 12, SA000000112233, DA000000000111, MPLS 0x1234, SIP 192.168.3.1, DIP 192.168.2.1
888 Output eth 1/1 Tag 10, SA000006223355, DA000006224466, SIP 192.168.3.1, DIP 192.168.2.1
889
890 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x100c/0x1fff apply:set_field=ofdpa_vrf:1 goto:20
891 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xa0001 group=any,port=any,weight=0 output=1
892 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20000001 group=any,port=any,weight=0 set_field=eth_src=00:00:06:22:33:55,set_field=eth_dst=00:00:06:22:44:66,set_field=vlan_vid=10,group=0xa0001
893 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x1234,mpls_bos=1,ofdpa_mpls_data_first_nibble=4 apply:mpls_dec,pop_mpls=0x0800,set_field=ofdpa_vrf:1 goto:30
894 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.3.2/255.255.255.0,ofdpa_vrf=1 write:group=0x20000001 goto:60
895 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=12/0xfff,eth_dst=00:00:00:00:01:11,eth_type=0x8847 goto:24
896 """
897 def runTest(self):
898 delete_all_flows(self.controller)
899 delete_all_groups(self.controller)
900
901 test_ports = sorted(config["port_map"].keys())
902
903 input_port = test_ports[0]
904 output_port = test_ports[1]
905
macauley_cheng77205a42015-11-06 15:24:21 +0800906 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800907 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x100c/0x1fff apply:set_field=ofdpa_vrf:1 goto:20")
908 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0xa000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
909 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x20000001 group=any,port=any,weight=0 set_field=eth_src=00:00:06:22:33:55,set_field=eth_dst=00:00:06:22:44:66,set_field=vlan_vid=10,group=0xa000"+str(output_port))
910 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x1234,mpls_bos=1,ofdpa_mpls_data_first_nibble=4 apply:mpls_dec,pop_mpls=0x0800,set_field=ofdpa_vrf:1 goto:30")
911 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.3.2/255.255.255.0,ofdpa_vrf=1 write:group=0x20000001 goto:60")
912 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=12/0xfff,eth_dst=00:00:00:00:01:11,eth_type=0x8847 goto:24")
913
914 input_pkt = simple_packet(
915 '00 00 00 00 01 11 00 00 00 11 22 33 81 00 00 0c '
916 '88 47 01 23 41 3f 45 00 00 26 00 00 00 00 3f 00 '
917 'f5 84 c0 a8 02 01 c0 a8 03 02 00 01 02 03 04 05 '
918 '06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 '
919 '16 17 18 19')
920
921 output_pkt = simple_packet(
922 '00 00 06 22 44 66 00 00 06 22 33 55 81 00 00 0a '
923 '08 00 45 00 00 26 00 00 00 00 3e 00 f6 84 c0 a8 '
924 '02 01 c0 a8 03 02 00 01 02 03 04 05 06 07 08 09 '
925 '0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
926
927 self.dataplane.send(input_port, str(input_pkt))
928 verify_packet(self, str(output_pkt), output_port)
929
930
931class encap_2mpls_l3(base_tests.SimpleDataPlane):
932 """
933 [Encap two MPLS labels with L3]
934 Encap two MPLS labels with L3 routing
935
936 Inject eth 1/3 Tag 2, SA000000112233, DA000000113355, SIP 192.168.1.10, DIP 192.168.2.2
937 Output eth 1/1 SA000004223355, DA000004224466, Tag2, Outer Label 0x903, EXP 7, TTL 250, Inner Label 0x901, EXP 7, TTL 250; IP the same as original
938
939 ./dpctl tcp:192.168.1.1:6633 flow-mod table=0,cmd=add,prio=1 in_port=0/0xffff0000 goto:10
940 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
941 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=2/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
942 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
943 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
944 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 set_field=mpls_label:0x903,push_mpls=0x8847,group=0x90000001
945 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x92000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ttl_out,group=0x93000001
946 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x92000001 goto:60
947 """
948 def runTest(self):
949 delete_all_flows(self.controller)
950 delete_all_groups(self.controller)
951
952 test_ports = sorted(config["port_map"].keys())
953
954 input_port = test_ports[0]
955 output_port = test_ports[1]
956
macauley_cheng77205a42015-11-06 15:24:21 +0800957 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800958 apply_dpctl_mod(self, config, "flow-mod table=0,cmd=add,prio=1 in_port=0/0xffff0000 goto:10")
959 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
960 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
961 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
962 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
963 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 set_field=mpls_label:0x903,push_mpls=0x8847,group=0x90000001")
964 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x92000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ttl_out,group=0x93000001")
965 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x92000001 goto:60")
966
967 input_pkt = simple_packet(
968 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 02 '
969 '08 00 45 00 00 4e 04 d2 00 00 7f 00 b0 81 c0 a8 '
970 '03 0a c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
971 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
972 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
973 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
974
975 output_pkt = simple_packet(
976 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
977 '88 47 00 90 3e fa 00 90 1f fa 45 00 00 4e 04 d2 '
978 '00 00 7e 00 b1 81 c0 a8 03 0a c0 a8 02 02 00 00 '
979 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
980 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
981 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
982 '00 00 00 00 00 00 00 00')
983
984 self.dataplane.send(input_port, str(input_pkt))
985 verify_packet(self, str(output_pkt), output_port)
986
987
988class decap_2mpls_l3(base_tests.SimpleDataPlane):
989 """
990 [Decap two MPLS labels with L3]
991 Decap two MPLS labels with L3 routing
992
993 Inject eth 1/1 SA000004223355, DA000004224466, Tag2, Outer Label 0x903, EXP 7, TTL 250, Inner Label 0x901, SIP 192.168.3.2, DIP 192.168.2.10
994 Output eth 1/3 SA000006223355, DA000006224466, Tag2, SIP 192.168.3.2, DIP 192.168.2.10
995
996 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20003 group=any,port=any,weight=0 output=3
997 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20000003 group=any,port=any,weight=0 set_field=eth_src=00:00:06:22:33:55,set_field=eth_dst=00:00:06:22:44:66,set_field=vlan_vid=2,group=0x20003
998 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff apply:set_field=ofdpa_vrf:1 goto:20
999 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24
1000 ./dpctl tcp:192.168.1.1:6633 flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec goto:24
1001 ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1,ofdpa_mpls_data_first_nibble=4 apply:mpls_dec,pop_mpls=0x0800,set_field=ofdpa_vrf:1 goto:30
1002 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0,ofdpa_vrf=1 write:group=0x20000003 goto:60
1003 """
1004 def runTest(self):
1005 delete_all_flows(self.controller)
1006 delete_all_groups(self.controller)
1007
1008 test_ports = sorted(config["port_map"].keys())
1009
1010 input_port = test_ports[0]
1011 output_port = test_ports[1]
1012
macauley_cheng77205a42015-11-06 15:24:21 +08001013 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +08001014 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
1015 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x20000003 group=any,port=any,weight=0 set_field=eth_src=00:00:06:22:33:55,set_field=eth_dst=00:00:06:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
1016 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff apply:set_field=ofdpa_vrf:1 goto:20")
1017 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=2/0xfff,eth_dst=00:00:04:22:33:55,eth_type=0x8847 goto:24")
1018 apply_dpctl_mod(self, config, "flow-mod table=23,cmd=add,prio=203 eth_type=0x8847,mpls_label=0x903 apply:pop_mpls=0x8847,mpls_dec goto:24")
1019 apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x901,mpls_bos=1,ofdpa_mpls_data_first_nibble=4 apply:mpls_dec,pop_mpls=0x0800,set_field=ofdpa_vrf:1 goto:30")
1020 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0,ofdpa_vrf=1 write:group=0x20000003 goto:60")
1021
1022 input_pkt = simple_packet(
1023 '00 00 04 22 33 55 00 00 04 22 44 66 81 00 00 02 '
1024 '88 47 00 90 3e fa 00 90 1f fa 45 00 00 26 00 00 '
1025 '00 00 7e 06 b6 75 c0 a8 03 02 c0 a8 02 0a 00 03 '
1026 '00 06 00 01 f7 fa 00 00 00 00 50 00 04 00 2f 5d '
1027 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1028 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1029 '00 00 00 00 00 00 00 00')
1030
1031 output_pkt = simple_packet(
1032 '00 00 06 22 44 66 00 00 06 22 33 55 81 00 00 02 '
1033 '08 00 45 00 00 26 00 00 00 00 f9 06 3b 75 c0 a8 '
1034 '03 02 c0 a8 02 0a 00 03 00 06 00 01 f7 fa 00 00 '
1035 '00 00 50 00 04 00 2f 5d 00 00 00 00 00 00 00 00 '
1036 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1037 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
1038
1039 self.dataplane.send(input_port, str(input_pkt))
1040 verify_packet(self, str(output_pkt), output_port)
1041
1042
1043class encap_3mpls_l3(base_tests.SimpleDataPlane):
1044 """
1045 [Encap 3 MPLS labels with L3]
1046 Encap 3 MPLS labels with L3 routing
1047
1048 Inject eth 1/3 Tag 2, SA000000112233, DA000000113355, SIP 192.168.1.10, DIP 192.168.2.2
1049 Output eth 1/1 SA000004223355, DA000004224466, Tag2, OuterLabel 0x904 EXP 7, TTL 250, M 0x903, Inner0x901, EXP 7, TTL 250; IP the same as original
1050
1051 ./dpctl tcp:192.168.1.1:6633 flow-mod table=0,cmd=add,prio=1 in_port=0/0xffff0000 goto:10
1052 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
1053 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=2/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
1054 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
1055 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
1056 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x94000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x904,group=0x90000001
1057 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 set_field=mpls_label:0x903,push_mpls=0x8847,group=0x94000001
1058 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x92000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ttl_out,group=0x93000001
1059 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x92000001 goto:60
1060 """
1061 def runTest(self):
1062 delete_all_flows(self.controller)
1063 delete_all_groups(self.controller)
1064
1065 test_ports = sorted(config["port_map"].keys())
1066
1067 input_port = test_ports[0]
1068 output_port = test_ports[1]
1069
macauley_cheng77205a42015-11-06 15:24:21 +08001070 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +08001071 apply_dpctl_mod(self, config, "flow-mod table=0,cmd=add,prio=1 in_port=0/0xffff0000 goto:10")
1072 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
1073 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=2/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
1074 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
1075 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x90000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
1076 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x94000001 group=any,port=any,weight=0 push_mpls=0x8847,set_field=mpls_label:0x904,group=0x90000001")
1077 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x93000001 group=any,port=any,weight=0 set_field=mpls_label:0x903,push_mpls=0x8847,group=0x94000001")
1078 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x92000001 group=any,port=any,weight=0 set_field=mpls_label:0x901,set_field=mpls_tc:7,set_field=ofdpa_mpls_ttl:250,ttl_out,group=0x93000001")
1079 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x92000001 goto:60")
1080
1081 input_pkt = simple_packet(
1082 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 02 '
1083 '08 00 45 00 00 4e 04 d2 00 00 7f 00 b0 81 c0 a8 '
1084 '03 0a c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
1085 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1086 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1087 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
1088
1089 output_pkt = simple_packet(
1090 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
1091 '88 47 00 90 4e fa 00 90 3e fa 00 90 1f fa 45 00 '
1092 '00 4e 04 d2 00 00 7e 00 b1 81 c0 a8 03 0a c0 a8 '
1093 '02 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1094 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1095 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
1096 '00 00 00 00 00 00 00 00 00 00 00 00')
1097
1098 self.dataplane.send(input_port, str(input_pkt))
1099 verify_packet(self, str(output_pkt), output_port)
1100