Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1578127

Re: [PATCH net-next v5 10/11] bpf: Remove bpf_sys.h from selftests

From "Wangnan (F)" <wangnan0@huawei.com>
Newsgroups linux.kernel
Subject Re: [PATCH net-next v5 10/11] bpf: Remove bpf_sys.h from selftests
Date 2017-02-10 03:40 +0100
Message-ID <t99hU-5Ry-19@gated-at.bofh.it> (permalink)
References <t96k1-465-3@gated-at.bofh.it> <t97zr-4Mk-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw



On 2017/2/10 7:21, Mickaël Salaün wrote:
> Add require dependency headers.
>
> Signed-off-by: Mickaël Salaün <mic@digikod.net>
> Cc: Alexei Starovoitov <ast@fb.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Shuah Khan <shuah@kernel.org>
> ---
>   tools/lib/bpf/bpf.c                         |  6 ++++++
>   tools/testing/selftests/bpf/bpf_sys.h       | 27 ---------------------------
>   tools/testing/selftests/bpf/test_lpm_map.c  |  1 -
>   tools/testing/selftests/bpf/test_lru_map.c  |  1 -
>   tools/testing/selftests/bpf/test_maps.c     |  1 -
>   tools/testing/selftests/bpf/test_tag.c      |  3 +--
>   tools/testing/selftests/bpf/test_verifier.c |  4 ++--
>   7 files changed, 9 insertions(+), 34 deletions(-)
>   delete mode 100644 tools/testing/selftests/bpf/bpf_sys.h
>
> diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c
> index f8a2b7fa7741..50e04cc5dddd 100644
> --- a/tools/lib/bpf/bpf.c
> +++ b/tools/lib/bpf/bpf.c
> @@ -50,7 +50,13 @@ static __u64 ptr_to_u64(const void *ptr)
>   static int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr,
>   		   unsigned int size)
>   {
> +#ifdef __NR_bpf
>   	return syscall(__NR_bpf, cmd, attr, size);
> +#else
> +	fprintf(stderr, "No bpf syscall, kernel headers too old?\n");
> +	errno = ENOSYS;
> +	return -1;
> +#endif
>   }
>   

We don't need check __NR_bpf again. It has already
been checked at the header of this file:

#ifndef __NR_bpf
# if defined(__i386__)
#  define __NR_bpf 357
# elif defined(__x86_64__)
#  define __NR_bpf 321
# elif defined(__aarch64__)
#  define __NR_bpf 280
# else
#  error __NR_bpf not defined. libbpf does not support your arch.
# endif
#endif

Thank you.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH net-next v5 00/11] Improve BPF selftests and use the library (net-next tree) Mickaël Salaün <mic@digikod.net> - 2017-02-10 00:30 +0100
  [PATCH net-next v5 09/11] bpf: Use bpf_create_map() from the library Mickaël Salaün <mic@digikod.net> - 2017-02-10 00:30 +0100
  [PATCH net-next v5 11/11] bpf: Add test_tag to .gitignore Mickaël Salaün <mic@digikod.net> - 2017-02-10 00:30 +0100
  [PATCH net-next v5 01/11] tools: Sync {,tools/}include/uapi/linux/bpf.h Mickaël Salaün <mic@digikod.net> - 2017-02-10 00:40 +0100
  [PATCH net-next v5 07/11] bpf: Use bpf_map_delete_elem() from the library Mickaël Salaün <mic@digikod.net> - 2017-02-10 01:30 +0100
  [PATCH net-next v5 06/11] bpf: Use bpf_map_lookup_elem() from the library Mickaël Salaün <mic@digikod.net> - 2017-02-10 01:40 +0100
  [PATCH net-next v5 10/11] bpf: Remove bpf_sys.h from selftests Mickaël Salaün <mic@digikod.net> - 2017-02-10 01:50 +0100
    Re: [PATCH net-next v5 10/11] bpf: Remove bpf_sys.h from selftests "Wangnan (F)" <wangnan0@huawei.com> - 2017-02-10 03:40 +0100
  Re: [PATCH net-next v5 00/11] Improve BPF selftests and use the  library (net-next tree) David Miller <davem@davemloft.net> - 2017-02-10 22:00 +0100

csiph-web