blob: 7d064500039a7dca449deee920ff0f4b644ef566 [file] [log] [blame]
Matteo Scandoloa229eca2017-08-08 13:05:28 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
macauley_cheng0a0a7f62015-11-06 11:36:50 +080017import logging
18import oftest.base_tests as base_tests
19from oftest import config
20from oftest.testutils import *
21from util import *
22from accton_util import convertIP4toStr as toIpV4Str
23from accton_util import convertMACtoStr as toMacStr
24
25
26class test_v4(base_tests.SimpleDataPlane):
27 """
28 [PIM BIDR IPv4]
29 PIM BIDR IPv4
30
31 Inject eth 1/3 tag 3, SA unknown, DA 01005E010101, SIP 192.168.2.1, DIP 224.0.0.1
32 Output eth 1/1 tag 2, SA 000001223355, DA 01005e010101, SIP 192.168.2.1, DIP 224.0.0.1
33
34 Inject eth 1/1 tag 2, SA unknown, DA 01005E010101, SIP 192.168.2.1, DIP 224.0.0.1
35 Output eth 1/3 tag 3, SA 000002223355, DA 01005e010101, SIP 192.168.2.1, DIP 224.0.0.1
36
37 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x00001fff goto:20
38 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x00001fff goto:20
39 ./dpctl tcp:0.0.0.0:6633 flow-mod table=20,cmd=add,prio=201 eth_dst=01:00:5e:01:01:01/ff:ff:ff:80:00:00,eth_type=0x0800 goto:40
macauley_cheng77205a42015-11-06 15:24:21 +080040 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
41 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 output=3
macauley_cheng0a0a7f62015-11-06 11:36:50 +080042 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x58000001 group=any,port=any,weight=0 set_field=eth_src=00:00:01:22:33:55,set_field=vlan_vid=2,group=0x20001
43 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x58000002 group=any,port=any,weight=0 set_field=eth_src=00:00:02:22:33:55,set_field=vlan_vid=3,group=0x30003
macauley_cheng77205a42015-11-06 15:24:21 +080044 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=0 group=0x58000001 group=any,port=any,weight=0 group=0x58000002
macauley_cheng0a0a7f62015-11-06 11:36:50 +080045 ./dpctl tcp:0.0.0.0:6633 flow-mod table=40,cmd=add,prio=401 eth_type=0x800,ip_dst=224.0.0.1 write:group=0x60058001 goto:60
46 """
47 def runTest(self):
48 delete_all_flows(self.controller)
49 delete_all_groups(self.controller)
50
51 test_ports = sorted(config["port_map"].keys())
52
53 input_port = test_ports[0]
54 output_port = test_ports[1]
55
macauley_cheng77205a42015-11-06 15:24:21 +080056 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080057 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1002/0x00001fff goto:20")
58 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x00001fff goto:20")
59 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 eth_dst=01:00:5e:01:01:01/ff:ff:ff:80:00:00,eth_type=0x0800 goto:40")
60 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))
61 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(input_port)+" group=any,port=any,weight=0 output="+str(input_port))
62 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x58000001 group=any,port=any,weight=0 set_field=eth_src=00:00:01:22:33:55,set_field=vlan_vid=2,group=0x2000"+str(output_port))
63 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x58000002 group=any,port=any,weight=0 set_field=eth_src=00:00:02:22:33:55,set_field=vlan_vid=3,group=0x3000"+str(input_port))
macauley_chengcc04e2f2015-11-06 15:07:51 +080064 apply_dpctl_mod(self, config, "group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=0 group=0x58000001 group=any,port=any,weight=0 group=0x58000002")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080065 apply_dpctl_mod(self, config, "flow-mod table=40,cmd=add,prio=401 eth_type=0x800,ip_dst=224.0.0.1 write:group=0x60058001 goto:60")
66
67 input_pkt = simple_packet(
68 '01 00 5e 01 01 01 00 00 00 00 00 aa 81 00 00 03 '
69 '08 00 45 00 00 4e 04 d2 00 00 7f 00 94 33 c0 a8 '
70 '02 01 e0 00 00 01 00 00 00 00 00 00 00 00 00 00 '
71 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
72 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
73 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
74
75 output_pkt = simple_packet(
76 '01 00 5e 01 01 01 00 00 01 22 33 55 81 00 00 02 '
77 '08 00 45 00 00 4e 04 d2 00 00 7e 00 95 33 c0 a8 '
78 '02 01 e0 00 00 01 00 00 00 00 00 00 00 00 00 00 '
79 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
80 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
81 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
82
83 self.dataplane.send(input_port, str(input_pkt))
84 verify_packet(self, str(output_pkt), output_port)
85
86 input_pkt = simple_packet(
87 '01 00 5e 01 01 01 00 00 00 00 00 aa 81 00 00 02 '
88 '08 00 45 00 00 4e 04 d2 00 00 7f 00 94 33 c0 a8 '
89 '02 01 e0 00 00 01 00 00 00 00 00 00 00 00 00 00 '
90 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
91 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
92 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
93
94 output_pkt = simple_packet(
95 '01 00 5e 01 01 01 00 00 02 22 33 55 81 00 00 03 '
96 '08 00 45 00 00 4e 04 d2 00 00 7e 00 95 33 c0 a8 '
97 '02 01 e0 00 00 01 00 00 00 00 00 00 00 00 00 00 '
98 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
99 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
100 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
101
102 self.dataplane.send(output_port, str(input_pkt))
103 verify_packet(self, str(output_pkt), input_port)
104
105
106class test_v6(base_tests.SimpleDataPlane):
107 """
108 [PIM BIDR IPv4]
109 PIM BIDR IPv4
110
111 Inject eth 1/3 tag 3, SA unknown, DA 333300224477, SIP 2015::1, DIP ff01::2, UDP proto
112 Output eth 1/1 tag 2, SA 000001223355, DA 333300224477, SIP 2015::1, DIP ff01::2
113
114 Inject eth 1/1 tag 2, SA unknown, DA 333300224477, SIP 2015::1, DIP ff01::2, UDP proto
115 Output eth 1/3 tag 3, SA 000002223355, DA 333300224477, SIP 2015::1, DIP ff01::2
116
117 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
118 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff goto:20
119 ./dpctl tcp:0.0.0.0:6633 flow-mod table=20,cmd=add,prio=201 eth_dst=33:33:00:22:44:77/ff:ff:00:00:00:00,eth_type=0x86dd goto:40
macauley_cheng77205a42015-11-06 15:24:21 +0800120 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
121 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 output=3
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800122 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x58000001 group=any,port=any,weight=0 set_field=eth_src=00:00:01:22:33:55,set_field=vlan_vid=2,group=0x20001
123 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x58000002 group=any,port=any,weight=0 set_field=eth_src=00:00:02:22:33:55,set_field=vlan_vid=3,group=0x30003
macauley_cheng77205a42015-11-06 15:24:21 +0800124 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=0 group=0x58000001 group=any,port=any,weight=0 group=0x58000002
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800125 ./dpctl tcp:0.0.0.0:6633 flow-mod table=40,cmd=add,prio=401 eth_type=0x86dd,ipv6_dst=ff01::2 write:group=0x60058001 goto:60
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
133 input_port = test_ports[0]
134 output_port = test_ports[1]
135
macauley_cheng77205a42015-11-06 15:24:21 +0800136 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800137 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1002/0x00001fff goto:20")
138 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x00001fff goto:20")
139 apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 eth_dst=33:33:00:22:44:77/ff:ff:00:00:00:00,eth_type=0x86dd goto:40")
140 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))
141 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(input_port)+" group=any,port=any,weight=0 output="+str(input_port))
142 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x58000001 group=any,port=any,weight=0 set_field=eth_src=00:00:01:22:33:55,set_field=vlan_vid=2,group=0x2000"+str(output_port))
143 apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x58000002 group=any,port=any,weight=0 set_field=eth_src=00:00:02:22:33:55,set_field=vlan_vid=3,group=0x3000"+str(input_port))
macauley_chengcc04e2f2015-11-06 15:07:51 +0800144 apply_dpctl_mod(self, config, "group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=0 group=0x58000001 group=any,port=any,weight=0 group=0x58000002")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800145 apply_dpctl_mod(self, config, "flow-mod table=40,cmd=add,prio=401 eth_type=0x86dd,ipv6_dst=ff01::2 write:group=0x60058001 goto:60")
146
147 input_pkt = simple_packet(
148 '33 33 00 22 44 77 00 00 00 00 00 aa 81 00 00 03 '
149 '86 dd 60 00 00 00 00 26 11 7f 20 15 00 00 00 00 '
150 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
151 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
152 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
153 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
154
155 output_pkt = simple_packet(
156 '33 33 00 22 44 77 00 00 01 22 33 55 81 00 00 02 '
157 '86 dd 60 00 00 00 00 26 11 7e 20 15 00 00 00 00 '
158 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
159 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
160 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
161 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
162
163 self.dataplane.send(input_port, str(input_pkt))
164 verify_packet(self, str(output_pkt), output_port)
165
166 input_pkt = simple_packet(
167 '33 33 00 22 44 77 00 00 00 00 00 aa 81 00 00 02 '
168 '86 dd 60 00 00 00 00 26 11 7f 20 15 00 00 00 00 '
169 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
170 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
171 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
172 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
173
174 output_pkt = simple_packet(
175 '33 33 00 22 44 77 00 00 02 22 33 55 81 00 00 03 '
176 '86 dd 60 00 00 00 00 26 11 7e 20 15 00 00 00 00 '
177 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
178 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
179 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
180 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
181
182 self.dataplane.send(output_port, str(input_pkt))
183 verify_packet(self, str(output_pkt), input_port)