From e18fe8a220f268624e5b670d6adcf2d4080866aa Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 9 Apr 2010 15:19:12 -0700 Subject: [PATCH] ofproto: Copy the flow being translated in xlate_actions(). This change should have no user-visible effect, but it paves the way for the following commit, which requires the action_xlate_ctx's flow to be modifiable. --- ofproto/ofproto.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index fd1256fc..9ddf6b15 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -1999,7 +1999,7 @@ add_controller_action(struct odp_actions *actions, struct action_xlate_ctx { /* Input. */ - const flow_t *flow; /* Flow to which these actions correspond. */ + flow_t flow; /* Flow to which these actions correspond. */ int recurse; /* Recursion level, via xlate_table_action. */ struct ofproto *ofproto; const struct ofpbuf *packet; /* The packet corresponding to 'flow', or a @@ -2062,13 +2062,11 @@ static void xlate_table_action(struct action_xlate_ctx *ctx, uint16_t in_port) { if (!ctx->recurse) { + uint16_t old_in_port = ctx->flow.in_port; struct rule *rule; - flow_t flow; - - flow = *ctx->flow; - flow.in_port = in_port; - rule = lookup_valid_rule(ctx->ofproto, &flow); + ctx->flow.in_port = in_port; + rule = lookup_valid_rule(ctx->ofproto, &ctx->flow); if (rule) { if (rule->super) { rule = rule->super; @@ -2078,6 +2076,7 @@ xlate_table_action(struct action_xlate_ctx *ctx, uint16_t in_port) do_xlate_actions(rule->actions, rule->n_actions, ctx); ctx->recurse--; } + ctx->flow.in_port = old_in_port; } } @@ -2092,13 +2091,13 @@ xlate_output_action(struct action_xlate_ctx *ctx, switch (ntohs(oao->port)) { case OFPP_IN_PORT: - add_output_action(ctx, ctx->flow->in_port); + add_output_action(ctx, ctx->flow.in_port); break; case OFPP_TABLE: - xlate_table_action(ctx, ctx->flow->in_port); + xlate_table_action(ctx, ctx->flow.in_port); break; case OFPP_NORMAL: - if (!ctx->ofproto->ofhooks->normal_cb(ctx->flow, ctx->packet, + if (!ctx->ofproto->ofhooks->normal_cb(&ctx->flow, ctx->packet, ctx->out, ctx->tags, &ctx->nf_output_iface, ctx->ofproto->aux)) { @@ -2121,7 +2120,7 @@ xlate_output_action(struct action_xlate_ctx *ctx, break; default: odp_port = ofp_port_to_odp_port(ntohs(oao->port)); - if (odp_port != ctx->flow->in_port) { + if (odp_port != ctx->flow.in_port) { add_output_action(ctx, odp_port); } break; @@ -2165,9 +2164,9 @@ do_xlate_actions(const union ofp_action *in, size_t n_in, const union ofp_action *ia; const struct ofport *port; - port = port_array_get(&ctx->ofproto->ports, ctx->flow->in_port); + port = port_array_get(&ctx->ofproto->ports, ctx->flow.in_port); if (port && port->opp.config & (OFPPC_NO_RECV | OFPPC_NO_RECV_STP) && - port->opp.config & (eth_addr_equals(ctx->flow->dl_dst, stp_eth_addr) + port->opp.config & (eth_addr_equals(ctx->flow.dl_dst, stp_eth_addr) ? OFPPC_NO_RECV_STP : OFPPC_NO_RECV)) { /* Drop this flow. */ return; @@ -2255,7 +2254,7 @@ xlate_actions(const union ofp_action *in, size_t n_in, struct action_xlate_ctx ctx; COVERAGE_INC(ofproto_ofp2odp); odp_actions_init(out); - ctx.flow = flow; + ctx.flow = *flow; ctx.recurse = 0; ctx.ofproto = ofproto; ctx.packet = packet; -- 2.30.2