Hangbin Liu <haliu@xxxxxxxxxx> writes: > On Wed, Oct 28, 2020 at 09:00:41PM -0600, David Ahern wrote: >> >> nope. you need to be able to handle this. Ubuntu 20.10 was just >> >> released, and it has a version of libbpf. If you are going to integrate >> >> libbpf into other packages like iproute2, it needs to just work with >> >> that version. >> > >> > OK, I can replace bpf_program__section_name by bpf_program__title(). >> >> I believe this one can be handled through a compatability check. Looks >> the rename / deprecation is fairly recent (78cdb58bdf15f from Sept 2020). > > Hi David, > > I just come up with another way. In configure, build a temp program and update > the function checking every time is not graceful. How about just check the > libbpf version, since libbpf has exported all functions in src/libbpf.map. > > Currently, only bpf_program__section_name() is added in 0.2.0, all other > needed functions are supported in 0.1.0. > > So in configure, the new check would like: Why is this easier than just checking for the function you need? In xdp-tools configure we have a test like this: check_perf_consume() { cat >$TMPDIR/libbpftest.c <<EOF #include <bpf/libbpf.h> int main(int argc, char **argv) { perf_buffer__consume(NULL); return 0; } EOF libbpf_err=$($CC -o $TMPDIR/libbpftest $TMPDIR/libbpftest.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS 2>&1) if [ "$?" -eq "0" ]; then echo "HAVE_LIBBPF_PERF_BUFFER__CONSUME:=y" >>"$CONFIG" echo "yes" else echo "HAVE_LIBBPF_PERF_BUFFER__CONSUME:=n" >>"$CONFIG" echo "no" fi } Just do that for __section_name(), and you'll also be able to work with custom libbpf versions using LIBBPF_DIR. > static const char *get_bpf_program__section_name(const struct bpf_program *prog) > { > #ifdef HAVE_LIBBPF_SECTION_NAME > return bpf_program__section_name(prog); > #else > return bpf_program__title(prog, false); > #endif > } This bit is fine :) -Toke