summaryrefslogtreecommitdiffstats
path: root/src/parser_bison.y
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2019-06-05 17:07:42 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2019-06-05 17:54:50 +0200
commitf211921e25e683eb0cbfac08fd0289a07b6d67d1 (patch)
treeaa8f8e60a97d152a6abee8483afd48cace4d98a1 /src/parser_bison.y
parent60e917fa7cb55b4f675110bae78df56cd49bd486 (diff)
src: perform evaluation after parsing
Since 61236968b7a1 ("parser: evaluate commands immediately after parsing"), evaluation is invoked from the parsing phase in order to improve error reporting. However, this approach is problematic from the cache perspective since we don't know if a full or partial netlink dump from the kernel is needed. If the number of objects in the kernel is significant, the netlink dump operation to build the cache may significantly slow down commands. This patch moves the evaluation phase after the parsing phase as a preparation update to allow for a better strategy to build the cache. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r--src/parser_bison.y27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 2a39db31..8026708e 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -48,8 +48,6 @@ void parser_init(struct nft_ctx *nft, struct parser_state *state,
state->msgs = msgs;
state->cmds = cmds;
state->scopes[0] = scope_init(&state->top_scope, NULL);
- state->ectx.nft = nft;
- state->ectx.msgs = msgs;
init_list_head(&state->indesc_list);
}
@@ -792,17 +790,8 @@ input : /* empty */
| input line
{
if ($2 != NULL) {
- LIST_HEAD(list);
-
$2->location = @2;
-
- list_add_tail(&$2->list, &list);
- if (cmd_evaluate(&state->ectx, $2) < 0) {
- cmd_free($2);
- if (++state->nerrs == nft->parser_max_errors)
- YYABORT;
- } else
- list_splice_tail(&list, state->cmds);
+ list_add_tail(&$2->list, state->cmds);
}
}
;
@@ -878,22 +867,10 @@ line : common_block { $$ = NULL; }
* work.
*/
if ($1 != NULL) {
- LIST_HEAD(list);
-
$1->location = @1;
-
- list_add_tail(&$1->list, &list);
- if (cmd_evaluate(&state->ectx, $1) < 0) {
- cmd_free($1);
- if (++state->nerrs == nft->parser_max_errors)
- YYABORT;
- } else
- list_splice_tail(&list, state->cmds);
+ list_add_tail(&$1->list, state->cmds);
}
- if (state->nerrs)
- YYABORT;
$$ = NULL;
-
YYACCEPT;
}
;