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