From patchwork Tue Apr 27 19:45:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 427961 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp4931020jao; Tue, 27 Apr 2021 12:45:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3FQnbQx1mOgIvcYRTK3paM7UAd+4b01azx30e3KM/A3UD8V95m/AloKlx1pXefQjS/JcA X-Received: by 2002:a17:906:1c83:: with SMTP id g3mr25441868ejh.93.1619552758119; Tue, 27 Apr 2021 12:45:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619552758; cv=none; d=google.com; s=arc-20160816; b=nFqmcTTXEcZZov7nMysP97sscsd5fDpMYETzub1oVsUS0tql/MlVsLiafry73VdtDy /v8rBtuOLXnoV98AkXMRMxkvhaHKVTS72IkOCaE7ge5rf9++sxp9rleA8hosCTF23HLq Eb6vb0gYjToIX1LVWkLX5CLapQ7BqtwmzzbGq/qweiQcL5bm9ju4p4MMTA+lnhmXqgBW 4w2i8fDWkHGl/oNEvLUf0BgaeoZVkFSEA9HZ2nhBrPHtlzOyZkwZRd2x8oQPLYPcIFrV lE2PCnvKlT91xiUnRxrDBXAbYTS8EoNZfsl3CXQ+xh1LQeF11k8NNFcO7RwXbqG/aFhv IzDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=skdrZ6q0Cq9tX9lqK66FJzwUFI74j24Xps4+UlFystQ=; b=MPhKdOx+d4Six3+h9w6WbplPJWvX+z3NEDImpIsVVq+1VFJQy9emkOEB8lMYVnEGaw lg3i6WfsUMLVj9alDIb26EhhQxAnLhCEQLJFgw599aR3F5TfVG1srvrn/77AGV3o6lTH BXWCKbvVombhhp4k22/UKGLMyIE10k7l1vbXa2QCQrFxXxHODP0TtuVsPi/KFXfSmWtB dyEWLgt+VMZw8NCo4nl2buLfyzJKzVKe/5r+MOrm1nwU9U92gqu4bHrvk9tbX+HC13Lb Oaxz06CJjhQAtv3m3Wrj/MsM9Z4j4+j2WLoi4+3yia7Y7KTlhSRQcX6BQ8WUUIuChxUw Ds4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="P6EaCGT/"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si3346816edz.247.2021.04.27.12.45.57; Tue, 27 Apr 2021 12:45:58 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="P6EaCGT/"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238877AbhD0Tqd (ORCPT + 8 others); Tue, 27 Apr 2021 15:46:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:50100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235661AbhD0Tqc (ORCPT ); Tue, 27 Apr 2021 15:46:32 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AFD8C611F2; Tue, 27 Apr 2021 19:45:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619552748; bh=LDoohEnCArlGbum8fJyPABYpTo/IiOc7gWRCmRENEKk=; h=From:To:Cc:Subject:Date:From; b=P6EaCGT/1tkDXdwDRUEY2vhTWX1m+SMp/BC74NckIuFC3v52raY7xWHQJXhbwF6FC 1oIkAOqxAY2PspZWRW1Nf/SB0VXMIR17dorDxV1tN9tL1Z+fkpyj1PVC9mICvAqw2R 2SADRJxZmjuFQGI9SX+gi16LHTbQdq936nnHSjjw2oWO9E78aU6Ib6kn9UY8YmRP0g 6YXVqpzpBlX91HsXDQGVRnfG3omFaTieOBP8z0Znu7ztm/LKedkUZJw/IdV/BfYDuM VyCIS2E6hkCMfDmm1i/tBS8xuJlyX2mmiq6qR6N1hoEnURQIrPTsnGOJxg1mef+/EL Y6FLqYORW4mfQ== From: Arnd Bergmann To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Jakub Kicinski Cc: Arnd Bergmann , Balazs Scheidler , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] netfilter: nft_socket: fix an unused variable warning Date: Tue, 27 Apr 2021 21:45:18 +0200 Message-Id: <20210427194528.2325108-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann The variable is only used in an #ifdef, causing a harmless warning: net/netfilter/nft_socket.c: In function 'nft_socket_init': net/netfilter/nft_socket.c:137:27: error: unused variable 'level' [-Werror=unused-variable] 137 | unsigned int len, level; | ^~~~~ Move it into the same #ifdef block. Fixes: e0bb96db96f8 ("netfilter: nft_socket: add support for cgroupsv2") Signed-off-by: Arnd Bergmann --- net/netfilter/nft_socket.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.29.2 diff --git a/net/netfilter/nft_socket.c b/net/netfilter/nft_socket.c index 9c169d100651..f9c5ff6024e0 100644 --- a/net/netfilter/nft_socket.c +++ b/net/netfilter/nft_socket.c @@ -134,7 +134,7 @@ static int nft_socket_init(const struct nft_ctx *ctx, const struct nlattr * const tb[]) { struct nft_socket *priv = nft_expr_priv(expr); - unsigned int len, level; + unsigned int len; if (!tb[NFTA_SOCKET_DREG] || !tb[NFTA_SOCKET_KEY]) return -EINVAL; @@ -160,7 +160,9 @@ static int nft_socket_init(const struct nft_ctx *ctx, len = sizeof(u32); break; #ifdef CONFIG_CGROUPS - case NFT_SOCKET_CGROUPV2: + case NFT_SOCKET_CGROUPV2: { + unsigned int level; + if (!tb[NFTA_SOCKET_LEVEL]) return -EINVAL; @@ -171,6 +173,7 @@ static int nft_socket_init(const struct nft_ctx *ctx, priv->level = level; len = sizeof(u64); break; + } #endif default: return -EOPNOTSUPP; From patchwork Tue Apr 27 19:45:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 427962 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp4931157jao; Tue, 27 Apr 2021 12:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwudahdVQm6gS0Fd082RXZCIcOSDU0pJ7JnMIxGFfOraCRABvisVtit06eTrY6cr0OVjVNn X-Received: by 2002:a05:6402:1519:: with SMTP id f25mr6316664edw.277.1619552768812; Tue, 27 Apr 2021 12:46:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619552768; cv=none; d=google.com; s=arc-20160816; b=GXDEpxuRMsrIjfVdK8/vrt8KfjvGYNFu270X6WmfXNnlBl1qaqlkYXVX4ZE3Dc03JR mNXOvTmZR1jqoaqLxEpau2FtBR73NMrzKF2kFg1ZhaFW8S9fzUc0tPG9sS0cY47aM4n2 jhXwRkZY5fc5/U/crnxgYN0mRkmd2jv3EyrMnWzam3A+OBzC+1KpEth34jtPtgcwPQ/4 8E6ajbGhxtqstYm8G4jQlVQOPDYCAR/J8EaBCoQ7mZpkZlNcvMP4SiFpZ+cGkBI9K/PX MnEW18QqQv1sKjhvqnD7EtirEiNBavQgPm1jwKX38Ozl0SF4joeHAW2NppbLpNllas02 o8vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dXZL4VMhEat97ja3ZjZ4RJDfasecMv9OcN7Yqb3fR44=; b=PvrldOSjLEhwew6Hfd1CNHX54IqIQF59vLdzkUAwTSyz/8rEbUhabpR6rpO6ht60zy 49bAaf6KQeA5CsfPMZ3mcXPmE+vtdQxq6ylIeIUQ+P+tkMYtW+XnrjJBCHJut9GY6RYo RhpzCve4y6BBeym718vxJC98jcHoBIi4FrBeIOIC/7uwUbCFGBP69CvjW7m6NwbXLZHJ za8WMPUhok8ylPVgsSiw513DuLdZO2tdwRINVfqgB4BqAZmGj/8vhQYs+OB63KKA8+XL HZdV3BfXJ2yjWjQU0bNFAim908Aq4EdPEQzPldH8G6w+ohuLj47Xfypwl4Uz/OStKbWQ LglA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r4uY2em2; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf4si711657ejb.383.2021.04.27.12.46.08; Tue, 27 Apr 2021 12:46:08 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r4uY2em2; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238985AbhD0Tqo (ORCPT + 8 others); Tue, 27 Apr 2021 15:46:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:50240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235661AbhD0Tqn (ORCPT ); Tue, 27 Apr 2021 15:46:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E71C6023B; Tue, 27 Apr 2021 19:45:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619552759; bh=xLX5Y1/h9Ll5Xq3l/iKgtd536wc5fsuPUiC9i35GC2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4uY2em21Cu3E3S8kfddwM0mxkRxB9zBBQRGyyb7mSCF9MrLOo+kvN00n9VCLj8WN 8c3ZCrGMVzcdnz8Ms05Uksdy6/xGONCIhNaAdG5F7Qw0ZEJP99TsPjg/FERUtkddZ1 hjY0xnBpwNzPmkAWx+bHwgxPHGE/ksoIXzqLPo6otOLWj2s8UE4LMdUyiO5kpfZwXy bObx/C9cMN5fjE//6/FrvYX6jU2sn+PR8/ZF17cxVNSJJDtT+eX6KiBZEj8an4eIcG 7ic2zr4fZW505hvMnXlekVtU+tM7QevYQI10b94RGuQ2TmwoPXdCRC9ECebHxTA09q UwcJoHFyeB/hw== From: Arnd Bergmann To: Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Jakub Kicinski Cc: Arnd Bergmann , Balazs Scheidler , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] netfilter: nft_socket: fix build with CONFIG_SOCK_CGROUP_DATA=n Date: Tue, 27 Apr 2021 21:45:19 +0200 Message-Id: <20210427194528.2325108-2-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210427194528.2325108-1-arnd@kernel.org> References: <20210427194528.2325108-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Arnd Bergmann In some configurations, the sock_cgroup_ptr() function is not available: net/netfilter/nft_socket.c: In function 'nft_sock_get_eval_cgroupv2': net/netfilter/nft_socket.c:47:16: error: implicit declaration of function 'sock_cgroup_ptr'; did you mean 'obj_cgroup_put'? [-Werror=implicit-function-declaration] 47 | cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); | ^~~~~~~~~~~~~~~ | obj_cgroup_put net/netfilter/nft_socket.c:47:14: error: assignment to 'struct cgroup *' from 'int' makes pointer from integer without a cast [-Werror=int-conversion] 47 | cgrp = sock_cgroup_ptr(&sk->sk_cgrp_data); | ^ Change the caller to match the same #ifdef check, only calling it when the function is defined. Fixes: e0bb96db96f8 ("netfilter: nft_socket: add support for cgroupsv2") Signed-off-by: Arnd Bergmann --- I don't actually know what the right fix is for this, I only checked that my patch fixes the build failure. Is is possible that the function should always be defined. Please make sure you review carefully before applying. --- net/netfilter/nft_socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.29.2 diff --git a/net/netfilter/nft_socket.c b/net/netfilter/nft_socket.c index f9c5ff6024e0..d601974c9d2e 100644 --- a/net/netfilter/nft_socket.c +++ b/net/netfilter/nft_socket.c @@ -34,7 +34,7 @@ static void nft_socket_wildcard(const struct nft_pktinfo *pkt, } } -#ifdef CONFIG_CGROUPS +#ifdef CONFIG_SOCK_CGROUP_DATA static noinline bool nft_sock_get_eval_cgroupv2(u32 *dest, const struct nft_pktinfo *pkt, u32 level) { @@ -106,7 +106,7 @@ static void nft_socket_eval(const struct nft_expr *expr, } nft_socket_wildcard(pkt, regs, sk, dest); break; -#ifdef CONFIG_CGROUPS +#ifdef CONFIG_SOCK_CGROUP_DATA case NFT_SOCKET_CGROUPV2: if (!nft_sock_get_eval_cgroupv2(dest, pkt, priv->level)) { regs->verdict.code = NFT_BREAK;