Subject: Re: 答复: 答复: [PATCH bpf-next] samples/bpf: check detach prog exist or not in xdp_fwd

From: Toke Høiland-Jørgensen <[email-masked]>
Date: Tue, 17 May 2022 11:42:59 +0200

> Could I add helper function to implement this function which can check
> the program name and see if it attach to the device.

You just need to call bpf_prog_get_fd_by_id() followed by
bpf_obj_get_info_by_fd(), and the program name will be in info.name.
Here's an example in libxdp where we pull out the prog name:

https://github.com/xdp-project/xdp-tools/blob/master/lib/libxdp/libxdp.c#L1165

-Toke