[ovs-dev] [PATCH 1/2] ofproto: Copy the flow being translated in xlate_actions().

Justin Pettit jpettit at nicira.com
Tue Apr 13 07:38:35 UTC 2010


Looks good.

--Justin


On Apr 9, 2010, at 3:48 PM, Ben Pfaff wrote:

> 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 files changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index fd1256f..9ddf6b1 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;
> -- 
> 1.6.6.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list