lib/ofctl_v_*: Enable to filter flow stats by priority

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.

This patch enables lib/ofctl_v_* modules to filter flow stats by
priority.

This patch is suggested by China Shenzhen TICOMM Information
Technology Co. Ltd.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2016-12-08 16:49:00 +09:00 committed by FUJITA Tomonori
parent 002cbbe1ec
commit e0c446a6b4
6 changed files with 45 additions and 0 deletions

View File

@ -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`

View File

@ -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)

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -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)