From nobody Tue Oct 7 19:22:14 2025 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) (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 9F54C2BE042 for ; Tue, 8 Jul 2025 08:23:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751963012; cv=none; b=Xf/fhsvvvQ2PPE0fEh1prsqgekckVttXlQRTGsE9leWyyE/VCeYxHtKLnHRPKn+q/mLX9hTnigfU2XSnxfn3NAgbQ5krIuNfb+60c615E9G/pAAsVvb06Pv76a0o1bCCDtmpc/1buSUtYlZEKFvgKdycRMlWA0By0bj7LBeXAJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1751963012; c=relaxed/simple; bh=YslBrAgYZPoRig7rfxo1T/sFcH28GOBG7fNzhFWjPEU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G9SPRrSqvscAFwrlRPYPzdpRw2kY5YDE+BT8k2TsmthF5XRjnbE9ecGA+tdZ0basXRUqqCmWTuCELUqSaaVx1syqwggBdzxdAjXk6MJT6e7J2tkiPYG/D8SA7W/8A5mNOGDStdi3MQ7fXb2Y9G1ppyihA58lXxB/Be1gHAObXug= 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=ugYOmMbV; arc=none smtp.client-ip=95.215.58.172 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ugYOmMbV" 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=1751963007; 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: in-reply-to:in-reply-to:references:references; bh=nFFj+EmUdX78YSHXH0ceZJh4m8HxnLe9oo1MhOydXdw=; b=ugYOmMbVKHL5YAQXXq3fcbAlUPYQieljGabIsAYmEHXFaLHCJ5RkTI/Dxt241HSsOB65ug X74S82uEQAbDtwwh0fLlQHGjdHvbYemGrjbNSNOuJmbWez7HKRIOIwji7aC4P6navYUJZ1 spu6hyzBaTTyM6eb/8ENPy/MuOhxpUc= From: Tao Chen To: daniel@iogearbox.net, razor@blackwall.org, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, andrii@kernel.org, martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org, yonghong.song@linux.dev, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me, haoluo@google.com, jolsa@kernel.org, mattbobrowski@google.com, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com, horms@kernel.org, willemb@google.com, jakub@cloudflare.com, pablo@netfilter.org, kadlec@netfilter.org, hawk@kernel.org Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, Tao Chen Subject: [PATCH bpf-next v2 2/7] bpf: Remove attach_type in bpf_cgroup_link Date: Tue, 8 Jul 2025 16:22:23 +0800 Message-ID: <20250708082228.824766-3-chen.dylane@linux.dev> In-Reply-To: <20250708082228.824766-1-chen.dylane@linux.dev> References: <20250708082228.824766-1-chen.dylane@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Use attach_type in bpf_link, and remove it in bpf_cgroup_link. Signed-off-by: Tao Chen --- include/linux/bpf-cgroup.h | 1 - kernel/bpf/cgroup.c | 13 ++++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h index 70c8b94e797..082ccd8ad96 100644 --- a/include/linux/bpf-cgroup.h +++ b/include/linux/bpf-cgroup.h @@ -103,7 +103,6 @@ struct bpf_cgroup_storage { struct bpf_cgroup_link { struct bpf_link link; struct cgroup *cgroup; - enum bpf_attach_type type; }; =20 struct bpf_prog_list { diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index bacdd0ca741..72c8b50dca0 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -984,7 +984,7 @@ static int __cgroup_bpf_replace(struct cgroup *cgrp, struct hlist_head *progs; bool found =3D false; =20 - atype =3D bpf_cgroup_atype_find(link->type, new_prog->aux->attach_btf_id); + atype =3D bpf_cgroup_atype_find(link->link.attach_type, new_prog->aux->at= tach_btf_id); if (atype < 0) return -EINVAL; =20 @@ -1396,8 +1396,8 @@ static void bpf_cgroup_link_release(struct bpf_link *= link) } =20 WARN_ON(__cgroup_bpf_detach(cg_link->cgroup, NULL, cg_link, - cg_link->type, 0)); - if (cg_link->type =3D=3D BPF_LSM_CGROUP) + link->attach_type, 0)); + if (link->attach_type =3D=3D BPF_LSM_CGROUP) bpf_trampoline_unlink_cgroup_shim(cg_link->link.prog); =20 cg =3D cg_link->cgroup; @@ -1439,7 +1439,7 @@ static void bpf_cgroup_link_show_fdinfo(const struct = bpf_link *link, "cgroup_id:\t%llu\n" "attach_type:\t%d\n", cg_id, - cg_link->type); + link->attach_type); } =20 static int bpf_cgroup_link_fill_link_info(const struct bpf_link *link, @@ -1455,7 +1455,7 @@ static int bpf_cgroup_link_fill_link_info(const struc= t bpf_link *link, cgroup_unlock(); =20 info->cgroup.cgroup_id =3D cg_id; - info->cgroup.attach_type =3D cg_link->type; + info->cgroup.attach_type =3D link->attach_type; return 0; } =20 @@ -1497,7 +1497,6 @@ int cgroup_bpf_link_attach(const union bpf_attr *attr= , struct bpf_prog *prog) bpf_link_init(&link->link, BPF_LINK_TYPE_CGROUP, &bpf_cgroup_link_lops, prog, attr->link_create.attach_type); link->cgroup =3D cgrp; - link->type =3D attr->link_create.attach_type; =20 err =3D bpf_link_prime(&link->link, &link_primer); if (err) { @@ -1506,7 +1505,7 @@ int cgroup_bpf_link_attach(const union bpf_attr *attr= , struct bpf_prog *prog) } =20 err =3D cgroup_bpf_attach(cgrp, NULL, NULL, link, - link->type, BPF_F_ALLOW_MULTI | attr->link_create.flags, + link->link.attach_type, BPF_F_ALLOW_MULTI | attr->link_create.flags, attr->link_create.cgroup.relative_fd, attr->link_create.cgroup.expected_revision); if (err) { --=20 2.48.1