acctonUseDpctl/
diff --git a/acctonUseDpctl/allow_all_ucast_route.py b/acctonUseDpctl/allow_all_ucast_route.py
new file mode 100755
index 0000000..f5a69f3
--- /dev/null
+++ b/acctonUseDpctl/allow_all_ucast_route.py
@@ -0,0 +1,58 @@
+import logging
+import oftest.base_tests as base_tests
+from oftest import config
+from oftest.testutils import *
+from util import *
+from accton_util import convertIP4toStr as toIpV4Str
+from accton_util import convertMACtoStr as toMacStr
+"""
+ [Allow all VLAN and unicast route]
+ Whatever incoming VLAN tag, do unicast route and output to specified port
+
+ Inject eth 1/3 Tag3, SA000000112233, DA000000113355, SIP 192.168.1.100, DIP 192.168.2.2
+ Output eth 1/1 Tag2, SA 000004223355, DA 000004224466
+
+ dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1000/0x1000 goto:20
+ 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
+ dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output=1
+ 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
+ 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
+ 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
+ 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
+"""
+
+class test1(base_tests.SimpleDataPlane):
+ def runTest(self):
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+
+ test_ports = sorted(config["port_map"].keys())
+ input_port = test_ports[0]
+ output_port = test_ports[1]
+
+ apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1000/0x1000 goto:20")
+ 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")
+ apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x20001 group=any,port=any,weight=0 output="+str(output_port))
+ 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")
+ 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")
+ 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))
+ 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")
+
+ input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
+ eth_src="00:00:00:11:22:33",
+ ip_src=toIpV4Str(0xc0a80164),
+ ip_dst=toIpV4Str(0xc0a80202))
+
+ output_pkt = simple_tcp_packet(eth_dst="00:00:04:22:44:66",
+ eth_src="00:00:04:22:33:55",
+ ip_src=toIpV4Str(0xc0a80164),
+ ip_dst=toIpV4Str(0xc0a80202))
+
+ self.dataplane.send(input_port, str(input_pkt))
+ verify_packet(self, str(output_pkt), output_port)
+
+
+
+
+
+
\ No newline at end of file
diff --git a/acctonUseDpctl/basic.py b/acctonUseDpctl/basic.py
index b7bf28a..e7d82d6 100755
--- a/acctonUseDpctl/basic.py
+++ b/acctonUseDpctl/basic.py
@@ -12,7 +12,7 @@
test_ports = sorted(config["port_map"].keys())
- json_result = apply_dpctl_cmd(self, config, "features")
+ json_result = apply_dpctl_get_cmd(self, config, "features")
#pprint(json_result)
result=json_result["RECEIVED"][1]
self.assertTrue(result["tabs"]==64, "Table size is not correct")
@@ -24,7 +24,7 @@
test_ports = sorted(config["port_map"].keys())
- json_result = apply_dpctl_cmd(self, config, "get-config")
+ json_result = apply_dpctl_get_cmd(self, config, "get-config")
#pprint(json_result)
result=json_result["RECEIVED"][1]
self.assertNotEqual(result["conf"], {}, "Config reply nothing")
diff --git a/acctonUseDpctl/util.py b/acctonUseDpctl/util.py
index 757d889..b8d451e 100755
--- a/acctonUseDpctl/util.py
+++ b/acctonUseDpctl/util.py
@@ -6,21 +6,25 @@
test_tmp_file=os.getcwd()+os.sep+"dpctloutputtmp.tmp"
-def apply_dpctl_cmd(test, config, cmd):
+def apply_dpctl(test, config, cmd):
switch_ip = config["switch_ip"]
if len(switch_ip) == 0:
assert(0)
-
- #create the tmp file
- try:
- subprocess.check_call(["ls", test_tmp_file])
- except subprocess.CalledProcessError:
- open(test_tmp_file, "w").close()
- subprocess.call(["sudo", "chmod", "a+w", test_tmp_file])
#apply dpctl command
subprocess.call("dpctl tcp:"+switch_ip+":6633 "+cmd+" > "+test_tmp_file, shell=True)
+
+def apply_dpctl_get_cmd(test, config, cmd):
+
+ #create the tmp file
+ if not os.path.isfile(test_tmp_file):
+ open(test_tmp_file, "w").close()
+ subprocess.call(["sudo", "chmod", "a+w", test_tmp_file])
+
+ apply_dpctl(test, config, cmd)
+
+ #parse result
with open(test_tmp_file) as tmp_file:
try:
json_result=json.loads(tmp_file.read(), encoding='utf-8')
@@ -31,4 +35,9 @@
"""
test.assertTrue(False, "NO json format, dpctl may fail")
- return json_result
\ No newline at end of file
+ return json_result
+
+def apply_dpctl_mod(test, config, cmd):
+ apply_dpctl(test, config, cmd)
+
+
\ No newline at end of file