From nobody Sun May 11 17:39:49 2025 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60E51201259 for <linux-kernel@vger.kernel.org>; Tue, 1 Apr 2025 11:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743508670; cv=none; b=jpuXm6EoB8U8EyYMEiywC6DRUBicPXt1hTES9Iih5L8TGfJMyRMceLxI0mDRQJjEQJ1qUVGsh3KPgUQoXAO+9OV2n+w69ihS0PjEZ9a+GtJBIF3UkmcMr4ekpZEKGJCpt7HDtPafA/CJGwYqeYViTb5p1ygE1FKtajOVwm2C1dc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743508670; c=relaxed/simple; bh=0nF+xuWoBYdZV0D86oQiQH2Vwm5eF02ZJMZE7MDdRmA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hH31BZMr/p184SntqzFDv7ofEt2HZgfwHSVlaFvb10H4VHDBnXuQpD9FcoD7BHwlKv1Fn2ddgZAnZQlWKzZ9biQh8eaocNnZQQLxnfJy/U7yWvYN/QeWebziX2G/UUCHzp/WWwCj6uSCUePSq24J4d8FibQiA6mcZgaAzk+QWjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=DwaWVLd3; arc=none smtp.client-ip=209.85.221.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="DwaWVLd3" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-3914bc3e01aso3068216f8f.2 for <linux-kernel@vger.kernel.org>; Tue, 01 Apr 2025 04:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743508666; x=1744113466; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QES0z4GKQZ/03VJyRHrdN6C5fCNjDAjguyeu9jRmFsw=; b=DwaWVLd3S1DkuWMm1lSXsFQg7ulbNgQpfwCCVUiCFybu6QOp397A3uFhgvrfjkVOh/ RVQ2Thxkn+by3rPERCqRA78wx7CLJ+hRMhQ0qRRz+Ol5VlCG2HfVAVeDtELVQIX/n0HF gVJSfT6vpH1OJYLEI0anrTVXoW5Z1pD6iqieHS9HQKhM6ot9YN4Kz0zluKJJGi9w/zeQ g5pnNQwwJK0MzsSNSJmm+EIuMswc/GOpYD3H+aiWhyqblo2VOkfONqFBOt+JrrauoSWk 6upiWFPQWzMFmYikfsMHiqe12GWyC3noYHv7QqHVtyLQgClJ7X4IIbmIej5O24TDmVpx AyGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743508666; x=1744113466; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QES0z4GKQZ/03VJyRHrdN6C5fCNjDAjguyeu9jRmFsw=; b=rkkicRgOO9Y13n+wEb1+1G9LN7576haEZyL5+J5zmShbCRSiLiGAhnTGq+7kwDd5Fe xfOVTNDLz64iz2DSrXVKGfGccl8J1X/B5ln1Se5jL2Zk+XhN2rgin0/SC88jnHO1YOfc m3sRZ9w+iqXTgbAzfiR+n9y5G0kXeByTg2GIbVQNbjylndehfBiNWdQ/ZOKxFHFShCF0 wbsSlv5j+cZhjqfPq0K1gGYU6rrxmT7+bPsIXWPJFNAehtZTj0GtiltbBb52bKbbdR+h GiMg6f9HDgwX9ai2FRvafiOPlGEdZjO6Ry6anYKPXm+uayj5AfkR9wfYfwsDHUrsbVKg VqgA== X-Forwarded-Encrypted: i=1; AJvYcCValy9UEDhM89B1UNOwgqFw0kmUIYrmYDHtlhHPuyrUfpy3fKhCuZE9CwHkF4nRegpnkPCrkLTj3SxZEDY=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1UyNgQcqAt9AyhN4wAckP4v65tpt0B138qvdpyEtIgot4i9Ma zGI3FvIZ9n7if9OUXFqcMsckk3VVxUXF6RE3Zy3BnvXhNpKbItU+V4elVYQNuM8= X-Gm-Gg: ASbGnctVrMsmSzxHtcGOEp12Xps4qt0/CxYcbAiLXC/JVDdN93TXvtoHFV3b7itrobn 2RNe7PF3qWQ00Pk8EbeWS7M1IQkpiuRkMkmpqs6ReA0ugOhuZOVdEBAXpH6GHv+JSqnNRKxNbad YjsNGGC4zuwk61axhZuMjvcEcRYQ5ZD1XMgDDFep7lYoGTu2ELsVSOhDKUWEmHZ3wnbDwuUNsTR RGNcb213OJ/uQiYiIGms+K7GcIDLatGTLcQR0VOEIB2bLeRP9ymIkD+2MQ7rauyyF26avaJM9N6 8bjcs7uNS2vDBumvDaDes244AyBsaQcTw86WiGzCe3WDd85qfFXpMIKS0Q== X-Google-Smtp-Source: AGHT+IGbkEZGFrvbkbtiGNNuU6I3p4pFZhW/qtEV+/o0HWkjf6ohu6IRuXXV/ov23+gGbTey36rZSg== X-Received: by 2002:a5d:5f45:0:b0:391:2306:5131 with SMTP id ffacd0b85a97d-39c1211b902mr10393579f8f.45.1743508666586; Tue, 01 Apr 2025 04:57:46 -0700 (PDT) Received: from blackdock.suse.cz ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b7a42a3sm14130150f8f.91.2025.04.01.04.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 04:57:46 -0700 (PDT) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com> To: netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>, Jan Engelhardt <ej@inai.de>, Florian Westphal <fw@strlen.de>, Pablo Neira Ayuso <pablo@netfilter.org>, Jozsef Kadlecsik <kadlec@netfilter.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org> Subject: [PATCH v3 1/3] netfilter: Make xt_cgroup independent from net_cls Date: Tue, 1 Apr 2025 13:57:30 +0200 Message-ID: <20250401115736.1046942-2-mkoutny@suse.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401115736.1046942-1-mkoutny@suse.com> References: <20250401115736.1046942-1-mkoutny@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The xt_group matching supports the default hierarchy since commit c38c4597e4bf3 ("netfilter: implement xt_cgroup cgroup2 path match"). The cgroup v1 matching (based on clsid) and cgroup v2 matching (based on path) are rather independent. Downgrade the Kconfig dependency to mere CONFIG_SOCK_GROUP_DATA so that xt_group can be built even without CONFIG_NET_CLS_CGROUP for path matching. Also add a message for users when they attempt to specify any clsid. Link: https://lists.opensuse.org/archives/list/kernel@lists.opensuse.org/th= read/S23NOILB7MUIRHSKPBOQKJHVSK26GP6X/ Cc: Jan Engelhardt <ej@inai.de> Cc: Florian Westphal <fw@strlen.de> Signed-off-by: Michal Koutn=C3=BD <mkoutny@suse.com> --- net/netfilter/Kconfig | 2 +- net/netfilter/xt_cgroup.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig index df2dc21304efb..346ac2152fa18 100644 --- a/net/netfilter/Kconfig +++ b/net/netfilter/Kconfig @@ -1180,7 +1180,7 @@ config NETFILTER_XT_MATCH_CGROUP tristate '"control group" match support' depends on NETFILTER_ADVANCED depends on CGROUPS - select CGROUP_NET_CLASSID + select SOCK_CGROUP_DATA help Socket/process control group matching allows you to match locally generated packets based on which net_cls control group processes diff --git a/net/netfilter/xt_cgroup.c b/net/netfilter/xt_cgroup.c index c0f5e9a4f3c65..66915bf0d89ad 100644 --- a/net/netfilter/xt_cgroup.c +++ b/net/netfilter/xt_cgroup.c @@ -23,6 +23,8 @@ MODULE_DESCRIPTION("Xtables: process control group matchi= ng"); MODULE_ALIAS("ipt_cgroup"); MODULE_ALIAS("ip6t_cgroup"); =20 +#define NET_CLS_CLASSID_INVALID_MSG "xt_cgroup: classid invalid without ne= t_cls cgroups\n" + static int cgroup_mt_check_v0(const struct xt_mtchk_param *par) { struct xt_cgroup_info_v0 *info =3D par->matchinfo; @@ -30,6 +32,11 @@ static int cgroup_mt_check_v0(const struct xt_mtchk_para= m *par) if (info->invert & ~1) return -EINVAL; =20 + if (!IS_ENABLED(CONFIG_CGROUP_NET_CLASSID)) { + pr_info(NET_CLS_CLASSID_INVALID_MSG); + return -EINVAL; + } + return 0; } =20 @@ -51,6 +58,11 @@ static int cgroup_mt_check_v1(const struct xt_mtchk_para= m *par) return -EINVAL; } =20 + if (info->has_classid && !IS_ENABLED(CONFIG_CGROUP_NET_CLASSID)) { + pr_info(NET_CLS_CLASSID_INVALID_MSG); + return -EINVAL; + } + info->priv =3D NULL; if (info->has_path) { cgrp =3D cgroup_get_from_path(info->path); @@ -83,6 +95,11 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_para= m *par) return -EINVAL; } =20 + if (info->has_classid && !IS_ENABLED(CONFIG_CGROUP_NET_CLASSID)) { + pr_info(NET_CLS_CLASSID_INVALID_MSG); + return -EINVAL; + } + info->priv =3D NULL; if (info->has_path) { cgrp =3D cgroup_get_from_path(info->path); --=20 2.48.1 From nobody Sun May 11 17:39:49 2025 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A40F3202962 for <linux-kernel@vger.kernel.org>; Tue, 1 Apr 2025 11:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743508671; cv=none; b=KKsLKHIUcibTF4pV2yrLU+DWUkQnZjLpYdmz5RZQ1oinkAv5v1CuumlBb7Tq76WdFFNjYmofPLTVqTYq7REbTj2yrDY3yUUUHsoGvt2wwjDxoeCYiXqmClwwV8o8ELUARrdPovEn7ZZzr5Ttm0qVFFani+3+d0w9Wv2NRvMj3QY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743508671; c=relaxed/simple; bh=VK+fAhdQMlQ7VgF66YAdeZfWP2MQ7T6BVegVmMM36Xg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Yh6yNt5j+Ef1oyy8Gna9t2Mtmm3Z6kh881XWpQOv0LFjFOexOJ0k4JQjnyHbw4t7de41Y+ukpv9mOS6gVc5CHh3AGOmfUPx+1PQSCys9WLA1rBXEQGGZ+YHG788xA7JjE4WRKeiL+UayKsW4HIoLGJBkX60FmuJvGsMq2h+x7FY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Flqb95Wh; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Flqb95Wh" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-43ce70f9afbso56716285e9.0 for <linux-kernel@vger.kernel.org>; Tue, 01 Apr 2025 04:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743508668; x=1744113468; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7JL5RckWDUXDVUtbygqah1s+l5iawSiiKQxqaHFxngI=; b=Flqb95Whxarxx1y2zVRSDYwRML1hN7aXeN35K4bl8fDUlJqo/VG3VJ4g5+Pmm34uDQ IzJbI0zMYE7CP1btv9zVFz9E2UquF9+C3vhtnGEdshBfOq7jupORYeZ3YrKvakx+0iPA dIq3XWbINFY4RWuJPRvmAIHVBWfP1bmr0jKp7vfDcsv1PWLIaF2wDvb4XFGYBbpTOQLB W1Dv7r10XCjb2IyazhBtL04RFQJNlheJNdyNZ6ZiAvqCpcc6+ebT6/qhqm2npQwqwW2u cVuxru68SXS7cQVDncdlwPM4K+tN7hO1V7kr4w5OMkzp4JWw/4y1lAYZ/MpwTdNAR9PR 3e2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743508668; x=1744113468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7JL5RckWDUXDVUtbygqah1s+l5iawSiiKQxqaHFxngI=; b=lx3zZtnvVlcHnwm9jQgL4rOX5KkIeF+aK/pH/vvVf8Gn2IR1aAeb3bzy8p8L6J3t7f Q8LG4Vcru6IfH2ioYldpzqM4BCRZVHv5z1Z/kataHQHibTL13ygIoN9rKWnKLyWoOGXY X1C0r3mUjLeD1EEaYZvrskCHnVZ9ixyegfuelD+9W25+QvG4/77Uv1NeuhZI56lBarLN rFp6DHwQclZetvMgPkkE7E3Gg3Rna1sGPQ7VZ7ckCNbMSfcK4RvjvwloNiTjCPPw7Bxl hnr41r5sGTcZLrWlUykQg342vOvSEyQyb0Xl9hSCs9254OeraA2K8SBRW9FQxk9tXphh 2Veg== X-Forwarded-Encrypted: i=1; AJvYcCUgYlhI8tuX6EwmVnhvqYPu6IEyMZ/2CuKQAztfFslD8LATwvL8OD1CpZNdLFymiezKeUvAUzVUCW1xMKU=@vger.kernel.org X-Gm-Message-State: AOJu0YzspwLwcbQ392v1sxSywmhhjsusQpCnz5FPscI++LSw6BmTRF3c cwouvoqaqexO5kGDS4dZFsDHsjBh0kAM8pPS9vRsVqXeSvm9E/koEgkb7dlmv60= X-Gm-Gg: ASbGncvi/gFqsUld8KMS4bjB//c6TkrNXULz+yxoRBble0SEeH1P73jgCk7pLlA/wN3 Ouky9Q4kyHwwLbr15BnOyDXq+aDrj7D57RJxlPTgJRrB9ZGVlwcWtpC+owOlta0BMEVP2NT/Ydy wQnGF7mNk/U9HwQxHI+csVlObI4M5W0ZqEW0nNEAsigSgm2kiM69BZ2l0zPluOtxblmMdE1+mpe lDtTa6DBsRp+0Dpy3Cv2TFchMqLA2HqDrM/7BDIfvo+RXBKBKsutFOvcDCbe5TiK2n606UiBjas ZSALaUmElWW1U3HKb+jADDnHJZ3gzRkTh9fbsOhmL3/5Rzw= X-Google-Smtp-Source: AGHT+IFLfOc6mWYMvUI2usLmBhWmFn3VeupA7JlTfwgrP5x7X9un5A68VjtyMV5CDIEoULbCkYWxhg== X-Received: by 2002:a05:6000:4282:b0:391:1652:f0bf with SMTP id ffacd0b85a97d-39c120f741amr10153656f8f.33.1743508667931; Tue, 01 Apr 2025 04:57:47 -0700 (PDT) Received: from blackdock.suse.cz ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b7a42a3sm14130150f8f.91.2025.04.01.04.57.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 04:57:47 -0700 (PDT) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com> To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org Cc: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>, "David S. Miller" <davem@davemloft.net>, David Ahern <dsahern@kernel.org>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>, Pablo Neira Ayuso <pablo@netfilter.org>, Jozsef Kadlecsik <kadlec@netfilter.org> Subject: [PATCH v3 2/3] cgroup: Guard users of sock_cgroup_classid() Date: Tue, 1 Apr 2025 13:57:31 +0200 Message-ID: <20250401115736.1046942-3-mkoutny@suse.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401115736.1046942-1-mkoutny@suse.com> References: <20250401115736.1046942-1-mkoutny@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Exclude code that relies on sock_cgroup_classid() as preparation of removal of the function. Signed-off-by: Michal Koutn=C3=BD <mkoutny@suse.com> --- net/ipv4/inet_diag.c | 2 +- net/netfilter/xt_cgroup.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 321acc8abf17e..886dbe65ed9e8 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -160,7 +160,7 @@ int inet_diag_msg_attrs_fill(struct sock *sk, struct sk= _buff *skb, ext & (1 << (INET_DIAG_TCLASS - 1))) { u32 classid =3D 0; =20 -#ifdef CONFIG_SOCK_CGROUP_DATA +#ifdef CONFIG_CGROUP_NET_CLASSID classid =3D sock_cgroup_classid(&sk->sk_cgrp_data); #endif /* Fallback to socket priority if class id isn't set. diff --git a/net/netfilter/xt_cgroup.c b/net/netfilter/xt_cgroup.c index 66915bf0d89ad..c437fbd59ec13 100644 --- a/net/netfilter/xt_cgroup.c +++ b/net/netfilter/xt_cgroup.c @@ -117,6 +117,7 @@ static int cgroup_mt_check_v2(const struct xt_mtchk_par= am *par) static bool cgroup_mt_v0(const struct sk_buff *skb, struct xt_action_param *par) { +#ifdef CONFIG_CGROUP_NET_CLASSID const struct xt_cgroup_info_v0 *info =3D par->matchinfo; struct sock *sk =3D skb->sk; =20 @@ -125,6 +126,8 @@ cgroup_mt_v0(const struct sk_buff *skb, struct xt_actio= n_param *par) =20 return (info->id =3D=3D sock_cgroup_classid(&skb->sk->sk_cgrp_data)) ^ info->invert; +#endif + return false; } =20 static bool cgroup_mt_v1(const struct sk_buff *skb, struct xt_action_param= *par) @@ -140,9 +143,12 @@ static bool cgroup_mt_v1(const struct sk_buff *skb, st= ruct xt_action_param *par) if (ancestor) return cgroup_is_descendant(sock_cgroup_ptr(skcd), ancestor) ^ info->invert_path; +#ifdef CONFIG_CGROUP_NET_CLASSID else return (info->classid =3D=3D sock_cgroup_classid(skcd)) ^ info->invert_classid; +#endif + return false; } =20 static bool cgroup_mt_v2(const struct sk_buff *skb, struct xt_action_param= *par) @@ -158,9 +164,12 @@ static bool cgroup_mt_v2(const struct sk_buff *skb, st= ruct xt_action_param *par) if (ancestor) return cgroup_is_descendant(sock_cgroup_ptr(skcd), ancestor) ^ info->invert_path; +#ifdef CONFIG_CGROUP_NET_CLASSID else return (info->classid =3D=3D sock_cgroup_classid(skcd)) ^ info->invert_classid; +#endif + return false; } =20 static void cgroup_mt_destroy_v1(const struct xt_mtdtor_param *par) --=20 2.48.1 From nobody Sun May 11 17:39:49 2025 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDED420299A for <linux-kernel@vger.kernel.org>; Tue, 1 Apr 2025 11:57:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743508672; cv=none; b=GQYZ2/JUSayvTcLDsjooyYUA+QVADjM6qZn3Rla7VCwadIcD6oXW6ajfkzI1lKQKLZuocmXrsJiHVTbc7jmdXE6Y96Y394AmKE72RoqRfrTjr3x4gGGA+cvAjWHKsixi0H5EfUQ2ahaDZwCq8S+e8N8JmsLfQ59JDY1XkXufv0M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743508672; c=relaxed/simple; bh=E0+exfqVjPHy3u7zfUx/DCOqizSWrHwao0vl1kGvu+8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UtWJ6QVeHaF9VEN9vUaRV2gdlOPFdlK3zT7Vv4vd4Q5IIXnxPZcpOgAwhTG4V4bDvFEulo114i0JJWsDXyzliKxzNOku8eWyAmaKH3TtERqLhhmP+fSp754x77Ridwvd6ZTjihClAIw8Ntb33K48TD/1cR/00Q9LsyGRUujoRMo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=Qh09Uo0r; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Qh09Uo0r" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-39c13fa05ebso1227306f8f.0 for <linux-kernel@vger.kernel.org>; Tue, 01 Apr 2025 04:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1743508669; x=1744113469; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CYfumVgNUUGcpEJ27Q8ui1p/c9wt59eDcNpxRKPwCw8=; b=Qh09Uo0rikyhA24f6vOfv7CnUvOYVQfcXoQwYw6RPeBUlwxVPWTelLfVu40mZER6/b m6KRfqcZgGT+wJwAGv5Z/kPnZt/tzifYbCMmbm/WWseGMDMX1C/RIET6kGAIJy8uK5Nr blokd9GCBcsyWmxVlXNSawPnJN/yZ950UJn8zybZsB7UWkBy8uddunPg59QR7rgHkjYN ib15Km+qr/5SqjTQZTev4qyfn2XV1cuUOw49oFy+ougj8g3wS2mrTOXbasn+CkZge84i EgkwlvheOkMX9oBi4lVAsCFy99/yfJ5zGLsQhx90FtSR8PW6JJwAf2aofGpXT8aTqzKm YdLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743508669; x=1744113469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CYfumVgNUUGcpEJ27Q8ui1p/c9wt59eDcNpxRKPwCw8=; b=eQYEcMNkLRU+ifJb0yRkvtgx1BD5B9Z8MocJrj624d8020TbdpOotUsdY79dWMdYLz 07mcSOcnG5hS8+X+4JxyKBBJooplJ5L5b6M0DzXqE6hMU+fPKJ2HapoFtvS2fhRAID7o qHhJNOM98wtH2qI52uRShKAB+s7JuPzLev2HZvESowMqhsWFlogYNhngOSoty0B/J8jn lwMLU/01aa1nDteyJOUl3BiCzzAq8m6hy+5hbVFRI7PeXHj56t/bBGYzCeNIxMkRiA3r 7QraGkHtm0HKb7h0xucXNxWVi7WU7tZbRi8fgd5QVgtubMLLOdbgTiKJCzkEgZGdCcx9 RD4A== X-Forwarded-Encrypted: i=1; AJvYcCV5iusawezRz6cYhICyjXmrio7cqFaAoj5ybXWCpJMsgk/D46tvCCsS01N6hrt2ugd31L1Z4VE5bLOMHXk=@vger.kernel.org X-Gm-Message-State: AOJu0YzikPEhMyw9VeJsVYZWCMP6oNG17O+FPCrPlmiwLAnJe3qXRm+M NstaxoXjV2A6UQCcAEZUxkqcSSTibQ/v5mPPqut6UHyxwzngEGu6jKviSaa0Jhk= X-Gm-Gg: ASbGncvzHjoO/Jzi3QsXo1TfdmEszmqMmh4tSa5Bt6XyfswubhgTb0tLYfOzniZH6nj 7S8H3ivI0deO16p2NUQGuFECOul0C3dvclMlotkyVHA4hznSe8ic7qvt1nXhMr++jgwbQJwgKtD Dg2BHoJHO3OUsAw2XzmTHLEewP+R9nh7ToaE2UUGlqmsXMflCcf709GTxBqtd+VNEXYNJ37FNh7 gwpILBjm5+Ma0orih4wHJlDuCAqbnBSZyGT+lEo4jNrwHhIirB5vYL7dcwTB1932PfhJgEAoCxU H8k0ZtD19C7KZDu7lx1qKyifgYjv6HG3XmNIG41+KNAd4Co= X-Google-Smtp-Source: AGHT+IHft1xCvejDy94t7YBv8XrfyqQwOT6qYu3NmUFkGtsxbskgvYLtZMr36q2jppnAQb1Fl+BCKA== X-Received: by 2002:a05:6000:4027:b0:391:2b11:657 with SMTP id ffacd0b85a97d-39c121186d5mr10146209f8f.38.1743508669030; Tue, 01 Apr 2025 04:57:49 -0700 (PDT) Received: from blackdock.suse.cz ([193.86.92.181]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-39c0b7a42a3sm14130150f8f.91.2025.04.01.04.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Apr 2025 04:57:48 -0700 (PDT) From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com> To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Cc: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>, Tejun Heo <tj@kernel.org>, Johannes Weiner <hannes@cmpxchg.org> Subject: [PATCH v3 3/3] cgroup: Drop sock_cgroup_classid() dummy implementation Date: Tue, 1 Apr 2025 13:57:32 +0200 Message-ID: <20250401115736.1046942-4-mkoutny@suse.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250401115736.1046942-1-mkoutny@suse.com> References: <20250401115736.1046942-1-mkoutny@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The semantic of returning 0 is unclear when !CONFIG_CGROUP_NET_CLASSID. Since there are no callers of sock_cgroup_classid() with that config anymore we can undefine the helper at all and enforce all (future) callers to handle cases when !CONFIG_CGROUP_NET_CLASSID. Signed-off-by: Michal Koutn=C3=BD <mkoutny@suse.com> --- include/linux/cgroup-defs.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 17960a1e858db..28f33b0807c9a 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -866,14 +866,12 @@ static inline u16 sock_cgroup_prioidx(const struct so= ck_cgroup_data *skcd) #endif } =20 +#ifdef CONFIG_CGROUP_NET_CLASSID static inline u32 sock_cgroup_classid(const struct sock_cgroup_data *skcd) { -#ifdef CONFIG_CGROUP_NET_CLASSID return READ_ONCE(skcd->classid); -#else - return 0; -#endif } +#endif =20 static inline void sock_cgroup_set_prioidx(struct sock_cgroup_data *skcd, u16 prioidx) @@ -883,13 +881,13 @@ static inline void sock_cgroup_set_prioidx(struct soc= k_cgroup_data *skcd, #endif } =20 +#ifdef CONFIG_CGROUP_NET_CLASSID static inline void sock_cgroup_set_classid(struct sock_cgroup_data *skcd, u32 classid) { -#ifdef CONFIG_CGROUP_NET_CLASSID WRITE_ONCE(skcd->classid, classid); -#endif } +#endif =20 #else /* CONFIG_SOCK_CGROUP_DATA */ =20 --=20 2.48.1