]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser: allow typeof in objref maps
authorFlorian Westphal <fw@strlen.de>
Thu, 29 Feb 2024 10:41:23 +0000 (11:41 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 29 Feb 2024 23:38:33 +0000 (00:38 +0100)
Its currently not possible to declare a map that
stores object references with the "typeof" keyword, e.g.

map m {
type ipv4_addr : limit

will work, but

map m {
typeof ip saddr : limit

will give a syntax error ("unexpected limit").
Followup pach will add support for listing side too.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/parser_bison.y

index cba37c686f66ca9c99ab35031011e583f6b55492..cd1dc658882dc996f76b3b5b2b332485b5285461 100644 (file)
@@ -2340,6 +2340,15 @@ map_block                :       /* empty */     { $$ = $<set>-1; }
                                $1->flags  |= NFT_SET_OBJECT;
                                $$ = $1;
                        }
+                       |       map_block       TYPEOF
+                                               typeof_expr     COLON   map_block_obj_type
+                                               stmt_separator
+                       {
+                               $1->key = $3;
+                               $1->objtype = $5;
+                               $1->flags  |= NFT_SET_OBJECT;
+                               $$ = $1;
+                       }
                        |       map_block       FLAGS           set_flag_list   stmt_separator
                        {
                                $1->flags |= $3;