Skip to content

Commit

Permalink
ofproto-dpif: Refactor compose_clone()
Browse files Browse the repository at this point in the history
Add a new function clone_xlate_actions(), which shares the same
signature as do_xlate_actions();  Later patch will make use
of this function.

Signed-off-by: Andy Zhou <[email protected]>
Tested-by: Greg Rose <[email protected]>
Reviewed-by: Greg Rose <[email protected]>
  • Loading branch information
azhou-nicira committed Sep 27, 2017
1 parent 5fbd022 commit c9f0a44
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions ofproto/ofproto-dpif-xlate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5334,7 +5334,8 @@ reversible_actions(const struct ofpact *ofpacts, size_t ofpacts_len)
}

static void
compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc)
clone_xlate_actions(const struct ofpact *actions, size_t actions_len,
struct xlate_ctx *ctx)
{
struct ofpbuf old_stack = ctx->stack;
union mf_subvalue new_stack[1024 / sizeof(union mf_subvalue)];
Expand All @@ -5347,12 +5348,11 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc)
ofpbuf_put(&ctx->action_set, old_action_set.data, old_action_set.size);

size_t offset, ac_offset;
size_t oc_actions_len = ofpact_nest_get_action_len(oc);
struct flow old_flow = ctx->xin->flow;

if (reversible_actions(oc->actions, oc_actions_len)) {
if (reversible_actions(actions, actions_len)) {
old_flow = ctx->xin->flow;
do_xlate_actions(oc->actions, oc_actions_len, ctx);
do_xlate_actions(actions, actions_len, ctx);
if (ctx->freezing) {
finish_freezing(ctx);
}
Expand All @@ -5373,7 +5373,7 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc)
if (ctx->xbridge->support.clone) { /* Use clone action */
/* Use clone action as datapath clone. */
offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_CLONE);
do_xlate_actions(oc->actions, oc_actions_len, ctx);
do_xlate_actions(actions, actions_len, ctx);
if (ctx->freezing) {
finish_freezing(ctx);
}
Expand All @@ -5386,7 +5386,7 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc)
offset = nl_msg_start_nested(ctx->odp_actions, OVS_ACTION_ATTR_SAMPLE);
ac_offset = nl_msg_start_nested(ctx->odp_actions,
OVS_SAMPLE_ATTR_ACTIONS);
do_xlate_actions(oc->actions, oc_actions_len, ctx);
do_xlate_actions(actions, actions_len, ctx);
if (ctx->freezing) {
finish_freezing(ctx);
}
Expand Down Expand Up @@ -5424,6 +5424,14 @@ compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc)
ctx->xin->flow = old_flow;
}

static void
compose_clone(struct xlate_ctx *ctx, const struct ofpact_nest *oc)
{
size_t oc_actions_len = ofpact_nest_get_action_len(oc);

clone_xlate_actions(oc->actions, oc_actions_len, ctx);
}

static void
xlate_meter_action(struct xlate_ctx *ctx, const struct ofpact_meter *meter)
{
Expand Down

0 comments on commit c9f0a44

Please sign in to comment.