Matteo Scandolo | a229eca | 2017-08-08 13:05:28 -0700 | [diff] [blame] | 1 | |
| 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_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 17 | import logging
|
| 18 | import oftest.base_tests as base_tests
|
| 19 | from oftest import config
|
| 20 | from oftest.testutils import *
|
| 21 | from util import *
|
| 22 | from accton_util import convertIP4toStr as toIpV4Str
|
| 23 | from accton_util import convertMACtoStr as toMacStr
|
| 24 |
|
| 25 |
|
| 26 | class dnat(base_tests.SimpleDataPlane):
|
| 27 | """
|
| 28 | [DNAT]
|
| 29 | DNAT (inbound)
|
| 30 |
|
| 31 | Inject eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 200.0.0.1, DIP 100.0.0.01, Sport 2828, Dport 5000
|
| 32 | Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.1, DIP 10.0.0.01, Sport 2828, Dport 2000
|
| 33 |
|
| 34 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x10c8/0x1fff goto:20
|
| 35 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
|
| 36 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
|
| 37 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28
|
| 38 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60
|
| 39 | """
|
| 40 | def runTest(self):
|
| 41 | delete_all_flows(self.controller)
|
| 42 | delete_all_groups(self.controller)
|
| 43 |
|
| 44 | test_ports = sorted(config["port_map"].keys())
|
| 45 |
|
| 46 | input_port = test_ports[0]
|
| 47 | output_port = test_ports[1]
|
| 48 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 49 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 50 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20")
|
| 51 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 52 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
|
| 53 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28")
|
| 54 | apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60")
|
| 55 |
|
| 56 | input_pkt = simple_packet(
|
| 57 | '00 00 00 00 02 00 00 00 00 00 02 01 81 00 00 c8 '
|
| 58 | '08 00 45 00 00 2a 04 d2 00 00 7f 06 0a fa c8 00 '
|
| 59 | '00 01 64 00 00 01 0b 0c 13 88 00 01 f7 fa 00 00 '
|
| 60 | '00 00 50 00 04 00 69 50 00 00 00 00')
|
| 61 |
|
| 62 | output_pkt = simple_packet(
|
| 63 | '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
|
| 64 | '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 fa c8 00 '
|
| 65 | '00 01 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
|
| 66 | '00 00 50 00 04 00 cf 08 00 00 00 00')
|
| 67 |
|
| 68 | self.dataplane.send(input_port, str(input_pkt))
|
| 69 | verify_packet(self, str(output_pkt), output_port)
|
| 70 |
|
| 71 |
|
| 72 | class dnat_vrf(base_tests.SimpleDataPlane):
|
| 73 | """
|
| 74 | [DNAT VRF]
|
| 75 | DNAT (inbound) with specified VRF
|
| 76 |
|
| 77 | Inject eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 200.0.0.1, DIP 100.0.0.01, Sport 2828, Dport 5000
|
| 78 | Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.1, DIP 10.0.0.01, Sport 2828, Dport 2000
|
| 79 |
|
| 80 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
|
| 81 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
|
| 82 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
|
| 83 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
|
| 84 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28
|
| 85 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000,ofdpa_vrf=3 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60
|
| 86 | """
|
| 87 | def runTest(self):
|
| 88 | delete_all_flows(self.controller)
|
| 89 | delete_all_groups(self.controller)
|
| 90 |
|
| 91 | test_ports = sorted(config["port_map"].keys())
|
| 92 |
|
| 93 | input_port = test_ports[0]
|
| 94 | output_port = test_ports[1]
|
| 95 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 96 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 97 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
|
| 98 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(output_port)+",vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
|
| 99 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 100 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
|
| 101 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28")
|
| 102 | apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000,ofdpa_vrf=3 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x23000001 goto:60")
|
| 103 |
|
| 104 | input_pkt = simple_packet(
|
| 105 | '00 00 00 00 02 00 00 00 00 00 02 01 81 00 00 c8 '
|
| 106 | '08 00 45 00 00 2a 04 d2 00 00 7f 06 0a fa c8 00 '
|
| 107 | '00 01 64 00 00 01 0b 0c 13 88 00 01 f7 fa 00 00 '
|
| 108 | '00 00 50 00 04 00 69 50 00 00 00 00')
|
| 109 |
|
| 110 | output_pkt = simple_packet(
|
| 111 | '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
|
| 112 | '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 fa c8 00 '
|
| 113 | '00 01 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
|
| 114 | '00 00 50 00 04 00 cf 08 00 00 00 00')
|
| 115 |
|
| 116 | self.dataplane.send(input_port, str(input_pkt))
|
| 117 | verify_packet(self, str(output_pkt), output_port)
|
| 118 |
|
macauley_cheng | cc04e2f | 2015-11-06 15:07:51 +0800 | [diff] [blame] | 119 | """
|
| 120 | currently this case will fail, due to packet rx SRC IP problem
|
| 121 | """
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 122 | class dnat_ecmp(base_tests.SimpleDataPlane):
|
| 123 | """
|
| 124 | [DNAT ECMP]
|
| 125 | DNAT (inbound) with ECMP
|
| 126 |
|
| 127 | Inject eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 200.0.0.1, DIP 100.0.0.01, Sport 2828, Dport 5000 [increase SIP]
|
| 128 | Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.X, DIP 10.0.0.01, Sport 2828, Dport 2000
|
| 129 | Output eth 1/5 DA000005224466, SA000005223355, Tag 2, SIP 200.0.0.X, DIP 10.0.0.01, Sport 2828, Dport 2000
|
| 130 |
|
| 131 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x10c8/0x1fff goto:20
|
| 132 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
|
| 133 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
|
| 134 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20005 group=any,port=any,weight=0 output=5
|
| 135 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000005 group=any,port=any,weight=0 set_field=eth_src=00:00:05:22:33:55,set_field=eth_dst=00:00:05:22:44:66,set_field=vlan_vid=2,group=0x20005
|
| 136 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x23000001 group=any,port=any,weight=0 group=0x23000005
|
| 137 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28
|
| 138 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x71000001 goto:60
|
| 139 | """
|
| 140 | def runTest(self):
|
| 141 | delete_all_flows(self.controller)
|
| 142 | delete_all_groups(self.controller)
|
| 143 |
|
| 144 | test_ports = sorted(config["port_map"].keys())
|
| 145 |
|
| 146 | input_port = test_ports[0]
|
| 147 | output_port = test_ports[1]
|
| 148 | output_port2 = test_ports[2]
|
| 149 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 150 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 151 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
|
| 152 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 153 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
|
| 154 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x2000"+str(output_port2)+" group=any,port=any,weight=0 output="+str(output_port2))
|
| 155 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000005 group=any,port=any,weight=0 set_field=eth_src=00:00:05:22:33:55,set_field=eth_dst=00:00:05:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port2))
|
| 156 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x23000001 group=any,port=any,weight=0 group=0x23000005")
|
| 157 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=200/0xfff,eth_dst=00:00:00:00:02:00,eth_type=0x0800 goto:28")
|
| 158 | apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x71000001 goto:60")
|
| 159 |
|
| 160 | #increased SIP
|
| 161 | input_pkt = simple_packet(
|
| 162 | '00 00 00 00 02 00 00 00 00 00 02 01 81 00 00 c8 '
|
| 163 | '08 00 45 00 00 2a 04 d2 00 00 7f 06 0a fa c8 00 '
|
| 164 | '00 01 64 00 00 01 0b 0c 13 88 00 01 f7 fa 00 00 '
|
| 165 | '00 00 50 00 04 00 69 50 00 00 00 00')
|
| 166 |
|
| 167 | #random SIP
|
| 168 | output_pkt = simple_packet(
|
| 169 | '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
|
| 170 | '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 ee c8 00 '
|
| 171 | '00 0d 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
|
| 172 | '00 00 50 00 04 00 ce fc 00 00 00 00')
|
| 173 |
|
| 174 | #random SIP
|
| 175 | output_pkt2 = simple_packet(
|
| 176 | '00 00 05 22 44 66 00 00 05 22 33 55 81 00 00 02 '
|
| 177 | '08 00 45 00 00 2a 04 d2 00 00 7e 06 65 ef c8 00 '
|
| 178 | '00 0c 0a 00 00 01 0b 0c 07 d0 00 01 f7 fa 00 00 '
|
| 179 | '00 00 50 00 04 00 ce fd 00 00 00 00')
|
| 180 |
|
| 181 | self.dataplane.send(input_port, str(input_pkt))
|
| 182 | verify_packet(self, str(output_pkt), output_port)
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 183 | self.dataplane.send(input_port, str(input_pkt))
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 184 | verify_packet(self, str(output_pkt2), output_port2)
|
| 185 |
|
| 186 |
|
| 187 | class dnat_decap_mpls(base_tests.SimpleDataPlane):
|
| 188 | """
|
| 189 | [Decap MPLS label and DNAT]
|
| 190 | Decap MPLS label and DNAT
|
| 191 |
|
| 192 | Inject eth 1/3 Tag 12, SA000000112233, DA000000000111, MPLS 0x1234, SIP 200.0.0.1, DIP 100.0.0.1
|
| 193 | Output eth 1/1 DA000000000101, SA000000000100, Tag 100, SIP 200.0.0.1, DIP 10.0.0.01
|
| 194 |
|
| 195 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x640001 group=any,port=any,weight=0 output=1
|
| 196 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x640001
|
| 197 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x100c/0x1fff apply:set_field=ofdpa_vrf:1 goto:20
|
| 198 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=12/0xfff,eth_dst=00:00:00:00:01:11,eth_type=0x8847 goto:24
|
| 199 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x1234,mpls_bos=1,ofdpa_mpls_data_first_nibble=4 apply:mpls_dec,pop_mpls=0x0800,set_field=ofdpa_vrf:1 goto:30
|
| 200 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ofdpa_vrf=1 write:set_field=ip_dst:10.0.0.1,group=0x23000001 goto:60
|
| 201 | """
|
| 202 | def runTest(self):
|
| 203 | delete_all_flows(self.controller)
|
| 204 | delete_all_groups(self.controller)
|
| 205 |
|
| 206 | test_ports = sorted(config["port_map"].keys())
|
| 207 |
|
| 208 | input_port = test_ports[0]
|
| 209 | output_port = test_ports[1]
|
| 210 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 211 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 212 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x64000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 213 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x23000001 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:01:00,set_field=eth_dst=00:00:00:00:01:01,set_field=vlan_vid=100,group=0x64000"+str(output_port))
|
| 214 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x100c/0x1fff apply:set_field=ofdpa_vrf:1 goto:20")
|
| 215 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=12/0xfff,eth_dst=00:00:00:00:01:11,eth_type=0x8847 goto:24")
|
| 216 | apply_dpctl_mod(self, config, "flow-mod table=24,cmd=add,prio=204 eth_type=0x8847,mpls_label=0x1234,mpls_bos=1,ofdpa_mpls_data_first_nibble=4 apply:mpls_dec,pop_mpls=0x0800,set_field=ofdpa_vrf:1 goto:30")
|
| 217 | apply_dpctl_mod(self, config, "flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ofdpa_vrf=1 write:set_field=ip_dst:10.0.0.1,group=0x23000001 goto:60")
|
| 218 |
|
| 219 | input_pkt = simple_packet(
|
| 220 | '00 00 00 00 01 11 00 00 00 11 22 33 81 00 00 0c '
|
| 221 | '88 47 01 23 41 3f 45 00 00 26 00 00 00 00 3f 00 '
|
| 222 | '4f d6 c8 00 00 01 64 00 00 01 00 01 02 03 04 05 '
|
| 223 | '06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 '
|
| 224 | '16 17 18 19')
|
| 225 |
|
| 226 | output_pkt = simple_packet(
|
| 227 | '00 00 00 00 01 01 00 00 00 00 01 00 81 00 00 64 '
|
| 228 | '08 00 45 00 00 26 00 00 00 00 3e 00 aa d6 c8 00 '
|
| 229 | '00 01 0a 00 00 01 00 01 02 03 04 05 06 07 08 09 '
|
| 230 | '0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19')
|
| 231 |
|
| 232 | self.dataplane.send(input_port, str(input_pkt))
|
| 233 | verify_packet(self, str(output_pkt), output_port)
|
| 234 |
|
| 235 |
|
| 236 | class snat(base_tests.SimpleDataPlane):
|
| 237 | """
|
| 238 | [SNAT]
|
| 239 | SNAT (outbound)
|
| 240 |
|
| 241 | Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828
|
| 242 | Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.01, Sport 5000, Dport 2828
|
| 243 |
|
| 244 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20
|
| 245 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29
|
| 246 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
|
| 247 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC80003
|
| 248 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30
|
| 249 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x22000002 goto:60
|
| 250 | """
|
| 251 | def runTest(self):
|
| 252 | delete_all_flows(self.controller)
|
| 253 | delete_all_groups(self.controller)
|
| 254 |
|
| 255 | test_ports = sorted(config["port_map"].keys())
|
| 256 |
|
| 257 | input_port = test_ports[0]
|
| 258 | output_port = test_ports[1]
|
| 259 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 260 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 261 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20")
|
| 262 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29")
|
| 263 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0xC8000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 264 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC8000"+str(output_port))
|
| 265 | apply_dpctl_mod(self, config, "flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30")
|
| 266 | apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x22000002 goto:60")
|
| 267 |
|
| 268 | input_pkt = simple_packet(
|
| 269 | '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
|
| 270 | '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
|
| 271 | '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
|
| 272 | '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
|
| 273 |
|
| 274 | output_pkt = simple_packet(
|
| 275 | '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
|
| 276 | '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f6 64 00 '
|
| 277 | '00 01 c8 00 00 01 13 88 0b 0c 00 01 f7 fa 00 00 '
|
| 278 | '00 00 50 00 04 00 69 4c 00 00 00 00 00 00 00 00')
|
| 279 |
|
| 280 | self.dataplane.send(input_port, str(input_pkt))
|
| 281 | verify_packet(self, str(output_pkt), output_port)
|
| 282 |
|
| 283 |
|
| 284 | class snat_vrf(base_tests.SimpleDataPlane):
|
| 285 | """
|
| 286 | [SNAT VRF]
|
| 287 | SNAT (outbound) with specified VRF
|
| 288 |
|
| 289 | Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828
|
| 290 | Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.01, Sport 5000, Dport 2828
|
| 291 |
|
| 292 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
|
| 293 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3
|
| 294 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29
|
| 295 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
|
| 296 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC80003
|
| 297 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000,ofdpa_vrf=3 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30
|
| 298 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0,ofdpa_vrf=3 write:group=0x22000002 goto:60
|
| 299 | """
|
| 300 | def runTest(self):
|
| 301 | delete_all_flows(self.controller)
|
| 302 | delete_all_groups(self.controller)
|
| 303 |
|
| 304 | test_ports = sorted(config["port_map"].keys())
|
| 305 |
|
| 306 | input_port = test_ports[0]
|
| 307 | output_port = test_ports[1]
|
| 308 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 309 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 310 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
|
| 311 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x10c8/0x1fff goto:20 apply:set_field=ofdpa_vrf:3")
|
| 312 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29")
|
| 313 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0xC8000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 314 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC8000"+str(output_port))
|
| 315 | apply_dpctl_mod(self, config, "flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000,ofdpa_vrf=3 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30")
|
| 316 | apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0,ofdpa_vrf=3 write:group=0x22000002 goto:60")
|
| 317 |
|
| 318 | input_pkt = simple_packet(
|
| 319 | '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
|
| 320 | '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
|
| 321 | '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
|
| 322 | '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
|
| 323 |
|
| 324 | output_pkt = simple_packet(
|
| 325 | '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
|
| 326 | '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f6 64 00 '
|
| 327 | '00 01 c8 00 00 01 13 88 0b 0c 00 01 f7 fa 00 00 '
|
| 328 | '00 00 50 00 04 00 69 4c 00 00 00 00 00 00 00 00')
|
| 329 |
|
| 330 | self.dataplane.send(input_port, str(input_pkt))
|
| 331 | verify_packet(self, str(output_pkt), output_port)
|
| 332 |
|
macauley_cheng | cc04e2f | 2015-11-06 15:07:51 +0800 | [diff] [blame] | 333 | """
|
| 334 | currently this case will fail, due to packet rx src IP problem
|
| 335 | """
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 336 | class snat_ecmp(base_tests.SimpleDataPlane):
|
| 337 | """
|
| 338 | [SNAT ECMP]
|
| 339 | SNAT (outbound) with ECMP
|
| 340 |
|
| 341 | Inject eth 1/1 DA000000000100, SA000000000101, Tag 100, SIP 10.0.0.1, DIP 200.0.0.01, Sport 2000, Dport 2828 [increase DIP]
|
| 342 | Output eth 1/3 DA000000000200, SA000000000201, Tag 200, SIP 100.0.0.1, DIP 200.0.0.X, Sport 5000, Dport 2828
|
| 343 | Output eth 1/5 DA000000000500, SA000000000501, Tag 5, SIP 100.0.0.1, DIP 200.0.0.X, Sport 5000, Dport 2828
|
| 344 |
|
| 345 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=1,vlan_vid=0x1064/0x1fff goto:20
|
| 346 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29
|
| 347 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0xC80003 group=any,port=any,weight=0 output=3
|
| 348 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC80003
|
| 349 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50005 group=any,port=any,weight=0 output=5
|
| 350 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x22000005 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:05:00,set_field=eth_dst=00:00:00:00:05:01,set_field=vlan_vid=5,group=0x50005
|
| 351 | ./dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x22000002 group=any,port=any,weight=0 group=0x22000005
|
| 352 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30
|
| 353 | ./dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x71000001 goto:60
|
| 354 | """
|
| 355 | def runTest(self):
|
| 356 | delete_all_flows(self.controller)
|
| 357 | delete_all_groups(self.controller)
|
| 358 |
|
| 359 | test_ports = sorted(config["port_map"].keys())
|
| 360 |
|
| 361 | input_port = test_ports[0]
|
| 362 | output_port = test_ports[1]
|
| 363 | output_port2 = test_ports[2]
|
| 364 |
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 365 | apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 366 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1064/0x1fff goto:20")
|
| 367 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 vlan_vid=100/0xfff,eth_dst=00:00:00:00:01:00,eth_type=0x0800 goto:29")
|
| 368 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0xC8000"+str(output_port)+" group=any,port=any,weight=0 output="+str(output_port))
|
| 369 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000002 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:02:00,set_field=eth_dst=00:00:00:00:02:01,set_field=vlan_vid=200,group=0xC8000"+str(output_port))
|
| 370 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x5000"+str(output_port2)+" group=any,port=any,weight=0 output="+str(output_port2))
|
| 371 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x22000005 group=any,port=any,weight=0 set_field=eth_src=00:00:00:00:05:00,set_field=eth_dst=00:00:00:00:05:01,set_field=vlan_vid=5,group=0x5000"+str(output_port))
|
| 372 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=sel,group=0x71000001 group=any,port=any,weight=0 group=0x22000002 group=any,port=any,weight=0 group=0x22000005")
|
| 373 | apply_dpctl_mod(self, config, "flow-mod table=29,cmd=add,prio=291 eth_type=0x800,ip_src=10.0.0.1,ip_proto=6,tcp_src=2000 write:set_field=ip_src:100.0.0.1,set_field=tcp_src:5000 goto:30")
|
| 374 | apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=200.0.0.1/255.255.255.0 write:group=0x71000001 goto:60")
|
| 375 |
|
| 376 | #increased DIP
|
| 377 | input_pkt = simple_packet(
|
| 378 | '00 00 00 00 01 00 00 00 00 00 02 00 81 00 00 64 '
|
| 379 | '08 00 45 00 00 2e 04 d2 00 00 7f 06 64 f6 0a 00 '
|
| 380 | '00 01 c8 00 00 01 07 d0 0b 0c 00 01 f7 fa 00 00 '
|
| 381 | '00 00 50 00 04 00 cf 04 00 00 00 00 00 00 00 00')
|
| 382 |
|
| 383 | #rnadom DIP
|
| 384 | output_pkt = simple_packet(
|
| 385 | '00 00 00 00 02 01 00 00 00 00 02 00 81 00 00 c8 '
|
| 386 | '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b e8 64 00 '
|
| 387 | '00 01 c8 00 00 0f 13 88 0b 0c 00 01 f7 fa 00 00 '
|
| 388 | '00 00 50 00 04 00 69 3e 00 00 00 00 00 00 00 00')
|
| 389 |
|
| 390 | #rnadom DIP
|
| 391 | output_pkt2 = simple_packet(
|
| 392 | '00 00 00 00 05 01 00 00 00 00 05 00 81 00 00 05 '
|
| 393 | '08 00 45 00 00 2e 04 d2 00 00 7e 06 0b f4 64 00 '
|
| 394 | '00 01 c8 00 00 03 13 88 0b 0c 00 01 f7 fa 00 00 '
|
| 395 | '00 00 50 00 04 00 69 4a 00 00 00 00 00 00 00 00')
|
| 396 |
|
| 397 | self.dataplane.send(input_port, str(input_pkt))
|
| 398 | verify_packet(self, str(output_pkt), output_port)
|
macauley_cheng | 77205a4 | 2015-11-06 15:24:21 +0800 | [diff] [blame] | 399 | self.dataplane.send(input_port, str(input_pkt))
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 400 | verify_packet(self, str(output_pkt2), output_port2)
|