* [PATCH nft] parser: deduplicate map with data interval
@ 2023-08-02 15:48 Florian Westphal
0 siblings, 0 replies; only message in thread
From: Florian Westphal @ 2023-08-02 15:48 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
Its copypasted, the copy is same as original
except that it specifies a map key that maps to an interval.
Add an exra rule that returns 0 or EXPR_F_INTERVAL, then
use that in a single rule.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/parser_bison.y | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 36172713470a..5637829332ce 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -727,7 +727,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 <val> map_block_obj_type map_block_data_interval
%type <flowtable> flowtable_block_alloc flowtable_block
%destructor { flowtable_free($$); } flowtable_block_alloc
@@ -2225,6 +2225,10 @@ map_block_obj_type : COUNTER close_scope_counter { $$ = NFT_OBJECT_COUNTER; }
| SYNPROXY close_scope_synproxy { $$ = NFT_OBJECT_SYNPROXY; }
;
+map_block_data_interval : INTERVAL { $$ = EXPR_F_INTERVAL; }
+ | { $$ = 0; }
+ ;
+
map_block : /* empty */ { $$ = $<set>-1; }
| map_block common_block
| map_block stmt_separator
@@ -2234,22 +2238,12 @@ map_block : /* empty */ { $$ = $<set>-1; }
$$ = $1;
}
| map_block TYPE
- data_type_expr COLON data_type_expr
- stmt_separator close_scope_type
- {
- $1->key = $3;
- $1->data = $5;
-
- $1->flags |= NFT_SET_MAP;
- $$ = $1;
- }
- | map_block TYPE
- data_type_expr COLON INTERVAL data_type_expr
+ data_type_expr COLON map_block_data_interval data_type_expr
stmt_separator close_scope_type
{
$1->key = $3;
$1->data = $6;
- $1->data->flags |= EXPR_F_INTERVAL;
+ $1->data->flags |= $5;
$1->flags |= NFT_SET_MAP;
$$ = $1;
--
2.41.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-02 15:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-02 15:48 [PATCH nft] parser: deduplicate map with data interval Florian Westphal
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).