From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 698C9C751C1 for ; Fri, 13 Dec 2019 20:38:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A829124728 for ; Fri, 13 Dec 2019 20:38:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728179AbfLMQEF (ORCPT ); Fri, 13 Dec 2019 11:04:05 -0500 Received: from Chamillionaire.breakpoint.cc ([193.142.43.52]:40350 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728177AbfLMQEF (ORCPT ); Fri, 13 Dec 2019 11:04:05 -0500 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1ifnQB-0004Dh-2j; Fri, 13 Dec 2019 17:04:03 +0100 From: Florian Westphal To: Cc: Florian Westphal Subject: [PATCH nft v2 07/11] mnl: round up the map data size too Date: Fri, 13 Dec 2019 17:03:41 +0100 Message-Id: <20191213160345.30057-8-fw@strlen.de> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191213160345.30057-1-fw@strlen.de> References: <20191213160345.30057-1-fw@strlen.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org 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 --- src/mnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.23.0