flow_query: handle different switch representations of nw src/dst masks
There are multiple wire representations of the same OpenFlow match. One example
is the nw src/dst masks, where mask indices 32 to 63 are equivalent. A switch
may return a different representation of the same match in a flow stats reply
than was originally sent in a flow-mod, and the flow_query tests need to handle
this.
The solution is to define a canonical representation of the match for the
purpose of checking equality. In this case all nw src/dst mask indices >= 32
are changed to 32. The main change is canonicalizing the match received from
the switch (in `flow_tbl_verify`) before checking it against the already
canonical matches sent to the switch.
diff --git a/tests/flow_query.py b/tests/flow_query.py
index e7f1718..5b81460 100644
--- a/tests/flow_query.py
+++ b/tests/flow_query.py
@@ -950,9 +950,22 @@
# sense to qualify ip_proto if eth_type is qualified to be 0x0800 (IP).
# The canonical form of flow match criteria will "wildcard out"
# all such cases.
+ # - The IP mask values from 32 to 63 are equivalent. Canonicalize to 32.
def canonical(self):
result = copy.deepcopy(self)
+ if wildcard_get(result.match.wildcards, ofp.OFPFW_NW_SRC_MASK) > 32:
+ result.match.wildcards = wildcard_set(result.match.wildcards, \
+ ofp.OFPFW_NW_SRC_MASK, \
+ 32 \
+ )
+
+ if wildcard_get(result.match.wildcards, ofp.OFPFW_NW_DST_MASK) > 32:
+ result.match.wildcards = wildcard_set(result.match.wildcards, \
+ ofp.OFPFW_NW_DST_MASK, \
+ 32 \
+ )
+
if wildcard_get(result.match.wildcards, ofp.OFPFW_DL_VLAN) != 0:
result.match.wildcards = wildcard_set(result.match.wildcards, \
ofp.OFPFW_DL_VLAN_PCP, \
@@ -1477,6 +1490,7 @@
for fs in self.flow_stats.entries:
flow_in = Flow_Cfg()
flow_in.from_flow_stat(fs)
+ flow_in = flow_in.canonical()
logging.info("Received flow:")
logging.info(str(flow_in))
fc = self.flow_tbl.find(flow_in)