]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: maps: update data expression dtype based on set
authorFlorian Westphal <fw@strlen.de>
Thu, 13 Feb 2020 11:45:55 +0000 (12:45 +0100)
committerFlorian Westphal <fw@strlen.de>
Thu, 13 Feb 2020 12:16:48 +0000 (13:16 +0100)
What we want:
-               update @sticky-set-svc-M53CN2XYVUHRQ7UB { ip saddr : 0x00000002 }
what we got:
+               update @sticky-set-svc-M53CN2XYVUHRQ7UB { ip saddr : 0x2000000 [invalid type] }

Reported-by: Serguei Bezverkhi <sbezverk@gmail.com>
Close: https://bugzilla.netfilter.org/show_bug.cgi?id=1405
Signed-off-by: Florian Westphal <fw@strlen.de>
src/netlink_delinearize.c
tests/shell/testcases/maps/dumps/typeof_maps_update_0.nft [new file with mode: 0644]
tests/shell/testcases/maps/typeof_maps_update_0 [new file with mode: 0755]

index 7d9c764625c5195ca65a3c11f9e9f389e499062a..4f774fb9f150c204c55b90213765aeeb9a183b65 100644 (file)
@@ -1424,6 +1424,7 @@ static void netlink_parse_dynset(struct netlink_parse_ctx *ctx,
        }
 
        if (expr_data != NULL) {
+               expr_set_type(expr_data, set->data->dtype, set->data->byteorder);
                stmt = map_stmt_alloc(loc);
                stmt->map.set   = set_ref_expr_alloc(loc, set);
                stmt->map.key   = expr;
diff --git a/tests/shell/testcases/maps/dumps/typeof_maps_update_0.nft b/tests/shell/testcases/maps/dumps/typeof_maps_update_0.nft
new file mode 100644 (file)
index 0000000..698219c
--- /dev/null
@@ -0,0 +1,21 @@
+table ip kube-nfproxy-v4 {
+       map sticky-set-svc-M53CN2XYVUHRQ7UB {
+               type ipv4_addr : mark
+               size 65535
+               timeout 6m
+       }
+
+       map sticky-set-svc-153CN2XYVUHRQ7UB {
+               typeof ip daddr : meta mark
+               size 65535
+               timeout 1m
+       }
+
+       chain k8s-nfproxy-sep-TMVEFT7EX55F4T62 {
+               update @sticky-set-svc-M53CN2XYVUHRQ7UB { ip saddr : 0x00000002 }
+       }
+
+       chain k8s-nfproxy-sep-GMVEFT7EX55F4T62 {
+               update @sticky-set-svc-153CN2XYVUHRQ7UB { ip saddr : 0x00000003 }
+       }
+}
diff --git a/tests/shell/testcases/maps/typeof_maps_update_0 b/tests/shell/testcases/maps/typeof_maps_update_0
new file mode 100755 (executable)
index 0000000..c233b13
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# check update statement doesn't print "invalid dtype" on the data element.
+
+EXPECTED="table ip kube-nfproxy-v4 {
+ map sticky-set-svc-M53CN2XYVUHRQ7UB {
+  type ipv4_addr : mark
+  size 65535
+  timeout 6m
+ }
+
+ map sticky-set-svc-153CN2XYVUHRQ7UB {
+  typeof ip daddr : meta mark
+  size 65535
+  timeout 1m
+ }
+
+ chain k8s-nfproxy-sep-TMVEFT7EX55F4T62 {
+  update @sticky-set-svc-M53CN2XYVUHRQ7UB { ip saddr : 0x2 }
+ }
+ chain k8s-nfproxy-sep-GMVEFT7EX55F4T62 {
+  update @sticky-set-svc-153CN2XYVUHRQ7UB { ip saddr : 0x3 }
+ }
+}"
+
+set -e
+$NFT -f - <<< $EXPECTED
+