On 7/23/17 5:54 PM, Jakub Kicinski wrote: > On Sat, 22 Jul 2017 00:20:50 -0700, Jakub Kicinski wrote: >> One thing which is not clear to me is how to get the association >> between programs and maps? Would we need to extend >> BPF_OBJ_GET_INFO_BY_FD to provide this info? > > Another thing that I can't find a way of doing is telling whether BPF fs > file is representing a map or a program. Is there a way to do this > today? > Once you have the fd you should be able to look at /proc/pid/fd/%d I have been using this: static int bpf_get_type(__u32 fd, __u32 pid, enum bpf_type *type) { char file[PATH_MAX]; char buf[512]; ssize_t n; *type = BPF_TYPE_UNSPEC; snprintf(file, sizeof(file), "/proc/%d/fd/%d", pid, fd); n = readlink(file, buf, sizeof(buf)); if (n < 0) return -1; if (strstr(buf, "bpf-prog")) *type = BPF_TYPE_PROG; else if (strstr(buf, "bpf-map")) *type = BPF_TYPE_MAP; return 0; }