Re: [RFC PATCH v1 3/3] bpftool: Prefer zlib-rs over zlib when available

From: Ian Rogers

Date: Thu Oct 29 2026 - 23:12:04 EST


On Thu, Oct 29, 2026 at 5:15 PM Quentin Monnet <qmo@xxxxxxxxxx> wrote:
>
> 2026-10-29 09:29 UTC-0700 ~ Ian Rogers <irogers@xxxxxxxxxx>
> > Add zlib-rs and zlib to FEATURE_TESTS and FEATURE_DISPLAY in
> > tools/bpf/bpftool/Makefile and use feature_rust_lib to configure
> > ZLIB_CFLAGS and ZLIB_LIBS when zlib-rs is detected, falling back to -lz.
>
>
> Hi Ian, bpftool doesn't make an intensive use of zlib (mostly, it's a
> requirement from other dependencies; we may also use it to unzip the
> kernel config on the host if necessary for probing BPF features on the
> system, but only on some distributions). So I'm struggling to understand
> the motivation for your proposal, what do we gain by switching to
> zlib-rs when available? I understand this implementation is in Rust, but
> I'm not sure the added complexity and feature probing in the build
> system is worth it.

Hi Quentin,

At my workplace, we are transitioning from zlib to zlib-rs for both
security and performance reasons. I'd like to keep upstream tools
aligned but they don't have to be, it just seems nice. I agree zlib is
of a lower priority to users than, say, zstd. For attackers, like with
brotli, it is probably an area of interest. Knowing the implementation
is memory safe is at least something in favor of zlib-rs. I sent this
series out as an RFC because I obviously have no way to mandate what
upstream should or shouldn't be doing. There are things that can make
life a little nicer and easier, and this patch series, for me, is one
of them.

> > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> > ---
> > tools/bpf/bpftool/.gitignore | 1 +
> > tools/bpf/bpftool/Makefile | 56 ++++++++++++++++++++++++++++++++----
> > 2 files changed, 51 insertions(+), 6 deletions(-)
> >
> > diff --git a/tools/bpf/bpftool/.gitignore b/tools/bpf/bpftool/.gitignore
> > index a736f64dc5dc..ea2222373634 100644
> > --- a/tools/bpf/bpftool/.gitignore
> > +++ b/tools/bpf/bpftool/.gitignore
> > @@ -6,5 +6,6 @@ bpftool*.8
> > FEATURE-DUMP.bpftool
> > feature
> > libbpf
> > +libz_rs
> > /*.skel.h
> > /vmlinux.h
> > diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> > index b0f7168e7943..a193cf89a034 100644
> > --- a/tools/bpf/bpftool/Makefile
> > +++ b/tools/bpf/bpftool/Makefile
> > @@ -1,5 +1,6 @@
> > # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> > include ../../scripts/Makefile.include
> > +include ../../scripts/Makefile.arch
>
>
> Looking at the GitHub mirror repository for bpftool, I'd avoid including
> this additional Makefile if I could.

Ack. I also acknowledge that the CI failed because the patches were
against perf-tools-next.

Thanks,
Ian

> Thanks,
> Quentin