Skip to content

Commit

Permalink
configure: Detect presence of bpf_program__type()
Browse files Browse the repository at this point in the history
The bpf_program__type() helper was renamed from bpf_program__get_type() in
libbpf 0.7.0, so add detection for this and redefine the new name as a
wrapper if it is not present.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
  • Loading branch information
tohojo committed Apr 12, 2023
1 parent a76e7a2 commit 92d379e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ check_libbpf_functions()
check_libbpf_function "bpf_object__next_map" "(NULL, NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS"
check_libbpf_function "bpf_object__next_program" "(NULL, NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS"
check_libbpf_function "bpf_program__insn_cnt" "(NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS"
check_libbpf_function "bpf_program__type" "(NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS"
check_libbpf_function "bpf_map_create" "(0, NULL, 0, 0, 0, NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS"
check_libbpf_function "perf_buffer__new_raw" "(0, 0, NULL, NULL, NULL, NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS"
check_libbpf_function "bpf_xdp_attach" "(0, 0, 0, NULL)" "" "$LIBBPF_CFLAGS" "$LIBBPF_LDLIBS"
Expand Down
7 changes: 7 additions & 0 deletions lib/libxdp/libxdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ static size_t bpf_program__insn_cnt(const struct bpf_program *prog)
}
#endif

#ifndef HAVE_LIBBPF_BPF_PROGRAM__TYPE
static inline enum bpf_prog_type bpf_program__type(const struct bpf_program *prog)
{
return bpf_program__get_type((struct bpf_program *)prog);
}
#endif

/* This function has been deprecated in libbpf, but we expose an API that uses
* section names, so we reimplement it to keep compatibility
*/
Expand Down

0 comments on commit 92d379e

Please sign in to comment.