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 | dc5eb58 | 2015-10-26 14:29:17 +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 | [Allow all VLAN and unicast route]
|
| 26 | Whatever incoming VLAN tag, do unicast route and output to specified port
|
| 27 |
|
| 28 | Inject eth 1/3 Tag3, SA000000112233, DA000000113355, SIP 192.168.1.100, DIP 192.168.2.2
|
| 29 | Output eth 1/1 Tag2, SA 000004223355, DA 000004224466
|
| 30 |
|
| 31 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1000/0x1000 goto:20
|
| 32 | dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
|
| 33 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
|
| 34 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x20001
|
| 35 | dpctl tcp:192.168.1.1:6633 flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x20000001 goto:60
|
| 36 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output=3
|
| 37 | dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60
|
| 38 | """
|
| 39 |
|
| 40 | class test1(base_tests.SimpleDataPlane):
|
| 41 | def runTest(self):
|
| 42 | delete_all_flows(self.controller)
|
| 43 | delete_all_groups(self.controller)
|
| 44 |
|
| 45 | test_ports = sorted(config["port_map"].keys())
|
| 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 | dc5eb58 | 2015-10-26 14:29:17 +0800 | [diff] [blame] | 50 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1000/0x1000 goto:20")
|
| 51 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 52 | 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))
|
| 53 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x20000001 group=any,port=any,weight=0 set_field=eth_src=00:00:04:22:33:55,set_field=eth_dst=00:00:04:22:44:66,set_field=vlan_vid=2,group=0x2000"+str(output_port))
|
macauley_cheng | dc5eb58 | 2015-10-26 14:29:17 +0800 | [diff] [blame] | 54 | apply_dpctl_mod(self, config, "flow-mod table=30,cmd=add,prio=301 eth_type=0x0800,ip_dst=192.168.2.2/255.255.255.0 write:group=0x20000001 goto:60")
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 55 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x3000"+str(input_port)+" group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
|
| 56 | apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x3000"+str(input_port)+" goto:60")
|
macauley_cheng | dc5eb58 | 2015-10-26 14:29:17 +0800 | [diff] [blame] | 57 |
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 58 | input_pkt = simple_packet(
|
| 59 | '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
|
| 60 | '08 00 45 00 00 52 00 01 00 00 40 06 f5 ee c0 a8 '
|
| 61 | '01 64 c0 a8 02 02 04 d2 00 50 00 00 00 00 00 00 '
|
| 62 | '00 00 50 02 20 00 6c 46 00 00 44 44 44 44 44 44 '
|
| 63 | '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
|
| 64 | '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
|
| 65 | '44 44 44 44')
|
macauley_cheng | 4bb7ffc | 2015-10-26 15:30:26 +0800 | [diff] [blame] | 66 |
|
macauley_cheng | 0a0a7f6 | 2015-11-06 11:36:50 +0800 | [diff] [blame] | 67 | output_pkt = simple_packet(
|
| 68 | '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
|
| 69 | '08 00 45 00 00 52 00 01 00 00 3f 06 f6 ee c0 a8 '
|
| 70 | '01 64 c0 a8 02 02 04 d2 00 50 00 00 00 00 00 00 '
|
| 71 | '00 00 50 02 20 00 6c 46 00 00 44 44 44 44 44 44 '
|
| 72 | '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
|
| 73 | '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
|
| 74 | '44 44 44 44')
|
macauley_cheng | dc5eb58 | 2015-10-26 14:29:17 +0800 | [diff] [blame] | 75 |
|
| 76 | self.dataplane.send(input_port, str(input_pkt))
|
| 77 | verify_packet(self, str(output_pkt), output_port)
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 | |