diff options
author | Ben Pfaff <blp@ovn.org> | 2017-01-19 20:39:26 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-01-20 14:10:35 -0800 |
commit | bac295648d693edfe437d240cfb24a7c55ec169e (patch) | |
tree | 439eb88f7f44646cf135078ccd86b4b19233aeea /ovn | |
parent | f1393f6f3469c25d22a7633c7b1fe0e8be94ed3d (diff) | |
download | openvswitch-bac295648d693edfe437d240cfb24a7c55ec169e.tar.gz |
actions: Make "arp { drop; };" acceptable.
Before this commit, the OVN action parser would accept "arp {};" and then
the formatter would format it back as "arp { drop; };", but the parser
didn't accept the latter. There were basically two choices: make the
parser accept "arp { drop; };" or make the formatter output "arp {};"
(or both). This patch does (only) the former, and adds a test to avoid
regression.
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Mickey Spiegel <mickeys.dev@gmail.com>
Diffstat (limited to 'ovn')
-rw-r--r-- | ovn/lib/actions.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/ovn/lib/actions.c b/ovn/lib/actions.c index 57704885e..f1faab395 100644 --- a/ovn/lib/actions.c +++ b/ovn/lib/actions.c @@ -179,7 +179,7 @@ struct action_context { struct expr *prereqs; /* Prerequisites to apply to match. */ }; -static bool parse_action(struct action_context *); +static void parse_actions(struct action_context *, enum lex_type sentinel); static bool action_parse_field(struct action_context *ctx, @@ -1040,11 +1040,7 @@ parse_nested_action(struct action_context *ctx, enum ovnact_type type, .ovnacts = &nested, .prereqs = NULL }; - while (!lexer_match(ctx->lexer, LEX_T_RCURLY)) { - if (!parse_action(&inner_ctx)) { - break; - } - } + parse_actions(&inner_ctx, LEX_T_RCURLY); /* XXX Not really sure what we should do with prerequisites for nested * actions. */ @@ -1743,7 +1739,7 @@ parse_action(struct action_context *ctx) } static void -parse_actions(struct action_context *ctx) +parse_actions(struct action_context *ctx, enum lex_type sentinel) { /* "drop;" by itself is a valid (empty) set of actions, but it can't be * combined with other actions because that doesn't make sense. */ @@ -1752,11 +1748,11 @@ parse_actions(struct action_context *ctx) && lexer_lookahead(ctx->lexer) == LEX_T_SEMICOLON) { lexer_get(ctx->lexer); /* Skip "drop". */ lexer_get(ctx->lexer); /* Skip ";". */ - lexer_force_end(ctx->lexer); + lexer_force_match(ctx->lexer, sentinel); return; } - while (ctx->lexer->token.type != LEX_T_END) { + while (!lexer_match(ctx->lexer, sentinel)) { if (!parse_action(ctx)) { return; } @@ -1791,7 +1787,7 @@ ovnacts_parse(struct lexer *lexer, const struct ovnact_parse_params *pp, .prereqs = NULL, }; if (!lexer->error) { - parse_actions(&ctx); + parse_actions(&ctx, LEX_T_END); } if (!lexer->error) { |