netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 2/3] parser: compact map RHS type
Date: Thu,  4 Mar 2021 02:07:34 +0100	[thread overview]
Message-ID: <20210304010735.28683-2-fw@strlen.de> (raw)
In-Reply-To: <20210304010735.28683-1-fw@strlen.de>

Similar to previous patch, we can avoid duplication.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 src/parser_bison.y | 38 +++++++++-----------------------------
 1 file changed, 9 insertions(+), 29 deletions(-)

diff --git a/src/parser_bison.y b/src/parser_bison.y
index 363569ffacb6..c4f3e341333d 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -627,6 +627,7 @@ int nft_lex(void *, void *, void *);
 
 %type <set>			map_block_alloc map_block
 %destructor { set_free($$); }	map_block_alloc
+%type <val>			map_block_obj_type
 
 %type <flowtable>		flowtable_block_alloc flowtable_block
 %destructor { flowtable_free($$); }	flowtable_block_alloc
@@ -1877,6 +1878,12 @@ map_block_alloc		:	/* empty */
 			}
 			;
 
+map_block_obj_type	:	COUNTER	{ $$ = NFT_OBJECT_COUNTER; }
+			|	QUOTA { $$ = NFT_OBJECT_QUOTA; }
+			|	LIMIT { $$ = NFT_OBJECT_LIMIT; }
+			|	SECMARK { $$ = NFT_OBJECT_SECMARK; }
+			;
+
 map_block		:	/* empty */	{ $$ = $<set>-1; }
 			|	map_block	common_block
 			|	map_block	stmt_separator
@@ -1930,38 +1937,11 @@ map_block		:	/* empty */	{ $$ = $<set>-1; }
 				$$ = $1;
 			}
 			|	map_block	TYPE
-						data_type_expr	COLON	COUNTER
-						stmt_separator
-			{
-				$1->key = $3;
-				$1->objtype = NFT_OBJECT_COUNTER;
-				$1->flags  |= NFT_SET_OBJECT;
-				$$ = $1;
-			}
-			|	map_block	TYPE
-						data_type_expr	COLON	QUOTA
-						stmt_separator
-			{
-				$1->key = $3;
-				$1->objtype = NFT_OBJECT_QUOTA;
-				$1->flags  |= NFT_SET_OBJECT;
-				$$ = $1;
-			}
-			|	map_block	TYPE
-						data_type_expr	COLON	LIMIT
-						stmt_separator
-			{
-				$1->key = $3;
-				$1->objtype = NFT_OBJECT_LIMIT;
-				$1->flags  |= NFT_SET_OBJECT;
-				$$ = $1;
-			}
-			|	map_block	TYPE
-						data_type_expr	COLON	SECMARK
+						data_type_expr	COLON	map_block_obj_type
 						stmt_separator
 			{
 				$1->key = $3;
-				$1->objtype = NFT_OBJECT_SECMARK;
+				$1->objtype = $5;
 				$1->flags  |= NFT_SET_OBJECT;
 				$$ = $1;
 			}
-- 
2.26.2


  reply	other threads:[~2021-03-04  1:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-04  1:07 [PATCH nft 1/3] parser: squash duplicated spec/specid rules Florian Westphal
2021-03-04  1:07 ` Florian Westphal [this message]
2021-03-05 20:16   ` [PATCH nft 2/3] parser: compact map RHS type Pablo Neira Ayuso
2021-03-04  1:07 ` [PATCH nft 3/3] parser: compact ct obj list types Florian Westphal

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=20210304010735.28683-2-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.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).