From patchwork Mon Sep 16 15:14:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 1986162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=AkMgaGGd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=netfilter-devel+bounces-3904-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6pPQ69F3z1y1g for ; Tue, 17 Sep 2024 01:15:06 +1000 (AEST) 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C57B91C21B19 for ; Mon, 16 Sep 2024 15:15:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 885BC158DB9; Mon, 16 Sep 2024 15:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AkMgaGGd" X-Original-To: netfilter-devel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0849915884A; Mon, 16 Sep 2024 15:14:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726499694; cv=none; b=MR1hZD3n2e/V4E2+qYEBnMdttuKhSpqn+dGTIHuQ4Mx8ZgAeTfhQeDr5ffUCJ1WubdO0m+681Z3+JlfU+9kcYuYkHnlacTCITIUZvZatg2ttEMxi3qRZ85wYXk5uhWRBx3rMyiRfXGWKfsiSDlDe+kMCUOqyMQAsV662gVZgaDo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726499694; c=relaxed/simple; bh=jrRofr/U5OtmLYNGeEnCahQZRnPI1mplJUHcOcBZ8IE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JLU/YGjFtbbLTkdtlrDwJUiddwE5VMKd7eFve4r2WXo6+wZ7gf2NuqaGYe5S1q1EcSXEXd7nrQHUH6hOuthvMnb6bcWhRceyrQ01EboZI7lvUIoKCAFAPinfpuqoTJStEZcXdVZQYyhP9n3CATmbQ+VDrSb8eh2tl2vS0srdpIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AkMgaGGd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CEED1C4CECF; Mon, 16 Sep 2024 15:14:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726499693; bh=jrRofr/U5OtmLYNGeEnCahQZRnPI1mplJUHcOcBZ8IE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AkMgaGGdY2LprBLSHL/Jmlx0ZcTaj8ETlqhYB4FY2WVEmI1YYK0/FPlokk3BpghtJ zAUsMWcefvmDfjEaxDAG6EZnERiKD6K5QqQK1YejoO2y8zRHo5NcouNHZ3hX9JcXh4 im2LlDePeUx4/Lehp8QtF0mTV5kyJqx4qXgGM+cIxCBsrhw/CjO088NirqkL3qPT/I O4cH9fmL04b/pruWC9ZKBqWzjZuxsHcdLUsE7iesUjb04z4tZDqMlPvtMdeASpTA6n WVnfCEkmx9W+EFKOjvKe1yiGWegvw0XLOCJl3x1wg4SDQVPJZGTsC0/e30owRGkGQ1 6qPbDtPuxVaQA== From: Simon Horman Date: Mon, 16 Sep 2024 16:14:41 +0100 Subject: [PATCH nf-next 1/2] netfilter: conntrack: compile label helpers unconditionally Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240916-ct-ifdef-v1-1-81ef1798143b@kernel.org> References: <20240916-ct-ifdef-v1-0-81ef1798143b@kernel.org> In-Reply-To: <20240916-ct-ifdef-v1-0-81ef1798143b@kernel.org> To: Pablo Neira Ayuso , Jozsef Kadlecsik Cc: Andy Shevchenko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, llvm@lists.linux.dev X-Mailer: b4 0.14.0 The condition on CONFIG_NF_CONNTRACK_LABELS being removed by this patch guards compilation of non-trivial implementations of ctnetlink_dump_labels() and ctnetlink_label_size(). However, this is not necessary as each of these functions will always return 0 if CONFIG_NF_CONNTRACK_LABELS is not defined as each function starts with the equivalent of: struct nf_conn_labels *labels = nf_ct_labels_find(ct); if (!labels) return 0; And nf_ct_labels_find always returns NULL if CONFIG_NF_CONNTRACK_LABELS is not enabled. So I believe that the compiler optimises the code away in such cases anyway. Some advantages of this approach are: 1. Fewer #ifdefs, fewer headaches 2. The trivial implementations can be dropped 3. A follow-up patch, to conditionally compile ctnetlink_label_size only when it is used becomes simpler (see point 1) Found by inspection. Compile tested only. Signed-off-by: Simon Horman --- net/netfilter/nf_conntrack_netlink.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 123e2e933e9b..f1f7dff08953 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -382,7 +382,6 @@ static int ctnetlink_dump_secctx(struct sk_buff *skb, const struct nf_conn *ct) #define ctnetlink_dump_secctx(a, b) (0) #endif -#ifdef CONFIG_NF_CONNTRACK_LABELS static inline int ctnetlink_label_size(const struct nf_conn *ct) { struct nf_conn_labels *labels = nf_ct_labels_find(ct); @@ -411,10 +410,6 @@ ctnetlink_dump_labels(struct sk_buff *skb, const struct nf_conn *ct) return 0; } -#else -#define ctnetlink_dump_labels(a, b) (0) -#define ctnetlink_label_size(a) (0) -#endif #define master_tuple(ct) &(ct->master->tuplehash[IP_CT_DIR_ORIGINAL].tuple) From patchwork Mon Sep 16 15:14:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 1986163 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=lrKuAHXy; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=netfilter-devel+bounces-3905-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X6pPX1J9pz1y1g for ; Tue, 17 Sep 2024 01:15:12 +1000 (AEST) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E550A280CAA for ; Mon, 16 Sep 2024 15:15:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98825158862; Mon, 16 Sep 2024 15:14:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lrKuAHXy" X-Original-To: netfilter-devel@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 19E3C158866; Mon, 16 Sep 2024 15:14:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726499697; cv=none; b=fnZLkL8A8ayMU6q+sMFexM3IVbad6/nMEbe6Pu9YxVF04jRyANBwAak7SCDFVA74o3odX8M0thzYS8ToMxc0Rr+fnWVsqZO8O9vPCJTX1mcO+FuPBuSanU9PcT7sAFg5FsO2zdNFNtmL3EBFE7YYDALT6ITFmkPwcMT0q0BHDE0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726499697; c=relaxed/simple; bh=OIBh/0baW7ACKehuo5TRfPDRDt7fKE/BEc8K0THsT0Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hpMtql73qOfo+/YxTYAa+t0/bLhoQH51IaEIK+F8+TQkRvKS+t4JyrSiRebdsOKzLwjYBGDXAMJ9c2JWu4S13JziRi6Z4brn41hlzJhKHjx46xLV896CGq03WTFHL1Jq6QVLTDUzEMzsCt7TzmmWiJbzLyfKZdbUdFgxEXe/4Fg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lrKuAHXy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB9D9C4CECE; Mon, 16 Sep 2024 15:14:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726499696; bh=OIBh/0baW7ACKehuo5TRfPDRDt7fKE/BEc8K0THsT0Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lrKuAHXyOrZko7ATpHmsjgj8bU/jUQ3sCYA7LKdcW0cwJzLz28bCSDhCwah9atfmn T1CFA4UutXJ2D7H+GckA8VO25fl8wPXBKdxmKhFn/JSI0wWRlOFHPhlhj1Uok1MnRF suxMH/MciD4WuCTV8mRZHgcRq86lu7pLMutR+W4paIOibgVyeRFGYwCY3Fy6Fyc2uZ k61YLjLCN9XQlnGqdzG18f1ka/iKgWejiJALf6gq5hQt8PhCtr+Js2z7PcIWKcU86l JQn7rcsJu4+SRUeQAQk4SUp4jpSYfbAfUzOZjeoICie90I6MARnL4t90Ool2oU0nnj w7c+nGwM3lA0A== From: Simon Horman Date: Mon, 16 Sep 2024 16:14:42 +0100 Subject: [PATCH nf-next 2/2] netfilter: conntrack: conditionally compile ctnetlink_label_size Precedence: bulk X-Mailing-List: netfilter-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240916-ct-ifdef-v1-2-81ef1798143b@kernel.org> References: <20240916-ct-ifdef-v1-0-81ef1798143b@kernel.org> In-Reply-To: <20240916-ct-ifdef-v1-0-81ef1798143b@kernel.org> To: Pablo Neira Ayuso , Jozsef Kadlecsik Cc: Andy Shevchenko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, llvm@lists.linux.dev X-Mailer: b4 0.14.0 Only provide ctnetlink_label_size when it is used, which is when CONFIG_NF_CONNTRACK_EVENTS is configured. Flagged by clang-18 W=1 builds as: .../nf_conntrack_netlink.c:385:19: warning: unused function 'ctnetlink_label_size' [-Wunused-function] 385 | static inline int ctnetlink_label_size(const struct nf_conn *ct) | ^~~~~~~~~~~~~~~~~~~~ Found by manually tweaking .config. Compile tested only. Link: https://lore.kernel.org/netfilter-devel/20240909151712.GZ2097826@kernel.org/ Cc: Andy Shevchenko Signed-off-by: Simon Horman --- net/netfilter/nf_conntrack_netlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index f1f7dff08953..cac48277a7d5 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c @@ -382,6 +382,7 @@ static int ctnetlink_dump_secctx(struct sk_buff *skb, const struct nf_conn *ct) #define ctnetlink_dump_secctx(a, b) (0) #endif +#ifdef CONFIG_NF_CONNTRACK_EVENTS static inline int ctnetlink_label_size(const struct nf_conn *ct) { struct nf_conn_labels *labels = nf_ct_labels_find(ct); @@ -390,6 +391,7 @@ static inline int ctnetlink_label_size(const struct nf_conn *ct) return 0; return nla_total_size(sizeof(labels->bits)); } +#endif static int ctnetlink_dump_labels(struct sk_buff *skb, const struct nf_conn *ct)