macauley_cheng | dc5eb58 | 2015-10-26 14:29:17 +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 | [Allow all VLAN and unicast route]
|
| 10 | Whatever incoming VLAN tag, do unicast route and output to specified port
|
| 11 |
|
| 12 | Inject eth 1/3 Tag3, SA000000112233, DA000000113355, SIP 192.168.1.100, DIP 192.168.2.2
|
| 13 | Output eth 1/1 Tag2, SA 000004223355, DA 000004224466
|
| 14 |
|
| 15 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1000/0x1000 goto:20
|
| 16 | 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
|
| 17 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
|
| 18 | 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
|
| 19 | 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
|
| 20 | 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
|
| 21 | 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
|
| 22 | """
|
| 23 |
|
| 24 | class test1(base_tests.SimpleDataPlane):
|
| 25 | def runTest(self):
|
| 26 | delete_all_flows(self.controller)
|
| 27 | delete_all_groups(self.controller)
|
| 28 |
|
| 29 | test_ports = sorted(config["port_map"].keys())
|
| 30 | input_port = test_ports[0]
|
| 31 | output_port = test_ports[1]
|
| 32 |
|
| 33 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1000/0x1000 goto:20")
|
| 34 | 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")
|
| 35 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output="+str(output_port))
|
| 36 | 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=0x20001")
|
| 37 | 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")
|
| 38 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
|
| 39 | 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=0x30003 goto:60")
|
| 40 |
|
| 41 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 42 | eth_src="00:00:00:11:22:33",
|
| 43 | ip_src=toIpV4Str(0xc0a80164),
|
| 44 | ip_dst=toIpV4Str(0xc0a80202))
|
| 45 |
|
| 46 | output_pkt = simple_tcp_packet(eth_dst="00:00:04:22:44:66",
|
| 47 | eth_src="00:00:04:22:33:55",
|
| 48 | ip_src=toIpV4Str(0xc0a80164),
|
| 49 | ip_dst=toIpV4Str(0xc0a80202))
|
| 50 |
|
| 51 | self.dataplane.send(input_port, str(input_pkt))
|
| 52 | verify_packet(self, str(output_pkt), output_port)
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 | |