[ovs-dev] [PATCH] ovn: Clean up log() action parsing errors.

Mark Michelson mmichels at redhat.com
Tue Jul 31 12:21:31 UTC 2018


The 0-day Robot needs to lay off the pipe.

Acked-by: Mark Michelson <mmichels at redhat.com>

On 07/31/2018 02:03 AM, Justin Pettit wrote:
> This also add some OVN action parsing tests.
> 
> Suggested-by: Ben Pfaff <blp at ovn.org>
> Signed-off-by: Justin Pettit <jpettit at ovn.org>
> ---
>   ovn/lib/actions.c |  9 ++++++++-
>   tests/ovn.at      | 19 +++++++++++++++++++
>   2 files changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c
> index 2126fd57551e..bc1a20040cff 100644
> --- a/ovn/lib/actions.c
> +++ b/ovn/lib/actions.c
> @@ -2071,7 +2071,8 @@ parse_log_arg(struct action_context *ctx, struct ovnact_log *log)
>           } else if (lexer_match_id(ctx->lexer, "allow")) {
>               log->verdict = LOG_VERDICT_ALLOW;
>           } else {
> -            lexer_syntax_error(ctx->lexer, "unknown acl verdict");
> +            lexer_syntax_error(ctx->lexer, "unknown verdict");
> +            return;
>           }
>       } else if (lexer_match_id(ctx->lexer, "name")) {
>           if (!lexer_force_match(ctx->lexer, LEX_T_EQUALS)) {
> @@ -2103,6 +2104,9 @@ parse_log_arg(struct action_context *ctx, struct ovnact_log *log)
>                   log->severity = severity;
>                   lexer_get(ctx->lexer);
>                   return;
> +            } else {
> +                lexer_syntax_error(ctx->lexer, "unknown severity");
> +                return;
>               }
>           }
>           lexer_syntax_error(ctx->lexer, "expecting severity");
> @@ -2142,6 +2146,9 @@ parse_LOG(struct action_context *ctx)
>               lexer_match(ctx->lexer, LEX_T_COMMA);
>           }
>       }
> +    if (log->verdict == LOG_VERDICT_UNKNOWN) {
> +        lexer_syntax_error(ctx->lexer, "expecting verdict");
> +    }
>   }
>   
>   static void
> diff --git a/tests/ovn.at b/tests/ovn.at
> index df80b98d64b4..163f5c590516 100644
> --- a/tests/ovn.at
> +++ b/tests/ovn.at
> @@ -1224,6 +1224,25 @@ set_meter(100, 1000, );
>   set_meter(4294967295, 4294967295);
>       encodes as meter:3
>   
> +# log
> +log(verdict=allow, severity=warning);
> +    encodes as controller(userdata=00.00.00.07.00.00.00.00.00.04)
> +log(name="test1", verdict=drop, severity=info);
> +    encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06.74.65.73.74.31)
> +log(verdict=drop, severity=info, meter="meter1");
> +    encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06,meter_id=4)
> +log(name="test1", verdict=drop, severity=info, meter="meter1");
> +    encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06.74.65.73.74.31,meter_id=4)
> +log(verdict=drop);
> +    formats as log(verdict=drop, severity=info);
> +    encodes as controller(userdata=00.00.00.07.00.00.00.00.01.06)
> +log(verdict=bad_verdict, severity=info);
> +    Syntax error at `bad_verdict' unknown verdict.
> +log(verdict=drop, severity=bad_severity);
> +    Syntax error at `bad_severity' unknown severity.
> +log(severity=notice);
> +    Syntax error at `;' expecting verdict.
> +
>   # put_nd_ra_opts
>   reg1[0] = put_nd_ra_opts(addr_mode = "slaac", mtu = 1500, prefix = aef0::/64, slla = ae:01:02:03:04:05);
>       encodes as controller(userdata=00.00.00.08.00.00.00.00.00.01.de.10.00.00.00.40.86.00.00.00.ff.00.ff.ff.00.00.00.00.00.00.00.00.05.01.00.00.00.00.05.dc.03.04.40.c0.ff.ff.ff.ff.ff.ff.ff.ff.00.00.00.00.ae.f0.00.00.00.00.00.00.00.00.00.00.00.00.00.00.01.01.ae.01.02.03.04.05,pause)
> 



More information about the dev mailing list