From 332325e3c3fab4c25bb5f387f9663205f63748dc Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Wed, 30 Oct 2019 21:45:39 +0100 Subject: libnftables: Store top_scope in struct nft_ctx Allow for interactive sessions to make use of defines. Since parser is initialized for each line, top scope defines didn't persist although they are actually useful for stuff like: | # nft -i | define goodports = { 22, 23, 80, 443 } | add rule inet t c tcp dport $goodports accept | add rule inet t c tcp sport $goodports accept While being at it, introduce scope_alloc() and scope_free(). Signed-off-by: Phil Sutter Acked-by: Pablo Neira Ayuso --- src/parser_bison.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/parser_bison.y') diff --git a/src/parser_bison.y b/src/parser_bison.y index 6f525d5b..3f283256 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -42,13 +42,13 @@ #include "parser_bison.h" void parser_init(struct nft_ctx *nft, struct parser_state *state, - struct list_head *msgs, struct list_head *cmds) + struct list_head *msgs, struct list_head *cmds, + struct scope *top_scope) { memset(state, 0, sizeof(*state)); - init_list_head(&state->top_scope.symbols); state->msgs = msgs; state->cmds = cmds; - state->scopes[0] = scope_init(&state->top_scope, NULL); + state->scopes[0] = scope_init(top_scope, NULL); init_list_head(&state->indesc_list); } -- cgit v1.2.3