When using bpftool to create new BPF objects (loaded programs, maps, etc.), it is not currently possible to retrieve a safe handle to the created objects. Users can set a given name for a program or a map, but names have no guarantee to be unique. They can pin the objects to a given path under the bpffs, and this should mostly work, unless there's some race condition with the objects being unpinned and replace.
As an alternative solution, we could have bpftool printing the IDs of the created/registered objects on successful creation (instead of printing nothing today).
This could be helpful for CI tests, for example, where we could delete objects created by bpftool (and only them) in tear-down steps.
When using bpftool to create new BPF objects (loaded programs, maps, etc.), it is not currently possible to retrieve a safe handle to the created objects. Users can set a given name for a program or a map, but names have no guarantee to be unique. They can pin the objects to a given path under the bpffs, and this should mostly work, unless there's some race condition with the objects being unpinned and replace.
As an alternative solution, we could have bpftool printing the IDs of the created/registered objects on successful creation (instead of printing nothing today).
This could be helpful for CI tests, for example, where we could delete objects created by bpftool (and only them) in tear-down steps.