Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xdp-loader: Only load the BPF program we need from object files
When xdp-loader is loading a BPF object file it'll do so through the libbpf bpf_object__load() API. This loads the whole BPF object, including all BPF programs defined in the object file. Apart from being wasteful (those programs will just get unloaded from the kernel when xdp-loader exits), this can also make loading fail if one of those programs are unable to be loaded for whatever reason. The concrete failure that was observed for this is older object files that don't use the new-style SEC("xdp"), in which case libbpf will fail to set a program type. For the program we're targeting as loading, libxdp will reset the program type (to attach to a dispatcher), so we can load such programs, but extra programs in the same object file that are compiled like this will fail for no good reason. As a solution, just disable autoloading of all programs in the object file after loading it; libxdp will re-enable autoloading of the program we are targeting to attach to the interface before loading it into the kernel. Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
- Loading branch information