]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
netlink_delinearize: also postprocess OP_AND in set element context
authorFlorian Westphal <fw@strlen.de>
Mon, 1 Aug 2022 11:03:18 +0000 (13:03 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 4 Aug 2022 23:46:39 +0000 (01:46 +0200)
Pablo reports:
add rule netdev nt y update @macset { vlan id timeout 5s }

listing still shows the raw expression:
 update @macset { @ll,112,16 & 0xfff timeout 5s }

so also cover the 'set element' case.

Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
include/netlink.h
src/netlink_delinearize.c
tests/shell/testcases/sets/dumps/0070stacked_l2_headers.nft

index 71c888fa0b407d47e073ec92f460eb0c805c401d..63d07edf419eacac1e1f816c8a61602903ae7a91 100644 (file)
@@ -44,8 +44,10 @@ struct netlink_parse_ctx {
 
 
 #define RULE_PP_IN_CONCATENATION       (1 << 0)
+#define RULE_PP_IN_SET_ELEM            (1 << 1)
 
-#define RULE_PP_REMOVE_OP_AND          (RULE_PP_IN_CONCATENATION)
+#define RULE_PP_REMOVE_OP_AND          (RULE_PP_IN_CONCATENATION | \
+                                        RULE_PP_IN_SET_ELEM)
 
 struct rule_pp_ctx {
        struct proto_ctx        pctx;
index 8851043bf2779eba2dd01d6d13e34ff608a01b3e..0da6cc78f94fac07d83bd9c99e4f41ea0f68d488 100644 (file)
@@ -2661,7 +2661,9 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
                expr_postprocess(ctx, &expr->prefix);
                break;
        case EXPR_SET_ELEM:
+               ctx->flags |= RULE_PP_IN_SET_ELEM;
                expr_postprocess(ctx, &expr->key);
+               ctx->flags &= ~RULE_PP_IN_SET_ELEM;
                break;
        case EXPR_EXTHDR:
                exthdr_dependency_kill(&ctx->pdctx, expr, ctx->pctx.family);
index ef254b96879e67582ffcd586cbec90a7c542f6fa..0057e9c62e4d3b82e702dc1e02b625ac59099e54 100644 (file)
@@ -1,14 +1,28 @@
 table netdev nt {
+       set vlanidset {
+               typeof vlan id
+               size 1024
+               flags dynamic,timeout
+       }
+
        set macset {
                typeof ether saddr . vlan id
                size 1024
                flags dynamic,timeout
        }
 
+       set ipset {
+               typeof vlan id . ip saddr
+               size 1024
+               flags dynamic,timeout
+       }
+
        chain nc {
                update @macset { ether saddr . vlan id timeout 5s } counter packets 0 bytes 0
                ether saddr . vlan id @macset
                vlan pcp 1
                ether saddr 0a:0b:0c:0d:0e:0f vlan id 42
+               update @vlanidset { vlan id timeout 5s } counter packets 0 bytes 0
+               update @ipset { vlan id . ip saddr timeout 5s } counter packets 0 bytes 0
        }
 }