Message ID | 20201109070802.3638167-1-haliu@redhat.com |
---|---|
Headers | show |
Series | iproute2: add libbpf support | expand |
On 11/9/20 12:07 AM, Hangbin Liu wrote: > This patch adds a check to see if we have libbpf support. 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. > > Add another variable LIBBPF_FORCE to control whether to build iproute2 > with libbpf. If set to on, then force to build with libbpf and exit if > not available. If set to off, then force to not build with libbpf. > > Signed-off-by: Hangbin Liu <haliu@redhat.com> > > v4: > 1) Remove duplicate LIBBPF_CFLAGS > 2) Remove un-needed -L since using static libbpf.a > 3) Fix == not supported in dash > 4) Extend LIBBPF_FORCE to support on/off, when set to on, stop building when > there is no libbpf support. If set to off, discard libbpf check. > 5) Print libbpf version after checking > > v3: > Check function bpf_program__section_name() separately and only use it > on higher libbpf version. > > v2: > No update > --- > configure | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 108 insertions(+) > > diff --git a/configure b/configure > index 307912aa..3081a2ac 100755 > --- a/configure > +++ b/configure > @@ -2,6 +2,11 @@ > # SPDX-License-Identifier: GPL-2.0 > # This is not an autoconf generated configure > # > +# Influential LIBBPF environment variables: > +# LIBBPF_FORCE={on,off} on: require link against libbpf; > +# off: disable libbpf probing > +# LIBBPF_LIBDIR Path to libbpf to use > + > INCLUDE=${1:-"$PWD/include"} > > # Output file which is input to Makefile > @@ -240,6 +245,106 @@ check_elf() > fi > } > > +have_libbpf_basic() > +{ > + cat >$TMPDIR/libbpf_test.c <<EOF > +#include <bpf/libbpf.h> > +int main(int argc, char **argv) { > + bpf_program__set_autoload(NULL, false); > + bpf_map__ifindex(NULL); > + bpf_map__set_pin_path(NULL, NULL); > + bpf_object__open_file(NULL, NULL); > + return 0; > +} > +EOF > + > + $CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1 > + local ret=$? > + > + rm -f $TMPDIR/libbpf_test.c $TMPDIR/libbpf_test > + return $ret > +} > + > +have_libbpf_sec_name() > +{ > + cat >$TMPDIR/libbpf_sec_test.c <<EOF > +#include <bpf/libbpf.h> > +int main(int argc, char **argv) { > + void *ptr; > + bpf_program__section_name(NULL); > + return 0; > +} > +EOF > + > + $CC -o $TMPDIR/libbpf_sec_test $TMPDIR/libbpf_sec_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1 > + local ret=$? > + > + rm -f $TMPDIR/libbpf_sec_test.c $TMPDIR/libbpf_sec_test > + return $ret > +} > + > +check_force_libbpf_on() > +{ > + # if set LIBBPF_FORCE=on but no libbpf support, just exist the config > + # process to make sure we don't build without libbpf. > + if [ "$LIBBPF_FORCE" = on ]; then > + echo " LIBBPF_FORCE=on set, but couldn't find a usable libbpf" > + exit 1 > + fi > +} > + > +check_libbpf() > +{ > + # if set LIBBPF_FORCE=off, disable libbpf entirely > + if [ "$LIBBPF_FORCE" = off ]; then > + echo "no" > + return > + fi > + > + if ! ${PKG_CONFIG} libbpf --exists && [ -z "$LIBBPF_DIR" ] ; then > + echo "no" > + check_force_libbpf_on > + return > + fi > + > + if [ $(uname -m) = x86_64 ]; then > + local LIBBPF_LIBDIR="${LIBBPF_DIR}/lib64" > + else > + local LIBBPF_LIBDIR="${LIBBPF_DIR}/lib" > + fi > + > + if [ -n "$LIBBPF_DIR" ]; then > + LIBBPF_CFLAGS="-I${LIBBPF_DIR}/include" > + LIBBPF_LDLIBS="${LIBBPF_LIBDIR}/libbpf.a -lz -lelf" > + LIBBPF_VERSION=$(PKG_CONFIG_LIBDIR=${LIBBPF_LIBDIR}/pkgconfig ${PKG_CONFIG} libbpf --modversion) > + else > + LIBBPF_CFLAGS=$(${PKG_CONFIG} libbpf --cflags) > + LIBBPF_LDLIBS=$(${PKG_CONFIG} libbpf --libs) > + LIBBPF_VERSION=$(${PKG_CONFIG} libbpf --modversion) > + fi > + > + if ! have_libbpf_basic; then > + echo "no" > + echo " libbpf version $LIBBPF_VERSION is too low, please update it to at least 0.1.0" > + check_force_libbpf_on > + return > + else > + echo "HAVE_LIBBPF:=y" >>$CONFIG > + echo 'CFLAGS += -DHAVE_LIBBPF ' $LIBBPF_CFLAGS >> $CONFIG > + echo 'LDLIBS += ' $LIBBPF_LDLIBS >>$CONFIG > + fi > + > + # bpf_program__title() is deprecated since libbpf 0.2.0, use > + # bpf_program__section_name() instead if we support > + if have_libbpf_sec_name; then > + echo "HAVE_LIBBPF_SECTION_NAME:=y" >>$CONFIG > + echo 'CFLAGS += -DHAVE_LIBBPF_SECTION_NAME ' >> $CONFIG > + fi > + > + echo "yes" > + echo " libbpf version $LIBBPF_VERSION" > +} > + > check_selinux() > # SELinux is a compile time option in the ss utility > { > @@ -385,6 +490,9 @@ check_setns > echo -n "SELinux support: " > check_selinux > > +echo -n "libbpf support: " > +check_libbpf > + > echo -n "ELF support: " > check_elf > > Something is off with the version detection. # LIBBPF_LIBDIR=/tmp/libbpf ./configure TC schedulers ATM no libc has setns: yes SELinux support: no libbpf support: yes libbpf version 0.1.0 ELF support: yes /tmp/libbpf has an install of top of tree as of today which is: /tmp/libbpf/usr/lib64/libbpf.so.0.3.0 This is using Ubuntu 20.10.
On Fri, Nov 13, 2020 at 08:26:51PM -0700, David Ahern wrote: > > +# Influential LIBBPF environment variables: > > +# LIBBPF_FORCE={on,off} on: require link against libbpf; > > +# off: disable libbpf probing > > +# LIBBPF_LIBDIR Path to libbpf to use > > + ... > > +check_libbpf() > > +{ > > + # if set LIBBPF_FORCE=off, disable libbpf entirely > > + if [ "$LIBBPF_FORCE" = off ]; then > > + echo "no" > > + return > > + fi > > + > > + if ! ${PKG_CONFIG} libbpf --exists && [ -z "$LIBBPF_DIR" ] ; then > > + echo "no" > > + check_force_libbpf_on > > + return > > + fi ... > > Something is off with the version detection. > > # LIBBPF_LIBDIR=/tmp/libbpf ./configure My copy-past error. It should take LIBBPF_DIR, but I wrote LIBBPF_LIBDIR in the description... Also the folder should be libbpf dest dir, not libbpf dir directly. To be consistent with the libbpf document. I will change LIBBPF_DIR to LIBBPF_DESTDIR(Please tell me if you think the name is not suitable). The fix diff will looks like diff --git a/configure b/configure index 3081a2ac..5ca10337 100755 --- a/configure +++ b/configure @@ -5,7 +5,7 @@ # Influential LIBBPF environment variables: # LIBBPF_FORCE={on,off} on: require link against libbpf; # off: disable libbpf probing -# LIBBPF_LIBDIR Path to libbpf to use +# LIBBPF_DESTDIR Path to libbpf dest dir to use INCLUDE=${1:-"$PWD/include"} @@ -301,20 +301,20 @@ check_libbpf() return fi - if ! ${PKG_CONFIG} libbpf --exists && [ -z "$LIBBPF_DIR" ] ; then + if ! ${PKG_CONFIG} libbpf --exists && [ -z "$LIBBPF_DESTDIR" ] ; then echo "no" check_force_libbpf_on return fi if [ $(uname -m) = x86_64 ]; then - local LIBBPF_LIBDIR="${LIBBPF_DIR}/lib64" + local LIBBPF_LIBDIR="${LIBBPF_DESTDIR}/usr/lib64" else - local LIBBPF_LIBDIR="${LIBBPF_DIR}/lib" + local LIBBPF_LIBDIR="${LIBBPF_DESTDIR}/usr/lib" fi - if [ -n "$LIBBPF_DIR" ]; then - LIBBPF_CFLAGS="-I${LIBBPF_DIR}/include" + if [ -n "$LIBBPF_DESTDIR" ]; then + LIBBPF_CFLAGS="-I${LIBBPF_DESTDIR}/usr/include" LIBBPF_LDLIBS="${LIBBPF_LIBDIR}/libbpf.a -lz -lelf" LIBBPF_VERSION=$(PKG_CONFIG_LIBDIR=${LIBBPF_LIBDIR}/pkgconfig ${PKG_CONFIG} libbpf --modversion) else When you compile libbpf, it should like $ mkdir /tmp/libbpf_destdir $ cd libbpf/src/ $ make ... CC libbpf.so.0.2.0 $ DESTDIR=/tmp/libbpf_destdir make install Then in iproute2, configure it with $ LIBBPF_DIR=/tmp/libbpf_destdir ./configure TC schedulers ATM no libc has setns: yes SELinux support: no libbpf support: yes libbpf version 0.2.0 ELF support: yes libmnl support: yes Berkeley DB: no need for strlcpy: yes libcap support: yes Thanks Hangbin
On 11/15/20 9:30 PM, Hangbin Liu wrote: > diff --git a/configure b/configure > index 3081a2ac..5ca10337 100755 > --- a/configure > +++ b/configure > @@ -5,7 +5,7 @@ > # Influential LIBBPF environment variables: > # LIBBPF_FORCE={on,off} on: require link against libbpf; > # off: disable libbpf probing > -# LIBBPF_LIBDIR Path to libbpf to use > +# LIBBPF_DESTDIR Path to libbpf dest dir to use DESTDIR as a name applies to an install script. I think LIBBPF_DIR is fine. You can enhance the description to make it clear.
On Sun, Nov 15, 2020 at 10:56 PM Hangbin Liu <haliu@redhat.com> 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. LIBBPF_FORCE can be set to on to force configure > abort if no suitable libbpf is found (useful for automatic packaging > that wants to enforce the dependency), or set off to disable libbpf check > and build iproute2 with legacy bpf. > > 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. > > v5: > a) Fix LIBBPF_DIR typo and description, use libbpf DESTDIR as LIBBPF_DIR > dest. > b) Fix bpf_prog_load_dev typo. > c) rebase to latest iproute2-next. For the reasons explained multiple times earlier: Nacked-by: Alexei Starovoitov <ast@kernel.org>
On Sun, 15 Nov 2020 23:19:26 -0800 Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > On Sun, Nov 15, 2020 at 10:56 PM Hangbin Liu <haliu@redhat.com> 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. LIBBPF_FORCE can be set to on to force configure > > abort if no suitable libbpf is found (useful for automatic packaging > > that wants to enforce the dependency), or set off to disable libbpf check > > and build iproute2 with legacy bpf. > > > > 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. > > > > v5: > > a) Fix LIBBPF_DIR typo and description, use libbpf DESTDIR as LIBBPF_DIR > > dest. > > b) Fix bpf_prog_load_dev typo. > > c) rebase to latest iproute2-next. > > For the reasons explained multiple times earlier: > Nacked-by: Alexei Starovoitov <ast@kernel.org> We really need to get another BPF-ELF loaded into iproute2. I have done a number of practical projects with TC-BPF and it sucks that iproute2 have this out-dated (compiled in) BPF-loader. Examples jumping through hoops to get XDP + TC to collaborate[1], and dealing with iproute2 map-elf layout[2]. Thus, IMHO we MUST move forward and get started with converting iproute2 to libbpf, and start on the work to deprecate the build in BPF-ELF-loader. I would prefer ripping out the BPF-ELF-loader and replace it with libbpf that handle the older binary elf-map layout, but I do understand if you want to keep this around. (at least for the next couple of releases). Maybe we can get a little closer to what Alexei wants? When compiled against dynamic libbpf, then I would use 'ldd' command to see what libbpf lib version is used. When compiled/linked statically against a custom libbpf version (already supported via LIBBPF_DIR) then *I* think is difficult to figure out that version of libbpf I'm using. Could we add the libbpf version info in 'tc -V', as then it would remove one of my concerns with static linking. I actually fear that it will be a bad user experience, when we start to have multiple userspace tools that load BPF, but each is compiled and statically linked with it own version of libbpf (with git submodule an increasing number of tools will have more variations!). Small variations in supported features can cause strange and difficult troubleshooting. A practical example is xdp-cpumap-tc[1] where I had to instruct the customer to load XDP-program *BEFORE* TC-program to have map (that is shared between TC and XDP) being created correctly, for userspace tool written in libbpf to have proper map-access and info. I actually thinks it makes sense to have iproute2 require a specific libbpf version, and also to move this version requirement forward, as the kernel evolves features that gets added into libbpf. I know this is kind of controversial, and an attempt to pressure distro vendors to update libbpf. Maybe it will actually backfire, as the person generating the DEB/RPM software package will/can choose to compile iproute2 without ELF-BPF/libbpf support. [1] https://github.com/xdp-project/xdp-cpumap-tc [2] https://github.com/netoptimizer/bpf-examples/blob/71db45b28ec/traffic-pacing-edt/edt_pacer02.c#L33-L35 -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer (p.s. I actually like dynamic libs, as I can do evil tricks like LD_PRELOAD, e.g. if system had too old libbpf when I could have my own and have iproute2 load it via LD_PRELOAD. I know we shouldn't encourage tricks like this, but I've used these kind of trick with success before).
On Sun, 15 Nov 2020 23:19:26 -0800 Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > On Sun, Nov 15, 2020 at 10:56 PM Hangbin Liu <haliu@redhat.com> 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. LIBBPF_FORCE can be set to on to force configure > > abort if no suitable libbpf is found (useful for automatic packaging > > that wants to enforce the dependency), or set off to disable libbpf check > > and build iproute2 with legacy bpf. > > > > 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. > > > > v5: > > a) Fix LIBBPF_DIR typo and description, use libbpf DESTDIR as LIBBPF_DIR > > dest. > > b) Fix bpf_prog_load_dev typo. > > c) rebase to latest iproute2-next. > > For the reasons explained multiple times earlier: > Nacked-by: Alexei Starovoitov <ast@kernel.org> Could you propose a trial balloon patch to show what you would like to see in iproute2?
Jesper Dangaard Brouer <brouer@redhat.com> writes: > When compiled against dynamic libbpf, then I would use 'ldd' command to > see what libbpf lib version is used. When compiled/linked statically > against a custom libbpf version (already supported via LIBBPF_DIR) then > *I* think is difficult to figure out that version of libbpf I'm using. > Could we add the libbpf version info in 'tc -V', as then it would > remove one of my concerns with static linking. Agreed, I think we should definitely add the libbpf version to the tool version output. -Toke
On Mon, Nov 16, 2020 at 03:54:46PM +0100, Jesper Dangaard Brouer wrote: > > Thus, IMHO we MUST move forward and get started with converting > iproute2 to libbpf, and start on the work to deprecate the build in > BPF-ELF-loader. I would prefer ripping out the BPF-ELF-loader and > replace it with libbpf that handle the older binary elf-map layout, but > I do understand if you want to keep this around. (at least for the next > couple of releases). I don't understand why legacy code has to be around. Having the legacy code and an option to build tc without libbpf creates backward compatibility risk to tc users: Newer tc may not load bpf progs that older tc did. > I actually fear that it will be a bad user experience, when we start to > have multiple userspace tools that load BPF, but each is compiled and > statically linked with it own version of libbpf (with git submodule an > increasing number of tools will have more variations!). So far people either freeze bpftool that they use to load progs or they use libbpf directly in their applications. Any other way means that the application behavior will be unpredictable. If a company built a bpf-based product and wants to distibute such product as a package it needs a way to specify this dependency in pkg config. 'tc -V' is not something that can be put in a spec. The main iproute2 version can be used as a dependency, but it's meaningless when presence of libbpf and its version is not strictly derived from iproute2 spec. The users should be able to write in their spec: BuildRequires: iproute-tc >= 5.10 and be confident that tc will load the prog they've developed and tested. > I actually thinks it makes sense to have iproute2 require a specific > libbpf version, and also to move this version requirement forward, as > the kernel evolves features that gets added into libbpf. +1
On Mon, Nov 16, 2020 at 06:37:57PM -0800, Alexei Starovoitov wrote: > On Mon, Nov 16, 2020 at 03:54:46PM +0100, Jesper Dangaard Brouer wrote: > > > > Thus, IMHO we MUST move forward and get started with converting > > iproute2 to libbpf, and start on the work to deprecate the build in > > BPF-ELF-loader. I would prefer ripping out the BPF-ELF-loader and > > replace it with libbpf that handle the older binary elf-map layout, but > > I do understand if you want to keep this around. (at least for the next > > couple of releases). > > I don't understand why legacy code has to be around. > Having the legacy code and an option to build tc without libbpf creates > backward compatibility risk to tc users: > Newer tc may not load bpf progs that older tc did. If a distro choose to compile iproute2 with libbpf, I don't think they will compile iproute2 without libbpf in new version. So yum/apt-get update from official source doesn't like a problem. Unless a user choose to use a self build iproute2 version. Then the self build version may also don't have other supports, like libelf, libnml, libcap etc. > > > I actually fear that it will be a bad user experience, when we start to > > have multiple userspace tools that load BPF, but each is compiled and > > statically linked with it own version of libbpf (with git submodule an > > increasing number of tools will have more variations!). > > So far people either freeze bpftool that they use to load progs > or they use libbpf directly in their applications. > Any other way means that the application behavior will be unpredictable. > If a company built a bpf-based product and wants to distibute such > product as a package it needs a way to specify this dependency in pkg config. > 'tc -V' is not something that can be put in a spec. > The main iproute2 version can be used as a dependency, but it's meaningless > when presence of libbpf and its version is not strictly derived from > iproute2 spec. > The users should be able to write in their spec: > BuildRequires: iproute-tc >= 5.10 > and be confident that tc will load the prog they've developed and tested. The current patch does have a libbpf version check, it need at least libbpf 0.1.0. So if a distro starts to build iproute2 based on libbpf, there will have a dependence. The rule could be added to rpm spec file, or what else the distro choose. That's the distro compiler's work. Unless you want to say a company built a bpf-based product, they only add iproute2 version dependence(let's say some distros has iproute2 5.12 with libbpf supported), and somehow forgot add libbpf version dependence check and distro check. At the same time a user run the product on a distro without libbpf compiled on iproute2 5.12. That do will cause problem. But if I'm the user, I will think the company is not professional for bpf product that they even do not know libbpf is needed... So my opinion: for end user, the distro should take care of libbpf and iproute2 version control. For bpf company, they should take care if libbpf is used by the iproute2 and what distros they support. Please correct me if I missed something. Thanks Hangbin
On 11/16/20 7:54 AM, Jesper Dangaard Brouer wrote: > When compiled against dynamic libbpf, then I would use 'ldd' command to > see what libbpf lib version is used. When compiled/linked statically > against a custom libbpf version (already supported via LIBBPF_DIR) then > *I* think is difficult to figure out that version of libbpf I'm using. > Could we add the libbpf version info in 'tc -V', as then it would > remove one of my concerns with static linking. Adding libbpf version to 'tc -V' and 'ip -V' seems reasonable. As for the bigger problem, trying to force user space components to constantly chase latest and greatest S/W versions is not the right answer. The crux of the problem here is loading bpf object files and what will most likely be a never ending stream of enhancements that impact the proper loading of them. bpftool is much more suited to the job of managing bpf files versus iproute2 which is the de facto implementation for networking APIs. bpftool ships as part of a common linux tools package, so it will naturally track kernel versions for those who want / need latest and greatest versions. Users who are not building their own agents for managing bpf files (which I think is much more appropriate for production use cases than forking command line utilities) can use bpftool to load files, manage maps which are then attached to the programs, etc, and then invoke iproute2 to handle the networking attach / detach / list with detailed information. That said, the legacy bpf code in iproute2 has created some expectations, and iproute2 can not simply remove existing capabilities. Moving iproute2 to libbpf provides an improvement over the current status by allowing ‘modern’ bpf object files to be loaded without affecting legacy users, even if it does not allow latest and greatest bpf capabilities at every moment in time (again, a constantly moving reference point). iproute2 is a networking configuration tool, not a bpf management tool. Hangbin’s approach gives full flexibility to those who roll their own and for distributions who value stability, it allows iproute2 to use latest and greatest libbpf for those who want to chase the pot of gold at the end of the rainbow, or they can choose stability with an OS distro’s libbpf or legacy bpf. I believe this is the right compromise at this point in time.
On 17/11/2020 02:37, Alexei Starovoitov wrote: > If a company built a bpf-based product and wants to distibute such > product as a package it needs a way to specify this dependency in pkg config. > 'tc -V' is not something that can be put in a spec. > The main iproute2 version can be used as a dependency, but it's meaningless > when presence of libbpf and its version is not strictly derived from > iproute2 spec. But if libbpf is dynamically linked, they can put Requires: libbpf >= 0.3.0 Requires: iproute-tc >= 5.10 and get the dependency behaviour they need. No? -ed
On Mon, Nov 16, 2020 at 08:38:15PM -0700, David Ahern wrote: > > As for the bigger problem, trying to force user space components to > constantly chase latest and greatest S/W versions is not the right answer. Your own nexthop enhancements in the kernel code follow 1-1 with iproute2 changes. So the users do chase the latest kernel and the latest iproute2 if they want the networking feature. Yet you're arguing that for bpf features they shouldn't have such expectations with iproute2 which will not support the latest kernel bpf features. I sense a lot of bias here. > The crux of the problem here is loading bpf object files and what will > most likely be a never ending stream of enhancements that impact the > proper loading of them. Please stop this misinformation spread. Multiple people explained numerous times that libbpf takes care of backward compatibility. > That said, the legacy bpf code in iproute2 has created some > expectations, and iproute2 can not simply remove existing capabilities. It certainly can remove them by moving to libbpf. > iproute2 is a networking configuration tool, not a bpf management tool. > Hangbin’s approach gives full flexibility to those who roll their own > and for distributions who value stability, it allows iproute2 to use > latest and greatest libbpf for those who want to chase the pot of gold > at the end of the rainbow, or they can choose stability with an OS > distro’s libbpf or legacy bpf. I believe this is the right compromise at > this point in time. In other words you're saying that upstream iproute2 is a kitchen sink of untested combinations of libraries and distros suppose to do a ton of extra work to provide their users a quality iproute2.
On Tue, Nov 17, 2020 at 11:19:33AM +0800, Hangbin Liu wrote: > On Mon, Nov 16, 2020 at 06:37:57PM -0800, Alexei Starovoitov wrote: > > On Mon, Nov 16, 2020 at 03:54:46PM +0100, Jesper Dangaard Brouer wrote: > > > > > > Thus, IMHO we MUST move forward and get started with converting > > > iproute2 to libbpf, and start on the work to deprecate the build in > > > BPF-ELF-loader. I would prefer ripping out the BPF-ELF-loader and > > > replace it with libbpf that handle the older binary elf-map layout, but > > > I do understand if you want to keep this around. (at least for the next > > > couple of releases). > > > > I don't understand why legacy code has to be around. > > Having the legacy code and an option to build tc without libbpf creates > > backward compatibility risk to tc users: > > Newer tc may not load bpf progs that older tc did. > > If a distro choose to compile iproute2 with libbpf, I don't think they will > compile iproute2 without libbpf in new version. So yum/apt-get update from > official source doesn't like a problem. > > Unless a user choose to use a self build iproute2 version. Then the self build > version may also don't have other supports, like libelf, libnml, libcap etc. > > > > > > I actually fear that it will be a bad user experience, when we start to > > > have multiple userspace tools that load BPF, but each is compiled and > > > statically linked with it own version of libbpf (with git submodule an > > > increasing number of tools will have more variations!). > > > > So far people either freeze bpftool that they use to load progs > > or they use libbpf directly in their applications. > > Any other way means that the application behavior will be unpredictable. > > If a company built a bpf-based product and wants to distibute such > > product as a package it needs a way to specify this dependency in pkg config. > > 'tc -V' is not something that can be put in a spec. > > The main iproute2 version can be used as a dependency, but it's meaningless > > when presence of libbpf and its version is not strictly derived from > > iproute2 spec. > > The users should be able to write in their spec: > > BuildRequires: iproute-tc >= 5.10 > > and be confident that tc will load the prog they've developed and tested. > > The current patch does have a libbpf version check, it need at least libbpf > 0.1.0. So if a distro starts to build iproute2 based on libbpf, there will > have a dependence. The rule could be added to rpm spec file, or what else > the distro choose. That's the distro compiler's work. > > Unless you want to say a company built a bpf-based product, they only > add iproute2 version dependence(let's say some distros has iproute2 5.12 with > libbpf supported), and somehow forgot add libbpf version dependence check > and distro check. At the same time a user run the product on a distro without > libbpf compiled on iproute2 5.12. That do will cause problem. right. You've answered Ed's question: > But if libbpf is dynamically linked, they can put > Requires: libbpf >= 0.3.0 > Requires: iproute-tc >= 5.10 > and get the dependency behaviour they need. No? It is a problem because >= 5.10 cannot capture legacy vs libbpf. > But if I'm the user, I will think the company is not professional for bpf > product that they even do not know libbpf is needed... > > So my opinion: for end user, the distro should take care of libbpf and > iproute2 version control. For bpf company, they should take care if libbpf > is used by the iproute2 and what distros they support. So you're saying that bpf community shouldn't care about their users. The distros suppose to step forward and provide proper bpf support in tools like iproute2? In other words iproute2 upstream doesn't care about shipping quality product. It's distros job now. Thanks, but no. iproute2 should stay with legacy obsolete prog loader and the users should switch to bpftool + iproute2 combination. bpftool for loading progs and iproute2 for networking configs.