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