summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/source/app/ofctl_rest.rst9
-rw-r--r--ryu/lib/ofctl_v1_0.py6
-rw-r--r--ryu/lib/ofctl_v1_2.py6
-rw-r--r--ryu/lib/ofctl_v1_3.py6
-rw-r--r--ryu/lib/ofctl_v1_4.py6
-rw-r--r--ryu/lib/ofctl_v1_5.py12
6 files changed, 45 insertions, 0 deletions
diff --git a/doc/source/app/ofctl_rest.rst b/doc/source/app/ofctl_rest.rst
index c69692c5..03f4b29f 100644
--- a/doc/source/app/ofctl_rest.rst
+++ b/doc/source/app/ofctl_rest.rst
@@ -248,8 +248,17 @@ Get flows stats filtered by fields
cookie Require matching entries to contain this cookie value (int) 1 0
cookie_mask Mask used to restrict the cookie bits that must match (int) 1 0
match Fields to match (dict) {"in_port": 1} {} #wildcarded
+ priority Priority of the entry (int) (See Note) 11111 #wildcarded
============ ================================================================== =============== ===============
+ .. NOTE::
+
+ OpenFlow Spec does not allow to filter flow entries by priority,
+ but when with a large amount of flow entries, filtering by priority
+ is convenient to get statistics efficiently.
+ So, this app provides priority field for filtering.
+
+
Response message body:
The same as :ref:`get-all-flows-stats`
diff --git a/ryu/lib/ofctl_v1_0.py b/ryu/lib/ofctl_v1_0.py
index be7d3913..6ef4a90b 100644
--- a/ryu/lib/ofctl_v1_0.py
+++ b/ryu/lib/ofctl_v1_0.py
@@ -330,6 +330,9 @@ def get_flow_stats(dp, waiters, flow=None):
flow.get('table_id', 0xff))
out_port = UTIL.ofp_port_from_user(
flow.get('out_port', dp.ofproto.OFPP_NONE))
+ # Note: OpenFlow does not allow to filter flow entries by priority,
+ # but for efficiency, ofctl provides the way to do it.
+ priority = int(flow.get('priority', -1))
stats = dp.ofproto_parser.OFPFlowStatsRequest(
dp, 0, match, table_id, out_port)
@@ -340,6 +343,9 @@ def get_flow_stats(dp, waiters, flow=None):
flows = []
for msg in msgs:
for stats in msg.body:
+ if 0 <= priority != stats.priority:
+ continue
+
actions = actions_to_str(stats.actions)
match = match_to_str(stats.match)
diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py
index 3ba1eb4a..998d5356 100644
--- a/ryu/lib/ofctl_v1_2.py
+++ b/ryu/lib/ofctl_v1_2.py
@@ -493,6 +493,9 @@ def get_flow_stats(dp, waiters, flow=None):
cookie = int(flow.get('cookie', 0))
cookie_mask = int(flow.get('cookie_mask', 0))
match = to_match(dp, flow.get('match', {}))
+ # Note: OpenFlow does not allow to filter flow entries by priority,
+ # but for efficiency, ofctl provides the way to do it.
+ priority = int(flow.get('priority', -1))
stats = dp.ofproto_parser.OFPFlowStatsRequest(
dp, table_id, out_port, out_group, cookie, cookie_mask, match)
@@ -503,6 +506,9 @@ def get_flow_stats(dp, waiters, flow=None):
flows = []
for msg in msgs:
for stats in msg.body:
+ if 0 <= priority != stats.priority:
+ continue
+
actions = actions_to_str(stats.instructions)
match = match_to_str(stats.match)
s = {'priority': stats.priority,
diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 4744a2ea..4d5a5a54 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -448,6 +448,9 @@ def get_flow_stats(dp, waiters, flow=None, to_user=True):
cookie = int(flow.get('cookie', 0))
cookie_mask = int(flow.get('cookie_mask', 0))
match = to_match(dp, flow.get('match', {}))
+ # Note: OpenFlow does not allow to filter flow entries by priority,
+ # but for efficiency, ofctl provides the way to do it.
+ priority = int(flow.get('priority', -1))
stats = dp.ofproto_parser.OFPFlowStatsRequest(
dp, flags, table_id, out_port, out_group, cookie, cookie_mask,
@@ -459,6 +462,9 @@ def get_flow_stats(dp, waiters, flow=None, to_user=True):
flows = []
for msg in msgs:
for stats in msg.body:
+ if 0 <= priority != stats.priority:
+ continue
+
s = {'priority': stats.priority,
'cookie': stats.cookie,
'idle_timeout': stats.idle_timeout,
diff --git a/ryu/lib/ofctl_v1_4.py b/ryu/lib/ofctl_v1_4.py
index 9bd6336b..219f99ff 100644
--- a/ryu/lib/ofctl_v1_4.py
+++ b/ryu/lib/ofctl_v1_4.py
@@ -322,6 +322,9 @@ def get_flow_stats(dp, waiters, flow=None, to_user=True):
cookie = int(flow.get('cookie', 0))
cookie_mask = int(flow.get('cookie_mask', 0))
match = to_match(dp, flow.get('match', {}))
+ # Note: OpenFlow does not allow to filter flow entries by priority,
+ # but for efficiency, ofctl provides the way to do it.
+ priority = int(flow.get('priority', -1))
stats = dp.ofproto_parser.OFPFlowStatsRequest(
dp, flags, table_id, out_port, out_group, cookie, cookie_mask,
@@ -333,6 +336,9 @@ def get_flow_stats(dp, waiters, flow=None, to_user=True):
flows = []
for msg in msgs:
for stats in msg.body:
+ if 0 <= priority != stats.priority:
+ continue
+
s = stats.to_jsondict()[stats.__class__.__name__]
s['instructions'] = instructions_to_str(stats.instructions)
s['match'] = match_to_str(stats.match)
diff --git a/ryu/lib/ofctl_v1_5.py b/ryu/lib/ofctl_v1_5.py
index 867a39e0..19f57b31 100644
--- a/ryu/lib/ofctl_v1_5.py
+++ b/ryu/lib/ofctl_v1_5.py
@@ -354,6 +354,9 @@ def get_flow_desc_stats(dp, waiters, flow=None, to_user=True):
cookie = int(flow.get('cookie', 0))
cookie_mask = int(flow.get('cookie_mask', 0))
match = to_match(dp, flow.get('match', {}))
+ # Note: OpenFlow does not allow to filter flow entries by priority,
+ # but for efficiency, ofctl provides the way to do it.
+ priority = int(flow.get('priority', -1))
stats = dp.ofproto_parser.OFPFlowDescStatsRequest(
dp, flags, table_id, out_port, out_group, cookie, cookie_mask,
@@ -365,6 +368,9 @@ def get_flow_desc_stats(dp, waiters, flow=None, to_user=True):
flows = []
for msg in msgs:
for stats in msg.body:
+ if 0 <= priority != stats.priority:
+ continue
+
s = stats.to_jsondict()[stats.__class__.__name__]
s['instructions'] = instructions_to_str(stats.instructions)
s['stats'] = stats_to_str(stats.stats)
@@ -386,6 +392,9 @@ def get_flow_stats(dp, waiters, flow=None, to_user=True):
cookie = int(flow.get('cookie', 0))
cookie_mask = int(flow.get('cookie_mask', 0))
match = to_match(dp, flow.get('match', {}))
+ # Note: OpenFlow does not allow to filter flow entries by priority,
+ # but for efficiency, ofctl provides the way to do it.
+ priority = int(flow.get('priority', -1))
stats = dp.ofproto_parser.OFPFlowStatsRequest(
dp, flags, table_id, out_port, out_group, cookie, cookie_mask,
@@ -397,6 +406,9 @@ def get_flow_stats(dp, waiters, flow=None, to_user=True):
flows = []
for msg in msgs:
for stats in msg.body:
+ if 0 <= priority != stats.priority:
+ continue
+
s = stats.to_jsondict()[stats.__class__.__name__]
s['stats'] = stats_to_str(stats.stats)
s['match'] = match_to_str(stats.match)