* [PATCH 1/2] netlink: use set location for IO errors
@ 2014-03-07 10:12 Patrick McHardy
2014-03-07 10:12 ` [PATCH 2/2] parser: add grammatical distinction for verdict maps Patrick McHardy
0 siblings, 1 reply; 2+ messages in thread
From: Patrick McHardy @ 2014-03-07 10:12 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
We currently crash when reporting a permission denied error for set additions.
This is due to using the wrong location, fix by passing in the set location.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
src/netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/netlink.c b/src/netlink.c
index b2bd3c5..daac64c 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -777,7 +777,7 @@ int netlink_add_set(struct netlink_ctx *ctx, const struct handle *h,
err = mnl_nft_set_add(nf_sock, nls, NLM_F_EXCL | NLM_F_ECHO);
if (err < 0)
- netlink_io_error(ctx, NULL, "Could not add set: %s",
+ netlink_io_error(ctx, &set->location, "Could not add set: %s",
strerror(errno));
set->handle.set =
--
1.8.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 2/2] parser: add grammatical distinction for verdict maps
2014-03-07 10:12 [PATCH 1/2] netlink: use set location for IO errors Patrick McHardy
@ 2014-03-07 10:12 ` Patrick McHardy
0 siblings, 0 replies; 2+ messages in thread
From: Patrick McHardy @ 2014-03-07 10:12 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
Currently the parser accepts verdicts in regular maps and non-verdicts
in verdict maps and we have to check matching types during evaluation.
Add grammar rules for verdict maps and seperate them from regular maps.
This has a couple of advantages:
- We recognize verdict maps completely in the parser and any attempt to
mix verdicts and other expressions will result in a syntax error.
So far this hasn't actually been checked.
- Using verdicts in non-verdict mappings will also result in a syntax
error instead of a datatype mismatch.
- There's a grammatical distinction between dictionaries and verdict
maps, which are actually statements.
This is needed as preparation for a following patch to turn verdicts
into pure statements, which in turn is needed to reinstate support for
using the queue verdict in maps, which was broken by the introduction
of the queue statement.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
src/parser.y | 52 +++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 13 deletions(-)
diff --git a/src/parser.y b/src/parser.y
index dd09fb4..0d97ae9 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -428,8 +428,11 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%type <expr> map_expr
%destructor { expr_free($$); } map_expr
-%type <expr> verdict_map_expr
-%destructor { expr_free($$); } verdict_map_expr
+%type <expr> verdict_map_stmt
+%destructor { expr_free($$); } verdict_map_stmt
+
+%type <expr> verdict_map_expr verdict_map_list_expr verdict_map_list_member_expr
+%destructor { expr_free($$); } verdict_map_expr verdict_map_list_expr verdict_map_list_member_expr
%type <expr> set_expr set_list_expr set_list_member_expr
%destructor { expr_free($$); } set_expr set_list_expr set_list_member_expr
@@ -1072,12 +1075,45 @@ verdict_stmt : verdict_expr
{
$$ = verdict_stmt_alloc(&@$, $1);
}
- | verdict_map_expr
+ | verdict_map_stmt
{
$$ = verdict_stmt_alloc(&@$, $1);
}
;
+verdict_map_stmt : concat_expr VMAP verdict_map_expr
+ {
+ $$ = map_expr_alloc(&@$, $1, $3);
+ }
+ ;
+
+verdict_map_expr : '{' verdict_map_list_expr '}'
+ {
+ $2->location = @$;
+ $$ = $2;
+ }
+ ;
+
+verdict_map_list_expr : verdict_map_list_member_expr
+ {
+ $$ = set_expr_alloc(&@$);
+ compound_expr_add($$, $1);
+ }
+ | verdict_map_list_expr COMMA verdict_map_list_member_expr
+ {
+ compound_expr_add($1, $3);
+ $$ = $1;
+ }
+ | verdict_map_list_expr COMMA opt_newline
+ ;
+
+verdict_map_list_member_expr: opt_newline map_lhs_expr COLON verdict_expr opt_newline
+ {
+ $$ = mapping_expr_alloc(&@$, $2, $4);
+ }
+ ;
+
+
counter_stmt : counter_stmt_alloc
| counter_stmt_alloc counter_args
@@ -1404,12 +1440,6 @@ map_expr : concat_expr MAP expr
}
;
-verdict_map_expr : concat_expr VMAP expr
- {
- $$ = map_expr_alloc(&@$, $1, $3);
- }
- ;
-
expr : concat_expr
| set_expr
| map_expr
@@ -1444,10 +1474,6 @@ set_list_member_expr : opt_newline expr opt_newline
{
$$ = mapping_expr_alloc(&@$, $2, $4);
}
- | opt_newline map_lhs_expr COLON verdict_expr opt_newline
- {
- $$ = mapping_expr_alloc(&@$, $2, $4);
- }
;
initializer_expr : expr
--
1.8.5.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-03-07 10:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07 10:12 [PATCH 1/2] netlink: use set location for IO errors Patrick McHardy
2014-03-07 10:12 ` [PATCH 2/2] parser: add grammatical distinction for verdict maps Patrick McHardy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).