[PATCH nft] src: don't need keyword for log level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We can handle log levels without keywords in our grammar, use string
instead.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 src/parser_bison.y | 32 ++++++++++++++++++++++++--------
 src/scanner.l      |  8 --------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/parser_bison.y b/src/parser_bison.y
index baf0a539efa0..f582221a089e 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -1517,14 +1517,30 @@ log_arg			:	PREFIX			string
 			}
 			;
 
-level_type		:	LEVEL_EMERG	{ $$ = LOG_EMERG; }
-			|	LEVEL_ALERT	{ $$ = LOG_ALERT; }
-			|	LEVEL_CRIT	{ $$ = LOG_CRIT; }
-			|	LEVEL_ERR	{ $$ = LOG_ERR; }
-			|	LEVEL_WARN	{ $$ = LOG_WARNING; }
-			|	LEVEL_NOTICE	{ $$ = LOG_NOTICE; }
-			|	LEVEL_INFO	{ $$ = LOG_INFO; }
-			|	LEVEL_DEBUG	{ $$ = LOG_DEBUG; }
+level_type		:	string
+			{
+				if (!strcmp("emerg", $1))
+					$$ = LOG_EMERG;
+				else if (!strcmp("alert", $1))
+					$$ = LOG_ALERT;
+				else if (!strcmp("crit", $1))
+					$$ = LOG_CRIT;
+				else if (!strcmp("err", $1))
+					$$ = LOG_ERR;
+				else if (!strcmp("warning", $1))
+					$$ = LOG_WARNING;
+				else if (!strcmp("notice", $1))
+					$$ = LOG_NOTICE;
+				else if (!strcmp("info", $1))
+					$$ = LOG_INFO;
+				else if (!strcmp("debug", $1))
+					$$ = LOG_DEBUG;
+				else {
+					erec_queue(error(&@1, "invalid log level", $1),
+						   state->msgs);
+					YYERROR;
+				}
+			}
 			;
 
 limit_stmt		:	LIMIT	RATE	limit_mode	NUM	SLASH	time_unit	limit_burst
diff --git a/src/scanner.l b/src/scanner.l
index 8b5a383bd095..467954374f11 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -299,14 +299,6 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 "snaplen"		{ return SNAPLEN; }
 "queue-threshold"	{ return QUEUE_THRESHOLD; }
 "level"			{ return LEVEL; }
-"emerg"			{ return LEVEL_EMERG; }
-"alert"			{ return LEVEL_ALERT; }
-"crit"			{ return LEVEL_CRIT; }
-"err"			{ return LEVEL_ERR; }
-"warn"			{ return LEVEL_WARN; }
-"notice"		{ return LEVEL_NOTICE; }
-"info"			{ return LEVEL_INFO; }
-"debug"			{ return LEVEL_DEBUG; }
 
 "queue"			{ return QUEUE;}
 "num"			{ return QUEUENUM;}
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux