blob: e0d5c6afe4db95f86127ccde59ba4a3fddc066d5 [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
33 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")
34 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 +080035 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))
36 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))
37 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))
38 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 +080039
macauley_cheng0a0a7f62015-11-06 11:36:50 +080040 input_pkt = simple_packet(
41 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
42 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
43 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
44 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080045
macauley_cheng0a0a7f62015-11-06 11:36:50 +080046 output_pkt = simple_packet(
47 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
48 '81 00 00 03 08 00 45 00 00 2e 04 d2 00 00 7f 00 '
49 'b2 47 c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
50 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
51 '00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080052
53 self.dataplane.send(input_port, str(input_pkt))
54 verify_packet(self, str(output_pkt), output_port)
55
56
57
58
59class double_tag_to_single_tag(base_tests.SimpleDataPlane):
60 """
61 [Double tag to single tag]
62 Pop outter tag of incoming double tagged packet
63
64 Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
65 Output eth 1/1 Tag 3, others not change
66
67 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
68 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
69 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
70 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30001 group=any,port=any,weight=0 output=1
71 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x30001
72 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
73 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
74
75 """
76 def runTest(self):
77 delete_all_flows(self.controller)
78 delete_all_groups(self.controller)
79
80 test_ports = sorted(config["port_map"].keys())
81 input_port = test_ports[0]
82 output_port = test_ports[1]
83
84 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 +080085 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 +080086 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 +080087 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))
88 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))
89 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))
90 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 +080091
macauley_cheng0a0a7f62015-11-06 11:36:50 +080092 input_pkt = simple_packet(
93 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 06 '
94 '81 00 00 03 08 00 45 00 00 2a 04 d2 00 00 7f 00 '
95 'b2 4b c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
96 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080097
macauley_cheng0a0a7f62015-11-06 11:36:50 +080098 output_pkt = simple_packet(
99 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
100 '08 00 45 00 00 2a 04 d2 00 00 7f 00 b2 4b c0 a8 '
101 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
102 '00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800103
104 self.dataplane.send(input_port, str(input_pkt))
105 verify_packet(self, str(output_pkt), output_port)
106
107
108
109
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800110class double2single_vlan_translate(base_tests.SimpleDataPlane):
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800111 """
112 [Double tag to single tag and modify inner tag]
113 Pop outter tag of incoming double tagged packet and modify inner tag
114
115 Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
116 Output eth 1/1 Tag 4, others not change
117
118 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
119 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
120 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
121 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x40001 group=any,port=any,weight=0 output=1
122 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x40001
123 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
124 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
125
126 """
127 def runTest(self):
128 delete_all_flows(self.controller)
129 delete_all_groups(self.controller)
130
131 test_ports = sorted(config["port_map"].keys())
132 input_port = test_ports[0]
133 output_port = test_ports[1]
134
135 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")
136 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")
137 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 +0800138 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))
139 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 +0800140 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 +0800141 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 +0800142
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800143 input_pkt = simple_packet(
144 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 06 '
145 '81 00 00 03 08 00 45 00 00 2a 04 d2 00 00 7f 00 '
146 'b2 4b c0 a8 01 64 c0 a8 02 02 00 00 00 00 00 00 '
147 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800148
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800149 output_pkt = simple_packet(
150 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 04 '
151 '08 00 45 00 00 2a 04 d2 00 00 7f 00 b2 4b c0 a8 '
152 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
153 '00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800154
155 self.dataplane.send(input_port, str(input_pkt))
156 verify_packet(self, str(output_pkt), output_port)
157
158
159
160class vlan_translate(base_tests.SimpleDataPlane):
161 """
162 [VLAN tanslate]
163 Swap incoming tagged packet to a specified VLAN tag
164
165 Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
166 Output eth 1/1 Tag 5, others not change
167
168 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
169 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
170 dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1
171 dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x50001
172 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
173 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
174
175 """
176 def runTest(self):
177 delete_all_flows(self.controller)
178 delete_all_groups(self.controller)
179
180 test_ports = sorted(config["port_map"].keys())
181 input_port = test_ports[0]
182 output_port = test_ports[1]
183
184 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")
185 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 +0800186 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))
187 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))
188 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))
189 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 +0800190
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800191 input_pkt = simple_packet(
192 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
193 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
194 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
195 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800196
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800197 output_pkt = simple_packet(
198 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 05 '
199 '08 00 45 00 00 2e 04 d2 00 00 7f 00 b2 47 c0 a8 '
200 '01 64 c0 a8 02 02 00 00 00 00 00 00 00 00 00 00 '
201 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
202
macauley_cheng4bb7ffc2015-10-26 15:30:26 +0800203 self.dataplane.send(input_port, str(input_pkt))
204 verify_packet(self, str(output_pkt), output_port)