blob: 5239e5cfa4253b63d89bb6fbd409a8bb01d03e95 [file] [log] [blame]
macauley_chengdc5eb582015-10-26 14:29:17 +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 [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
24class 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
macauley_cheng77205a42015-11-06 15:24:21 +080033 apply_dpctl_mod(self, config, "meter-mod cmd=del,meter=0xffffffff")
macauley_chengdc5eb582015-10-26 14:29:17 +080034 apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1000/0x1000 goto:20")
35 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_cheng0a0a7f62015-11-06 11:36:50 +080036 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))
37 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_chengdc5eb582015-10-26 14:29:17 +080038 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_cheng0a0a7f62015-11-06 11:36:50 +080039 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))
40 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_chengdc5eb582015-10-26 14:29:17 +080041
macauley_cheng0a0a7f62015-11-06 11:36:50 +080042 input_pkt = simple_packet(
43 '00 00 00 11 33 55 00 00 00 11 22 33 81 00 00 03 '
44 '08 00 45 00 00 52 00 01 00 00 40 06 f5 ee c0 a8 '
45 '01 64 c0 a8 02 02 04 d2 00 50 00 00 00 00 00 00 '
46 '00 00 50 02 20 00 6c 46 00 00 44 44 44 44 44 44 '
47 '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
48 '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
49 '44 44 44 44')
macauley_cheng4bb7ffc2015-10-26 15:30:26 +080050
macauley_cheng0a0a7f62015-11-06 11:36:50 +080051 output_pkt = simple_packet(
52 '00 00 04 22 44 66 00 00 04 22 33 55 81 00 00 02 '
53 '08 00 45 00 00 52 00 01 00 00 3f 06 f6 ee c0 a8 '
54 '01 64 c0 a8 02 02 04 d2 00 50 00 00 00 00 00 00 '
55 '00 00 50 02 20 00 6c 46 00 00 44 44 44 44 44 44 '
56 '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
57 '44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 44 '
58 '44 44 44 44')
macauley_chengdc5eb582015-10-26 14:29:17 +080059
60 self.dataplane.send(input_port, str(input_pkt))
61 verify_packet(self, str(output_pkt), output_port)
62
63
64
65
66
67