]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
mnl: round up the map data size too
authorFlorian Westphal <fw@strlen.de>
Tue, 10 Dec 2019 21:08:44 +0000 (22:08 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 17 Dec 2019 22:10:46 +0000 (23:10 +0100)
Same as key: if the size isn't divisible by BITS_PER_BYTE, we need to
round up, not down.

Without this, you can't store vlan ids in a map, as they are truncated
to 8 bit.

Signed-off-by: Florian Westphal <fw@strlen.de>
src/mnl.c

index 03afe79c23a8e278f50a42f75faeaae136ff4647..d5bdff293c6189a86cce955e0fa89b3c2c2f7f54 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -861,7 +861,7 @@ int mnl_nft_set_add(struct netlink_ctx *ctx, const struct cmd *cmd,
                nftnl_set_set_u32(nls, NFTNL_SET_DATA_TYPE,
                                  dtype_map_to_kernel(set->data->dtype));
                nftnl_set_set_u32(nls, NFTNL_SET_DATA_LEN,
-                                 set->data->len / BITS_PER_BYTE);
+                                 div_round_up(set->data->len, BITS_PER_BYTE));
        }
        if (set_is_objmap(set->flags))
                nftnl_set_set_u32(nls, NFTNL_SET_OBJ_TYPE, set->objtype);