Skip to contentSkip to conversation

expression: fix output of verdict maps

PATCH In review Pablo Neira Ayuso 2 participants 8 messages Jan 13, 2014 – Jan 16, 2014 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 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
index 71154cc..97481d0 100644
@@ -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
#1 lore raw
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.

#2 lore raw
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
index 7c18875..e5610e5 100644
@@ -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
index 0b8abac..5a5ec72 100644
@@ -210,7 +210,6 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 "$"			{ return '$'; }
 "="			{ return '='; }
 "=>"			{ return ARROW; }
-"vmap"			{ return VMAP; }
 
 "include"		{ return INCLUDE; }
 "define"		{ return DEFINE; }
author maintainer
#3 lore raw
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 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.

#4 lore raw
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.

author maintainer
#5 lore raw
In reply to 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().

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
---
 src/expression.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/expression.c +5 -1
index 71154cc..97481d0 100644
@@ -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
#6 lore raw
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.

author maintainer Applied
#7 lore raw
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.