|
|
b59ec1 |
From 72a88a128ebb386307e9d3ef1b71cefa52c7a0af Mon Sep 17 00:00:00 2001
|
|
|
b59ec1 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
b59ec1 |
Date: Thu, 9 Feb 2023 10:27:57 +0100
|
|
|
b59ec1 |
Subject: [PATCH] netlink_delinearize: also postprocess OP_AND in set element
|
|
|
b59ec1 |
context
|
|
|
b59ec1 |
|
|
|
b59ec1 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2094887
|
|
|
b59ec1 |
Upstream Status: nftables commit b1e3ed0335d13
|
|
|
b59ec1 |
|
|
|
b59ec1 |
commit b1e3ed0335d13d206a2a2698a1ba189fa396dbf3
|
|
|
b59ec1 |
Author: Florian Westphal <fw@strlen.de>
|
|
|
b59ec1 |
Date: Mon Aug 1 13:03:18 2022 +0200
|
|
|
b59ec1 |
|
|
|
b59ec1 |
netlink_delinearize: also postprocess OP_AND in set element context
|
|
|
b59ec1 |
|
|
|
b59ec1 |
Pablo reports:
|
|
|
b59ec1 |
add rule netdev nt y update @macset { vlan id timeout 5s }
|
|
|
b59ec1 |
|
|
|
b59ec1 |
listing still shows the raw expression:
|
|
|
b59ec1 |
update @macset { @ll,112,16 & 0xfff timeout 5s }
|
|
|
b59ec1 |
|
|
|
b59ec1 |
so also cover the 'set element' case.
|
|
|
b59ec1 |
|
|
|
b59ec1 |
Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
b59ec1 |
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
|
b59ec1 |
|
|
|
b59ec1 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
b59ec1 |
---
|
|
|
b59ec1 |
include/netlink.h | 4 +++-
|
|
|
b59ec1 |
src/netlink_delinearize.c | 2 ++
|
|
|
b59ec1 |
.../sets/dumps/0070stacked_l2_headers.nft | 14 ++++++++++++++
|
|
|
b59ec1 |
3 files changed, 19 insertions(+), 1 deletion(-)
|
|
|
b59ec1 |
|
|
|
b59ec1 |
diff --git a/include/netlink.h b/include/netlink.h
|
|
|
b59ec1 |
index 71c888f..63d07ed 100644
|
|
|
b59ec1 |
--- a/include/netlink.h
|
|
|
b59ec1 |
+++ b/include/netlink.h
|
|
|
b59ec1 |
@@ -44,8 +44,10 @@ struct netlink_parse_ctx {
|
|
|
b59ec1 |
|
|
|
b59ec1 |
|
|
|
b59ec1 |
#define RULE_PP_IN_CONCATENATION (1 << 0)
|
|
|
b59ec1 |
+#define RULE_PP_IN_SET_ELEM (1 << 1)
|
|
|
b59ec1 |
|
|
|
b59ec1 |
-#define RULE_PP_REMOVE_OP_AND (RULE_PP_IN_CONCATENATION)
|
|
|
b59ec1 |
+#define RULE_PP_REMOVE_OP_AND (RULE_PP_IN_CONCATENATION | \
|
|
|
b59ec1 |
+ RULE_PP_IN_SET_ELEM)
|
|
|
b59ec1 |
|
|
|
b59ec1 |
struct rule_pp_ctx {
|
|
|
b59ec1 |
struct proto_ctx pctx;
|
|
|
b59ec1 |
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
|
|
|
b59ec1 |
index 0b5519d..c6ad84d 100644
|
|
|
b59ec1 |
--- a/src/netlink_delinearize.c
|
|
|
b59ec1 |
+++ b/src/netlink_delinearize.c
|
|
|
b59ec1 |
@@ -2660,7 +2660,9 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
|
|
|
b59ec1 |
expr_postprocess(ctx, &expr->prefix);
|
|
|
b59ec1 |
break;
|
|
|
b59ec1 |
case EXPR_SET_ELEM:
|
|
|
b59ec1 |
+ ctx->flags |= RULE_PP_IN_SET_ELEM;
|
|
|
b59ec1 |
expr_postprocess(ctx, &expr->key);
|
|
|
b59ec1 |
+ ctx->flags &= ~RULE_PP_IN_SET_ELEM;
|
|
|
b59ec1 |
break;
|
|
|
b59ec1 |
case EXPR_EXTHDR:
|
|
|
b59ec1 |
exthdr_dependency_kill(&ctx->pdctx, expr, ctx->pctx.family);
|
|
|
b59ec1 |
diff --git a/tests/shell/testcases/sets/dumps/0070stacked_l2_headers.nft b/tests/shell/testcases/sets/dumps/0070stacked_l2_headers.nft
|
|
|
b59ec1 |
index ef254b9..0057e9c 100644
|
|
|
b59ec1 |
--- a/tests/shell/testcases/sets/dumps/0070stacked_l2_headers.nft
|
|
|
b59ec1 |
+++ b/tests/shell/testcases/sets/dumps/0070stacked_l2_headers.nft
|
|
|
b59ec1 |
@@ -1,14 +1,28 @@
|
|
|
b59ec1 |
table netdev nt {
|
|
|
b59ec1 |
+ set vlanidset {
|
|
|
b59ec1 |
+ typeof vlan id
|
|
|
b59ec1 |
+ size 1024
|
|
|
b59ec1 |
+ flags dynamic,timeout
|
|
|
b59ec1 |
+ }
|
|
|
b59ec1 |
+
|
|
|
b59ec1 |
set macset {
|
|
|
b59ec1 |
typeof ether saddr . vlan id
|
|
|
b59ec1 |
size 1024
|
|
|
b59ec1 |
flags dynamic,timeout
|
|
|
b59ec1 |
}
|
|
|
b59ec1 |
|
|
|
b59ec1 |
+ set ipset {
|
|
|
b59ec1 |
+ typeof vlan id . ip saddr
|
|
|
b59ec1 |
+ size 1024
|
|
|
b59ec1 |
+ flags dynamic,timeout
|
|
|
b59ec1 |
+ }
|
|
|
b59ec1 |
+
|
|
|
b59ec1 |
chain nc {
|
|
|
b59ec1 |
update @macset { ether saddr . vlan id timeout 5s } counter packets 0 bytes 0
|
|
|
b59ec1 |
ether saddr . vlan id @macset
|
|
|
b59ec1 |
vlan pcp 1
|
|
|
b59ec1 |
ether saddr 0a:0b:0c:0d:0e:0f vlan id 42
|
|
|
b59ec1 |
+ update @vlanidset { vlan id timeout 5s } counter packets 0 bytes 0
|
|
|
b59ec1 |
+ update @ipset { vlan id . ip saddr timeout 5s } counter packets 0 bytes 0
|
|
|
b59ec1 |
}
|
|
|
b59ec1 |
}
|
|
|
b59ec1 |
--
|
|
|
b59ec1 |
2.39.1
|
|
|
b59ec1 |
|