On Fri, Jun 11, 2021 at 07:30:49AM IST, Cong Wang wrote: > I see why you are creating TC filters now, because you are trying to > force the lifetime of a bpf target to align with the bpf program itself. > The deeper reason seems to be that a cls_bpf filter looks so small > that it appears to you that it has nothing but a bpf_prog, right? > Just to clarify on this further, BPF program still has its own lifetime, link takes a reference, and the filter still takes a reference on it (since it assumes ownership, so it was easier that way). When releasing the bpf_link if the prog pointer is set, we also detach the TC filter (which releases its reference on the prog). The link on destruction releases its reference. So the rest of refcount will depend on userspace holding/pinning the fd or not. -- Kartikeya