summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaryam Tahhan <maryam.tahhan@intel.com>2016-07-19 16:09:37 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-07-19 16:09:37 +0000
commit568524a40ab6fa4d570c65c6c42cd68c02c9dd22 (patch)
tree962196fbe9fe0e5b9bddff30af3f6ddf4cf597db
parentf35edfc71ee92d67e6cb587b116b64c3a005ac71 (diff)
parent0301f0ae94205046e38841851c024fe63fa614cf (diff)
Merge "ovs/ofctl: Fix validation method for complex flows."
-rw-r--r--src/ovs/ofctl.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/ovs/ofctl.py b/src/ovs/ofctl.py
index d7a2b320..a75d0be2 100644
--- a/src/ovs/ofctl.py
+++ b/src/ovs/ofctl.py
@@ -439,6 +439,21 @@ def flow_match(flow_dump, flow_src):
# perform unifications on both source and destination flows
flow_dump = flow_dump.replace('actions=', 'action=')
flow_src = flow_src.replace('actions=', 'action=')
+ # For complex flows the output of "ovs-ofctl dump-flows" can use the
+ # shorthand notation.
+ # eg if we set a flow with constraints on UDP ports like in the following
+ # {'dl_type': '0x0800', 'nw_proto': '17', 'in_port': '1', 'udp_dst': '0', 'actions': ['output:2']}
+ # dump-flows output can combine the first 2 constraints into 'udp' and translate
+ # 'udp_dst' into 'tp_dst' like
+ # "udp,in_port=1,tp_dst=0 actions=output:2".
+ # So the next replacements are needed.
+ flow_dump = flow_dump.replace('ip', 'dl_type=0x0800')
+ flow_dump = flow_dump.replace('tcp', 'nw_proto=6,dl_type=0x0800')
+ flow_dump = flow_dump.replace('udp', 'nw_proto=17,dl_type=0x0800')
+ flow_src = flow_src.replace('udp_src', 'tp_src')
+ flow_src = flow_src.replace('udp_dst', 'tp_dst')
+ flow_src = flow_src.replace('tcp_src', 'tp_src')
+ flow_src = flow_src.replace('tcp_dst', 'tp_dst')
# split flow strings into lists of comparable elements
flow_dump_list = re.findall(r"[\w.:=()]+", flow_dump)