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 <wliu43@illinois.edu>
Signed-off-by: Minoru TAKAHASHI <takahashi.minoru7@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Minoru TAKAHASHI 2015-09-02 13:20:28 +09:00 committed by FUJITA Tomonori
parent 2701fa129f
commit 22387e09e4
2 changed files with 26 additions and 6 deletions

View File

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

View File

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