macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 1 | import logging
|
| 2 | import oftest.base_tests as base_tests
|
| 3 | from oftest import config
|
| 4 | from oftest.testutils import *
|
| 5 | from util import *
|
| 6 | from accton_util import convertIP4toStr as toIpV4Str
|
| 7 | from accton_util import convertMACtoStr as toMacStr
|
| 8 |
|
| 9 | """
|
| 10 | Not verify yet, need to think how to verify meter
|
| 11 | """
|
| 12 |
|
| 13 | class dscp(base_tests.SimpleDataPlane):
|
| 14 | """
|
| 15 | [DSCP meter]
|
| 16 | DSCP meter
|
| 17 |
|
| 18 | Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100* 10 pkt/sec]
|
| 19 | Output eth 1/1 [10] no change
|
| 20 |
|
| 21 | Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 10 burst]
|
| 22 | Output eth 1/1 [8] no change; [2] dscp 2
|
| 23 |
|
| 24 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
|
| 25 | ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x06,meter=1 dscp_remark:rate=5,prec_level=2,burst=5
|
| 26 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
|
| 27 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 meter:1
|
| 28 | """
|
| 29 | def runTest(self):
|
| 30 | delete_all_flows(self.controller)
|
| 31 | delete_all_groups(self.controller)
|
| 32 |
|
| 33 | test_ports = sorted(config["port_map"].keys())
|
| 34 |
|
| 35 | input_port = test_ports[0]
|
| 36 | output_port = test_ports[1]
|
| 37 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 38 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 39 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
|
| 40 | apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x06,meter=1 dscp_remark:rate=5,prec_level=2,burst=5")
|
| 41 | 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))
|
| 42 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" meter:1")
|
| 43 |
|
| 44 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 45 | eth_src="00:00:00:11:22:33",
|
| 46 | ip_src=toIpV4Str(0xc0a80164),
|
| 47 | ip_dst=toIpV4Str(0xc0a80202),
|
| 48 | dl_vlan_enable=True,
|
| 49 | vlan_vid=2)
|
| 50 |
|
| 51 | output_pkt = input_pkt
|
| 52 |
|
| 53 | self.dataplane.send(input_port, str(input_pkt))
|
| 54 | verify_packet(self, str(output_pkt), output_port)
|
| 55 |
|
| 56 |
|
| 57 | class drop(base_tests.SimpleDataPlane):
|
| 58 | """
|
| 59 | [Drop meter]
|
| 60 | Drop meter
|
| 61 |
|
| 62 | Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 10 pkt/sec]
|
| 63 | Output eth 1/1 [8] output
|
| 64 |
|
| 65 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
|
| 66 | ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x01,meter=1 drop:rate=8
|
| 67 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
|
| 68 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 meter:1
|
| 69 | """
|
| 70 | def runTest(self):
|
| 71 | delete_all_flows(self.controller)
|
| 72 | delete_all_groups(self.controller)
|
| 73 |
|
| 74 | test_ports = sorted(config["port_map"].keys())
|
| 75 |
|
| 76 | input_port = test_ports[0]
|
| 77 | output_port = test_ports[1]
|
| 78 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 79 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 80 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
|
| 81 | apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x01,meter=1 drop:rate=8")
|
| 82 | 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))
|
| 83 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" meter:1")
|
| 84 |
|
| 85 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 86 | eth_src="00:00:00:11:22:33",
|
| 87 | ip_src=toIpV4Str(0xc0a80164),
|
| 88 | ip_dst=toIpV4Str(0xc0a80202),
|
| 89 | dl_vlan_enable=True,
|
| 90 | vlan_vid=2)
|
| 91 |
|
| 92 | output_pkt = input_pkt
|
| 93 |
|
| 94 | self.dataplane.send(input_port, str(input_pkt))
|
| 95 | verify_packet(self, str(output_pkt), output_port)
|
| 96 |
|
| 97 |
|
| 98 | class trtcm(base_tests.SimpleDataPlane):
|
| 99 | """
|
| 100 | [TrTCM meter]
|
| 101 | TrTCM meter
|
| 102 |
|
| 103 | Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 50 pkt/sec]
|
| 104 | Output eth 1/1 [16] vlan pcp 1 + [14] vlan pcp 3 + [20] vlan pcp 5
|
| 105 |
|
| 106 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
|
| 107 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
|
| 108 | ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=2
|
| 109 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1
|
| 110 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5
|
| 111 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3
|
| 112 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1
|
| 113 | """
|
| 114 | def runTest(self):
|
| 115 | delete_all_flows(self.controller)
|
| 116 | delete_all_groups(self.controller)
|
| 117 |
|
| 118 | test_ports = sorted(config["port_map"].keys())
|
| 119 |
|
| 120 | input_port = test_ports[0]
|
| 121 | output_port = test_ports[1]
|
| 122 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 123 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 124 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
|
| 125 | 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))
|
| 126 | apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=1,color_aware=0,color=2")
|
| 127 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1")
|
| 128 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5")
|
| 129 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3")
|
| 130 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1")
|
| 131 |
|
| 132 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 133 | eth_src="00:00:00:11:22:33",
|
| 134 | ip_src=toIpV4Str(0xc0a80164),
|
| 135 | ip_dst=toIpV4Str(0xc0a80202),
|
| 136 | dl_vlan_enable=True,
|
| 137 | vlan_vid=2,
|
| 138 | vlan_pcp=0)
|
| 139 |
|
| 140 | output_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 141 | eth_src="00:00:00:11:22:33",
|
| 142 | ip_src=toIpV4Str(0xc0a80164),
|
| 143 | ip_dst=toIpV4Str(0xc0a80202),
|
| 144 | dl_vlan_enable=True,
|
| 145 | vlan_vid=2,
|
| 146 | vlan_pcp=1)
|
| 147 |
|
| 148 | self.dataplane.send(input_port, str(input_pkt))
|
| 149 | verify_packet(self, str(output_pkt), output_port)
|
| 150 |
|
| 151 |
|
| 152 | class srtcm(base_tests.SimpleDataPlane):
|
| 153 | """
|
| 154 | [SrTCM meter]
|
| 155 | SrTCM meter
|
| 156 |
|
| 157 | Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 50 pkt/sec]
|
| 158 | Output eth 1/1 [15] vlan pcp 1 + [15] vlan pcp 3 + [20] vlan pcp 5
|
| 159 |
|
| 160 | Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 30 pkt/sec]
|
| 161 | Output eth 1/1 [15] vlan pcp 1 + [15] vlan pcp 3
|
| 162 |
|
| 163 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
|
| 164 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
|
| 165 | ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=1,burst=10 set_color:rate=20,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=2,burst=20
|
| 166 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1
|
| 167 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5
|
| 168 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3
|
| 169 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1
|
| 170 | """
|
| 171 | def runTest(self):
|
| 172 | delete_all_flows(self.controller)
|
| 173 | delete_all_groups(self.controller)
|
| 174 |
|
| 175 | test_ports = sorted(config["port_map"].keys())
|
| 176 |
|
| 177 | input_port = test_ports[0]
|
| 178 | output_port = test_ports[1]
|
| 179 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 180 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 181 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
|
| 182 | 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))
|
| 183 | apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=1,burst=10 set_color:rate=20,exp_id=0x1018,exp_type=3,mode=2,color_aware=0,color=2,burst=20")
|
| 184 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1")
|
| 185 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5")
|
| 186 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3")
|
| 187 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1")
|
| 188 |
|
| 189 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 190 | eth_src="00:00:00:11:22:33",
|
| 191 | ip_src=toIpV4Str(0xc0a80164),
|
| 192 | ip_dst=toIpV4Str(0xc0a80202),
|
| 193 | dl_vlan_enable=True,
|
| 194 | vlan_vid=2,
|
| 195 | vlan_pcp=0)
|
| 196 |
|
| 197 | output_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 198 | eth_src="00:00:00:11:22:33",
|
| 199 | ip_src=toIpV4Str(0xc0a80164),
|
| 200 | ip_dst=toIpV4Str(0xc0a80202),
|
| 201 | dl_vlan_enable=True,
|
| 202 | vlan_vid=2,
|
| 203 | vlan_pcp=1)
|
| 204 |
|
| 205 | self.dataplane.send(input_port, str(input_pkt))
|
| 206 | verify_packet(self, str(output_pkt), output_port)
|
| 207 |
|
| 208 |
|
| 209 | class mod_trtcm(base_tests.SimpleDataPlane):
|
| 210 | """
|
| 211 | [Mod TrTCM meter]
|
| 212 | Mod TrTCM meter
|
| 213 |
|
| 214 | Inject eth 1/3 {DA000000113355, SA000000112233, Tag 2} pkt [100 bytes, 50 pkt/sec]
|
| 215 | Output eth 1/1 [15] vlan pcp 1 + [28] vlan pcp 3 + [7] vlan pcp 5
|
| 216 |
|
| 217 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1002/0x1fff goto:20
|
| 218 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
|
| 219 | ./dpctl tcp:192.168.1.1:6633 meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=2
|
| 220 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x20001 apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1
|
| 221 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5
|
| 222 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3
|
| 223 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1
|
| 224 | """
|
| 225 | def runTest(self):
|
| 226 | delete_all_flows(self.controller)
|
| 227 | delete_all_groups(self.controller)
|
| 228 |
|
| 229 | test_ports = sorted(config["port_map"].keys())
|
| 230 |
|
| 231 | input_port = test_ports[0]
|
| 232 | output_port = test_ports[1]
|
| 233 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 234 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 502976c | 2015-11-06 11:40:31 +0800 | [diff] [blame] | 235 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1002/0x1fff goto:20")
|
| 236 | 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))
|
| 237 | apply_dpctl_mod(self, config, "meter-mod cmd=add,flags=0x6,meter=1 set_color:rate=10,burst=5,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=1 set_color:rate=20,burst=10,exp_id=0x1018,exp_type=3,mode=3,color_aware=0,color=2")
|
| 238 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_dst=00:00:00:11:33:55 write:group=0x2000"+str(output_port)+" apply:set_field=ofdpa_color_actions_index:1 goto:65 meter:1")
|
| 239 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=2,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:5")
|
| 240 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=1,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:3")
|
| 241 | apply_dpctl_mod(self, config, "flow-mod table=65,cmd=add,prio=651 ofdpa_color=0,ofdpa_color_actions_index=1 apply:set_field=vlan_pcp:1")
|
| 242 |
|
| 243 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 244 | eth_src="00:00:00:11:22:33",
|
| 245 | ip_src=toIpV4Str(0xc0a80164),
|
| 246 | ip_dst=toIpV4Str(0xc0a80202),
|
| 247 | dl_vlan_enable=True,
|
| 248 | vlan_vid=2,
|
| 249 | vlan_pcp=0)
|
| 250 |
|
| 251 | output_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 252 | eth_src="00:00:00:11:22:33",
|
| 253 | ip_src=toIpV4Str(0xc0a80164),
|
| 254 | ip_dst=toIpV4Str(0xc0a80202),
|
| 255 | dl_vlan_enable=True,
|
| 256 | vlan_vid=2,
|
| 257 | vlan_pcp=1)
|
| 258 |
|
| 259 | self.dataplane.send(input_port, str(input_pkt))
|
| 260 | verify_packet(self, str(output_pkt), output_port)
|
| 261 |
|
| 262 |
|
| 263 |
|