blob: f603c154085d317a7381b4e99e302f89af831821 [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 test_v4(base_tests.SimpleDataPlane):
11 """
12 [PIM BIDR IPv4]
13 PIM BIDR IPv4
14
15 Inject eth 1/3 tag 3, SA unknown, DA 01005E010101, SIP 192.168.2.1, DIP 224.0.0.1
16 Output eth 1/1 tag 2, SA 000001223355, DA 01005e010101, SIP 192.168.2.1, DIP 224.0.0.1
17
18 Inject eth 1/1 tag 2, SA unknown, DA 01005E010101, SIP 192.168.2.1, DIP 224.0.0.1
19 Output eth 1/3 tag 3, SA 000002223355, DA 01005e010101, SIP 192.168.2.1, DIP 224.0.0.1
20
21 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x00001fff goto:20
22 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x00001fff goto:20
23 ./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
24 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=1 output=1
25 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=1 output=3
26 ./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
27 ./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
28 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=1 group=0x58000001 group=any,port=any,weight=1 group=0x58000002
29 ./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
30 """
31 def runTest(self):
32 delete_all_flows(self.controller)
33 delete_all_groups(self.controller)
34
35 test_ports = sorted(config["port_map"].keys())
36
37 input_port = test_ports[0]
38 output_port = test_ports[1]
39
40 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1002/0x00001fff goto:20")
41 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x00001fff goto:20")
42 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")
43 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))
44 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))
45 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))
46 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))
47 apply_dpctl_mod(self, config, "group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=1 group=0x58000001 group=any,port=any,weight=1 group=0x58000002")
48 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")
49
50 input_pkt = simple_packet(
51 '01 00 5e 01 01 01 00 00 00 00 00 aa 81 00 00 03 '
52 '08 00 45 00 00 4e 04 d2 00 00 7f 00 94 33 c0 a8 '
53 '02 01 e0 00 00 01 00 00 00 00 00 00 00 00 00 00 '
54 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
55 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
56 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
57
58 output_pkt = simple_packet(
59 '01 00 5e 01 01 01 00 00 01 22 33 55 81 00 00 02 '
60 '08 00 45 00 00 4e 04 d2 00 00 7e 00 95 33 c0 a8 '
61 '02 01 e0 00 00 01 00 00 00 00 00 00 00 00 00 00 '
62 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
63 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
64 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
65
66 self.dataplane.send(input_port, str(input_pkt))
67 verify_packet(self, str(output_pkt), output_port)
68
69 input_pkt = simple_packet(
70 '01 00 5e 01 01 01 00 00 00 00 00 aa 81 00 00 02 '
71 '08 00 45 00 00 4e 04 d2 00 00 7f 00 94 33 c0 a8 '
72 '02 01 e0 00 00 01 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 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
75 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
76
77 output_pkt = simple_packet(
78 '01 00 5e 01 01 01 00 00 02 22 33 55 81 00 00 03 '
79 '08 00 45 00 00 4e 04 d2 00 00 7e 00 95 33 c0 a8 '
80 '02 01 e0 00 00 01 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 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '
83 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
84
85 self.dataplane.send(output_port, str(input_pkt))
86 verify_packet(self, str(output_pkt), input_port)
87
88
89class test_v6(base_tests.SimpleDataPlane):
90 """
91 [PIM BIDR IPv4]
92 PIM BIDR IPv4
93
94 Inject eth 1/3 tag 3, SA unknown, DA 333300224477, SIP 2015::1, DIP ff01::2, UDP proto
95 Output eth 1/1 tag 2, SA 000001223355, DA 333300224477, SIP 2015::1, DIP ff01::2
96
97 Inject eth 1/1 tag 2, SA unknown, DA 333300224477, SIP 2015::1, DIP ff01::2, UDP proto
98 Output eth 1/3 tag 3, SA 000002223355, DA 333300224477, SIP 2015::1, DIP ff01::2
99
100 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
101 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff goto:20
102 ./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
103 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=1 output=1
104 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=1 output=3
105 ./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
106 ./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
107 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=1 group=0x58000001 group=any,port=any,weight=1 group=0x58000002
108 ./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
109 """
110 def runTest(self):
111 delete_all_flows(self.controller)
112 delete_all_groups(self.controller)
113
114 test_ports = sorted(config["port_map"].keys())
115
116 input_port = test_ports[0]
117 output_port = test_ports[1]
118
119 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1002/0x00001fff goto:20")
120 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x00001fff goto:20")
121 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")
122 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))
123 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))
124 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))
125 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))
126 apply_dpctl_mod(self, config, "group-mod cmd=add,type=all,group=0x60058001 group=any,port=any,weight=1 group=0x58000001 group=any,port=any,weight=1 group=0x58000002")
127 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")
128
129 input_pkt = simple_packet(
130 '33 33 00 22 44 77 00 00 00 00 00 aa 81 00 00 03 '
131 '86 dd 60 00 00 00 00 26 11 7f 20 15 00 00 00 00 '
132 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
133 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
134 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
135 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
136
137 output_pkt = simple_packet(
138 '33 33 00 22 44 77 00 00 01 22 33 55 81 00 00 02 '
139 '86 dd 60 00 00 00 00 26 11 7e 20 15 00 00 00 00 '
140 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
141 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
142 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
143 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
144
145 self.dataplane.send(input_port, str(input_pkt))
146 verify_packet(self, str(output_pkt), output_port)
147
148 input_pkt = simple_packet(
149 '33 33 00 22 44 77 00 00 00 00 00 aa 81 00 00 02 '
150 '86 dd 60 00 00 00 00 26 11 7f 20 15 00 00 00 00 '
151 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
152 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
153 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
154 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
155
156 output_pkt = simple_packet(
157 '33 33 00 22 44 77 00 00 02 22 33 55 81 00 00 03 '
158 '86 dd 60 00 00 00 00 26 11 7e 20 15 00 00 00 00 '
159 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
160 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
161 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
162 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
163
164 self.dataplane.send(output_port, str(input_pkt))
165 verify_packet(self, str(output_pkt), input_port)