From 22387e09e41e5319978f47b04796067e2e6da3f7 Mon Sep 17 00:00:00 2001 From: Minoru TAKAHASHI Date: Wed, 2 Sep 2015 13:20:28 +0900 Subject: [PATCH] ofctl_v1_[23]: Fix the output result of get_flow_stats() Add flows OFPIT_APPLY_ACTIONS and OFPIT_WRITE_ACTIONS and OFPIT_CLEAR_ACTIONS as the type of instructions, respectively. Then, the output results of get_flow_stats() are the same. This patch fix this problem. before applying this patch: * case OFPIT_APPLY_ACTIONS and OFPIT_WRITE_ACTIONS { "1": [ { "actions": [ "OUTPUT:2", "OUTPUT:3" ], ... } ] } * case OFPIT_CLEAR_ACTIONS { "1": [ { "actions": [], ... } ] } after apply this patch: * case OFPIT_APPLY_ACTIONS { "1": [ { "actions": [ "OUTPUT:2", "OUTPUT:3" ], ... } ] } * case OFPIT_WRITE_ACTIONS { "1": [ { "actions": [ { "WRITE_ACTIONS": [ "OUTPUT:4", "OUTPUT:5" ] } ], ... } ] } * case OFPIT_CLEAR_ACTIONS { "1": [ { "actions": [ "CLEAR_ACTIONS" ], ... } ] } Reported-by: Liu, Weijie Signed-off-by: Minoru TAKAHASHI Signed-off-by: FUJITA Tomonori --- ryu/lib/ofctl_v1_2.py | 16 +++++++++++++--- ryu/lib/ofctl_v1_3.py | 16 +++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/ryu/lib/ofctl_v1_2.py b/ryu/lib/ofctl_v1_2.py index 7308e1c1..385b5ae3 100644 --- a/ryu/lib/ofctl_v1_2.py +++ b/ryu/lib/ofctl_v1_2.py @@ -163,9 +163,19 @@ def actions_to_str(instructions): for instruction in instructions: if isinstance(instruction, ofproto_v1_2_parser.OFPInstructionActions): - for a in instruction.actions: - actions.append(action_to_str(a)) - + if instruction.type == ofproto_v1_2.OFPIT_APPLY_ACTIONS: + for a in instruction.actions: + actions.append(action_to_str(a)) + elif instruction.type == ofproto_v1_2.OFPIT_WRITE_ACTIONS: + write_actions = [] + for a in instruction.actions: + write_actions.append(action_to_str(a)) + if write_actions: + actions.append({'WRITE_ACTIONS': write_actions}) + elif instruction.type == ofproto_v1_2.OFPIT_CLEAR_ACTIONS: + actions.append('CLEAR_ACTIONS') + else: + actions.append('UNKNOWN') elif isinstance(instruction, ofproto_v1_2_parser.OFPInstructionGotoTable): buf = 'GOTO_TABLE:' + str(instruction.table_id) diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py index 15452e6e..037b04ad 100644 --- a/ryu/lib/ofctl_v1_3.py +++ b/ryu/lib/ofctl_v1_3.py @@ -175,9 +175,19 @@ def actions_to_str(instructions): for instruction in instructions: if isinstance(instruction, ofproto_v1_3_parser.OFPInstructionActions): - for a in instruction.actions: - actions.append(action_to_str(a)) - + if instruction.type == ofproto_v1_3.OFPIT_APPLY_ACTIONS: + for a in instruction.actions: + actions.append(action_to_str(a)) + elif instruction.type == ofproto_v1_3.OFPIT_WRITE_ACTIONS: + write_actions = [] + for a in instruction.actions: + write_actions.append(action_to_str(a)) + if write_actions: + actions.append({'WRITE_ACTIONS': write_actions}) + elif instruction.type == ofproto_v1_3.OFPIT_CLEAR_ACTIONS: + actions.append('CLEAR_ACTIONS') + else: + actions.append('UNKNOWN') elif isinstance(instruction, ofproto_v1_3_parser.OFPInstructionGotoTable): buf = 'GOTO_TABLE:' + str(instruction.table_id)