expression: fix output of verdict maps
Pablo Neira Ayuso
maintainerPATCH 1/1 expression: fix output of verdict maps
% nft list table filter
table ip filter {
...
chain output {
...
ip saddr map { 1.1.1.1 => accept}
}
}It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in map_expr_print().
--- src/expression.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
src/expression.c +5 -1
@@ -689,7 +689,11 @@ struct expr *mapping_expr_alloc(const struct location *loc,static void map_expr_print (const struct expr *expr) {expr_print (expr->map); -printf (" map " ); +if (expr->mappings->ops->type ==EXPR_SET_REF && + expr->mappings->set->datatype->type ==TYPE_VERDICT ) +printf (" vmap " ); +else +printf (" map " );expr_print (expr->mappings); }
Signature · 1 line
1.7.10.4
Quoted 11 lines · Pablo Neira Ayuso
% nft list table filter
table ip filter { ... chain output { ... ip saddr map { 1.1.1.1 => accept} } }It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in
map_expr_print().
The fix is fine of course, but even better would be to get rid of the vmap keyword IMO. IIRC it only exists because I couldn't manage to get a conflict free grammar together, but it would be worth another try.
Quoted 10 lines · Patrick McHardy
Quoted 9 lines · Pablo Neira Ayuso
% nft list table filter
table ip filter { ... chain output { ... ip saddr map { 1.1.1.1 => accept} } }
Quoted 6 lines
Quoted 2 lines
It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in
map_expr_print().The fix is fine of course, but even better would be to get rid of the vmap keyword IMO. IIRC it only exists because I couldn't manage to get a conflict free grammar together, but it would be worth another try.
Actually this works fine. Is there agreement on removing the VMAP keyword? If so we should do it before the 0.099 release.
src/parser.y +1 -2
@@ -150,7 +150,6 @@ static void location_update(struct location *loc, struct location *rhs, int n) %token DASH "-" %token AT "@" %token ARROW "=>" -%token VMAP "vmap" %token INCLUDE "include" %token DEFINE "define"
@@ -1273,7 +1272,7 @@ map_expr : concat_expr MAP expr } ; -verdict_map_expr : concat_expr VMAP expr +verdict_map_expr : concat_expr MAP expr { $$ = map_expr_alloc(&@$, $1, $3); }
src/scanner.l +0 -1
@@ -210,7 +210,6 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "$" { return '$'; } "=" { return '='; } "=>" { return ARROW; } -"vmap" { return VMAP; } "include" { return INCLUDE; } "define" { return DEFINE; }
Pablo Neira Ayuso
maintainerQuoted 14 lines · Patrick McHardy
Quoted 13 lines · Patrick McHardy
Quoted 11 lines · Pablo Neira Ayuso
% nft list table filter
table ip filter { ... chain output { ... ip saddr map { 1.1.1.1 => accept} } }It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in
map_expr_print().
Quoted 6 lines
Quoted 3 lines
The fix is fine of course, but even better would be to get rid of the vmap keyword IMO. IIRC it only exists because I couldn't manage to get a conflict free grammar together, but it would be worth another try.
Actually this works fine. Is there agreement on removing the VMAP keyword? If so we should do it before the 0.099 release.
Sure, go ahead. I like it :) and it's consistent with other data maps.
Quoted 15 lines · Pablo Neira Ayuso
Quoted 14 lines · Patrick McHardy
Quoted 13 lines · Patrick McHardy
Quoted 11 lines · Pablo Neira Ayuso
% nft list table filter
table ip filter { ... chain output { ... ip saddr map { 1.1.1.1 => accept} } }It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in
map_expr_print().
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
The fix is fine of course, but even better would be to get rid of the vmap keyword IMO. IIRC it only exists because I couldn't manage to get a conflict free grammar together, but it would be worth another try.
Actually this works fine. Is there agreement on removing the VMAP keyword? If so we should do it before the 0.099 release.
Sure, go ahead. I like it :) and it's consistent with other data maps.
Crap, I missed that it actually does introduce conflicts. Will try to solve them or revert that patch.
Pablo Neira Ayuso
maintainerQuoted 11 lines · Pablo Neira Ayuso
% nft list table filter
table ip filter { ... chain output { ... ip saddr map { 1.1.1.1 => accept} } }It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in
map_expr_print().
Spinning over the list of pending stuff in my notepad before the release.
I think it's not so bad if we keep the 'vmap' for verdict maps. This can just become a synonym of 'map' if we ever find the way to make it work without ambiguity complains from the parser.
Quoted 29 lines
Signed-off-by Pablo Neira Ayuso <[email protected]>--- src/expression.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)src/expression.c +5
-1@@ -689,7 +689,11 @@ struct expr *mapping_expr_alloc(const struct location *loc,static void map_expr_print (const struct expr *expr) {expr_print (expr->map); -printf (" map " ); +if (expr->mappings->ops->type ==EXPR_SET_REF && + expr->mappings->set->datatype->type ==TYPE_VERDICT ) +printf (" vmap " ); +else +printf (" map " );expr_print (expr->mappings); }Signature · 6 lines
1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · Pablo Neira Ayuso
Quoted 11 lines · Pablo Neira Ayuso
% nft list table filter
table ip filter { ... chain output { ... ip saddr map { 1.1.1.1 => accept} } }It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in
map_expr_print().
Quoted 6 lines
Spinning over the list of pending stuff in my notepad before the release.
I think it's not so bad if we keep the 'vmap' for verdict maps. This can just become a synonym of 'map' if we ever find the way to make it work without ambiguity complains from the parser.
Yes, absolutely. We should just add your patch to fix the output for now.
Quoted 14 lines · Patrick McHardy
Quoted 13 lines · Pablo Neira Ayuso
Quoted 11 lines · Pablo Neira Ayuso
% nft list table filter
table ip filter { ... chain output { ... ip saddr map { 1.1.1.1 => accept} } }It displays 'map' instead of 'vmap'. Fix it by checking the mapping type in
map_expr_print().
Quoted 8 lines
Quoted 6 lines
Spinning over the list of pending stuff in my notepad before the release.
I think it's not so bad if we keep the 'vmap' for verdict maps. This can just become a synonym of 'map' if we ever find the way to make it work without ambiguity complains from the parser.
Yes, absolutely. We should just add your patch to fix the output for now.
Pushed to master.