testing vlan untag
diff --git a/accton/accton_util.py b/accton/accton_util.py
index 67a7191..155849f 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -548,20 +548,56 @@
logging.info("Add allow all vlan on port %d " %(in_port))
ctrl.message_send(request)
-def add_untag_vlan_table_flow(ctrl, in_port, send_barrier=False):
+def add_untag_vlan_table(ctrl, in_port,vlan_id=0x0000, send_barrier=False):
"""it a flow to allow all vlan untag 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, 0x0fff))
+ match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id))
+ actions=[]
+ #actions.append(ofp.action.push_vlan(0x8100))
+ actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x100a)))
request = ofp.message.flow_add(
table_id=10,
cookie=42,
match=match,
instructions=[
+ ofp.instruction.apply_actions(
+ actions=actions
+ ),
ofp.instruction.goto_table(20)
],
priority=0)
logging.info("Add allow all untag on port %d " %(in_port))
+ print "REQUEST:"
+ print request.show()
+ print "END"
+
+ ctrl.message_send(request)
+
+def add_untag_vlan_table_flow(ctrl, in_port,vlan_id=0x1001, vlan_mask=0x1fff, send_barrier=False):
+ """it a flow to allow all vlan untag 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(vlan_id, vlan_mask))
+ actions=[]
+ #actions.append(ofp.action.push_vlan(0x8100))
+ actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x100a)))
+ request = ofp.message.flow_add(
+ table_id=10,
+ cookie=42,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(
+ actions=actions
+ ),
+ ofp.instruction.goto_table(20)
+ ],
+ priority=0)
+ logging.info("Add allow all untag on port %d " %(in_port))
+ print "REQUEST:"
+ print request.show()
+ print "END"
+
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):
@@ -576,7 +612,7 @@
if vrf!=0:
actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf)))
- actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(value=vlan_id)))
+ #actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(value=vlan_id)))
request = ofp.message.flow_add(
table_id=10,
diff --git a/ofdpa/dev.py b/ofdpa/dev.py
index ba850a6..b5140b4 100644
--- a/ofdpa/dev.py
+++ b/ofdpa/dev.py
@@ -13,6 +13,7 @@
from oftest.testutils import *
from accton_util import *
+@disabled
class Purge(base_tests.SimpleDataPlane):
def runTest(self):
delete_all_flows(self.controller)
@@ -21,7 +22,7 @@
add_vlan_table_flow(self.controller, config["port_map"].keys(), 1)
verify_no_other_packets(self)
-
+@disabled
class FlowStats(base_tests.SimpleProtocol):
"""
Flow stats multipart transaction
@@ -35,3 +36,64 @@
for entry in stats:
print(entry.show())
+class TagFlow20to10(base_tests.SimpleDataPlane):
+ def runTest(self):
+ do_barrier(self.controller)
+ for port in config["port_map"].keys():
+ add_one_vlan_table_flow(self.controller, port, 10)
+ do_barrier(self.controller)
+ logging.info("Sending flow stats request")
+ stats = get_flow_stats(self, ofp.match())
+ print "STATS"
+ for entry in stats:
+ print(entry.show())
+ print "END"
+ do_barrier(self.controller)
+ verify_no_other_packets(self)
+@disabled
+class UnTagFlow0(base_tests.SimpleDataPlane):
+ def runTest(self):
+ do_barrier(self.controller)
+ for port in config["port_map"].keys():
+ add_untag_vlan_table_flow(self.controller, port, 0x0000, 0x1000)
+ do_barrier(self.controller)
+ logging.info("Sending flow stats request")
+ stats = get_flow_stats(self, ofp.match())
+ print "STATS"
+ for entry in stats:
+ print(entry.show())
+ print "END"
+ do_barrier(self.controller)
+ verify_no_other_packets(self)
+
+class UnTagFlow10(base_tests.SimpleDataPlane):
+ def runTest(self):
+ do_barrier(self.controller)
+ for port in config["port_map"].keys():
+ add_untag_vlan_table_flow(self.controller, port, 0x0000, 0x1fff)
+ do_barrier(self.controller)
+ logging.info("Sending flow stats request")
+ stats = get_flow_stats(self, ofp.match())
+ print "STATS"
+ for entry in stats:
+ print(entry.show())
+ print "END"
+ do_barrier(self.controller)
+ verify_no_other_packets(self)
+
+
+@disabled
+class UnTagFlow1(base_tests.SimpleDataPlane):
+ def runTest(self):
+ do_barrier(self.controller)
+ for port in config["port_map"].keys():
+ add_untag_vlan_table(self.controller, port)
+ do_barrier(self.controller)
+ logging.info("Sending flow stats request")
+ stats = get_flow_stats(self, ofp.match())
+ print "STATS"
+ for entry in stats:
+ print(entry.show())
+ print "END"
+ do_barrier(self.controller)
+ verify_no_other_packets(self)
diff --git a/ofdpa/onos.py b/ofdpa/onos.py
index 4f13c0d..abee77a 100644
--- a/ofdpa/onos.py
+++ b/ofdpa/onos.py
@@ -51,6 +51,57 @@
verify_no_other_packets(self)
+class PacketInMiss(base_tests.SimpleDataPlane):
+ """
+ Test packet in function for a table-miss flow
+ Send a packet to each dataplane port and verify that a packet
+ in message is received from the controller for each
+
+ NOTE: Verify This case the oft option shall not use --switch-ip
+ """
+
+ def runTest(self):
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+
+ parsed_vlan_pkt = simple_udp_packet(pktlen=104,
+ vlan_vid=0x1001, dl_vlan_enable=True)
+ vlan_pkt = str(parsed_vlan_pkt)
+ ports = sorted(config["port_map"].keys())
+ for port in ports:
+ add_one_l2_interface_group(self.controller, port, 1, True, False)
+ add_one_vlan_table_flow(self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
+
+ # create match
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.eth_type(0x0800))
+ match.oxm_list.append(ofp.oxm.ip_proto(17))
+ request = ofp.message.flow_add(
+ table_id=60,
+ cookie=42,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(
+ actions=[
+ ofp.action.output(
+ port=ofp.OFPP_CONTROLLER,
+ max_len=ofp.OFPCML_NO_BUFFER)]),
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1)
+
+ logging.info("Inserting packet in flow to controller")
+ self.controller.message_send(request)
+ do_barrier(self.controller)
+
+ for of_port in config["port_map"].keys():
+ logging.info("PacketInMiss test, port %d", of_port)
+ self.dataplane.send(of_port, vlan_pkt)
+
+ verify_packet_in(self, vlan_pkt, of_port, ofp.OFPR_ACTION)
+
+ verify_no_other_packets(self)
+
class VlanSupport(base_tests.SimpleDataPlane):
"""
Test L2 forwarding of both, untagged and double-tagged packets