diff options
Diffstat (limited to 'samples/bpf/fds_example.c')
| -rw-r--r-- | samples/bpf/fds_example.c | 13 | 
1 files changed, 8 insertions, 5 deletions
diff --git a/samples/bpf/fds_example.c b/samples/bpf/fds_example.c index 625e797be6ef..e29bd52ff9e8 100644 --- a/samples/bpf/fds_example.c +++ b/samples/bpf/fds_example.c @@ -14,6 +14,7 @@  #include "bpf_load.h"  #include "libbpf.h" +#include "sock_example.h"  #define BPF_F_PIN	(1 << 0)  #define BPF_F_GET	(1 << 1) @@ -49,17 +50,19 @@ static int bpf_map_create(void)  static int bpf_prog_create(const char *object)  { -	static const struct bpf_insn insns[] = { +	static struct bpf_insn insns[] = {  		BPF_MOV64_IMM(BPF_REG_0, 1),  		BPF_EXIT_INSN(),  	}; +	size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn);  	if (object) {  		assert(!load_bpf_file((char *)object));  		return prog_fd[0];  	} else { -		return bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, -				     insns, sizeof(insns), "GPL", 0); +		return bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, +					insns, insns_cnt, "GPL", 0, +					bpf_log_buf, BPF_LOG_BUF_SIZE);  	}  } @@ -83,12 +86,12 @@ static int bpf_do_map(const char *file, uint32_t flags, uint32_t key,  	}  	if ((flags & BPF_F_KEY_VAL) == BPF_F_KEY_VAL) { -		ret = bpf_update_elem(fd, &key, &value, 0); +		ret = bpf_map_update_elem(fd, &key, &value, 0);  		printf("bpf: fd:%d u->(%u:%u) ret:(%d,%s)\n", fd, key, value,  		       ret, strerror(errno));  		assert(ret == 0);  	} else if (flags & BPF_F_KEY) { -		ret = bpf_lookup_elem(fd, &key, &value); +		ret = bpf_map_lookup_elem(fd, &key, &value);  		printf("bpf: fd:%d l->(%u):%u ret:(%d,%s)\n", fd, key, value,  		       ret, strerror(errno));  		assert(ret == 0);  | 
