From 778de37d82e7bc90b4ba2abdfb0ebc8ddb2e7302 Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Fri, 13 Apr 2018 16:52:34 +0200 Subject: libnftables: Keep cmds list outside of parser_state Parser basically turns input into a list of commands and error messages. Having the commands list being part of struct parser_state does not make sense from this point of view, also it will have to go away with upcoming JSON support anyway. While being at it, change nft_netlink() to take just the list of commands instead of the whole parser state as parameter, also take care of command freeing in nft_run_cmd_from_* functions (where the list resides as auto-variable) instead of from inside nft_run(). Signed-off-by: Phil Sutter Signed-off-by: Pablo Neira Ayuso --- src/parser_bison.y | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 93346d76..1ca5d404 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -38,12 +38,13 @@ void parser_init(struct mnl_socket *nf_sock, struct nft_cache *cache, struct parser_state *state, struct list_head *msgs, - unsigned int debug_mask, struct output_ctx *octx) + struct list_head *cmds, unsigned int debug_mask, + struct output_ctx *octx) { memset(state, 0, sizeof(*state)); - init_list_head(&state->cmds); init_list_head(&state->top_scope.symbols); state->msgs = msgs; + state->cmds = cmds; state->scopes[0] = scope_init(&state->top_scope, NULL); state->ectx.cache = cache; state->ectx.msgs = msgs; @@ -748,7 +749,7 @@ input : /* empty */ if (++state->nerrs == nft->parser_max_errors) YYABORT; } else - list_splice_tail(&list, &state->cmds); + list_splice_tail(&list, state->cmds); } } ; @@ -834,7 +835,7 @@ line : common_block { $$ = NULL; } if (++state->nerrs == nft->parser_max_errors) YYABORT; } else - list_splice_tail(&list, &state->cmds); + list_splice_tail(&list, state->cmds); } if (state->nerrs) YYABORT; -- cgit v1.2.3