* [PATCH nft] meta: introduce broute expression
@ 2023-02-23 20:29 Sriram Yagnaraman
2023-02-23 23:06 ` Florian Westphal
0 siblings, 1 reply; 2+ messages in thread
From: Sriram Yagnaraman @ 2023-02-23 20:29 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal, Pablo Neira Ayuso, Sriram Yagnaraman
nft userspace tool support broute meta statment proposed in [1].
[1]: https://patchwork.ozlabs.org/project/netfilter-devel/patch/20230223202246.15640-1-sriram.yagnaraman@est.tech/
---
include/linux/netfilter/nf_tables.h | 2 ++
src/meta.c | 2 ++
src/parser_bison.y | 2 ++
src/scanner.l | 1 +
4 files changed, 7 insertions(+)
diff --git a/include/linux/netfilter/nf_tables.h b/include/linux/netfilter/nf_tables.h
index ff677f3a..9c6f02c2 100644
--- a/include/linux/netfilter/nf_tables.h
+++ b/include/linux/netfilter/nf_tables.h
@@ -931,6 +931,7 @@ enum nft_exthdr_attributes {
* @NFT_META_TIME_HOUR: hour of day (in seconds)
* @NFT_META_SDIF: slave device interface index
* @NFT_META_SDIFNAME: slave device interface name
+ * @NFT_META_BRI_BROUTE: packet br_netfilter_broute bit
*/
enum nft_meta_keys {
NFT_META_LEN,
@@ -969,6 +970,7 @@ enum nft_meta_keys {
NFT_META_TIME_HOUR,
NFT_META_SDIF,
NFT_META_SDIFNAME,
+ NFT_META_BRI_BROUTE,
__NFT_META_IIFTYPE,
};
diff --git a/src/meta.c b/src/meta.c
index 013e8cba..6f9ed06b 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -698,6 +698,8 @@ const struct meta_template meta_templates[] = {
[NFT_META_SDIFNAME] = META_TEMPLATE("sdifname", &ifname_type,
IFNAMSIZ * BITS_PER_BYTE,
BYTEORDER_HOST_ENDIAN),
+ [NFT_META_BRI_BROUTE] = META_TEMPLATE("broute", &integer_type,
+ 1 , BYTEORDER_HOST_ENDIAN),
};
static bool meta_key_is_unqualified(enum nft_meta_keys key)
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 824e5db8..e3440b2b 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -528,6 +528,7 @@ int nft_lex(void *, void *, void *);
%token OIFGROUP "oifgroup"
%token CGROUP "cgroup"
%token TIME "time"
+%token BROUTE "broute"
%token CLASSID "classid"
%token NEXTHOP "nexthop"
@@ -5122,6 +5123,7 @@ meta_key_unqualified : MARK { $$ = NFT_META_MARK; }
| TIME { $$ = NFT_META_TIME_NS; }
| DAY { $$ = NFT_META_TIME_DAY; }
| HOUR { $$ = NFT_META_TIME_HOUR; }
+ | BROUTE { $$ = NFT_META_BRI_BROUTE; }
;
meta_stmt : META meta_key SET stmt_expr close_scope_meta
diff --git a/src/scanner.l b/src/scanner.l
index bc5b5b62..f1ffa053 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -721,6 +721,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
"iifgroup" { return IIFGROUP; }
"oifgroup" { return OIFGROUP; }
"cgroup" { return CGROUP; }
+"broute" { return BROUTE; }
<SCANSTATE_EXPR_RT>{
"nexthop" { return NEXTHOP; }
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nft] meta: introduce broute expression
2023-02-23 20:29 [PATCH nft] meta: introduce broute expression Sriram Yagnaraman
@ 2023-02-23 23:06 ` Florian Westphal
0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2023-02-23 23:06 UTC (permalink / raw)
To: Sriram Yagnaraman; +Cc: netfilter-devel, Florian Westphal, Pablo Neira Ayuso
Sriram Yagnaraman <sriram.yagnaraman@est.tech> wrote:
> static bool meta_key_is_unqualified(enum nft_meta_keys key)
> diff --git a/src/parser_bison.y b/src/parser_bison.y
> index 824e5db8..e3440b2b 100644
> --- a/src/parser_bison.y
> +++ b/src/parser_bison.y
> @@ -528,6 +528,7 @@ int nft_lex(void *, void *, void *);
> %token OIFGROUP "oifgroup"
> %token CGROUP "cgroup"
> %token TIME "time"
> +%token BROUTE "broute"
I think you don't need to add a new token.
meta_key_parse() should pick this up from the meta_template
array automatically.
> index bc5b5b62..f1ffa053 100644
> --- a/src/scanner.l
> +++ b/src/scanner.l
> @@ -721,6 +721,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
> "iifgroup" { return IIFGROUP; }
> "oifgroup" { return OIFGROUP; }
> "cgroup" { return CGROUP; }
> +"broute" { return BROUTE; }
and this should not be needed either.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-23 23:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-23 20:29 [PATCH nft] meta: introduce broute expression Sriram Yagnaraman
2023-02-23 23:06 ` Florian Westphal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.