This allows users to specify named sets by using the expression directly, rather than having to lookup the data type to use, or the needed size via 'nft describe". Example: table filter { set allowed_dports { type typeof(tcp dport); } map nametomark { type typeof(osf name) : typeof(meta mark); } map port2helper { type ipv4_addr . inet_service : typeof(ct helper); } } Currently, listing such a table will lose the typeof() expression: nft will print the datatype instead, just as if "type inet_service" would have been used. For types with non-fixed widths, the new "type, width" format added in previous patch is used. Signed-off-by: Florian Westphal <fw@xxxxxxxxx> --- src/parser_bison.y | 5 +++++ src/scanner.l | 1 + 2 files changed, 6 insertions(+) diff --git a/src/parser_bison.y b/src/parser_bison.y index ee169fbac194..876050ba6863 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -192,6 +192,7 @@ int nft_lex(void *, void *, void *); %token DEFINE "define" %token REDEFINE "redefine" %token UNDEFINE "undefine" +%token TYPEOF "typeof" %token FIB "fib" @@ -1844,6 +1845,10 @@ data_type_atom_expr : type_identifier $3, NULL); xfree($1); } + | TYPEOF '(' primary_expr ')' + { + $$ = $3; + } ; data_type_expr : data_type_atom_expr diff --git a/src/scanner.l b/src/scanner.l index c1adcbddbd73..cd563aa0ca1f 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -243,6 +243,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr}) "define" { return DEFINE; } "redefine" { return REDEFINE; } "undefine" { return UNDEFINE; } +"typeof" { return TYPEOF; } "describe" { return DESCRIBE; } -- 2.21.0