From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 69-171-232-181.mail-mxout.facebook.com (69-171-232-181.mail-mxout.facebook.com [69.171.232.181]) (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 6E15C3AFAE3 for ; Sat, 17 Oct 2026 02:53:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=69.171.232.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792205621; cv=none; b=cVEPG3Q1E/IunnLmX7X1uDYwDsL6c4SSFoAbf1WuGj2RTMkSgdZJ60EuXzQqmN/YF5+J2HkScjvNP3E4n6pmze4Y0YZIKIx6ncUO1GQ9JV35qU85G6J4t/afrmYQYCwlYmgFx+VtSakXs5JpSA+lkL8uoA1RNqGpHOjj5EDfLkU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792205621; c=relaxed/simple; bh=CRQOy9uTXhGtzR2PfHD5e5sVz4hKe4QN0cz7oVEhmTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=idnTFFjLGY48r1RrgSdWXuClCElmCsUI9q6o0NelFNt4UsuEizPFfkvqZGCbBoM2RJzyJ1gh782phnmimpz8AHnk7BE9BbAZmcniMmxwD4snSUbWnrIjUMeJerDknCYJY5MJ6GBvevaRr9WODF2jCRVs/62QFExnWG88mvYUHA4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=fail smtp.mailfrom=linux.dev; arc=none smtp.client-ip=69.171.232.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.dev Received: by devvm16039.vll0.facebook.com (Postfix, from userid 128203) id 7C41B31B3B00F6; Fri, 16 Oct 2026 19:53:03 -0700 (PDT) From: Yonghong Song To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Eduard Zingerman , kernel-team@fb.com Subject: [PATCH bpf-next v12 18/25] libbpf: Add cleanup_info to bpf_prog_load_opts Date: Fri, 16 Oct 2026 19:53:03 -0700 Message-ID: <20261017025303.1928466-1-yonghong.song@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261017025129.1914859-1-yonghong.song@linux.dev> References: <20261017025129.1914859-1-yonghong.song@linux.dev> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Let a caller hand the kernel an exception cleanup table: bpf_prog_load_opts grows cleanup_info_cnt, cleanup_info and cleanup_info_rec_size, which bpf_prog_load() passes on to BPF_PROG_LOAD. cleanup_info_cnt comes first to fill the hole after fd_array_cnt. Signed-off-by: Yonghong Song --- tools/lib/bpf/bpf.c | 6 +++++- tools/lib/bpf/bpf.h | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index b49822d212ae..b4031f62bdee 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -295,7 +295,7 @@ int bpf_prog_load(enum bpf_prog_type prog_type, const struct bpf_insn *insns, size_t insn_cnt, struct bpf_prog_load_opts *opts) { - const size_t attr_sz =3D offsetofend(union bpf_attr, keyring_id); + const size_t attr_sz =3D offsetofend(union bpf_attr, cleanup_info_cnt); void *finfo =3D NULL, *linfo =3D NULL; const char *func_info, *line_info; __u32 log_size, log_level, attach_prog_fd, attach_btf_obj_fd; @@ -370,6 +370,10 @@ int bpf_prog_load(enum bpf_prog_type prog_type, attr.fd_array =3D ptr_to_u64(OPTS_GET(opts, fd_array, NULL)); attr.fd_array_cnt =3D OPTS_GET(opts, fd_array_cnt, 0); =20 + attr.cleanup_info =3D ptr_to_u64(OPTS_GET(opts, cleanup_info, NULL)); + attr.cleanup_info_rec_size =3D OPTS_GET(opts, cleanup_info_rec_size, 0)= ; + attr.cleanup_info_cnt =3D OPTS_GET(opts, cleanup_info_cnt, 0); + if (log_level) { attr.log_buf =3D ptr_to_u64(log_buf); attr.log_size =3D log_size; diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 826d9cc9ab65..64699e0e4e1a 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h @@ -128,9 +128,17 @@ struct bpf_prog_load_opts { =20 /* if set, provides the length of fd_array */ __u32 fd_array_cnt; + + /* exception cleanup table: cleanup_info_cnt records of + * cleanup_info_rec_size bytes each (struct bpf_cleanup_info), + * holding instruction indices into insns + */ + __u32 cleanup_info_cnt; + const void *cleanup_info; + __u32 cleanup_info_rec_size; size_t :0; }; -#define bpf_prog_load_opts__last_field fd_array_cnt +#define bpf_prog_load_opts__last_field cleanup_info_rec_size =20 LIBBPF_API int bpf_prog_load(enum bpf_prog_type prog_type, const char *prog_name, const char *license, --=20 2.53.0-Meta