Re: [PATCH net-next v5 04/11] bpf: Use bpf_load_program() from the library

From: Wangnan (F)
Date: Thu Feb 09 2017 - 21:58:54 EST




On 2017/2/10 10:25, Wangnan (F) wrote:


On 2017/2/10 7:21, MickaÃl SalaÃn wrote:
Replace bpf_prog_load() with bpf_load_program() calls.

Signed-off-by: MickaÃl SalaÃn <mic@xxxxxxxxxxx>
Cc: Alexei Starovoitov <ast@xxxxxx>
Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
Cc: Shuah Khan <shuah@xxxxxxxxxx>
---
tools/lib/bpf/bpf.c | 6 +++---
tools/lib/bpf/bpf.h | 4 ++--
tools/testing/selftests/bpf/Makefile | 4 +++-
tools/testing/selftests/bpf/bpf_sys.h | 21 ---------------------
tools/testing/selftests/bpf/test_tag.c | 6 ++++--
tools/testing/selftests/bpf/test_verifier.c | 8 +++++---
6 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
index 3ddb58a36d3c..58ce252073fa 100644
--- a/tools/lib/bpf/bpf.c
+++ b/tools/lib/bpf/bpf.c
@@ -42,7 +42,7 @@
# endif
#endif
-static __u64 ptr_to_u64(void *ptr)
+static __u64 ptr_to_u64(const void *ptr)
{
return (__u64) (unsigned long) ptr;
}
@@ -69,8 +69,8 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size,
return sys_bpf(BPF_MAP_CREATE, &attr, sizeof(attr));
}
-int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
- size_t insns_cnt, char *license,
+int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
+ size_t insns_cnt, const char *license,
__u32 kern_version, char *log_buf, size_t log_buf_sz)
{
int fd;
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h
index a2f9853dd882..bc959a2de023 100644
--- a/tools/lib/bpf/bpf.h
+++ b/tools/lib/bpf/bpf.h
@@ -28,8 +28,8 @@ int bpf_create_map(enum bpf_map_type map_type, int key_size, int value_size,
/* Recommend log buffer size */
#define BPF_LOG_BUF_SIZE 65536
-int bpf_load_program(enum bpf_prog_type type, struct bpf_insn *insns,
- size_t insns_cnt, char *license,
+int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns,
+ size_t insns_cnt, const char *license,
__u32 kern_version, char *log_buf,
size_t log_buf_sz);

For libbpf changes:

And for similar code in patch 5-8:

Acked-by Wang Nan <wangnan0@xxxxxxxxxx>

Thank you.

Acked-by Wang Nan <wangnan0@xxxxxxxxxx>

Thank you.