diff options
author | Phil Sutter <phil@nwl.cc> | 2018-04-13 16:52:34 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2018-04-14 13:53:02 +0200 |
commit | 778de37d82e7bc90b4ba2abdfb0ebc8ddb2e7302 (patch) | |
tree | 6dd8a979e615db7fb9c4f165b0011e5ec2a6efc1 /src/parser_bison.y | |
parent | fd9b62f6fdace59be247008b67506abb82bbf4a8 (diff) |
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 <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r-- | src/parser_bison.y | 9 |
1 files changed, 5 insertions, 4 deletions
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; |