blob: 0b6706d7f1c185351b752dfb65f728a536f2eed3 [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
macauley_cheng77205a42015-11-06 15:24:21 +080024 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
25 ./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 +080026 ./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
macauley_cheng77205a42015-11-06 15:24:21 +080028 ./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 +080029 ./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
macauley_cheng77205a42015-11-06 15:24:21 +080040 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +080041 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1002/0x00001fff goto:20")
42 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x00001fff goto:20")
43 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")
44 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))
45 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))
46 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))
47 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 +080048 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 +080049 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")
50
51 input_pkt = simple_packet(
52 '01 00 5e 01 01 01 00 00 00 00 00 aa 81 00 00 03 '
53 '08 00 45 00 00 4e 04 d2 00 00 7f 00 94 33 c0 a8 '
54 '02 01 e0 00 00 01 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 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
58
59 output_pkt = simple_packet(
60 '01 00 5e 01 01 01 00 00 01 22 33 55 81 00 00 02 '
61 '08 00 45 00 00 4e 04 d2 00 00 7e 00 95 33 c0 a8 '
62 '02 01 e0 00 00 01 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 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
66
67 self.dataplane.send(input_port, str(input_pkt))
68 verify_packet(self, str(output_pkt), output_port)
69
70 input_pkt = simple_packet(
71 '01 00 5e 01 01 01 00 00 00 00 00 aa 81 00 00 02 '
72 '08 00 45 00 00 4e 04 d2 00 00 7f 00 94 33 c0 a8 '
73 '02 01 e0 00 00 01 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 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
77
78 output_pkt = simple_packet(
79 '01 00 5e 01 01 01 00 00 02 22 33 55 81 00 00 03 '
80 '08 00 45 00 00 4e 04 d2 00 00 7e 00 95 33 c0 a8 '
81 '02 01 e0 00 00 01 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 '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00')
85
86 self.dataplane.send(output_port, str(input_pkt))
87 verify_packet(self, str(output_pkt), input_port)
88
89
90class test_v6(base_tests.SimpleDataPlane):
91 """
92 [PIM BIDR IPv4]
93 PIM BIDR IPv4
94
95 Inject eth 1/3 tag 3, SA unknown, DA 333300224477, SIP 2015::1, DIP ff01::2, UDP proto
96 Output eth 1/1 tag 2, SA 000001223355, DA 333300224477, SIP 2015::1, DIP ff01::2
97
98 Inject eth 1/1 tag 2, SA unknown, DA 333300224477, SIP 2015::1, DIP ff01::2, UDP proto
99 Output eth 1/3 tag 3, SA 000002223355, DA 333300224477, SIP 2015::1, DIP ff01::2
100
101 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1002/0x1fff goto:20
102 ./dpctl tcp:0.0.0.0:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff goto:20
103 ./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 +0800104 ./dpctl tcp:0.0.0.0:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
105 ./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 +0800106 ./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
107 ./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 +0800108 ./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 +0800109 ./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
110 """
111 def runTest(self):
112 delete_all_flows(self.controller)
113 delete_all_groups(self.controller)
114
115 test_ports = sorted(config["port_map"].keys())
116
117 input_port = test_ports[0]
118 output_port = test_ports[1]
119
macauley_cheng77205a42015-11-06 15:24:21 +0800120 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_cheng0a0a7f62015-11-06 11:36:50 +0800121 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1002/0x00001fff goto:20")
122 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x00001fff goto:20")
123 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")
124 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))
125 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))
126 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))
127 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 +0800128 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 +0800129 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")
130
131 input_pkt = simple_packet(
132 '33 33 00 22 44 77 00 00 00 00 00 aa 81 00 00 03 '
133 '86 dd 60 00 00 00 00 26 11 7f 20 15 00 00 00 00 '
134 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
135 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
136 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
137 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
138
139 output_pkt = simple_packet(
140 '33 33 00 22 44 77 00 00 01 22 33 55 81 00 00 02 '
141 '86 dd 60 00 00 00 00 26 11 7e 20 15 00 00 00 00 '
142 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
143 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
144 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
145 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
146
147 self.dataplane.send(input_port, str(input_pkt))
148 verify_packet(self, str(output_pkt), output_port)
149
150 input_pkt = simple_packet(
151 '33 33 00 22 44 77 00 00 00 00 00 aa 81 00 00 02 '
152 '86 dd 60 00 00 00 00 26 11 7f 20 15 00 00 00 00 '
153 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
154 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
155 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
156 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
157
158 output_pkt = simple_packet(
159 '33 33 00 22 44 77 00 00 02 22 33 55 81 00 00 03 '
160 '86 dd 60 00 00 00 00 26 11 7e 20 15 00 00 00 00 '
161 '00 00 00 00 00 00 00 00 00 01 ff 01 00 00 00 00 '
162 '00 00 00 00 00 00 00 00 00 02 00 3f 00 41 00 26 '
163 '71 8f 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d '
164 '0e 0f 10 11 12 13 14 15 00 00 00 00 00 00 00 00')
165
166 self.dataplane.send(output_port, str(input_pkt))
167 verify_packet(self, str(output_pkt), input_port)