From bc0e773fa3620fa3c4fef817d3b2256542be6b11 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Thu, 6 Aug 2020 10:48:12 -0400 Subject: [PATCH 15/22] Allow bare ct_commits when no nested actions are required. In the fixes commit below, ct_commit was changed to use nested actions. This requires that curly braces be present for all ct_commits. When adjusting ovn-northd, some ct_commits were not updated to have them. This commit changes the behavior of the ct_commit action not to require curly braces if there are no nested actions required. Fixes: 6cfb44a76c61("Used nested actions in ct_commit") Signed-off-by: Mark Michelson --- lib/actions.c | 20 ++++++++++++++++---- tests/ovn.at | 5 ++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lib/actions.c b/lib/actions.c index 79ac79a95..245486b0a 100644 --- a/lib/actions.c +++ b/lib/actions.c @@ -630,15 +630,27 @@ ovnact_ct_next_free(struct ovnact_ct_next *a OVS_UNUSED) static void parse_CT_COMMIT(struct action_context *ctx) { - - parse_nested_action(ctx, OVNACT_CT_COMMIT, "ip", - WR_CT_COMMIT); + if (ctx->lexer->token.type == LEX_T_LCURLY) { + parse_nested_action(ctx, OVNACT_CT_COMMIT, "ip", + WR_CT_COMMIT); + } else { + /* Add an empty nested action to allow for "ct_commit;" syntax */ + add_prerequisite(ctx, "ip"); + struct ovnact_nest *on = ovnact_put(ctx->ovnacts, OVNACT_CT_COMMIT, + OVNACT_ALIGN(sizeof *on)); + on->nested_len = 0; + on->nested = NULL; + } } static void format_CT_COMMIT(const struct ovnact_nest *on, struct ds *s) { - format_nested_action(on, "ct_commit", s); + if (on->nested_len) { + format_nested_action(on, "ct_commit", s); + } else { + ds_put_cstr(s, "ct_commit;"); + } } static void diff --git a/tests/ovn.at b/tests/ovn.at index b626bcfcc..2651b3eac 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -1047,8 +1047,11 @@ ct_next; has prereqs ip # ct_commit +ct_commit; + encodes as ct(commit,zone=NXM_NX_REG13[0..15]) + has prereqs ip ct_commit { }; - formats as ct_commit { drop; }; + formats as ct_commit; encodes as ct(commit,zone=NXM_NX_REG13[0..15]) has prereqs ip ct_commit { ct_mark=1; }; -- 2.26.2