netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH 25/26] scanner: meta: Move to own scope
Date: Sat, 19 Feb 2022 14:28:13 +0100	[thread overview]
Message-ID: <20220219132814.30823-26-phil@nwl.cc> (raw)
In-Reply-To: <20220219132814.30823-1-phil@nwl.cc>

This allows to isolate 'length' and 'protocol' keywords shared by other
scopes as well.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 include/parser.h   | 1 +
 src/parser_bison.y | 9 +++++----
 src/scanner.l      | 7 ++++---
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/include/parser.h b/include/parser.h
index 0dcc30be64780..bc42229c1a83b 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -41,6 +41,7 @@ enum startcond_type {
 	PARSER_SC_IP,
 	PARSER_SC_IP6,
 	PARSER_SC_LIMIT,
+	PARSER_SC_META,
 	PARSER_SC_POLICY,
 	PARSER_SC_QUOTA,
 	PARSER_SC_SCTP,
diff --git a/src/parser_bison.y b/src/parser_bison.y
index c6f5d4947356c..cd6f22ef8e915 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -951,6 +951,7 @@ close_scope_import	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_IMPORT
 close_scope_ipsec	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_IPSEC); };
 close_scope_list	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_LIST); };
 close_scope_limit	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_LIMIT); };
+close_scope_meta	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_META); };
 close_scope_mh		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_MH); };
 close_scope_monitor	: { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_MONITOR); };
 close_scope_nat		: { scanner_pop_start_cond(nft->scanner, PARSER_SC_STMT_NAT); };
@@ -4912,7 +4913,7 @@ chain_expr		:	variable_expr
 			}
 			;
 
-meta_expr		:	META	meta_key
+meta_expr		:	META	meta_key	close_scope_meta
 			{
 				$$ = meta_expr_alloc(&@$, $2);
 			}
@@ -4920,7 +4921,7 @@ meta_expr		:	META	meta_key
 			{
 				$$ = meta_expr_alloc(&@$, $1);
 			}
-			|	META	STRING
+			|	META	STRING	close_scope_meta
 			{
 				struct error_record *erec;
 				unsigned int key;
@@ -4973,7 +4974,7 @@ meta_key_unqualified	:	MARK		{ $$ = NFT_META_MARK; }
 			|       HOUR		{ $$ = NFT_META_TIME_HOUR; }
 			;
 
-meta_stmt		:	META	meta_key	SET	stmt_expr
+meta_stmt		:	META	meta_key	SET	stmt_expr	close_scope_meta
 			{
 				switch ($2) {
 				case NFT_META_SECMARK:
@@ -4997,7 +4998,7 @@ meta_stmt		:	META	meta_key	SET	stmt_expr
 			{
 				$$ = meta_stmt_alloc(&@$, $1, $3);
 			}
-			|	META	STRING	SET	stmt_expr
+			|	META	STRING	SET	stmt_expr	close_scope_meta
 			{
 				struct error_record *erec;
 				unsigned int key;
diff --git a/src/scanner.l b/src/scanner.l
index 8d4907dc1fdfe..be01c6f3b3bc6 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -207,6 +207,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 %s SCANSTATE_IP
 %s SCANSTATE_IP6
 %s SCANSTATE_LIMIT
+%s SCANSTATE_META
 %s SCANSTATE_POLICY
 %s SCANSTATE_QUOTA
 %s SCANSTATE_SCTP
@@ -503,14 +504,14 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 	"dscp"			{ return DSCP; }
 }
 "ecn"			{ return ECN; }
-"length"		{ return LENGTH; }
+<SCANSTATE_EXPR_UDP,SCANSTATE_IP,SCANSTATE_IP6,SCANSTATE_META,SCANSTATE_TCP,SCANSTATE_SCTP,SCANSTATE_EXPR_SCTP_CHUNK>"length"		{ return LENGTH; }
 <SCANSTATE_EXPR_FRAG,SCANSTATE_IP>{
 	"frag-off"		{ return FRAG_OFF; }
 }
 <SCANSTATE_EXPR_OSF,SCANSTATE_IP>{
 	"ttl"			{ return TTL; }
 }
-"protocol"		{ return PROTOCOL; }
+<SCANSTATE_CT,SCANSTATE_IP,SCANSTATE_META,SCANSTATE_TYPE>"protocol"		{ return PROTOCOL; }
 <SCANSTATE_EXPR_MH,SCANSTATE_EXPR_UDP,SCANSTATE_EXPR_UDPLITE,SCANSTATE_ICMP,SCANSTATE_IGMP,SCANSTATE_IP,SCANSTATE_SCTP,SCANSTATE_TCP>{
 	"checksum"		{ return CHECKSUM; }
 }
@@ -688,7 +689,7 @@ addrstring	({macaddr}|{ip4addr}|{ip6addr})
 
 "mh"			{ scanner_push_start_cond(yyscanner, SCANSTATE_EXPR_MH); return MH; }
 
-"meta"			{ return META; }
+"meta"			{ scanner_push_start_cond(yyscanner, SCANSTATE_META); return META; }
 "mark"			{ return MARK; }
 "iif"			{ return IIF; }
 "iifname"		{ return IIFNAME; }
-- 
2.34.1


  parent reply	other threads:[~2022-02-19 13:29 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-19 13:27 [nft PATCH 00/26] scanner: Some fixes, many new scopes Phil Sutter
2022-02-19 13:27 ` [nft PATCH 01/26] tests: py: Test connlimit statement Phil Sutter
2022-02-19 13:27 ` [nft PATCH 02/26] scanner: Move 'maps' keyword into list cmd scope Phil Sutter
2022-02-19 13:27 ` [nft PATCH 03/26] scanner: Some time units are only used in limit scope Phil Sutter
2022-02-20  0:38   ` Pablo Neira Ayuso
2022-02-20  0:40     ` Pablo Neira Ayuso
2022-02-20  0:44     ` Phil Sutter
2022-02-19 13:27 ` [nft PATCH 04/26] scanner: rt: Move seg-left keyword into scope Phil Sutter
2022-02-19 13:27 ` [nft PATCH 05/26] scanner: icmp{,v6}: Move to own scope Phil Sutter
2022-02-19 13:27 ` [nft PATCH 06/26] scanner: igmp: " Phil Sutter
2022-02-19 13:27 ` [nft PATCH 07/26] scanner: tcp: " Phil Sutter
2022-02-19 13:27 ` [nft PATCH 08/26] scanner: synproxy: " Phil Sutter
2022-02-19 13:27 ` [nft PATCH 09/26] scanner: comp: " Phil Sutter
2022-02-19 13:27 ` [nft PATCH 10/26] scanner: udp{,lite}: " Phil Sutter
2022-02-19 13:27 ` [nft PATCH 11/26] scanner: dccp, th: Move to own scopes Phil Sutter
2022-02-19 13:28 ` [nft PATCH 12/26] scanner: osf: Move to own scope Phil Sutter
2022-02-19 13:28 ` [nft PATCH 13/26] scanner: ah, esp: Move to own scopes Phil Sutter
2022-02-19 13:28 ` [nft PATCH 14/26] scanner: dst, frag, hbh, mh: " Phil Sutter
2022-02-19 13:28 ` [nft PATCH 15/26] scanner: type: Move to own scope Phil Sutter
2022-02-19 13:28 ` [nft PATCH 16/26] scanner: rt: Extend scope over rt0, rt2 and srh Phil Sutter
2022-02-19 13:28 ` [nft PATCH 17/26] scanner: monitor: Move to own Scope Phil Sutter
2022-02-19 13:28 ` [nft PATCH 18/26] scanner: reset: move " Phil Sutter
2022-02-19 13:28 ` [nft PATCH 19/26] scanner: import, export: Move to own scopes Phil Sutter
2022-02-19 13:28 ` [nft PATCH 20/26] scanner: reject: Move to own scope Phil Sutter
2022-02-19 13:28 ` [nft PATCH 21/26] scanner: flags: move " Phil Sutter
2022-02-19 13:28 ` [nft PATCH 22/26] scanner: policy: " Phil Sutter
2022-02-19 13:28 ` [nft PATCH 23/26] scanner: nat: Move " Phil Sutter
2022-02-19 13:28 ` [nft PATCH 24/26] scanner: at: " Phil Sutter
2022-02-19 13:28 ` Phil Sutter [this message]
2022-02-19 13:28 ` [nft PATCH 26/26] scanner: dup, fwd, tproxy: Move to own scopes Phil Sutter
2022-02-20  0:34 ` [nft PATCH 00/26] scanner: Some fixes, many new scopes Pablo Neira Ayuso
2022-02-20  0:46   ` Phil Sutter
2022-02-28 21:40   ` Pablo Neira Ayuso
2022-03-01 17:24     ` Phil Sutter
2022-03-01 21:07       ` Pablo Neira Ayuso
2022-03-02 13:50         ` Phil Sutter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220219132814.30823-26-phil@nwl.cc \
    --to=phil@nwl.cc \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).