* [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled
@ 2017-06-09 5:30 Martin KaFai Lau
2017-06-09 5:30 ` [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0 Martin KaFai Lau
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Martin KaFai Lau @ 2017-06-09 5:30 UTC (permalink / raw)
To: netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, Yonghong Song, kernel-team
test_bpf_obj_id() should not expect a non zero jited_prog_len
to be returned by bpf_obj_get_info_by_fd() when
net.core.bpf_jit_enable is 0.
The patch checks for net.core.bpf_jit_enable and
has different expectation on jited_prog_len.
This patch also removes the pwd.h header which I forgot
to remove after making changes.
Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
Reported-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
tools/testing/selftests/bpf/test_progs.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 8189bfc7e277..fec13ab84fca 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -23,7 +23,7 @@ typedef __u16 __sum16;
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/types.h>
-#include <pwd.h>
+#include <fcntl.h>
#include <linux/bpf.h>
#include <linux/err.h>
@@ -297,6 +297,7 @@ static void test_bpf_obj_id(void)
const __u32 array_key = 0;
const int nr_iters = 2;
const char *file = "./test_obj_id.o";
+ const char *jit_sysctl = "/proc/sys/net/core/bpf_jit_enable";
struct bpf_object *objs[nr_iters];
int prog_fds[nr_iters], map_fds[nr_iters];
@@ -305,9 +306,18 @@ static void test_bpf_obj_id(void)
struct bpf_map_info map_infos[nr_iters + 1];
char jited_insns[128], xlated_insns[128];
__u32 i, next_id, info_len, nr_id_found, duration = 0;
- int err = 0;
+ int sysctl_fd, jit_enabled = 0, err = 0;
__u64 array_value;
+ sysctl_fd = open(jit_sysctl, 0, O_RDONLY);
+ if (sysctl_fd != -1) {
+ char tmpc;
+
+ if (read(sysctl_fd, &tmpc, sizeof(tmpc)) == 1)
+ jit_enabled = (tmpc != '0');
+ close(sysctl_fd);
+ }
+
err = bpf_prog_get_fd_by_id(0);
CHECK(err >= 0 || errno != ENOENT,
"get-fd-by-notexist-prog-id", "err %d errno %d\n", err, errno);
@@ -339,13 +349,14 @@ static void test_bpf_obj_id(void)
if (CHECK(err ||
prog_infos[i].type != BPF_PROG_TYPE_SOCKET_FILTER ||
info_len != sizeof(struct bpf_prog_info) ||
- !prog_infos[i].jited_prog_len ||
+ (jit_enabled && !prog_infos[i].jited_prog_len) ||
!prog_infos[i].xlated_prog_len,
"get-prog-info(fd)",
- "err %d errno %d i %d type %d(%d) info_len %u(%lu) jited_prog_len %u xlated_prog_len %u\n",
+ "err %d errno %d i %d type %d(%d) info_len %u(%lu) jit_enabled %d jited_prog_len %u xlated_prog_len %u\n",
err, errno, i,
prog_infos[i].type, BPF_PROG_TYPE_SOCKET_FILTER,
info_len, sizeof(struct bpf_prog_info),
+ jit_enabled,
prog_infos[i].jited_prog_len,
prog_infos[i].xlated_prog_len))
goto done;
--
2.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0
2017-06-09 5:30 [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Martin KaFai Lau
@ 2017-06-09 5:30 ` Martin KaFai Lau
2017-06-09 10:06 ` Daniel Borkmann
` (2 more replies)
2017-06-09 10:06 ` [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Daniel Borkmann
` (2 subsequent siblings)
3 siblings, 3 replies; 8+ messages in thread
From: Martin KaFai Lau @ 2017-06-09 5:30 UTC (permalink / raw)
To: netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, Yonghong Song, kernel-team
llvm 5.0 does not like the section name and the function name
to be the same:
clang -I. -I./include/uapi -I../../../include/uapi \
-I../../../../samples/bpf/ \
-Wno-compare-distinct-pointer-types \
-O2 -target bpf -c \
linux/tools/testing/selftests/bpf/test_obj_id.c -o \
linux/tools/testing/selftests/bpf/test_obj_id.o
fatal error: error in backend: 'test_prog_id' label emitted multiple times to
assembly file
clang-5.0: error: clang frontend command failed with exit code 70 (use -v to
see invocation)
clang version 5.0.0 (trunk 304326) (llvm/trunk 304329)
This patch makes changes to the section name and the function name.
Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
Reported-by: Alexei Starovoitov <ast@fb.com>
Reported-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
tools/testing/selftests/bpf/test_obj_id.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/test_obj_id.c b/tools/testing/selftests/bpf/test_obj_id.c
index d8723aaf827a..880d2963b472 100644
--- a/tools/testing/selftests/bpf/test_obj_id.c
+++ b/tools/testing/selftests/bpf/test_obj_id.c
@@ -23,8 +23,8 @@ struct bpf_map_def SEC("maps") test_map_id = {
.max_entries = 1,
};
-SEC("test_prog_id")
-int test_prog_id(struct __sk_buff *skb)
+SEC("test_obj_id_dummy")
+int test_obj_id(struct __sk_buff *skb)
{
__u32 key = 0;
__u64 *value;
--
2.9.3
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0
2017-06-09 5:30 ` [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0 Martin KaFai Lau
@ 2017-06-09 10:06 ` Daniel Borkmann
2017-06-09 15:40 ` Yonghong Song
2017-06-09 19:15 ` David Miller
2 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-06-09 10:06 UTC (permalink / raw)
To: Martin KaFai Lau, netdev; +Cc: Alexei Starovoitov, Yonghong Song, kernel-team
On 06/09/2017 07:30 AM, Martin KaFai Lau wrote:
> llvm 5.0 does not like the section name and the function name
> to be the same:
>
> clang -I. -I./include/uapi -I../../../include/uapi \
> -I../../../../samples/bpf/ \
> -Wno-compare-distinct-pointer-types \
> -O2 -target bpf -c \
> linux/tools/testing/selftests/bpf/test_obj_id.c -o \
> linux/tools/testing/selftests/bpf/test_obj_id.o
> fatal error: error in backend: 'test_prog_id' label emitted multiple times to
> assembly file
> clang-5.0: error: clang frontend command failed with exit code 70 (use -v to
> see invocation)
> clang version 5.0.0 (trunk 304326) (llvm/trunk 304329)
>
> This patch makes changes to the section name and the function name.
>
> Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
> Reported-by: Alexei Starovoitov <ast@fb.com>
> Reported-by: Yonghong Song <yhs@fb.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0
2017-06-09 5:30 ` [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0 Martin KaFai Lau
2017-06-09 10:06 ` Daniel Borkmann
@ 2017-06-09 15:40 ` Yonghong Song
2017-06-09 19:15 ` David Miller
2 siblings, 0 replies; 8+ messages in thread
From: Yonghong Song @ 2017-06-09 15:40 UTC (permalink / raw)
To: Martin KaFai Lau, netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team
On 6/8/17 10:30 PM, Martin KaFai Lau wrote:
> llvm 5.0 does not like the section name and the function name
> to be the same:
>
> clang -I. -I./include/uapi -I../../../include/uapi \
> -I../../../../samples/bpf/ \
> -Wno-compare-distinct-pointer-types \
> -O2 -target bpf -c \
> linux/tools/testing/selftests/bpf/test_obj_id.c -o \
> linux/tools/testing/selftests/bpf/test_obj_id.o
> fatal error: error in backend: 'test_prog_id' label emitted multiple times to
> assembly file
> clang-5.0: error: clang frontend command failed with exit code 70 (use -v to
> see invocation)
> clang version 5.0.0 (trunk 304326) (llvm/trunk 304329)
>
> This patch makes changes to the section name and the function name.
>
> Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
> Reported-by: Alexei Starovoitov <ast@fb.com>
> Reported-by: Yonghong Song <yhs@fb.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
> tools/testing/selftests/bpf/test_obj_id.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_obj_id.c b/tools/testing/selftests/bpf/test_obj_id.c
> index d8723aaf827a..880d2963b472 100644
> --- a/tools/testing/selftests/bpf/test_obj_id.c
> +++ b/tools/testing/selftests/bpf/test_obj_id.c
> @@ -23,8 +23,8 @@ struct bpf_map_def SEC("maps") test_map_id = {
> .max_entries = 1,
> };
>
> -SEC("test_prog_id")
> -int test_prog_id(struct __sk_buff *skb)
> +SEC("test_obj_id_dummy")
> +int test_obj_id(struct __sk_buff *skb)
> {
> __u32 key = 0;
> __u64 *value;
>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0
2017-06-09 5:30 ` [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0 Martin KaFai Lau
2017-06-09 10:06 ` Daniel Borkmann
2017-06-09 15:40 ` Yonghong Song
@ 2017-06-09 19:15 ` David Miller
2 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-06-09 19:15 UTC (permalink / raw)
To: kafai; +Cc: netdev, ast, daniel, yhs, kernel-team
From: Martin KaFai Lau <kafai@fb.com>
Date: Thu, 8 Jun 2017 22:30:17 -0700
> llvm 5.0 does not like the section name and the function name
> to be the same:
>
> clang -I. -I./include/uapi -I../../../include/uapi \
> -I../../../../samples/bpf/ \
> -Wno-compare-distinct-pointer-types \
> -O2 -target bpf -c \
> linux/tools/testing/selftests/bpf/test_obj_id.c -o \
> linux/tools/testing/selftests/bpf/test_obj_id.o
> fatal error: error in backend: 'test_prog_id' label emitted multiple times to
> assembly file
> clang-5.0: error: clang frontend command failed with exit code 70 (use -v to
> see invocation)
> clang version 5.0.0 (trunk 304326) (llvm/trunk 304329)
>
> This patch makes changes to the section name and the function name.
>
> Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
> Reported-by: Alexei Starovoitov <ast@fb.com>
> Reported-by: Yonghong Song <yhs@fb.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Applied.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled
2017-06-09 5:30 [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Martin KaFai Lau
2017-06-09 5:30 ` [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0 Martin KaFai Lau
@ 2017-06-09 10:06 ` Daniel Borkmann
2017-06-09 15:39 ` Yonghong Song
2017-06-09 19:15 ` David Miller
3 siblings, 0 replies; 8+ messages in thread
From: Daniel Borkmann @ 2017-06-09 10:06 UTC (permalink / raw)
To: Martin KaFai Lau, netdev; +Cc: Alexei Starovoitov, Yonghong Song, kernel-team
On 06/09/2017 07:30 AM, Martin KaFai Lau wrote:
> test_bpf_obj_id() should not expect a non zero jited_prog_len
> to be returned by bpf_obj_get_info_by_fd() when
> net.core.bpf_jit_enable is 0.
>
> The patch checks for net.core.bpf_jit_enable and
> has different expectation on jited_prog_len.
>
> This patch also removes the pwd.h header which I forgot
> to remove after making changes.
>
> Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
> Reported-by: Yonghong Song <yhs@fb.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled
2017-06-09 5:30 [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Martin KaFai Lau
2017-06-09 5:30 ` [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0 Martin KaFai Lau
2017-06-09 10:06 ` [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Daniel Borkmann
@ 2017-06-09 15:39 ` Yonghong Song
2017-06-09 19:15 ` David Miller
3 siblings, 0 replies; 8+ messages in thread
From: Yonghong Song @ 2017-06-09 15:39 UTC (permalink / raw)
To: Martin KaFai Lau, netdev; +Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team
On 6/8/17 10:30 PM, Martin KaFai Lau wrote:
> test_bpf_obj_id() should not expect a non zero jited_prog_len
> to be returned by bpf_obj_get_info_by_fd() when
> net.core.bpf_jit_enable is 0.
>
> The patch checks for net.core.bpf_jit_enable and
> has different expectation on jited_prog_len.
>
> This patch also removes the pwd.h header which I forgot
> to remove after making changes.
>
> Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
> Reported-by: Yonghong Song <yhs@fb.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
> tools/testing/selftests/bpf/test_progs.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index 8189bfc7e277..fec13ab84fca 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -23,7 +23,7 @@ typedef __u16 __sum16;
> #include <sys/wait.h>
> #include <sys/resource.h>
> #include <sys/types.h>
> -#include <pwd.h>
> +#include <fcntl.h>
>
> #include <linux/bpf.h>
> #include <linux/err.h>
> @@ -297,6 +297,7 @@ static void test_bpf_obj_id(void)
> const __u32 array_key = 0;
> const int nr_iters = 2;
> const char *file = "./test_obj_id.o";
> + const char *jit_sysctl = "/proc/sys/net/core/bpf_jit_enable";
>
> struct bpf_object *objs[nr_iters];
> int prog_fds[nr_iters], map_fds[nr_iters];
> @@ -305,9 +306,18 @@ static void test_bpf_obj_id(void)
> struct bpf_map_info map_infos[nr_iters + 1];
> char jited_insns[128], xlated_insns[128];
> __u32 i, next_id, info_len, nr_id_found, duration = 0;
> - int err = 0;
> + int sysctl_fd, jit_enabled = 0, err = 0;
> __u64 array_value;
>
> + sysctl_fd = open(jit_sysctl, 0, O_RDONLY);
> + if (sysctl_fd != -1) {
> + char tmpc;
> +
> + if (read(sysctl_fd, &tmpc, sizeof(tmpc)) == 1)
> + jit_enabled = (tmpc != '0');
> + close(sysctl_fd);
> + }
> +
> err = bpf_prog_get_fd_by_id(0);
> CHECK(err >= 0 || errno != ENOENT,
> "get-fd-by-notexist-prog-id", "err %d errno %d\n", err, errno);
> @@ -339,13 +349,14 @@ static void test_bpf_obj_id(void)
> if (CHECK(err ||
> prog_infos[i].type != BPF_PROG_TYPE_SOCKET_FILTER ||
> info_len != sizeof(struct bpf_prog_info) ||
> - !prog_infos[i].jited_prog_len ||
> + (jit_enabled && !prog_infos[i].jited_prog_len) ||
> !prog_infos[i].xlated_prog_len,
> "get-prog-info(fd)",
> - "err %d errno %d i %d type %d(%d) info_len %u(%lu) jited_prog_len %u xlated_prog_len %u\n",
> + "err %d errno %d i %d type %d(%d) info_len %u(%lu) jit_enabled %d jited_prog_len %u xlated_prog_len %u\n",
> err, errno, i,
> prog_infos[i].type, BPF_PROG_TYPE_SOCKET_FILTER,
> info_len, sizeof(struct bpf_prog_info),
> + jit_enabled,
> prog_infos[i].jited_prog_len,
> prog_infos[i].xlated_prog_len))
> goto done;
>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled
2017-06-09 5:30 [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Martin KaFai Lau
` (2 preceding siblings ...)
2017-06-09 15:39 ` Yonghong Song
@ 2017-06-09 19:15 ` David Miller
3 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2017-06-09 19:15 UTC (permalink / raw)
To: kafai; +Cc: netdev, ast, daniel, yhs, kernel-team
From: Martin KaFai Lau <kafai@fb.com>
Date: Thu, 8 Jun 2017 22:30:16 -0700
> test_bpf_obj_id() should not expect a non zero jited_prog_len
> to be returned by bpf_obj_get_info_by_fd() when
> net.core.bpf_jit_enable is 0.
>
> The patch checks for net.core.bpf_jit_enable and
> has different expectation on jited_prog_len.
>
> This patch also removes the pwd.h header which I forgot
> to remove after making changes.
>
> Fixes: 95b9afd3987f ("bpf: Test for bpf ID")
> Reported-by: Yonghong Song <yhs@fb.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Applied, but please in the future provide a proper header posting
with Subject "[PATCH net-next 0/N] ...".
Thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-06-09 19:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-09 5:30 [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Martin KaFai Lau
2017-06-09 5:30 ` [PATCH net-next 2/2] bpf: Fix test_obj_id.c for llvm 5.0 Martin KaFai Lau
2017-06-09 10:06 ` Daniel Borkmann
2017-06-09 15:40 ` Yonghong Song
2017-06-09 19:15 ` David Miller
2017-06-09 10:06 ` [PATCH net-next 1/2] bpf: Fix test_bpf_obj_id() when the bpf_jit_enable sysctl is diabled Daniel Borkmann
2017-06-09 15:39 ` Yonghong Song
2017-06-09 19:15 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).