summaryrefslogtreecommitdiffstats
path: root/tools/bpf/bpftool/common.c
diff options
context:
space:
mode:
authorPrashant Bhole2017-11-08 05:55:47 +0100
committerDavid S. Miller2017-11-11 04:34:42 +0100
commit1852719658c0f853b5481c9eaed862f1a9355edc (patch)
tree2e80c8518feee8cc5b5e277239b5b1e30b4f1b43 /tools/bpf/bpftool/common.c
parentMerge branch 'BPF-directed-error-injection' (diff)
downloadkernel-qcow2-linux-1852719658c0f853b5481c9eaed862f1a9355edc.tar.gz
kernel-qcow2-linux-1852719658c0f853b5481c9eaed862f1a9355edc.tar.xz
kernel-qcow2-linux-1852719658c0f853b5481c9eaed862f1a9355edc.zip
tools: bpftool: open pinned object without type check
This was needed for opening any file in bpf-fs without knowing its object type Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/bpf/bpftool/common.c')
-rw-r--r--tools/bpf/bpftool/common.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index aa7017098b2a..6b3d25d6a782 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -122,9 +122,8 @@ static int mnt_bpffs(const char *target, char *buff, size_t bufflen)
return 0;
}
-int open_obj_pinned_any(char *path, enum bpf_obj_type exp_type)
+int open_obj_pinned(char *path)
{
- enum bpf_obj_type type;
int fd;
fd = bpf_obj_get(path);
@@ -136,6 +135,18 @@ int open_obj_pinned_any(char *path, enum bpf_obj_type exp_type)
return -1;
}
+ return fd;
+}
+
+int open_obj_pinned_any(char *path, enum bpf_obj_type exp_type)
+{
+ enum bpf_obj_type type;
+ int fd;
+
+ fd = open_obj_pinned(path);
+ if (fd < 0)
+ return -1;
+
type = get_fd_type(fd);
if (type < 0) {
close(fd);