blob: 47f4a63e12ecd44f095dea0448ff71975fd8a858 [file] [log] [blame]
macauley_cheng0a0a7f62015-11-06 11:36:50 +08001import logging
2import oftest.base_tests as base_tests
3from oftest import config
4from oftest.testutils import *
5from util import *
6from accton_util import convertIP4toStr as toIpV4Str
7from accton_util import convertMACtoStr as toMacStr
8
9
10class dnat(base_tests.SimpleDataPlane):
11 """
12 [DNAT]
13 DNAT (inbound)
14
15 Inject eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 200.0.0.1, DIP 100.0.0.01, Sport 2828, Dport 5000
16 Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.1, DIP 10.0.0.01, Sport 2828, Dport 2000
17
18 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x10c8/0x1fff goto:20
19 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
20 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
21 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28
22 ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60
23 """
24 def runTest(self):
25 delete_all_flows(self.controller)
26 delete_all_groups(self.controller)
27
28 test_ports = sorted(config["port_map"].keys())
29
30 input_port = test_ports[0]
31 output_port = test_ports[1]
32
33 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20")
34 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
35 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
36 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28")
37 apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60")
38
39 input_pkt = simple_packet(
40 '00 00 00 00 02 00 00 00 00 00 02 01 81 00 00 c8 '
41 '08 00 45 00 00 2a 04 d2 00 00 7f 06 0a fa c8 00 '
42 '00 01 64 00 00 01 0b 0c 13 88 00 01 f7 fa 00 00 '
43 '00 00 50 00 04 00 69 50 00 00 00 00')
44
45 output_pkt = simple_packet(
46 '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
47 '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 fa c8 00 '
48 '00 01 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
49 '00 00 50 00 04 00 cf 08 00 00 00 00')
50
51 self.dataplane.send(input_port, str(input_pkt))
52 verify_packet(self, str(output_pkt), output_port)
53
54
55class dnat_vrf(base_tests.SimpleDataPlane):
56 """
57 [DNAT VRF]
58 DNAT (inbound) with specified VRF
59
60 Inject eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 200.0.0.1, DIP 100.0.0.01, Sport 2828, Dport 5000
61 Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.1, DIP 10.0.0.01, Sport 2828, Dport 2000
62
63 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
64 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
65 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
66 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
67 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28
68 ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000,ofdpa_vrf=3 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60
69 """
70 def runTest(self):
71 delete_all_flows(self.controller)
72 delete_all_groups(self.controller)
73
74 test_ports = sorted(config["port_map"].keys())
75
76 input_port = test_ports[0]
77 output_port = test_ports[1]
78
79 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
80 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
81 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
82 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
83 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28")
84 apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000,ofdpa_vrf=3 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60")
85
86 input_pkt = simple_packet(
87 '00 00 00 00 02 00 00 00 00 00 02 01 81 00 00 c8 '
88 '08 00 45 00 00 2a 04 d2 00 00 7f 06 0a fa c8 00 '
89 '00 01 64 00 00 01 0b 0c 13 88 00 01 f7 fa 00 00 '
90 '00 00 50 00 04 00 69 50 00 00 00 00')
91
92 output_pkt = simple_packet(
93 '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
94 '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 fa c8 00 '
95 '00 01 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
96 '00 00 50 00 04 00 cf 08 00 00 00 00')
97
98 self.dataplane.send(input_port, str(input_pkt))
99 verify_packet(self, str(output_pkt), output_port)
100
101
102class dnat_ecmp(base_tests.SimpleDataPlane):
103 """
104 [DNAT ECMP]
105 DNAT (inbound) with ECMP
106
107 Inject eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 200.0.0.1, DIP 100.0.0.01, Sport 2828, Dport 5000 [increase SIP]
108 Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.X, DIP 10.0.0.01, Sport 2828, Dport 2000
109 Output eth 1/5 DA000005224466, SA000005223355, Tag 2, SIP 200.0.0.X, DIP 10.0.0.01, Sport 2828, Dport 2000
110
111 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x10c8/0x1fff goto:20
112 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
113 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
114 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20005 group=any,port=any,weight=0 output=5
115 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000005 group=any,port=any,weight=0 set_field=eth_src=00:00:05:22:33:55,set_field=eth_dst=00:00:05:22:44:66,set_field=vlan_vid=2,group=0x20005
116 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x23000001 group=any,port=any,weight=0 group=0x23000005
117 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28
118 ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x71000001 goto:60
119 """
120 def runTest(self):
121 delete_all_flows(self.controller)
122 delete_all_groups(self.controller)
123
124 test_ports = sorted(config["port_map"].keys())
125
126 input_port = test_ports[0]
127 output_port = test_ports[1]
128 output_port2 = test_ports[2]
129
130 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
131 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
132 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
133 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))
134 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000005 group=any,port=any,weight=0 set_field=eth_src=00:00:05:22:33:55,set_field=eth_dst=00:00:05:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port2))
135 apply_dpctl_mod(self, config, "group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x23000001 group=any,port=any,weight=0 group=0x23000005")
136 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28")
137 apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x71000001 goto:60")
138
139 #increased SIP
140 input_pkt = simple_packet(
141 '00 00 00 00 02 00 00 00 00 00 02 01 81 00 00 c8 '
142 '08 00 45 00 00 2a 04 d2 00 00 7f 06 0a fa c8 00 '
143 '00 01 64 00 00 01 0b 0c 13 88 00 01 f7 fa 00 00 '
144 '00 00 50 00 04 00 69 50 00 00 00 00')
145
146 #random SIP
147 output_pkt = simple_packet(
148 '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
149 '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 ee c8 00 '
150 '00 0d 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
151 '00 00 50 00 04 00 ce fc 00 00 00 00')
152
153 #random SIP
154 output_pkt2 = simple_packet(
155 '00 00 05 22 44 66 00 00 05 22 33 55 81 00 00 02 '
156 '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 ef c8 00 '
157 '00 0c 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
158 '00 00 50 00 04 00 ce fd 00 00 00 00')
159
160 self.dataplane.send(input_port, str(input_pkt))
161 verify_packet(self, str(output_pkt), output_port)
162 verify_packet(self, str(output_pkt2), output_port2)
163
164
165class dnat_decap_mpls(base_tests.SimpleDataPlane):
166 """
167 [Decap MPLS label and DNAT]
168 Decap MPLS label and DNAT
169
170 Inject eth 1/3 Tag 12, SA000000112233, DA000000000111, MPLS 0x1234, SIP 200.0.0.1, DIP 100.0.0.1
171 Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.1, DIP 10.0.0.01
172
173 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
174 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
175 ./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
176 ./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
177 ./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
178 ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ofdpa_vrf=1 write:set_field=ip_dst:10.0.0.1,group=0x23000001 goto:60
179 """
180 def runTest(self):
181 delete_all_flows(self.controller)
182 delete_all_groups(self.controller)
183
184 test_ports = sorted(config["port_map"].keys())
185
186 input_port = test_ports[0]
187 output_port = test_ports[1]
188
189 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
190 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
191 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")
192 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")
193 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")
194 apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ofdpa_vrf=1 write:set_field=ip_dst:10.0.0.1,group=0x23000001 goto:60")
195
196 input_pkt = simple_packet(
197 '00 00 00 00 01 11 00 00 00 11 22 33 81 00 00 0c '
198 '88 47 01 23 41 3f 45 00 00 26 00 00 00 00 3f 00 '
199 '4f d6 c8 00 00 01 64 00 00 01 00 01 02 03 04 05 '
200 '06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 '
201 '16 17 18 19')
202
203 output_pkt = simple_packet(
204 '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
205 '08 00 45 00 00 26 00 00 00 00 3e 00 aa d6 c8 00 '
206 '00 01 0a 00 00 01 00 01 02 03 04 05 06 07 08 09 '
207 '0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
208
209 self.dataplane.send(input_port, str(input_pkt))
210 verify_packet(self, str(output_pkt), output_port)
211
212
213class snat(base_tests.SimpleDataPlane):
214 """
215 [SNAT]
216 SNAT (outbound)
217
218 Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828
219 Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.01, Sport 5000, Dport 2828
220
221 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20
222 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29
223 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
224 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC80003
225 ./dpctl tcp:192.168.1.1:6633 flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30
226 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x22000002 goto:60
227 """
228 def runTest(self):
229 delete_all_flows(self.controller)
230 delete_all_groups(self.controller)
231
232 test_ports = sorted(config["port_map"].keys())
233
234 input_port = test_ports[0]
235 output_port = test_ports[1]
236
237 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20")
238 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29")
239 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0xC8000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
240 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC8000"+str(output_port))
241 apply_dpctl_mod(self, config, "flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30")
242 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x22000002 goto:60")
243
244 input_pkt = simple_packet(
245 '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
246 '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
247 '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
248 '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
249
250 output_pkt = simple_packet(
251 '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
252 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f6 64 00 '
253 '00 01 c8 00 00 01 13 88 0b 0c 00 01 f7 fa 00 00 '
254 '00 00 50 00 04 00 69 4c 00 00 00 00 00 00 00 00')
255
256 self.dataplane.send(input_port, str(input_pkt))
257 verify_packet(self, str(output_pkt), output_port)
258
259
260class snat_vrf(base_tests.SimpleDataPlane):
261 """
262 [SNAT VRF]
263 SNAT (outbound) with specified VRF
264
265 Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828
266 Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.01, Sport 5000, Dport 2828
267
268 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
269 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
270 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29
271 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
272 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC80003
273 ./dpctl tcp:192.168.1.1:6633 flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000,ofdpa_vrf=3 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30
274 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0,ofdpa_vrf=3 write:group=0x22000002 goto:60
275 """
276 def runTest(self):
277 delete_all_flows(self.controller)
278 delete_all_groups(self.controller)
279
280 test_ports = sorted(config["port_map"].keys())
281
282 input_port = test_ports[0]
283 output_port = test_ports[1]
284
285 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
286 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
287 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29")
288 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0xC8000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
289 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC8000"+str(output_port))
290 apply_dpctl_mod(self, config, "flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000,ofdpa_vrf=3 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30")
291 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0,ofdpa_vrf=3 write:group=0x22000002 goto:60")
292
293 input_pkt = simple_packet(
294 '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
295 '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
296 '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
297 '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
298
299 output_pkt = simple_packet(
300 '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
301 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f6 64 00 '
302 '00 01 c8 00 00 01 13 88 0b 0c 00 01 f7 fa 00 00 '
303 '00 00 50 00 04 00 69 4c 00 00 00 00 00 00 00 00')
304
305 self.dataplane.send(input_port, str(input_pkt))
306 verify_packet(self, str(output_pkt), output_port)
307
308
309class snat_ecmp(base_tests.SimpleDataPlane):
310 """
311 [SNAT ECMP]
312 SNAT (outbound) with ECMP
313
314 Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828 [increase DIP]
315 Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.X, Sport 5000, Dport 2828
316 Output eth 1/5 DA000000000500, SA000000000501, Tag 5, SIP 100.0.0.1, DIP 200.0.0.X, Sport 5000, Dport 2828
317
318 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20
319 ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29
320 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
321 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC80003
322 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50005 group=any,port=any,weight=0 output=5
323 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000005 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:05:00,set_field=eth_dst=00:00:00:00:05:01,set_field=vlan_vid=5,group=0x50005
324 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x22000002 group=any,port=any,weight=0 group=0x22000005
325 ./dpctl tcp:192.168.1.1:6633 flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30
326 ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x71000001 goto:60
327 """
328 def runTest(self):
329 delete_all_flows(self.controller)
330 delete_all_groups(self.controller)
331
332 test_ports = sorted(config["port_map"].keys())
333
334 input_port = test_ports[0]
335 output_port = test_ports[1]
336 output_port2 = test_ports[2]
337
338 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20")
339 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29")
340 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0xC8000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
341 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC8000"+str(output_port))
342 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x5000"+str(output_port2)+" group=any,port=any,weight=0 output="+str(output_port2))
343 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000005 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:05:00,set_field=eth_dst=00:00:00:00:05:01,set_field=vlan_vid=5,group=0x5000"+str(output_port))
344 apply_dpctl_mod(self, config, "group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x22000002 group=any,port=any,weight=0 group=0x22000005")
345 apply_dpctl_mod(self, config, "flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30")
346 apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x71000001 goto:60")
347
348 #increased DIP
349 input_pkt = simple_packet(
350 '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
351 '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
352 '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
353 '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
354
355 #rnadom DIP
356 output_pkt = simple_packet(
357 '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
358 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b e8 64 00 '
359 '00 01 c8 00 00 0f 13 88 0b 0c 00 01 f7 fa 00 00 '
360 '00 00 50 00 04 00 69 3e 00 00 00 00 00 00 00 00')
361
362 #rnadom DIP
363 output_pkt2 = simple_packet(
364 '00 00 00 00 05 01 00 00 00 00 05 00 81 00 00 05 '
365 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f4 64 00 '
366 '00 01 c8 00 00 03 13 88 0b 0c 00 01 f7 fa 00 00 '
367 '00 00 50 00 04 00 69 4a 00 00 00 00 00 00 00 00')
368
369 self.dataplane.send(input_port, str(input_pkt))
370 verify_packet(self, str(output_pkt), output_port)
371 verify_packet(self, str(output_pkt2), output_port2)