diff mbox series

[nft,v2,07/11] mnl: round up the map data size too

Message ID 20191213160345.30057-8-fw@strlen.de
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series add typeof keyword | expand

Commit Message

Florian Westphal Dec. 13, 2019, 4:03 p.m. UTC
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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/mnl.c b/src/mnl.c
index 75113c74c224..bcf633002f15 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -870,7 +870,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);