diff options
author | Soumya Sambu <soumya.sambu@windriver.com> | 2025-03-26 06:45:06 +0000 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2025-03-26 11:28:46 -0700 |
commit | 092eaa77f61f8ab6ceeb0429030d750a2618b1ab (patch) | |
tree | 66a3f6a989452adc82bc0fc5c7643899b5ec5757 | |
parent | 4711dd7d3e0b072e40d04aa3f75f7c1ca38e1ff8 (diff) | |
download | meta-clang-092eaa77f61f8ab6ceeb0429030d750a2618b1ab.tar.gz |
libbpf: Backport bpf_btf_get_info_by_fd
bcc v0.29.1 depends on bpf_btf_get_info_by_fd, which was introduced in libbpf v1.2.0.
Since meta-oe kirkstone provides libbpf v0.7.0, this function was missing,
resulting in a linker error in the bcc build:
undefined reference to `bpf_btf_get_info_by_fd`
This patch backports the necessary commit from libbpf v1.2.0 to v0.7.0,
allowing bcc v0.29.1 to build successfully.
Upstream patch:
https://github.com/libbpf/libbpf/commit/30f6bc3c0a296638e3b6930dbcff6f1547f13997
Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com>
-rw-r--r-- | recipes-kernel/libbpf/libbpf/0001-libbpf-Introduce-bpf_-btf-link-map-prog-_get_info_by.patch | 88 | ||||
-rw-r--r-- | recipes-kernel/libbpf/libbpf_%.bbappend | 10 |
2 files changed, 98 insertions, 0 deletions
diff --git a/recipes-kernel/libbpf/libbpf/0001-libbpf-Introduce-bpf_-btf-link-map-prog-_get_info_by.patch b/recipes-kernel/libbpf/libbpf/0001-libbpf-Introduce-bpf_-btf-link-map-prog-_get_info_by.patch new file mode 100644 index 0000000..ad67791 --- /dev/null +++ b/recipes-kernel/libbpf/libbpf/0001-libbpf-Introduce-bpf_-btf-link-map-prog-_get_info_by.patch | |||
@@ -0,0 +1,88 @@ | |||
1 | From 30f6bc3c0a296638e3b6930dbcff6f1547f13997 Mon Sep 17 00:00:00 2001 | ||
2 | From: Ilya Leoshkevich <iii@linux.ibm.com> | ||
3 | Date: Wed, 15 Feb 2023 00:12:14 +0100 | ||
4 | Subject: [PATCH] libbpf: Introduce bpf_{btf,link,map,prog}_get_info_by_fd() | ||
5 | |||
6 | These are type-safe wrappers around bpf_obj_get_info_by_fd(). They | ||
7 | found one problem in selftests, and are also useful for adding | ||
8 | Memory Sanitizer annotations. | ||
9 | |||
10 | Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> | ||
11 | Signed-off-by: Andrii Nakryiko <andrii@kernel.org> | ||
12 | Link: https://lore.kernel.org/bpf/20230214231221.249277-2-iii@linux.ibm.com | ||
13 | |||
14 | Upstream-Status: Backport [https://github.com/libbpf/libbpf/commit/30f6bc3c0a296638e3b6930dbcff6f1547f13997] | ||
15 | |||
16 | Signed-off-by: Soumya Sambu <soumya.sambu@windriver.com> | ||
17 | --- | ||
18 | src/bpf.c | 20 ++++++++++++++++++++ | ||
19 | src/bpf.h | 9 +++++++++ | ||
20 | src/libbpf.map | 4 ++++ | ||
21 | 3 files changed, 33 insertions(+) | ||
22 | |||
23 | diff --git a/src/bpf.c b/src/bpf.c | ||
24 | index 418b259..7f4f4f7 100644 | ||
25 | --- a/src/bpf.c | ||
26 | +++ b/src/bpf.c | ||
27 | @@ -1118,6 +1118,26 @@ int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len) | ||
28 | return libbpf_err_errno(err); | ||
29 | } | ||
30 | |||
31 | +int bpf_prog_get_info_by_fd(int prog_fd, struct bpf_prog_info *info, __u32 *info_len) | ||
32 | +{ | ||
33 | + return bpf_obj_get_info_by_fd(prog_fd, info, info_len); | ||
34 | +} | ||
35 | + | ||
36 | +int bpf_map_get_info_by_fd(int map_fd, struct bpf_map_info *info, __u32 *info_len) | ||
37 | +{ | ||
38 | + return bpf_obj_get_info_by_fd(map_fd, info, info_len); | ||
39 | +} | ||
40 | + | ||
41 | +int bpf_btf_get_info_by_fd(int btf_fd, struct bpf_btf_info *info, __u32 *info_len) | ||
42 | +{ | ||
43 | + return bpf_obj_get_info_by_fd(btf_fd, info, info_len); | ||
44 | +} | ||
45 | + | ||
46 | +int bpf_link_get_info_by_fd(int link_fd, struct bpf_link_info *info, __u32 *info_len) | ||
47 | +{ | ||
48 | + return bpf_obj_get_info_by_fd(link_fd, info, info_len); | ||
49 | +} | ||
50 | + | ||
51 | int bpf_raw_tracepoint_open(const char *name, int prog_fd) | ||
52 | { | ||
53 | union bpf_attr attr; | ||
54 | diff --git a/src/bpf.h b/src/bpf.h | ||
55 | index 16b2175..8b78c62 100644 | ||
56 | --- a/src/bpf.h | ||
57 | +++ b/src/bpf.h | ||
58 | @@ -473,6 +473,15 @@ LIBBPF_API int bpf_map_get_fd_by_id(__u32 id); | ||
59 | LIBBPF_API int bpf_btf_get_fd_by_id(__u32 id); | ||
60 | LIBBPF_API int bpf_link_get_fd_by_id(__u32 id); | ||
61 | LIBBPF_API int bpf_obj_get_info_by_fd(int bpf_fd, void *info, __u32 *info_len); | ||
62 | +/* Type-safe variants of bpf_obj_get_info_by_fd(). The callers still needs to | ||
63 | + * pass info_len, which should normally be | ||
64 | + * sizeof(struct bpf_{prog,map,btf,link}_info), in order to be compatible with | ||
65 | + * different libbpf and kernel versions. | ||
66 | + */ | ||
67 | +LIBBPF_API int bpf_prog_get_info_by_fd(int prog_fd, struct bpf_prog_info *info, __u32 *info_len); | ||
68 | +LIBBPF_API int bpf_map_get_info_by_fd(int map_fd, struct bpf_map_info *info, __u32 *info_len); | ||
69 | +LIBBPF_API int bpf_btf_get_info_by_fd(int btf_fd, struct bpf_btf_info *info, __u32 *info_len); | ||
70 | +LIBBPF_API int bpf_link_get_info_by_fd(int link_fd, struct bpf_link_info *info, __u32 *info_len); | ||
71 | LIBBPF_API int bpf_prog_query(int target_fd, enum bpf_attach_type type, | ||
72 | __u32 query_flags, __u32 *attach_flags, | ||
73 | __u32 *prog_ids, __u32 *prog_cnt); | ||
74 | diff --git a/src/libbpf.map b/src/libbpf.map | ||
75 | index 47e70c9..c2df7aa 100644 | ||
76 | --- a/src/libbpf.map | ||
77 | +++ b/src/libbpf.map | ||
78 | @@ -438,4 +438,8 @@ LIBBPF_0.7.0 { | ||
79 | libbpf_probe_bpf_map_type; | ||
80 | libbpf_probe_bpf_prog_type; | ||
81 | libbpf_set_memlock_rlim_max; | ||
82 | + bpf_btf_get_info_by_fd; | ||
83 | + bpf_link_get_info_by_fd; | ||
84 | + bpf_map_get_info_by_fd; | ||
85 | + bpf_prog_get_info_by_fd; | ||
86 | } LIBBPF_0.6.0; | ||
87 | -- | ||
88 | 2.40.0 | ||
diff --git a/recipes-kernel/libbpf/libbpf_%.bbappend b/recipes-kernel/libbpf/libbpf_%.bbappend new file mode 100644 index 0000000..b5a6319 --- /dev/null +++ b/recipes-kernel/libbpf/libbpf_%.bbappend | |||
@@ -0,0 +1,10 @@ | |||
1 | FILESEXTRAPATHS:prepend := "${THISDIR}/libbpf:" | ||
2 | |||
3 | LIC_FILES_CHKSUM = "file://LICENSE.LGPL-2.1;md5=b370887980db5dd40659b50909238dbd" | ||
4 | |||
5 | SRC_URI += "\ | ||
6 | file://0001-libbpf-Introduce-bpf_-btf-link-map-prog-_get_info_by.patch" | ||
7 | |||
8 | S = "${WORKDIR}/git" | ||
9 | |||
10 | EXTRA_OEMAKE += " -C ${S}/src" | ||