Re: [PATCH bpf-next v5 1/6] libbpf: expose resolve_func_ptr() through libbpf_internal.h.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 2/28/24 09:45, Andrii Nakryiko wrote:
On Mon, Feb 26, 2024 at 5:04 PM Kui-Feng Lee <thinker.li@xxxxxxxxx> wrote:

bpftool is going to reuse this helper function to support shadow types of
struct_ops maps.

Signed-off-by: Kui-Feng Lee <thinker.li@xxxxxxxxx>
---
  tools/lib/bpf/libbpf.c          | 2 +-
  tools/lib/bpf/libbpf_internal.h | 2 ++
  2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 01f407591a92..ef8fd20f33ca 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -2145,7 +2145,7 @@ skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id)
         return t;
  }

-static const struct btf_type *
+const struct btf_type *
  resolve_func_ptr(const struct btf *btf, __u32 id, __u32 *res_id)
  {
         const struct btf_type *t;
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index ad936ac5e639..17e6d381da6a 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -234,6 +234,8 @@ struct btf_type;
  struct btf_type *btf_type_by_id(const struct btf *btf, __u32 type_id);
  const char *btf_kind_str(const struct btf_type *t);
  const struct btf_type *skip_mods_and_typedefs(const struct btf *btf, __u32 id, __u32 *res_id);
+/* This function is exposed to bpftool */
+const struct btf_type *resolve_func_ptr(const struct btf *btf, __u32 id, __u32 *res_id);

it's trivial helper, there is no need for bpftool to reuse it, let's
just implement a local helper for bpftool. We should have done the
same with skip_mods_and_typedefs() in gen.c, but oh well, we can fix
that later.

Generally speaking, I'd like to minimize amount of internal functions
exposed from libbpf to bpftool. It's justified if the logic is
non-trivial, but resolve_func_ptr() is not such case.

Ok! I will add an implementation in gen.c



  static inline enum btf_func_linkage btf_func_linkage(const struct btf_type *t)
  {
--
2.34.1





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux