From patchwork Sun Feb 4 02:35:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Guo X-Patchwork-Id: 196405 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp167633dyb; Sat, 3 Feb 2024 18:36:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHXcsBk5JkCSwUoJAooDxV5r5XPo5WRcF1jxuLq7Ny7DXnQYpLJ30GzRydgeUdSMxI3daQg X-Received: by 2002:a2e:a990:0:b0:2d0:794f:2cc1 with SMTP id x16-20020a2ea990000000b002d0794f2cc1mr6053022ljq.46.1707014192410; Sat, 03 Feb 2024 18:36:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707014192; cv=pass; d=google.com; s=arc-20160816; b=k3QGI5g7JOsIyfDBpYWNq0atSJ4kitH5NQkini1B9ooAugjswQjGMThj+wbTq90fx6 g6NrSS+yGu3QhZk/oObIAw+R3WdW7UUUAQK9kdsRL4s0Uap/H0ZMzHFLYyjRypJgbw7w 31imeajJ7wRdnuh+9LJuAC4P1AzHHabLLlk0F4/RqDJHT02xJAH8+QdCesf4OHu7Mp/7 BggDBHozLTwRNTLOU9ybhtFpmzKh+PsVdP++x9Ix5P2rfdJrUbN8iDn8Q38Rx1xkulNV bSgL+1GtJzJL0FRuS6QPXeuFGNcTKbbA1G7VMD3UqCIVFXDAtpZAH10nvr7yVQPJxT1e 2ZSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=b7S8ENIwTw6+9bm+IefdHUPbMFwYSdb9IyEZNWuDgq0=; fh=txuvxcrvR1A4o7pM25EXqN010Z3VL8hlDbXlC44343c=; b=nQaQthNQ9pV4PlH5nxNXkE7zlOX2gdh8+2BQYZ7Q6CxtSXWnJDkjQdhaQm5dvBclIl 9WJ9J9paYRIc84PS0xEzkvOx0Gj7hos8Ps6b7ayQdNQyiZeHOKXgb5f2QuY5hKgr9wwW d68dwADjeDjzk9WFg843HUE5a6QzshKaURobgEHOwn+IOL3aWGKGtzPNcrunUELs4XuN f4828GGCpY5b4rGHVQzfklrSM4p8wFw2u9VPMdye4bo64mDe7bOwwMlKxKLrYB/EZAFt r8s31Did27sN+LXyoQEQbN1LYPIX75xgPCq1mXubtrOnTDRuwHGBjmxHMphSzLuK9Cj7 Uk8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bwlXnTLH; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-51382-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51382-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev X-Forwarded-Encrypted: i=1; AJvYcCXJXVl9Nl/zMnAAckTxvQf1IavjZKW+SDTfUGgfa7v0tM3+hG01+puirPH7ZyzkY77JJIKnbfSA0hOBSSn5G666z51V8Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a4-20020a509b44000000b0055ef3bf39bfsi2398438edj.186.2024.02.03.18.36.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 18:36:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51382-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=bwlXnTLH; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-51382-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51382-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 950901F21C49 for ; Sun, 4 Feb 2024 02:36:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 180D3613C; Sun, 4 Feb 2024 02:35:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="bwlXnTLH" Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 01F531115 for ; Sun, 4 Feb 2024 02:35:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707014151; cv=none; b=MP2GPiuOZ9MfrpGkUEpZwqmplqpzx8d/lAt7sFKg1rgwzyzVr54txfXoK8fjUwohDCTBDMKKipXjw1KaJ8C0s+i5Xj1TRQW7/wteuaFGt4Sbg2FVaLuR+uFBWYQlwvCRajbjZhfFFPLW8F+piKBbErWVWKPB0K5pWbhC3H2AIFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707014151; c=relaxed/simple; bh=eXGrpUkM4UG4cBvAJQ7Qgo/L2pXhU3blLDwhWRms55k=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=h4K+Ands7rZVgrN//l2M3L3k43XLZi2HAukWnWab5IhLVXXDXDeGvZCLIVaI94hN8BFIdoNqm+nAqabSNRfaF3Cunc4uf7pltEyLyC5gukqvAxgGC6iukfqALr0np9K3F9DbuU7bo3qoG01fQWHDjjJ5a7FyGIiWXrpVWDsk9C0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=bwlXnTLH; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1707014146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=b7S8ENIwTw6+9bm+IefdHUPbMFwYSdb9IyEZNWuDgq0=; b=bwlXnTLHBbiARtjYG0PC/ic2kQthw/7x4CWl2f9jvhImeSZFCI9NAI7uk8QkKk+ev6OSyB RXp3HsUXJ9EnTkNIMBGAIg1vtq1zlhebAxQ2550ZDmOjNAoAl6X/AkoSUWc4Dqh3kncgPw mptpAmoAGFUTggvx4xNnw8JnyV0Cp8U= From: George Guo To: Jakub Kicinski , Paul Moore , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: George Guo , netdev@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/1] netlabel: cleanup struct netlbl_lsm_catmap Date: Sun, 4 Feb 2024 10:35:31 +0800 Message-Id: <20240204023531.2225264-1-dongtai.guo@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789934113610188135 X-GMAIL-MSGID: 1789934113610188135 From: George Guo Simplify the code from macro NETLBL_CATMAP_MAPTYPE to u64, and fix warning "Macros with complex values should be enclosed in parentheses" on "#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01", which is modified to "#define NETLBL_CATMAP_BIT ((u64)0x01)". Signed-off-by: George Guo Acked-by: Paul Moore --- V2: Yes, I understand what you are saying. Actually, there is a compile warnings on "#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01" which is missing parentheses. --- include/net/netlabel.h | 7 +++---- net/netlabel/netlabel_kapi.c | 8 ++++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/include/net/netlabel.h b/include/net/netlabel.h index d74f21f528de..0d04a8ae3811 100644 --- a/include/net/netlabel.h +++ b/include/net/netlabel.h @@ -145,15 +145,14 @@ struct netlbl_lsm_cache { * processing. * */ -#define NETLBL_CATMAP_MAPTYPE u64 #define NETLBL_CATMAP_MAPCNT 4 -#define NETLBL_CATMAP_MAPSIZE (sizeof(NETLBL_CATMAP_MAPTYPE) * 8) +#define NETLBL_CATMAP_MAPSIZE (sizeof(u64) * 8) #define NETLBL_CATMAP_SIZE (NETLBL_CATMAP_MAPSIZE * \ NETLBL_CATMAP_MAPCNT) -#define NETLBL_CATMAP_BIT (NETLBL_CATMAP_MAPTYPE)0x01 +#define NETLBL_CATMAP_BIT ((u64)0x01) struct netlbl_lsm_catmap { u32 startbit; - NETLBL_CATMAP_MAPTYPE bitmap[NETLBL_CATMAP_MAPCNT]; + u64 bitmap[NETLBL_CATMAP_MAPCNT]; struct netlbl_lsm_catmap *next; }; diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c index 27511c90a26f..7b844581ebee 100644 --- a/net/netlabel/netlabel_kapi.c +++ b/net/netlabel/netlabel_kapi.c @@ -610,7 +610,7 @@ int netlbl_catmap_walk(struct netlbl_lsm_catmap *catmap, u32 offset) struct netlbl_lsm_catmap *iter; u32 idx; u32 bit; - NETLBL_CATMAP_MAPTYPE bitmap; + u64 bitmap; iter = _netlbl_catmap_getnode(&catmap, offset, _CM_F_WALK, 0); if (iter == NULL) @@ -666,8 +666,8 @@ int netlbl_catmap_walkrng(struct netlbl_lsm_catmap *catmap, u32 offset) struct netlbl_lsm_catmap *prev = NULL; u32 idx; u32 bit; - NETLBL_CATMAP_MAPTYPE bitmask; - NETLBL_CATMAP_MAPTYPE bitmap; + u64 bitmask; + u64 bitmap; iter = _netlbl_catmap_getnode(&catmap, offset, _CM_F_WALK, 0); if (iter == NULL) @@ -857,7 +857,7 @@ int netlbl_catmap_setlong(struct netlbl_lsm_catmap **catmap, offset -= iter->startbit; idx = offset / NETLBL_CATMAP_MAPSIZE; - iter->bitmap[idx] |= (NETLBL_CATMAP_MAPTYPE)bitmap + iter->bitmap[idx] |= (u64)bitmap << (offset % NETLBL_CATMAP_MAPSIZE); return 0;