Skip to contentSkip to conversation

parser_bison: allow to use mark as datatype for maps and sets

PATCH In review Pablo Neira Ayuso 3 participants 5 messages Jun 16, 2015 – Jun 17, 2015 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 parser_bison: allow to use mark as datatype for maps and sets

Update the grammar to accept a MARK token as datatype.

---
@Patrick: I think you prefer this update rather than renaming this to packetmark. This comes in response to this patch proposal:
http://patchwork.ozlabs.org/patch/485058/

 src/parser_bison.y |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
src/parser_bison.y +10 -6
index 89874e9..6f47745 100644
@@ -398,12 +398,12 @@ static void location_update(struct location *loc, struct location *rhs, int n)
 %token XML			"xml"
 %token JSON			"json"
 
-%type <string>			identifier string comment_spec
-%destructor { xfree($$); }	identifier string comment_spec
+%type <string>			identifier type_identifier string comment_spec
+%destructor { xfree($$); }	identifier type_identifier string comment_spec
 
 %type <val>			time_spec
 
-%type <val>			type_identifier
+%type <val>			type_identifier_list
 %type <datatype>		data_type
 
 %type <cmd>			line
@@ -1028,7 +1028,7 @@ set_policy_spec		:	PERFORMANCE	{ $$ = NFT_SET_POL_PERFORMANCE; }
 			|	MEMORY		{ $$ = NFT_SET_POL_MEMORY; }
 			;
 
-data_type		:	type_identifier
+data_type		:	type_identifier_list
 			{
 				if ($1 & ~TYPE_MASK)
 					$$ = concat_type_alloc($1);
@@ -1037,7 +1037,7 @@ data_type		:	type_identifier
 			}
 			;
 
-type_identifier		:	identifier
+type_identifier_list	:	type_identifier
 			{
 				const struct datatype *dtype = datatype_lookup_byname($1);
 				if (dtype == NULL) {
@@ -1047,7 +1047,7 @@ type_identifier		:	identifier
 				}
 				$$ = dtype->type;
 			}
-			|	type_identifier	DOT		identifier
+			|	type_identifier_list	DOT	type_identifier
 			{
 				const struct datatype *dtype = datatype_lookup_byname($3);
 				if (dtype == NULL) {
@@ -1059,6 +1059,10 @@ type_identifier		:	identifier
 			}
 			;
 
+type_identifier		:	STRING	{ $$ = $1; }
+			|	MARK	{ $$ = xstrdup("mark"); }
+			;
+
 hook_spec		:	TYPE		STRING		HOOK		STRING		PRIORITY	NUM
 			{
 				$<chain>0->type		= chain_type_name_lookup($2);
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 8 lines · Pablo Neira Ayuso

Update the grammar to accept a MARK token as datatype.

---
@Patrick: I think you prefer this update rather than renaming this to packetmark. This comes in response to this patch proposal:
http://patchwork.ozlabs.org/patch/485058/

Yes, I think this is preferrable since the mark type can be used for things besides packet marking, f.i. conntracks.

author maintainer
#2 lore raw
Quoted 10 lines · Patrick McHardy
Quoted 8 lines · Pablo Neira Ayuso

Update the grammar to accept a MARK token as datatype.

---
@Patrick: I think you prefer this update rather than renaming this to packetmark. This comes in response to this patch proposal:
http://patchwork.ozlabs.org/patch/485058/

Quoted 2 lines

Yes, I think this is preferrable since the mark type can be used for things besides packet marking, f.i. conntracks.

Ok, then I'll push this patch, thanks!

#3 lore raw
Quoted 4 lines
Quoted 2 lines

Yes, I think this is preferrable since the mark type can be used for things besides packet marking, f.i. conntracks.

Ok, then I'll push this patch, thanks!

Great, marking by named map is now perfectly usuable.

One last (cosmetic reminder) thing, could the last occurence of "packetmark" type name in documentation also be replaced with "mark", for consistency?

in doc/nft.xml, lines 988, 1887.

Many thanks to you both.
-mk

author maintainer
#4 lore raw
Quoted 6 lines · Miroslav Kratochvil
Quoted 4 lines
Quoted 2 lines

Yes, I think this is preferrable since the mark type can be used for things besides packet marking, f.i. conntracks.

Ok, then I'll push this patch, thanks!

Quoted 7 lines

Great, marking by named map is now perfectly usuable.

One last (cosmetic reminder) thing, could the last occurence of "packetmark" type name in documentation also be replaced with "mark", for consistency?

in doc/nft.xml, lines 988, 1887.

Would you send us a Signed-off-by patch that I can apply via git am?

Thanks.