mbox series

[0/2] iproute2: ss: clarify build warnings when building with libbpf 0.5.0

Message ID 20240811223135.1173783-1-stefan.maetje@esd.eu (mailing list archive)
Headers show
Series iproute2: ss: clarify build warnings when building with libbpf 0.5.0 | expand

Message

Stefan Mätje Aug. 11, 2024, 10:31 p.m. UTC
Hi,
when building current iproute2 source on Ubuntu 22.04 with libbpf0
0.5.0 installed, I stumbled over the warning "libbpf version 0.5 or 
later is required, ...". This prompted me to look closer having the
version 0.5.0 installed which should suppress this warning.
The warning lured me into the impression that building without
warning should be possible using libbpf 0.5.0.

I found out that this warning came from ss.c where a conditional
compile path depends on LIBBPF_MAJOR_VERSION and LIBBPF_MINOR_VERSION.
Newer libbpf versions define these in libbpf_version.h but the library
version 0.5.0 and earlier on Ubuntu and Debian don't package this header.
The version 0.7.0 on Debian packages the header libbpf_version.h.

Therefore these defines were undefined during the build and prompted
the output of the warning message. I derived these version defines
from the library version in the configure script and provided them
via CFLAGS. This is the first patch.

Now building ss.c against the libbpf 0.5.0 with ENABLE_BPF_SKSTORAGE_SUPPORT
enabled, triggered compilation errors. The function btf_dump__new is
used there with a calling convention that was introduced with libbpf
version 0.6.0. Therefore ENABLE_BPF_SKSTORAGE_SUPPORT shall only be
enabled for libbpf versions >= 0.6.0.

Best regards,
    Stefan Mätje

Stefan Mätje (2):
  configure: provide surrogates for possibly missing libbpf_version.h
  ss: fix libbpf version check for ENABLE_BPF_SKSTORAGE_SUPPORT

 configure | 6 ++++++
 misc/ss.c | 6 +++---
 2 files changed, 9 insertions(+), 3 deletions(-)


base-commit: 354d8a36885172b6e27ca65ff85c2c51e740fda0

Comments

Stephen Hemminger Aug. 11, 2024, 11:25 p.m. UTC | #1
On Mon, 12 Aug 2024 00:31:33 +0200
Stefan Mätje <stefan.maetje@esd.eu> wrote:

> Hi,
> when building current iproute2 source on Ubuntu 22.04 with libbpf0
> 0.5.0 installed, I stumbled over the warning "libbpf version 0.5 or 
> later is required, ...". This prompted me to look closer having the
> version 0.5.0 installed which should suppress this warning.
> The warning lured me into the impression that building without
> warning should be possible using libbpf 0.5.0.

Why is using new iproute2 on 2 year old distro going to add
anything here? Especially when BPF has under gone breaking API changes
over the recent past.

> 
> I found out that this warning came from ss.c where a conditional
> compile path depends on LIBBPF_MAJOR_VERSION and LIBBPF_MINOR_VERSION.
> Newer libbpf versions define these in libbpf_version.h but the library
> version 0.5.0 and earlier on Ubuntu and Debian don't package this header.
> The version 0.7.0 on Debian packages the header libbpf_version.h.
> 
> Therefore these defines were undefined during the build and prompted
> the output of the warning message. I derived these version defines
> from the library version in the configure script and provided them
> via CFLAGS. This is the first patch.
> 
> Now building ss.c against the libbpf 0.5.0 with ENABLE_BPF_SKSTORAGE_SUPPORT
> enabled, triggered compilation errors. The function btf_dump__new is
> used there with a calling convention that was introduced with libbpf
> version 0.6.0. Therefore ENABLE_BPF_SKSTORAGE_SUPPORT shall only be
> enabled for libbpf versions >= 0.6.0.

Might be better just to drop support for old libbpf and also
the legacy mode. Having multiple versions means there is more code
that doesn't get covered by tests.

Also, configure shell script is getting to be so messy, it is time for a redo.
Maybe give up on make and go to meson?
Stefan Mätje Aug. 12, 2024, 9:46 a.m. UTC | #2
Am Sonntag, dem 11.08.2024 um 16:25 -0700 schrieb Stephen Hemminger:
> On Mon, 12 Aug 2024 00:31:33 +0200
> Stefan Mätje <stefan.maetje@esd.eu> wrote:
> 
> > Hi,
> > when building current iproute2 source on Ubuntu 22.04 with libbpf0
> > 0.5.0 installed, I stumbled over the warning "libbpf version 0.5 or 
> > later is required, ...". This prompted me to look closer having the
> > version 0.5.0 installed which should suppress this warning.
> > The warning lured me into the impression that building without
> > warning should be possible using libbpf 0.5.0.
> 
> Why is using new iproute2 on 2 year old distro going to add
> anything here? Especially when BPF has under gone breaking API changes
> over the recent past.

I'm sorry I didn't make my intentions clear. Ubuntu 22.04 is a LTS version
and will therefore not go away soon. And its unfortunate that thay packaged
this old libbpf version.

The aim of my patches was to bring the fact to your attention that the 
source implicitely promises to work with that version (by issueing the 
warning "libbpf version 0.5 or later is required") which is wrong.

I only wanted to save other people's time who also may try to figure out
why the warning is issued even on a 0.5.0 version that fulfills the
announced minimum version requirement.


> > I found out that this warning came from ss.c where a conditional
> > compile path depends on LIBBPF_MAJOR_VERSION and LIBBPF_MINOR_VERSION.
> > Newer libbpf versions define these in libbpf_version.h but the library
> > version 0.5.0 and earlier on Ubuntu and Debian don't package this header.
> > The version 0.7.0 on Debian packages the header libbpf_version.h.
> > 
> > Therefore these defines were undefined during the build and prompted
> > the output of the warning message. I derived these version defines
> > from the library version in the configure script and provided them
> > via CFLAGS. This is the first patch.
> > 
> > Now building ss.c against the libbpf 0.5.0 with ENABLE_BPF_SKSTORAGE_SUPPORT
> > enabled, triggered compilation errors. The function btf_dump__new is
> > used there with a calling convention that was introduced with libbpf
> > version 0.6.0. Therefore ENABLE_BPF_SKSTORAGE_SUPPORT shall only be
> > enabled for libbpf versions >= 0.6.0.
> 
> Might be better just to drop support for old libbpf and also
> the legacy mode. Having multiple versions means there is more code
> that doesn't get covered by tests.

Increasing the minimum required version to 0.7.0 would be fine for me. Then
the configure script patch can be dropped and the second patch only needs
to have the minimum LIBBPF_MINOR_VERSION limit increased to 7.

I provided the configure script patch only for the case that somebody wanted
to configure the build based on the exact version which the API changed 
and I had the patch already in place anyway.

> Also, configure shell script is getting to be so messy, it is time for a redo.
> Maybe give up on make and go to meson?
patchwork-bot+netdevbpf@kernel.org Aug. 15, 2024, 3:30 p.m. UTC | #3
Hello:

This series was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Mon, 12 Aug 2024 00:31:33 +0200 you wrote:
> Hi,
> when building current iproute2 source on Ubuntu 22.04 with libbpf0
> 0.5.0 installed, I stumbled over the warning "libbpf version 0.5 or
> later is required, ...". This prompted me to look closer having the
> version 0.5.0 installed which should suppress this warning.
> The warning lured me into the impression that building without
> warning should be possible using libbpf 0.5.0.
> 
> [...]

Here is the summary with links:
  - [1/2] configure: provide surrogates for possibly missing libbpf_version.h
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=0ddadc93e54f
  - [2/2] ss: fix libbpf version check for ENABLE_BPF_SKSTORAGE_SUPPORT
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=e9096586e070

You are awesome, thank you!