diff mbox series

[nft,1/5] parser_bison: Fix for chain prio name 'out'

Message ID 20180925122416.15224-2-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series Fix and improve for 0021prio_0 in tests/shell | expand

Commit Message

Phil Sutter Sept. 25, 2018, 12:24 p.m. UTC
Since 'out' is defined as a keyword in scanner.l, using it as a chain
priority name without quotes is not possible. Fix this by introducing
'extended_prio_name' in bison which may be either a string (as before)
or OUT, which is then converted into a string.

Fixes: c8a0e8c90e2d1 ("src: Set/print standard chain prios with textual names")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/parser_bison.y | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/parser_bison.y b/src/parser_bison.y
index 1c68b4f4420e7..831090b66e8ec 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -541,6 +541,8 @@  int nft_lex(void *, void *, void *);
 %destructor { handle_free(&$$); } set_spec setid_spec set_identifier obj_spec objid_spec obj_identifier
 %type <val>			family_spec family_spec_explicit chain_policy int_num
 %type <prio_spec>		extended_prio_spec prio_spec
+%type <string>			extended_prio_name
+%destructor { xfree($$); }	extended_prio_name
 
 %type <string>			dev_spec quota_unit
 %destructor { xfree($$); }	dev_spec quota_unit
@@ -1861,26 +1863,33 @@  prio_spec		:	PRIORITY extended_prio_spec
 			}
 			;
 
+extended_prio_name	:	OUT
+			{
+				$$ = strdup("out");
+			}
+			|	STRING
+			;
+
 extended_prio_spec	:	int_num
 			{
 				struct prio_spec spec = {0};
 				spec.num = $1;
 				$$ = spec;
 			}
-			|	STRING
+			|	extended_prio_name
 			{
 				struct prio_spec spec = {0};
 				spec.str = $1;
 				$$ = spec;
 			}
-			|	STRING PLUS NUM
+			|	extended_prio_name PLUS NUM
 			{
 				struct prio_spec spec = {0};
 				spec.num = $3;
 				spec.str = $1;
 				$$ = spec;
 			}
-			|	STRING DASH NUM
+			|	extended_prio_name DASH NUM
 			{
 				struct prio_spec spec = {0};
 				spec.num = -$3;