add new case
diff --git a/accton/accton_util.py b/accton/accton_util.py
index 3b77b1c..1c26766 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -413,7 +413,7 @@
if (flag == VLAN_TABLE_FLAG_ONLY_UNTAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH):
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(of_port))
- match.oxm_list.append(ofp.oxm.vlan_vid(0))
+ match.oxm_list.append(ofp.oxm.vlan_vid_masked(0, 0xfff))
request = ofp.message.flow_add(
table_id=10,
cookie=42,
@@ -436,6 +436,53 @@
return msgs
+def add_vlan_table_flow_pvid(ctrl, in_port, match_vid=None, pvid=1, send_barrier=False):
+ """it will tag pack as untagged packet wether it has tagg or not"""
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.in_port(in_port))
+ actions=[]
+ if match_vid == None:
+ match.oxm_list.append(ofp.oxm.vlan_vid(0))
+ actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+pvid)))
+ goto_table=20
+ else:
+ match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+match_vid, 0x1fff))
+ actions.append(ofp.action.push_vlan(0x8100))
+ actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+pvid)))
+ goto_table=20
+
+ request = ofp.message.flow_add(
+ table_id=10,
+ cookie=42,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(actions=actions)
+ ,ofp.instruction.goto_table(goto_table)
+ ],
+ priority=0)
+ logging.info("Add PVID %d on port %d and go to table %ld" %( pvid, in_port, goto_table))
+ ctrl.message_send(request)
+
+ if send_barrier:
+ do_barrier(ctrl)
+
+def add_vlan_table_flow_allow_all_vlan(ctrl, in_port, send_barrier=False):
+ """it st flow allow all vlan tag on this port"""
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.in_port(in_port))
+ match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000, 0x1000))
+ request = ofp.message.flow_add(
+ table_id=10,
+ cookie=42,
+ match=match,
+ instructions=[
+ ofp.instruction.goto_table(20)
+ ],
+ priority=0)
+ logging.info("Add allow all vlan on port %d " %(in_port))
+ ctrl.message_send(request)
+
+
def add_one_vlan_table_flow(ctrl, of_port, vlan_id=1, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False):
# table 10: vlan
# goto to table 20
diff --git a/accton/flow_test2.py b/accton/flow_test2.py
new file mode 100755
index 0000000..7ef7c2b
--- /dev/null
+++ b/accton/flow_test2.py
@@ -0,0 +1,58 @@
+"""
+Flow Test
+
+Test each flow table can set entry, and packet rx correctly.
+"""
+
+import logging
+
+from oftest import config
+import oftest.base_tests as base_tests
+import ofp
+from oftest.testutils import *
+from accton_util import *
+
+class qinq(base_tests.SimpleDataPlane):
+ def runTest(self):
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+
+ in_port = config["port_map"].keys()[0]
+ out_port=config["port_map"].keys()[1]
+ out_vlan=10
+ add_vlan_table_flow_pvid(self.controller, in_port, None, out_vlan, False)
+ add_vlan_table_flow_pvid(self.controller, in_port, 1,out_vlan, False)
+ group_id, msg=add_one_l2_interface_grouop(self.controller, out_port, out_vlan, True, False)
+ #add acl
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.in_port(in_port))
+ request = ofp.message.flow_add(
+ table_id=60,
+ cookie=42,
+ match=match,
+ instructions=[
+ ofp.instruction.write_actions(
+ actions=[
+ ofp.action.group(msg.group_id)])
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1000)
+ self.controller.message_send(request)
+
+ #input untag packet
+
+ parsed_pkt = simple_tcp_packet(pktlen=100)
+ pkt = str(parsed_pkt)
+ self.dataplane.send(in_port, pkt)
+
+ parsed_pkt = simple_tcp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=10)
+ verify_packet(self, str(parsed_pkt), out_port)
+
+ #input tag packet
+ parsed_pkt = simple_tcp_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=1)
+ pkt = str(parsed_pkt)
+ self.dataplane.send(in_port, pkt)
+
+ parsed_pkt = simple_tcp_packet_two_vlan(pktlen=108, out_dl_vlan_enable=True, out_vlan_vid=10,
+ in_dl_vlan_enable=True, in_vlan_vid=1)
+ verify_packet(self, str(parsed_pkt), out_port)