From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH nft 5/5] parser_bison: consolidate connlimit grammar rule for set elements
Date: Thu, 20 Mar 2025 13:10:59 +0100 [thread overview]
Message-ID: <20250320121059.328524-5-pablo@netfilter.org> (raw)
In-Reply-To: <20250320121059.328524-1-pablo@netfilter.org>
Define ct_limit_stmt_alloc and ct_limit_args to follow similar idiom
that is used for counters.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/parser_bison.y | 41 +++++++++++++++++++++--------------------
1 file changed, 21 insertions(+), 20 deletions(-)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index c26c99b05830..25fa69fb6f86 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -769,8 +769,8 @@ int nft_lex(void *, void *, void *);
%destructor { stmt_free($$); } stmt match_stmt verdict_stmt set_elem_stmt
%type <stmt> counter_stmt counter_stmt_alloc stateful_stmt last_stmt
%destructor { stmt_free($$); } counter_stmt counter_stmt_alloc stateful_stmt last_stmt
-%type <stmt> limit_stmt_alloc quota_stmt_alloc last_stmt_alloc
-%destructor { stmt_free($$); } limit_stmt_alloc quota_stmt_alloc last_stmt_alloc
+%type <stmt> limit_stmt_alloc quota_stmt_alloc last_stmt_alloc ct_limit_stmt_alloc
+%destructor { stmt_free($$); } limit_stmt_alloc quota_stmt_alloc last_stmt_alloc ct_limit_stmt_alloc
%type <stmt> objref_stmt objref_stmt_counter objref_stmt_limit objref_stmt_quota objref_stmt_ct objref_stmt_synproxy
%destructor { stmt_free($$); } objref_stmt objref_stmt_counter objref_stmt_limit objref_stmt_quota objref_stmt_ct objref_stmt_synproxy
@@ -3181,7 +3181,7 @@ objref_stmt : objref_stmt_counter
stateful_stmt : counter_stmt close_scope_counter
| limit_stmt close_scope_limit
| quota_stmt close_scope_quota
- | connlimit_stmt
+ | connlimit_stmt close_scope_ct
| last_stmt close_scope_last
;
@@ -3277,16 +3277,27 @@ verdict_map_list_member_expr: opt_newline set_elem_expr COLON verdict_expr opt_n
}
;
-connlimit_stmt : CT COUNT NUM close_scope_ct
+ct_limit_stmt_alloc : CT COUNT
{
$$ = connlimit_stmt_alloc(&@$);
- $$->connlimit.count = $3;
}
- | CT COUNT OVER NUM close_scope_ct
+ ;
+
+connlimit_stmt : ct_limit_stmt_alloc ct_limit_args
+ ;
+
+ct_limit_args : NUM
{
- $$ = connlimit_stmt_alloc(&@$);
- $$->connlimit.count = $4;
- $$->connlimit.flags = NFT_CONNLIMIT_F_INV;
+ assert($<stmt>0->type == STMT_CONNLIMIT);
+
+ $<stmt>0->connlimit.count = $1;
+ }
+ | OVER NUM
+ {
+ assert($<stmt>0->type == STMT_CONNLIMIT);
+
+ $<stmt>0->connlimit.count = $2;
+ $<stmt>0->connlimit.flags = NFT_CONNLIMIT_F_INV;
}
;
@@ -4629,17 +4640,7 @@ set_elem_stmt_list : set_elem_stmt
set_elem_stmt : counter_stmt close_scope_counter
| limit_stmt close_scope_limit
- | CT COUNT NUM close_scope_ct
- {
- $$ = connlimit_stmt_alloc(&@$);
- $$->connlimit.count = $3;
- }
- | CT COUNT OVER NUM close_scope_ct
- {
- $$ = connlimit_stmt_alloc(&@$);
- $$->connlimit.count = $4;
- $$->connlimit.flags = NFT_CONNLIMIT_F_INV;
- }
+ | connlimit_stmt close_scope_ct
| quota_stmt close_scope_quota
| last_stmt close_scope_last
;
--
2.30.2
prev parent reply other threads:[~2025-03-20 12:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 12:10 [PATCH nft 1/5] parser_bison: consolidate counter grammar rule for set elements Pablo Neira Ayuso
2025-03-20 12:10 ` [PATCH nft 2/5] parser_bison: consolidate limit " Pablo Neira Ayuso
2025-03-20 12:10 ` [PATCH nft 3/5] parser_bison: consolidate quota " Pablo Neira Ayuso
2025-03-20 12:10 ` [PATCH nft 4/5] parser_bison: consolidate last " Pablo Neira Ayuso
2025-03-20 12:10 ` Pablo Neira Ayuso [this message]
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=20250320121059.328524-5-pablo@netfilter.org \
--to=pablo@netfilter.org \
--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).