summaryrefslogtreecommitdiff
path: root/samples/bpf/fds_example.c
diff options
context:
space:
mode:
authorJakub Kicinski <jakub.kicinski@netronome.com>2019-02-28 06:04:13 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2019-03-01 02:53:45 +0300
commit1a9b268c90286cae99051353cb7dfb53ffd82676 (patch)
tree13672d85bbaeeab4e52a7b0d47199f53f43cc1b7 /samples/bpf/fds_example.c
parentf74a53d9a567f6bc6f6d8460e84c76bd2a45d016 (diff)
downloadlinux-1a9b268c90286cae99051353cb7dfb53ffd82676.tar.xz
samples: bpf: use libbpf where easy
Some samples don't really need the magic of bpf_load, switch them to libbpf. v2: - specify program types. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Acked-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'samples/bpf/fds_example.c')
-rw-r--r--samples/bpf/fds_example.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c
index 9854854f05d1..e51eb060244e 100644
--- a/samples/bpf/fds_example.c
+++ b/samples/bpf/fds_example.c
@@ -14,8 +14,8 @@
#include <bpf/bpf.h>
+#include "bpf/libbpf.h"
#include "bpf_insn.h"
-#include "bpf_load.h"
#include "sock_example.h"
#define BPF_F_PIN (1 << 0)
@@ -57,10 +57,14 @@ static int bpf_prog_create(const char *object)
BPF_EXIT_INSN(),
};
size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn);
+ char bpf_log_buf[BPF_LOG_BUF_SIZE];
+ struct bpf_object *obj;
+ int prog_fd;
if (object) {
- assert(!load_bpf_file((char *)object));
- return prog_fd[0];
+ assert(!bpf_prog_load(object, BPF_PROG_TYPE_UNSPEC,
+ &obj, &prog_fd));
+ return prog_fd;
} else {
return bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER,
insns, insns_cnt, "GPL", 0,