[PATCH 06/12] src: netlink: don't truncate set key lengths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If key is e.g. 12 bits, pretend its 16 instead of 8.  This is needed
to make sets work with header fields with size not divisible by 8.

Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
---
 src/netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/netlink.c b/src/netlink.c
index 8ede8e6..b1296cf 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -1100,7 +1100,7 @@ static int netlink_add_set_compat(struct netlink_ctx *ctx,
 	nft_set_attr_set_u32(nls, NFT_SET_ATTR_KEY_TYPE,
 			     dtype_map_to_kernel(set->keytype));
 	nft_set_attr_set_u32(nls, NFT_SET_ATTR_KEY_LEN,
-			     set->keylen / BITS_PER_BYTE);
+			     div_round_up(set->keylen, BITS_PER_BYTE));
 	if (set->flags & NFT_SET_MAP) {
 		nft_set_attr_set_u32(nls, NFT_SET_ATTR_DATA_TYPE,
 				     dtype_map_to_kernel(set->datatype));
@@ -1135,7 +1135,7 @@ static int netlink_add_set_batch(struct netlink_ctx *ctx,
 	nft_set_attr_set_u32(nls, NFT_SET_ATTR_KEY_TYPE,
 			     dtype_map_to_kernel(set->keytype));
 	nft_set_attr_set_u32(nls, NFT_SET_ATTR_KEY_LEN,
-			     set->keylen / BITS_PER_BYTE);
+			     div_round_up(set->keylen, BITS_PER_BYTE));
 	if (set->flags & NFT_SET_MAP) {
 		nft_set_attr_set_u32(nls, NFT_SET_ATTR_DATA_TYPE,
 				     dtype_map_to_kernel(set->datatype));
-- 
2.0.5

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux