blob: 557837b49137553d5952acc9f5b7126dafee3f84 [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
macauley_chengcc04e2f2015-11-06 15:07:51 +0800101"""
102currently this case will fail, due to packet rx SRC IP problem
103"""
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800104class dnat_ecmp(base_tests.SimpleDataPlane):
105 """
106 [DNAT ECMP]
107 DNAT (inbound) with ECMP
108
109 Inject eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 200.0.0.1, DIP 100.0.0.01, Sport 2828, Dport 5000 [increase SIP]
110 Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.X, DIP 10.0.0.01, Sport 2828, Dport 2000
111 Output eth 1/5 DA000005224466, SA000005223355, Tag 2, SIP 200.0.0.X, DIP 10.0.0.01, Sport 2828, Dport 2000
112
113 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x10c8/0x1fff goto:20
114 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
115 ./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
116 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20005 group=any,port=any,weight=0 output=5
117 ./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
118 ./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
119 ./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
120 ./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
121 """
122 def runTest(self):
123 delete_all_flows(self.controller)
124 delete_all_groups(self.controller)
125
126 test_ports = sorted(config["port_map"].keys())
127
128 input_port = test_ports[0]
129 output_port = test_ports[1]
130 output_port2 = test_ports[2]
131
132 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")
133 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))
134 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))
135 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))
136 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))
137 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")
138 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")
139 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")
140
141 #increased SIP
142 input_pkt = simple_packet(
143 '00 00 00 00 02 00 00 00 00 00 02 01 81 00 00 c8 '
144 '08 00 45 00 00 2a 04 d2 00 00 7f 06 0a fa c8 00 '
145 '00 01 64 00 00 01 0b 0c 13 88 00 01 f7 fa 00 00 '
146 '00 00 50 00 04 00 69 50 00 00 00 00')
147
148 #random SIP
149 output_pkt = simple_packet(
150 '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
151 '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 ee c8 00 '
152 '00 0d 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
153 '00 00 50 00 04 00 ce fc 00 00 00 00')
154
155 #random SIP
156 output_pkt2 = simple_packet(
157 '00 00 05 22 44 66 00 00 05 22 33 55 81 00 00 02 '
158 '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 ef c8 00 '
159 '00 0c 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
160 '00 00 50 00 04 00 ce fd 00 00 00 00')
161
162 self.dataplane.send(input_port, str(input_pkt))
163 verify_packet(self, str(output_pkt), output_port)
164 verify_packet(self, str(output_pkt2), output_port2)
165
166
167class dnat_decap_mpls(base_tests.SimpleDataPlane):
168 """
169 [Decap MPLS label and DNAT]
170 Decap MPLS label and DNAT
171
172 Inject eth 1/3 Tag 12, SA000000112233, DA000000000111, MPLS 0x1234, SIP 200.0.0.1, DIP 100.0.0.1
173 Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.1, DIP 10.0.0.01
174
175 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
176 ./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
177 ./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
178 ./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
179 ./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
180 ./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
181 """
182 def runTest(self):
183 delete_all_flows(self.controller)
184 delete_all_groups(self.controller)
185
186 test_ports = sorted(config["port_map"].keys())
187
188 input_port = test_ports[0]
189 output_port = test_ports[1]
190
191 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))
192 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))
193 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")
194 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")
195 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")
196 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")
197
198 input_pkt = simple_packet(
199 '00 00 00 00 01 11 00 00 00 11 22 33 81 00 00 0c '
200 '88 47 01 23 41 3f 45 00 00 26 00 00 00 00 3f 00 '
201 '4f d6 c8 00 00 01 64 00 00 01 00 01 02 03 04 05 '
202 '06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 '
203 '16 17 18 19')
204
205 output_pkt = simple_packet(
206 '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
207 '08 00 45 00 00 26 00 00 00 00 3e 00 aa d6 c8 00 '
208 '00 01 0a 00 00 01 00 01 02 03 04 05 06 07 08 09 '
209 '0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
210
211 self.dataplane.send(input_port, str(input_pkt))
212 verify_packet(self, str(output_pkt), output_port)
213
214
215class snat(base_tests.SimpleDataPlane):
216 """
217 [SNAT]
218 SNAT (outbound)
219
220 Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828
221 Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.01, Sport 5000, Dport 2828
222
223 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20
224 ./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
225 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
226 ./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
227 ./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
228 ./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
229 """
230 def runTest(self):
231 delete_all_flows(self.controller)
232 delete_all_groups(self.controller)
233
234 test_ports = sorted(config["port_map"].keys())
235
236 input_port = test_ports[0]
237 output_port = test_ports[1]
238
239 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20")
240 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")
241 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))
242 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))
243 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")
244 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")
245
246 input_pkt = simple_packet(
247 '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
248 '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
249 '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
250 '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
251
252 output_pkt = simple_packet(
253 '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
254 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f6 64 00 '
255 '00 01 c8 00 00 01 13 88 0b 0c 00 01 f7 fa 00 00 '
256 '00 00 50 00 04 00 69 4c 00 00 00 00 00 00 00 00')
257
258 self.dataplane.send(input_port, str(input_pkt))
259 verify_packet(self, str(output_pkt), output_port)
260
261
262class snat_vrf(base_tests.SimpleDataPlane):
263 """
264 [SNAT VRF]
265 SNAT (outbound) with specified VRF
266
267 Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828
268 Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.01, Sport 5000, Dport 2828
269
270 ./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
271 ./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
272 ./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
273 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
274 ./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
275 ./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
276 ./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
277 """
278 def runTest(self):
279 delete_all_flows(self.controller)
280 delete_all_groups(self.controller)
281
282 test_ports = sorted(config["port_map"].keys())
283
284 input_port = test_ports[0]
285 output_port = test_ports[1]
286
287 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")
288 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")
289 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")
290 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))
291 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))
292 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")
293 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")
294
295 input_pkt = simple_packet(
296 '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
297 '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
298 '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
299 '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
300
301 output_pkt = simple_packet(
302 '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
303 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f6 64 00 '
304 '00 01 c8 00 00 01 13 88 0b 0c 00 01 f7 fa 00 00 '
305 '00 00 50 00 04 00 69 4c 00 00 00 00 00 00 00 00')
306
307 self.dataplane.send(input_port, str(input_pkt))
308 verify_packet(self, str(output_pkt), output_port)
309
macauley_chengcc04e2f2015-11-06 15:07:51 +0800310"""
311currently this case will fail, due to packet rx src IP problem
312"""
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800313class snat_ecmp(base_tests.SimpleDataPlane):
314 """
315 [SNAT ECMP]
316 SNAT (outbound) with ECMP
317
318 Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828 [increase DIP]
319 Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.X, Sport 5000, Dport 2828
320 Output eth 1/5 DA000000000500, SA000000000501, Tag 5, SIP 100.0.0.1, DIP 200.0.0.X, Sport 5000, Dport 2828
321
322 ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20
323 ./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
324 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
325 ./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
326 ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50005 group=any,port=any,weight=0 output=5
327 ./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
328 ./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
329 ./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
330 ./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
331 """
332 def runTest(self):
333 delete_all_flows(self.controller)
334 delete_all_groups(self.controller)
335
336 test_ports = sorted(config["port_map"].keys())
337
338 input_port = test_ports[0]
339 output_port = test_ports[1]
340 output_port2 = test_ports[2]
341
342 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20")
343 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")
344 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))
345 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))
346 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))
347 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))
348 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")
349 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")
350 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")
351
352 #increased DIP
353 input_pkt = simple_packet(
354 '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
355 '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
356 '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
357 '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
358
359 #rnadom DIP
360 output_pkt = simple_packet(
361 '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
362 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b e8 64 00 '
363 '00 01 c8 00 00 0f 13 88 0b 0c 00 01 f7 fa 00 00 '
364 '00 00 50 00 04 00 69 3e 00 00 00 00 00 00 00 00')
365
366 #rnadom DIP
367 output_pkt2 = simple_packet(
368 '00 00 00 00 05 01 00 00 00 00 05 00 81 00 00 05 '
369 '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f4 64 00 '
370 '00 01 c8 00 00 03 13 88 0b 0c 00 01 f7 fa 00 00 '
371 '00 00 50 00 04 00 69 4a 00 00 00 00 00 00 00 00')
372
373 self.dataplane.send(input_port, str(input_pkt))
374 verify_packet(self, str(output_pkt), output_port)
375 verify_packet(self, str(output_pkt2), output_port2)