On Tue, Jan 25, 2022 at 4:10 AM Toke Høiland-Jørgensen <toke@xxxxxxxxxx> wrote: > > Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> writes: > > > On Fri, Jan 21, 2022 at 12:43 PM Toke Høiland-Jørgensen <toke@xxxxxxxxxx> wrote: > >> > >> Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> writes: > >> > >> > On Thu, Jan 20, 2022 at 3:44 AM Toke Høiland-Jørgensen <toke@xxxxxxxxxx> wrote: > >> >> > >> >> Andrii Nakryiko <andrii@xxxxxxxxxx> 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 also proposed a solution: log warning, so that your users will be aware and can modernize their code base and be ready for libbpf 1.0. You also keep ignoring this. Adding more obscure APIs and callbacks to let libxdp or iproute2 emulate old libbpf map definition syntax is not a good solution from my point of view. > > 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 :/ It's not just parsing the definition. We'll need to define an entire new protocol to dynamically add new custom BPF maps, and tie them together to BPF program code, adding/resolving relocations, etc. It's an overkill and not a good solution. You keep fighting hard to let users not do anything and use BPF object files generated years ago without recompilation and any source code changes. I so far haven't seen any *user* actually complain about this, only "middleman" libxdp and iproute2 are complaining right now. Did you check with your users how much of a problem it really is? In practice I've seen BPF users are quite willing to accommodate much more radical changes to their code with no problem. And John's reply just adds to that case. > > -Toke >