Allow higher priority flows to take precedence when there is a match
Change-Id: If5e92ba9f5801cb7cea423e4a82388b6ec845f1d
diff --git a/ponsim/ponsim.py b/ponsim/ponsim.py
index 932ea89..437290e 100644
--- a/ponsim/ponsim.py
+++ b/ponsim/ponsim.py
@@ -186,8 +186,14 @@
def process_frame(self, ingress_port, ingress_frame):
matched_mask = 0
+ highest_priority = 0
matched_flow = None
for flow in self.flows:
+ # flows are sorted by highest priority.
+ if matched_flow and flow.priority < highest_priority:
+ break
+
+ highest_priority = flow.priority
current_mask = self.is_match(flow, ingress_port, ingress_frame)
if current_mask > matched_mask:
matched_mask = current_mask