On 10/28/20 7:25 AM, Hangbin Liu wrote: > This series converts iproute2 to use libbpf for loading and attaching > BPF programs when it is available. This means that iproute2 will > correctly process BTF information and support the new-style BTF-defined > maps, while keeping compatibility with the old internal map definition > syntax. > > This is achieved by checking for libbpf at './configure' time, and using > it if available. By default the system libbpf will be used, but static > linking against a custom libbpf version can be achieved by passing > LIBBPF_DIR to configure. FORCE_LIBBPF can be set to force configure to > abort if no suitable libbpf is found (useful for automatic packaging > that wants to enforce the dependency). > > The old iproute2 bpf code is kept and will be used if no suitable libbpf > is available. When using libbpf, wrapper code ensures that iproute2 will > still understand the old map definition format, including populating > map-in-map and tail call maps before load. > > The examples in bpf/examples are kept, and a separate set of examples > are added with BTF-based map definitions for those examples where this > is possible (libbpf doesn't currently support declaratively populating > tail call maps). > > At last, Thanks a lot for Toke's help on this patch set. > > > v2: > a) Remove self defined IS_ERR_OR_NULL and use libbpf_get_error() instead. > b) Add ipvrf with libbpf support. > > fails to compile on Ubuntu 20.10: root@u2010-sfo3:~/iproute2.git# ./configure TC schedulers ATM yes IPT using xtables IPSET yes iptables modules directory: /usr/lib/x86_64-linux-gnu/xtables libc has setns: yes SELinux support: yes libbpf support: yes ELF support: yes libmnl support: yes Berkeley DB: no need for strlcpy: yes libcap support: yes root@u2010-sfo3:~/iproute2.git# make clean root@u2010-sfo3:~/iproute2.git# make -j 4 ... /usr/bin/ld: ../lib/libutil.a(bpf_libbpf.o): in function `load_bpf_object': bpf_libbpf.c:(.text+0x3cb): undefined reference to `bpf_program__section_name' /usr/bin/ld: bpf_libbpf.c:(.text+0x438): undefined reference to `bpf_program__section_name' /usr/bin/ld: bpf_libbpf.c:(.text+0x716): undefined reference to `bpf_program__section_name' collect2: error: ld returned 1 exit status make[1]: *** [Makefile:27: ip] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:64: all] Error 2