On Fri, 6 Nov 2020 at 08:41, Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> wrote: > > By default, off xdp is implemented by actively calling netlink on the > command line or in the program. This is very inconvenient for apps based > on xdp. For example, an app based on xdp + xsk exits abnormally, but xdp > is still working, which may cause some exceptions. And xsk cannot be > automatically recycled. We need to bind xdp to the process in some > cases, so that xdp can always be automatically released when the process exits. > > Although the signal can be used to handle this problem, it cannot handle > some signals that cannot be captured. At the same time, it is > inconvenient to use the signal to process in some cases. For example, a > library based on xdp + xsk is not very convenient to use the signal solve > this problem. > > This patch requires the app to actively call RTM_GETLINK after setting > xdp and use RTEXT_FILTER_XDPFD flags to let the kernel generate an fd, > and return it to the app through netlink. In this way, when the app > closes fd or the process exits, the release callback of fd can trigger > to off xdp. > Hi Xuan, You'd like a "process scoped XDP attachment", right? I believe the mechanism you're looking for is Andrii's bpf_link. Have look at commit aa8d3a716b59 ("bpf, xdp: Add bpf_link-based XDP attachment API"). Cheers, Björn