diff mbox series

[nft] parser: allow for string raw payload base

Message ID 20211116110937.630891-1-pablo@netfilter.org
State Accepted
Delegated to: Pablo Neira
Headers show
Series [nft] parser: allow for string raw payload base | expand

Commit Message

Pablo Neira Ayuso Nov. 16, 2021, 11:09 a.m. UTC
Remove new 'ih' token, allow to represent the raw payload base with a
string instead.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/parser_bison.y | 13 +++++++++++--
 src/scanner.l      |  1 -
 2 files changed, 11 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/src/parser_bison.y b/src/parser_bison.y
index eb89a58989e2..81d75ecb2fe8 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -318,7 +318,6 @@  int nft_lex(void *, void *, void *);
 %token LL_HDR			"ll"
 %token NETWORK_HDR		"nh"
 %token TRANSPORT_HDR		"th"
-%token INNER_HDR		"ih"
 
 %token BRIDGE			"bridge"
 
@@ -5261,7 +5260,17 @@  payload_raw_expr	:	AT	payload_base_spec	COMMA	NUM	COMMA	NUM
 payload_base_spec	:	LL_HDR		{ $$ = PROTO_BASE_LL_HDR; }
 			|	NETWORK_HDR	{ $$ = PROTO_BASE_NETWORK_HDR; }
 			|	TRANSPORT_HDR	{ $$ = PROTO_BASE_TRANSPORT_HDR; }
-			|	INNER_HDR	{ $$ = PROTO_BASE_INNER_HDR; }
+			|	STRING
+			{
+				if (!strcmp($1, "ih")) {
+					$$ = PROTO_BASE_INNER_HDR;
+				} else {
+					erec_queue(error(&@1, "unknown raw payload base"), state->msgs);
+					xfree($1);
+					YYERROR;
+				}
+				xfree($1);
+			}
 			;
 
 eth_hdr_expr		:	ETHER	eth_hdr_field	close_scope_eth
diff --git a/src/scanner.l b/src/scanner.l
index 5d263f9dc8b1..6cc7778dd85e 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -414,7 +414,6 @@  addrstring	({macaddr}|{ip4addr}|{ip6addr})
 "ll"			{ return LL_HDR; }
 "nh"			{ return NETWORK_HDR; }
 "th"			{ return TRANSPORT_HDR; }
-"ih"			{ return INNER_HDR; }
 
 "bridge"		{ return BRIDGE; }