Skip to content

Commit 8de6cae

Browse files
mauriciovasquezbernalanakryiko
authored andcommitted
libbpf: Expose bpf_core_{add,free}_cands() to bpftool
Expose bpf_core_add_cands() and bpf_core_free_cands() to handle candidates list. Signed-off-by: Mauricio Vásquez <[email protected]> Signed-off-by: Rafael David Tinoco <[email protected]> Signed-off-by: Lorenzo Fontana <[email protected]> Signed-off-by: Leonardo Di Donato <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent adb8fa1 commit 8de6cae

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5192,18 +5192,21 @@ size_t bpf_core_essential_name_len(const char *name)
51925192
return n;
51935193
}
51945194

5195-
static void bpf_core_free_cands(struct bpf_core_cand_list *cands)
5195+
void bpf_core_free_cands(struct bpf_core_cand_list *cands)
51965196
{
5197+
if (!cands)
5198+
return;
5199+
51975200
free(cands->cands);
51985201
free(cands);
51995202
}
52005203

5201-
static int bpf_core_add_cands(struct bpf_core_cand *local_cand,
5202-
size_t local_essent_len,
5203-
const struct btf *targ_btf,
5204-
const char *targ_btf_name,
5205-
int targ_start_id,
5206-
struct bpf_core_cand_list *cands)
5204+
int bpf_core_add_cands(struct bpf_core_cand *local_cand,
5205+
size_t local_essent_len,
5206+
const struct btf *targ_btf,
5207+
const char *targ_btf_name,
5208+
int targ_start_id,
5209+
struct bpf_core_cand_list *cands)
52075210
{
52085211
struct bpf_core_cand *new_cands, *cand;
52095212
const struct btf_type *t, *local_t;

tools/lib/bpf/libbpf_internal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,4 +529,13 @@ static inline int ensure_good_fd(int fd)
529529
return fd;
530530
}
531531

532+
/* The following two functions are exposed to bpftool */
533+
int bpf_core_add_cands(struct bpf_core_cand *local_cand,
534+
size_t local_essent_len,
535+
const struct btf *targ_btf,
536+
const char *targ_btf_name,
537+
int targ_start_id,
538+
struct bpf_core_cand_list *cands);
539+
void bpf_core_free_cands(struct bpf_core_cand_list *cands);
540+
532541
#endif /* __LIBBPF_LIBBPF_INTERNAL_H */

0 commit comments

Comments
 (0)