bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: John Fastabend <john.fastabend@gmail.com>,
	Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Andrii Nakryiko <andrii@kernel.org>, bpf <bpf@vger.kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Kernel Team <kernel-team@fb.com>,
	David Ahern <dsahern@kernel.org>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH v2 bpf-next 3/4] libbpf: deprecate legacy BPF map definitions
Date: Tue, 25 Jan 2022 22:52:39 +0100	[thread overview]
Message-ID: <87pmof32l4.fsf@toke.dk> (raw)
In-Reply-To: <61f06309dabcc_2e4c52085d@john.notmuch>

John Fastabend <john.fastabend@gmail.com> writes:

> Toke Høiland-Jørgensen wrote:
>> Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:
>> 
>> > On Fri, Jan 21, 2022 at 12:43 PM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>> >>
>> >> Andrii Nakryiko <andrii.nakryiko@gmail.com> writes:
>> >>
>> >> > On Thu, Jan 20, 2022 at 3:44 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>> >> >>
>> >> >> Andrii Nakryiko <andrii@kernel.org> writes:
>> >> >>
>> >> >> > Enact deprecation of legacy BPF map definition in SEC("maps") ([0]). For
>> >> >> > the definitions themselves introduce LIBBPF_STRICT_MAP_DEFINITIONS flag
>> >> >> > for libbpf strict mode. If it is set, error out on any struct
>> >> >> > bpf_map_def-based map definition. If not set, libbpf will print out
>> >> >> > a warning for each legacy BPF map to raise awareness that it goes
>> >> >> > away.
>> >> >>
>> >> >> We've touched upon this subject before, but I (still) don't think it's a
>> >> >> good idea to remove this support entirely: It makes it impossible to
>> >> >> write a loader that can handle both new and old BPF objects.
>> >> >>
>> >> >> So discourage the use of the old map definitions, sure, but please don't
>> >> >> make it completely impossible to load such objects.
>> >> >
>> >> > BTF-defined maps have been around for quite a long time now and only
>> >> > have benefits on top of the bpf_map_def way. The source code
>> >> > translation is also very straightforward. If someone didn't get around
>> >> > to update their BPF program in 2 years, I don't think we can do much
>> >> > about that.
>> >> >
>> >> > Maybe instead of trying to please everyone (especially those that
>> >> > refuse to do anything to their BPF programs), let's work together to
>> >> > nudge laggards to actually modernize their source code a little bit
>> >> > and gain some benefits from that along the way?
>> >>
>> >> I'm completely fine with nudging people towards the newer features, and
>> >> I think the compile-time deprecation warning when someone is using the
>> >> old-style map definitions in their BPF programs is an excellent way to
>> >> do that.
>> >>
>> >> I'm also fine with libbpf *by default* refusing to load programs that
>> >> use the old-style map definitions, but if the code is removed completely
>> >> it becomes impossible to write general-purpose loaders that can handle
>> >> both old and new programs. The obvious example of such a loader is
>> >> iproute2, the loader in xdp-tools is another.
>> >
>> > This is because you want to deviate from underlying BPF loader's
>> > behavior and feature set and dictate your own extended feature set in
>> > xdp-tools/iproute2/etc. You can technically do that, but with a lot of
>> > added complexity and headaches. But demanding libbpf to maintain
>> > deprecated and discouraged features/APIs/practices for 10+ years and
>> > accumulate all the internal cruft and maintenance burden isn't a great
>> > solution either.
>> 
>> Right, so work with me to find a solution? I already suggested several
>> ideas, and you just keep repeating "just use the old library", which is
>> tantamount to saying "take a hike".
>
> I'll just throw my $.02 here as I'm reviewing. On major versions its
> fairly common to not force API compat with the libs I'm used to working
> with. Most recent example that comes to my mind (just did this yesterday
> for example) was porting code into openssl3.x from older version. I
> mumbled a bit, but still did it so that I could get my tools working on
> latest and greatest.
>
> Going from 0.x -> 1.0 seems reasonable to break compat, users don't
> need to update immediately right? They can linger around on 0.x release
> until they have some time or reason to jump onto 1.0? Distro's can
> carry all versions for as long as necessary. Thats the value add of
> distributions in my mind anyways. And a 0.x version somewhat implies
> its not stable yet imo.

I'm fine with breaking compatibility of the library. We already handle
that in xdp-tools via standard configure probing. The problem here is
with breaking compatibility the data file format (i.e., BPF ELF files);
in your openssl example that would correspond to new versions of openssl
refusing to read certificate files that were issued before the upgrade.

I really don't get why this distinction is so hard to explain? Is there
some mental model disconnect here somewhere, or something?

>> I'm perfectly fine with having to jump through some more hoops to load
>> old programs, and moving the old maps section parsing out of libbpf and
>> into the caller is fine as well; but then we'd need to add some hooks to
>> libbpf to create the maps inside the bpf_object. I can submit patches to
>> do this, but I'm not going to bother if you're just going to reject them
>> because you don't want to accommodate anything other than your way of
>> doing things :/
>
> Can't xdp-tools run on 0.x for as long as wanted and flip over when
> it is ready? Same for iproute2 'tc' loader? I'm not seeing what would
> break except for random people trying to use tools in debug or
> experiments.

New stuff would break. I.e., then xdp-tools / tc would be stuck on that
version forever, and wouldn't be able to load any BPF programs that rely
on features added to libbpf after 1.0.

> FWIW the dumb netlink based loader I wrote to attach create qdiscs and
> attach filters is <100 lines of code so its not a huge lift if you end
> up having to roll your own here.

We're not just talking about "creating qdiscs and attaching filters"
here, we're talking about the loading of BPF object files. "Rolling my
own" means writing code that parses elf files, populates maps, creates
them in the kernel, does the relocations etc. That's essentially a
rewrite / fork of libbpf, which is what I'm trying to avoid...

-Toke


  reply	other threads:[~2022-01-25 21:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20  6:05 [PATCH v2 bpf-next 0/4] libbpf: deprecate legacy BPF map definitions Andrii Nakryiko
2022-01-20  6:05 ` [PATCH v2 bpf-next 1/4] selftests/bpf: fail build on compilation warning Andrii Nakryiko
2022-01-20  6:05 ` [PATCH v2 bpf-next 2/4] selftests/bpf: convert remaining legacy map definitions Andrii Nakryiko
2022-01-20  6:05 ` [PATCH v2 bpf-next 3/4] libbpf: deprecate legacy BPF " Andrii Nakryiko
2022-01-20 11:44   ` Toke Høiland-Jørgensen
2022-01-20 19:13     ` Andrii Nakryiko
2022-01-21 20:43       ` Toke Høiland-Jørgensen
2022-01-21 22:04         ` David Ahern
2022-01-24 16:21           ` Andrii Nakryiko
2022-01-24 16:15         ` Andrii Nakryiko
2022-01-25  0:27           ` David Ahern
2022-01-25  5:41             ` Andrii Nakryiko
2022-01-25 12:10           ` Toke Høiland-Jørgensen
2022-01-25 20:52             ` John Fastabend
2022-01-25 21:52               ` Toke Høiland-Jørgensen [this message]
2022-01-25 22:35                 ` John Fastabend
2022-01-26  0:01                   ` Andrii Nakryiko
2022-01-26  2:02                     ` David Ahern
2022-01-25 23:46             ` Andrii Nakryiko
2022-01-20  6:05 ` [PATCH v2 bpf-next 4/4] docs/bpf: update BPF map definition example Andrii Nakryiko
2022-01-25 20:52 ` [PATCH v2 bpf-next 0/4] libbpf: deprecate legacy BPF map definitions John Fastabend

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pmof32l4.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dsahern@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@fb.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).