]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
evaluate: disallow ct original {s,d}ddr from maps
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 15 Jan 2021 17:40:11 +0000 (18:40 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 15 Jan 2021 17:44:24 +0000 (18:44 +0100)
test.nft:6:55-71: Error: specify either ip or ip6 for address matching
add rule ip mangle manout ct direction reply mark set ct original daddr map { $ext1_ip : 0x11, $ext2_ip : 0x12 }
                                                      ^^^^^^^^^^^^^^^^^

Closes: https://bugzilla.netfilter.org/show_bug.cgi?id=1489
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/evaluate.c
tests/py/ip/ct.t
tests/py/ip/ct.t.payload

index 38dbc33d7826bb5cb8c129e06706db834737cf5b..c830dcdbd9651b767ed8da94a05fb95791cd8323 100644 (file)
@@ -1472,6 +1472,12 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr)
        const struct datatype *dtype;
        struct expr *key, *data;
 
+       if (map->map->etype == EXPR_CT &&
+           (map->map->ct.key == NFT_CT_SRC ||
+            map->map->ct.key == NFT_CT_DST))
+               return expr_error(ctx->msgs, map->map,
+                                 "specify either ip or ip6 for address matching");
+
        expr_set_context(&ctx->ectx, NULL, 0);
        if (expr_evaluate(ctx, &map->map) < 0)
                return -1;
index d3247f79113f1dd8e26ba6fdeac94b06ae830c5e..c5ce12747d42fadefa3985a28e101dd944c0fba6 100644 (file)
@@ -21,3 +21,6 @@ ct original protocol 17 ct reply proto-src 53;ok;ct protocol 17 ct reply proto-s
 
 # wrong address family
 ct reply ip daddr dead::beef;fail
+
+meta mark set ct original daddr map { 1.1.1.1 : 0x00000011 };fail
+meta mark set ct original ip daddr map { 1.1.1.1 : 0x00000011 };ok
index a7e08f98e6a3e4065cbc176cd3b7c253589cbb06..3348d16ddc72a831429b2077dbec449907d66a32 100644 (file)
@@ -56,3 +56,12 @@ ip test-ip4 output
   [ cmp eq reg 1 0x00000011 ]
   [ ct load proto_src => reg 1 , dir reply ]
   [ cmp eq reg 1 0x00003500 ]
+
+# meta mark set ct original ip daddr map { 1.1.1.1 : 0x00000011 }
+__map%d test-ip4 b
+__map%d test-ip4 0
+        element 01010101  : 00000011 0 [end]
+ip
+  [ ct load dst_ip => reg 1 , dir original ]
+  [ lookup reg 1 set __map%d dreg 1 ]
+  [ meta set mark with reg 1 ]