Re: [PATCH bpf-next 0/3] Introduce pinnable bpf_link kernel abstraction
From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2020-03-03 08:12:53
Also in:
bpf
On 3/2/20 11:24 PM, Toke Høiland-Jørgensen wrote:
Andrii Nakryiko [off-list ref] writes:quoted
On Mon, Mar 2, 2020 at 2:12 AM Toke Høiland-Jørgensen [off-list ref] wrote:quoted
Andrii Nakryiko [off-list ref] writes:quoted
This patch series adds bpf_link abstraction, analogous to libbpf's already existing bpf_link abstraction. This formalizes and makes more uniform existing bpf_link-like BPF program link (attachment) types (raw tracepoint and tracing links), which are FD-based objects that are automatically detached when last file reference is closed. These types of BPF program links are switched to using bpf_link framework. FD-based bpf_link approach provides great safety guarantees, by ensuring there is not going to be an abandoned BPF program attached, if user process suddenly exits or forgets to clean up after itself. This is especially important in production environment and is what all the recent new BPF link types followed. One of the previously existing inconveniences of FD-based approach, though, was the scenario in which user process wants to install BPF link and exit, but let attached BPF program run. Now, with bpf_link abstraction in place, it's easy to support pinning links in BPF FS, which is done as part of the same patch #1. This allows FD-based BPF program links to survive exit of a user process and original file descriptor being closed, by creating an file entry in BPF FS. This provides great safety by default, with simple way to opt out for cases where it's needed.
I can see the motivation for this abstraction in particular for tracing, but given the goal of bpf_link is to formalize and make the various program attachment types more uniform, how is this going to solve e.g. the tc/BPF case? There is no guarantee that while you create a link with the prog attached to cls_bpf that someone else is going to replace that qdisc underneath you, and hence you end up with the same case as if you would have only pinned the program itself (and not a link). So bpf_link then gives a wrong impression that something is still attached and active while it is not. What is the plan for these types?