Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp> --- v2 - changed for ofp_instruction --- lib/ofp-actions.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 66 insertions(+), 10 deletions(-)
diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 3e00366..d5422ec 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -1607,6 +1607,7 @@ ofpact_format(const struct ofpact *a, struct ds *s) const struct ofpact_autopath *autopath; const struct ofpact_controller *controller; const struct ofpact_tunnel *tunnel; + const struct ofpact_instruction *instruction; uint16_t port; switch (a->type) { @@ -1744,7 +1745,10 @@ ofpact_format(const struct ofpact *a, struct ds *s) case OFPACT_RESUBMIT: resubmit = ofpact_get_RESUBMIT(a); - if (resubmit->in_port != OFPP_IN_PORT && resubmit->table_id == 255) { + if (a->compat == -1 /* TODO:XXX use constant */) { + ds_put_format(s, "goto-table:%"PRIu8, resubmit->table_id); + } else if (resubmit->in_port != OFPP_IN_PORT + && resubmit->table_id == 255) { ds_put_format(s, "resubmit:%"PRIu16, resubmit->in_port); } else { ds_put_format(s, "resubmit("); @@ -1783,7 +1787,24 @@ ofpact_format(const struct ofpact *a, struct ds *s) break; case OFPACT_INSTRUCTION: - NOT_REACHED(); /* TODO:XXX */ + instruction = ofpact_get_INSTRUCTION(a); + switch (instruction->type) { + case OVSINST_OFPIT11_APPLY_ACTIONS: + ds_put_cstr(s, "apply_actions"); + break; + case OVSINST_OFPIT11_CLEAR_ACTIONS: + ds_put_cstr(s, "clear_actions"); + break; + case OVSINST_OFPIT11_WRITE_ACTIONS: + ds_put_cstr(s, "write_actions"); + break; + + case OVSINST_OFPIT11_WRITE_METADATA: + case OVSINST_OFPIT11_GOTO_TABLE: + default: + NOT_REACHED(); + break; + } break; } } @@ -1794,19 +1815,54 @@ void ofpacts_format(const struct ofpact *ofpacts, size_t ofpacts_len, struct ds *string) { - ds_put_cstr(string, "actions="); + const struct ofpact *a; + bool in_instruction = false; + int n_actions = 0; + if (!ofpacts_len) { - ds_put_cstr(string, "drop"); - } else { - const struct ofpact *a; + ds_put_cstr(string, "actions=drop"); + return; + } + + OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) { + if (a != ofpacts) { + ds_put_cstr(string, ","); + } else { + if (a->type == OFPACT_INSTRUCTION) { + ds_put_cstr(string, "instructions="); + } else { + ds_put_cstr(string, "actions="); + } + } + ofpact_format(a, string); - OFPACT_FOR_EACH (a, ofpacts, ofpacts_len) { - if (a != ofpacts) { - ds_put_cstr(string, ","); + n_actions++; + if (a->type == OFPACT_INSTRUCTION) { + struct ofpact_instruction *inst = ofpact_get_INSTRUCTION(a); + if (!in_instruction) { + if (inst->type == OVSINST_OFPIT11_APPLY_ACTIONS + || inst->type == OVSINST_OFPIT11_WRITE_ACTIONS) { + ds_put_cstr(string, "("); + in_instruction = true; + n_actions = 0; + } + } else { + if (n_actions <= 1) { + ds_put_cstr(string, "drop"); + } + ds_put_cstr(string, ")"); + in_instruction = false; + n_actions = 0; } - ofpact_format(a, string); } } + + if (in_instruction) { + if (n_actions == 0) { + ds_put_cstr(string, "drop"); + } + ds_put_cstr(string, ")"); + } } /* Internal use by helpers. */ -- 1.7.1.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev