[ovs-dev] [PATCH 06/14] actions: Factor out new helper function add_prerequisite().
Justin Pettit
jpettit at ovn.org
Fri Dec 11 01:13:58 UTC 2015
Acked-by: Justin Pettit <jpettit at ovn.org>
--Justin
> On Dec 8, 2015, at 5:08 PM, Ben Pfaff <blp at ovn.org> wrote:
>
> This will acquire new users in upcoming commits.
>
> Signed-off-by: Ben Pfaff <blp at ovn.org>
> ---
> ovn/lib/actions.c | 24 +++++++++++++++---------
> 1 file changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c
> index 693b1c1..581dbae 100644
> --- a/ovn/lib/actions.c
> +++ b/ovn/lib/actions.c
> @@ -183,6 +183,19 @@ parse_next_action(struct action_context *ctx)
> }
> }
>
> +/* Parses 'prerequisite' as an expression in the context of 'ctx', then adds it
> + * as a conjunction with the existing 'ctx->prereqs'. */
> +static void
> +add_prerequisite(struct action_context *ctx, const char *prerequisite)
> +{
> + struct expr *expr;
> + char *error;
> +
> + expr = expr_parse_string(prerequisite, ctx->symtab, &error);
> + ovs_assert(!error);
> + ctx->prereqs = expr_combine(EXPR_T_AND, ctx->prereqs, expr);
> +}
> +
> static void
> emit_ct(struct action_context *ctx, bool recirc_next, bool commit)
> {
> @@ -209,12 +222,7 @@ emit_ct(struct action_context *ctx, bool recirc_next, bool commit)
> ct->alg = 0;
>
> /* CT only works with IP, so set up a prerequisite. */
> - struct expr *expr;
> - char *error;
> -
> - expr = expr_parse_string("ip", ctx->symtab, &error);
> - ovs_assert(!error);
> - ctx->prereqs = expr_combine(EXPR_T_AND, ctx->prereqs, expr);
> + add_prerequisite(ctx, "ip");
> }
>
> static void
> @@ -249,9 +257,7 @@ parse_actions(struct action_context *ctx)
> emit_resubmit(ctx, ctx->output_ptable);
> } else if (lexer_match_id(ctx->lexer, "ip.ttl")) {
> if (lexer_match(ctx->lexer, LEX_T_DECREMENT)) {
> - struct expr *e = expr_parse_string("ip", ctx->symtab,
> - &ctx->error);
> - ctx->prereqs = expr_combine(EXPR_T_AND, ctx->prereqs, e);
> + add_prerequisite(ctx, "ip");
> ofpact_put_DEC_TTL(ctx->ofpacts);
> } else {
> action_syntax_error(ctx, "expecting `--'");
> --
> 2.1.3
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list