blob: 562890c26e290fb8b39a377d724a5f1ee8e75bdc [file] [log] [blame]
macauley_cheng4bb7ffc2015-10-26 15:30:26 +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 single_tag_to_double_tag(base_tests.SimpleDataPlane):
11 """
12 [Single tag to double tag]
13 Add a specified outer tag to incoming tagged packet
14
15 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
16 Output eth 1/1 Outter Tag 5, inner Tag 3, others not change
17
18 dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff apply:push_vlan=0x8100,set_field=vlan_vid=5 goto:20
19 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
20 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1
21 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x50001
22 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output=3
23 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60
24 """
25 def runTest(self):
26 delete_all_flows(self.controller)
27 delete_all_groups(self.controller)
28
29 test_ports = sorted(config["port_map"].keys())
30 input_port = test_ports[0]
31 output_port = test_ports[1]
32
macauley_cheng77205a42015-11-06 15:24:21 +080033 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080034 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff apply:push_vlan=0x8100,set_field=vlan_vid=5 goto:20")
35 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080036 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x5000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
37 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x5000"+str(output_port))
38 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(input_port)+" group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
39 apply_dpctl_mod(self, config, " flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x3000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080040
macauley_cheng0a0a7f62015-11-06 11:36:50 +080041 input_pkt = simple_packet(
42 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
43 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
44 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
45 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080046
macauley_cheng0a0a7f62015-11-06 11:36:50 +080047 output_pkt = simple_packet(
48 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
49 '81 00 00 03 08 00 45 00 00 2e 04 d2 00 00 7f 00 '
50 'b2 47 c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
51 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
52 '00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080053
54 self.dataplane.send(input_port, str(input_pkt))
55 verify_packet(self, str(output_pkt), output_port)
56
57
58
59
60class double_tag_to_single_tag(base_tests.SimpleDataPlane):
61 """
62 [Double tag to single tag]
63 Pop outter tag of incoming double tagged packet
64
65 Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
66 Output eth 1/1 Tag 3, others not change
67
68 dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11
69 dpctl tcp:192.168.1.1:6633 flow-mod table=11,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 goto:20
70 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
71 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30001 group=any,port=any,weight=0 output=1
72 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x30001
73 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
74 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60
75
76 """
77 def runTest(self):
78 delete_all_flows(self.controller)
79 delete_all_groups(self.controller)
80
81 test_ports = sorted(config["port_map"].keys())
82 input_port = test_ports[0]
83 output_port = test_ports[1]
84
macauley_cheng77205a42015-11-06 15:24:21 +080085 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080086 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080087 apply_dpctl_mod(self, config, "flow-mod table=11,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 goto:20")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080088 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080089 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
90 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x3000"+str(output_port))
91 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x6000"+str(input_port)+" group=any,port=any,weight=0 output="+str(input_port))
92 apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x6000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080093
macauley_cheng0a0a7f62015-11-06 11:36:50 +080094 input_pkt = simple_packet(
95 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 06 '
96 '81 00 00 03 08 00 45 00 00 2a 04 d2 00 00 7f 00 '
97 'b2 4b c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
98 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080099
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800100 output_pkt = simple_packet(
101 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
102 '08 00 45 00 00 2a 04 d2 00 00 7f 00 b2 4b c0 a8 '
103 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
104 '00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800105
106 self.dataplane.send(input_port, str(input_pkt))
107 verify_packet(self, str(output_pkt), output_port)
108
109
110
111
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800112class double2single_vlan_translate(base_tests.SimpleDataPlane):
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800113 """
114 [Double tag to single tag and modify inner tag]
115 Pop outter tag of incoming double tagged packet and modify inner tag
116
117 Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
118 Output eth 1/1 Tag 4, others not change
119
120 dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11
121 dpctl tcp:192.168.1.1:6633 flow-mod table=11,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 apply:set_field=vlan_vid=4 goto:20
122 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
123 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x40001 group=any,port=any,weight=0 output=1
124 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x40001
125 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
126 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60
127
128 """
129 def runTest(self):
130 delete_all_flows(self.controller)
131 delete_all_groups(self.controller)
132
133 test_ports = sorted(config["port_map"].keys())
134 input_port = test_ports[0]
135 output_port = test_ports[1]
136
macauley_cheng77205a42015-11-06 15:24:21 +0800137 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800138 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11")
139 apply_dpctl_mod(self, config, "flow-mod table=11,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 apply:set_field=vlan_vid=4 goto:20")
140 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800141 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x4000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
142 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x4000"+str(output_port))
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800143 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output="+str(input_port))
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800144 apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x6000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800145
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800146 input_pkt = simple_packet(
147 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 06 '
148 '81 00 00 03 08 00 45 00 00 2a 04 d2 00 00 7f 00 '
149 'b2 4b c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
150 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800151
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800152 output_pkt = simple_packet(
153 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 04 '
154 '08 00 45 00 00 2a 04 d2 00 00 7f 00 b2 4b c0 a8 '
155 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
156 '00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800157
158 self.dataplane.send(input_port, str(input_pkt))
159 verify_packet(self, str(output_pkt), output_port)
160
161
162
163class vlan_translate(base_tests.SimpleDataPlane):
164 """
165 [VLAN tanslate]
166 Swap incoming tagged packet to a specified VLAN tag
167
168 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
169 Output eth 1/1 Tag 5, others not change
170
171 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=vlan_vid=5 goto:20
172 dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
173 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1
174 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x50001
175 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output=3
176 dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60
177
178 """
179 def runTest(self):
180 delete_all_flows(self.controller)
181 delete_all_groups(self.controller)
182
183 test_ports = sorted(config["port_map"].keys())
184 input_port = test_ports[0]
185 output_port = test_ports[1]
186
macauley_cheng77205a42015-11-06 15:24:21 +0800187 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800188 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=vlan_vid=5 goto:20")
189 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800190 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x5000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
191 apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x5000"+str(output_port))
192 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(input_port)+" group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
193 apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x3000"+str(input_port)+" goto:60")
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800194
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800195 input_pkt = simple_packet(
196 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
197 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
198 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
199 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800200
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800201 output_pkt = simple_packet(
202 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
203 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
204 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
205 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
206
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800207 self.dataplane.send(input_port, str(input_pkt))
208 verify_packet(self, str(output_pkt), output_port)