netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] samples/bpf: fix a build issue
@ 2017-07-10 21:04 Yonghong Song
  2017-07-10 21:13 ` Daniel Borkmann
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yonghong Song @ 2017-07-10 21:04 UTC (permalink / raw)
  To: ast, daniel, brakmo, netdev; +Cc: kernel-team

With latest net-next:
====
clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -Isamples/bpf \
    -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
    -Wno-compare-distinct-pointer-types \
    -Wno-gnu-variable-sized-type-not-at-end \
    -Wno-address-of-packed-member -Wno-tautological-compare \
    -Wno-unknown-warning-option \
    -O2 -emit-llvm -c samples/bpf/tcp_synrto_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/tcp_synrto_kern.o
samples/bpf/tcp_synrto_kern.c:20:10: fatal error: 'bpf_endian.h' file not found
          ^~~~~~~~~~~~~~
1 error generated.
====

net has the same issue.

Add support for ntohl and htonl in tools/testing/selftests/bpf/bpf_endian.h.
Also move bpf_helpers.h from samples/bpf to selftests/bpf and change
compiler include logic so that programs in samples/bpf can access the headers
in selftests/bpf, but not the other way around.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 samples/bpf/Makefile                                   |  1 +
 tools/testing/selftests/bpf/Makefile                   |  1 -
 tools/testing/selftests/bpf/bpf_endian.h               | 14 ++++++++++++++
 {samples => tools/testing/selftests}/bpf/bpf_helpers.h |  0
 4 files changed, 15 insertions(+), 1 deletion(-)
 rename {samples => tools/testing/selftests}/bpf/bpf_helpers.h (100%)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 9c65058..87246be 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -207,6 +207,7 @@ $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
 # useless for BPF samples.
 $(obj)/%.o: $(src)/%.c
 	$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
+		-I$(srctree)/tools/testing/selftests/bpf/ \
 		-D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
 		-Wno-compare-distinct-pointer-types \
 		-Wno-gnu-variable-sized-type-not-at-end \
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 2ca51a8..153c3a1 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -37,6 +37,5 @@ CLANG ?= clang
 
 %.o: %.c
 	$(CLANG) -I. -I./include/uapi -I../../../include/uapi \
-		-I../../../../samples/bpf/ \
 		-Wno-compare-distinct-pointer-types \
 		-O2 -target bpf -c $< -o $@
diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h
index 487cbfb..74af266 100644
--- a/tools/testing/selftests/bpf/bpf_endian.h
+++ b/tools/testing/selftests/bpf/bpf_endian.h
@@ -23,11 +23,19 @@
 # define __bpf_htons(x)			__builtin_bswap16(x)
 # define __bpf_constant_ntohs(x)	___constant_swab16(x)
 # define __bpf_constant_htons(x)	___constant_swab16(x)
+# define __bpf_ntohl(x)			__builtin_bswap32(x)
+# define __bpf_htonl(x)			__builtin_bswap32(x)
+# define __bpf_constant_ntohl(x)	___constant_swab32(x)
+# define __bpf_constant_htonl(x)	___constant_swab32(x)
 #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 # define __bpf_ntohs(x)			(x)
 # define __bpf_htons(x)			(x)
 # define __bpf_constant_ntohs(x)	(x)
 # define __bpf_constant_htons(x)	(x)
+# define __bpf_ntohl(x)			(x)
+# define __bpf_htonl(x)			(x)
+# define __bpf_constant_ntohl(x)	(x)
+# define __bpf_constant_htonl(x)	(x)
 #else
 # error "Fix your compiler's __BYTE_ORDER__?!"
 #endif
@@ -38,5 +46,11 @@
 #define bpf_ntohs(x)				\
 	(__builtin_constant_p(x) ?		\
 	 __bpf_constant_ntohs(x) : __bpf_ntohs(x))
+#define bpf_htonl(x)				\
+	(__builtin_constant_p(x) ?		\
+	 __bpf_constant_htonl(x) : __bpf_htonl(x))
+#define bpf_ntohl(x)				\
+	(__builtin_constant_p(x) ?		\
+	 __bpf_constant_ntohl(x) : __bpf_ntohl(x))
 
 #endif /* __BPF_ENDIAN__ */
diff --git a/samples/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
similarity index 100%
rename from samples/bpf/bpf_helpers.h
rename to tools/testing/selftests/bpf/bpf_helpers.h
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net v2] samples/bpf: fix a build issue
  2017-07-10 21:04 [PATCH net v2] samples/bpf: fix a build issue Yonghong Song
@ 2017-07-10 21:13 ` Daniel Borkmann
  2017-07-10 22:10   ` Lawrence Brakmo
  2017-07-11 19:51 ` Jesper Dangaard Brouer
  2017-07-12  3:51 ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Daniel Borkmann @ 2017-07-10 21:13 UTC (permalink / raw)
  To: Yonghong Song, ast, brakmo, netdev; +Cc: kernel-team

On 07/10/2017 11:04 PM, Yonghong Song wrote:
> With latest net-next:
> ====
> clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -Isamples/bpf \
>      -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
>      -Wno-compare-distinct-pointer-types \
>      -Wno-gnu-variable-sized-type-not-at-end \
>      -Wno-address-of-packed-member -Wno-tautological-compare \
>      -Wno-unknown-warning-option \
>      -O2 -emit-llvm -c samples/bpf/tcp_synrto_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/tcp_synrto_kern.o
> samples/bpf/tcp_synrto_kern.c:20:10: fatal error: 'bpf_endian.h' file not found
>            ^~~~~~~~~~~~~~
> 1 error generated.
> ====
>
> net has the same issue.
>
> Add support for ntohl and htonl in tools/testing/selftests/bpf/bpf_endian.h.
> Also move bpf_helpers.h from samples/bpf to selftests/bpf and change
> compiler include logic so that programs in samples/bpf can access the headers
> in selftests/bpf, but not the other way around.
>
> Signed-off-by: Yonghong Song <yhs@fb.com>

LGTM, thanks!

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net v2] samples/bpf: fix a build issue
  2017-07-10 21:13 ` Daniel Borkmann
@ 2017-07-10 22:10   ` Lawrence Brakmo
  0 siblings, 0 replies; 6+ messages in thread
From: Lawrence Brakmo @ 2017-07-10 22:10 UTC (permalink / raw)
  To: Daniel Borkmann, Yonghong Song, Alexei Starovoitov,
	netdev@vger.kernel.org
  Cc: Kernel Team



On 7/10/17, 2:13 PM, "Daniel Borkmann" <daniel@iogearbox.net> wrote:

    On 07/10/2017 11:04 PM, Yonghong Song wrote:
    > With latest net-next:
    > ====
    > clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -Isamples/bpf \
    >      -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
    >      -Wno-compare-distinct-pointer-types \
    >      -Wno-gnu-variable-sized-type-not-at-end \
    >      -Wno-address-of-packed-member -Wno-tautological-compare \
    >      -Wno-unknown-warning-option \
    >      -O2 -emit-llvm -c samples/bpf/tcp_synrto_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/tcp_synrto_kern.o
    > samples/bpf/tcp_synrto_kern.c:20:10: fatal error: 'bpf_endian.h' file not found
    >            ^~~~~~~~~~~~~~
    > 1 error generated.
    > ====
    >
    > net has the same issue.
    >
    > Add support for ntohl and htonl in tools/testing/selftests/bpf/bpf_endian.h.
    > Also move bpf_helpers.h from samples/bpf to selftests/bpf and change
    > compiler include logic so that programs in samples/bpf can access the headers
    > in selftests/bpf, but not the other way around.
    >
    > Signed-off-by: Yonghong Song <yhs@fb.com>
    
    LGTM, thanks!
    
    Acked-by: Daniel Borkmann daniel@iogearbox.net

Acked-by: Lawrence Brakmo <brakmo@fb.com>
    


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net v2] samples/bpf: fix a build issue
  2017-07-10 21:04 [PATCH net v2] samples/bpf: fix a build issue Yonghong Song
  2017-07-10 21:13 ` Daniel Borkmann
@ 2017-07-11 19:51 ` Jesper Dangaard Brouer
  2017-07-11 20:02   ` Daniel Borkmann
  2017-07-12  3:51 ` David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Jesper Dangaard Brouer @ 2017-07-11 19:51 UTC (permalink / raw)
  To: Yonghong Song; +Cc: brouer, ast, daniel, brakmo, netdev, kernel-team


On Mon, 10 Jul 2017 14:04:28 -0700 Yonghong Song <yhs@fb.com> wrote:

> With latest net-next:
> ====
> clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -Isamples/bpf \
>     -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
>     -Wno-compare-distinct-pointer-types \
>     -Wno-gnu-variable-sized-type-not-at-end \
>     -Wno-address-of-packed-member -Wno-tautological-compare \
>     -Wno-unknown-warning-option \
>     -O2 -emit-llvm -c samples/bpf/tcp_synrto_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/tcp_synrto_kern.o
> samples/bpf/tcp_synrto_kern.c:20:10: fatal error: 'bpf_endian.h' file not found
>           ^~~~~~~~~~~~~~
> 1 error generated.
> ====
> 
> net has the same issue.
> 
> Add support for ntohl and htonl in tools/testing/selftests/bpf/bpf_endian.h.

I think this patch should have been split up in two patches. One where
you fix the compile issue, and one where you add support for ntohl and
htonl.  And you are also moving the file... I'm getting confused
reading this patch.

> Also move bpf_helpers.h from samples/bpf to selftests/bpf and change
> compiler include logic so that programs in samples/bpf can access the headers
> in selftests/bpf, but not the other way around.
> 
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
>  samples/bpf/Makefile                                   |  1 +
>  tools/testing/selftests/bpf/Makefile                   |  1 -
>  tools/testing/selftests/bpf/bpf_endian.h               | 14 ++++++++++++++
>  {samples => tools/testing/selftests}/bpf/bpf_helpers.h |  0
>  4 files changed, 15 insertions(+), 1 deletion(-)
>  rename {samples => tools/testing/selftests}/bpf/bpf_helpers.h (100%)
> 
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 9c65058..87246be 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -207,6 +207,7 @@ $(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
>  # useless for BPF samples.
>  $(obj)/%.o: $(src)/%.c
>  	$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
> +		-I$(srctree)/tools/testing/selftests/bpf/ \
>  		-D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
>  		-Wno-compare-distinct-pointer-types \
>  		-Wno-gnu-variable-sized-type-not-at-end \
> diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 2ca51a8..153c3a1 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -37,6 +37,5 @@ CLANG ?= clang
>  
>  %.o: %.c
>  	$(CLANG) -I. -I./include/uapi -I../../../include/uapi \
> -		-I../../../../samples/bpf/ \
>  		-Wno-compare-distinct-pointer-types \
>  		-O2 -target bpf -c $< -o $@
> diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h
> index 487cbfb..74af266 100644
> --- a/tools/testing/selftests/bpf/bpf_endian.h
> +++ b/tools/testing/selftests/bpf/bpf_endian.h
> @@ -23,11 +23,19 @@
>  # define __bpf_htons(x)			__builtin_bswap16(x)
>  # define __bpf_constant_ntohs(x)	___constant_swab16(x)
>  # define __bpf_constant_htons(x)	___constant_swab16(x)
> +# define __bpf_ntohl(x)			__builtin_bswap32(x)
> +# define __bpf_htonl(x)			__builtin_bswap32(x)
> +# define __bpf_constant_ntohl(x)	___constant_swab32(x)
> +# define __bpf_constant_htonl(x)	___constant_swab32(x)
>  #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
>  # define __bpf_ntohs(x)			(x)
>  # define __bpf_htons(x)			(x)
>  # define __bpf_constant_ntohs(x)	(x)
>  # define __bpf_constant_htons(x)	(x)
> +# define __bpf_ntohl(x)			(x)
> +# define __bpf_htonl(x)			(x)
> +# define __bpf_constant_ntohl(x)	(x)
> +# define __bpf_constant_htonl(x)	(x)
>  #else
>  # error "Fix your compiler's __BYTE_ORDER__?!"
>  #endif
> @@ -38,5 +46,11 @@
>  #define bpf_ntohs(x)				\
>  	(__builtin_constant_p(x) ?		\
>  	 __bpf_constant_ntohs(x) : __bpf_ntohs(x))
> +#define bpf_htonl(x)				\
> +	(__builtin_constant_p(x) ?		\
> +	 __bpf_constant_htonl(x) : __bpf_htonl(x))
> +#define bpf_ntohl(x)				\
> +	(__builtin_constant_p(x) ?		\
> +	 __bpf_constant_ntohl(x) : __bpf_ntohl(x))
>  
>  #endif /* __BPF_ENDIAN__ */
> diff --git a/samples/bpf/bpf_helpers.h b/tools/testing/selftests/bpf/bpf_helpers.h
> similarity index 100%
> rename from samples/bpf/bpf_helpers.h
> rename to tools/testing/selftests/bpf/bpf_helpers.h



-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net v2] samples/bpf: fix a build issue
  2017-07-11 19:51 ` Jesper Dangaard Brouer
@ 2017-07-11 20:02   ` Daniel Borkmann
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Borkmann @ 2017-07-11 20:02 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, Yonghong Song; +Cc: ast, brakmo, netdev, kernel-team

On 07/11/2017 09:51 PM, Jesper Dangaard Brouer wrote:
> On Mon, 10 Jul 2017 14:04:28 -0700 Yonghong Song <yhs@fb.com> wrote:
>
>> With latest net-next:
>> ====
>> clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -Isamples/bpf \
>>      -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
>>      -Wno-compare-distinct-pointer-types \
>>      -Wno-gnu-variable-sized-type-not-at-end \
>>      -Wno-address-of-packed-member -Wno-tautological-compare \
>>      -Wno-unknown-warning-option \
>>      -O2 -emit-llvm -c samples/bpf/tcp_synrto_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/tcp_synrto_kern.o
>> samples/bpf/tcp_synrto_kern.c:20:10: fatal error: 'bpf_endian.h' file not found
>>            ^~~~~~~~~~~~~~
>> 1 error generated.
>> ====
>>
>> net has the same issue.
>>
>> Add support for ntohl and htonl in tools/testing/selftests/bpf/bpf_endian.h.
>
> I think this patch should have been split up in two patches. One where
> you fix the compile issue, and one where you add support for ntohl and
> htonl.  And you are also moving the file... I'm getting confused
> reading this patch.

Could have been done, sure. Patch is still straight forward and small as-is,
so I don't really mind having this user space code squashed together.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH net v2] samples/bpf: fix a build issue
  2017-07-10 21:04 [PATCH net v2] samples/bpf: fix a build issue Yonghong Song
  2017-07-10 21:13 ` Daniel Borkmann
  2017-07-11 19:51 ` Jesper Dangaard Brouer
@ 2017-07-12  3:51 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-07-12  3:51 UTC (permalink / raw)
  To: yhs; +Cc: ast, daniel, brakmo, netdev, kernel-team

From: Yonghong Song <yhs@fb.com>
Date: Mon, 10 Jul 2017 14:04:28 -0700

> With latest net-next:
> ====
> clang  -nostdinc -isystem /usr/lib/gcc/x86_64-redhat-linux/6.3.1/include -I./arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/kconfig.h  -Isamples/bpf \
>     -D__KERNEL__ -D__ASM_SYSREG_H -Wno-unused-value -Wno-pointer-sign \
>     -Wno-compare-distinct-pointer-types \
>     -Wno-gnu-variable-sized-type-not-at-end \
>     -Wno-address-of-packed-member -Wno-tautological-compare \
>     -Wno-unknown-warning-option \
>     -O2 -emit-llvm -c samples/bpf/tcp_synrto_kern.c -o -| llc -march=bpf -filetype=obj -o samples/bpf/tcp_synrto_kern.o
> samples/bpf/tcp_synrto_kern.c:20:10: fatal error: 'bpf_endian.h' file not found
>           ^~~~~~~~~~~~~~
> 1 error generated.
> ====
> 
> net has the same issue.
> 
> Add support for ntohl and htonl in tools/testing/selftests/bpf/bpf_endian.h.
> Also move bpf_helpers.h from samples/bpf to selftests/bpf and change
> compiler include logic so that programs in samples/bpf can access the headers
> in selftests/bpf, but not the other way around.
> 
> Signed-off-by: Yonghong Song <yhs@fb.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-07-12  3:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-10 21:04 [PATCH net v2] samples/bpf: fix a build issue Yonghong Song
2017-07-10 21:13 ` Daniel Borkmann
2017-07-10 22:10   ` Lawrence Brakmo
2017-07-11 19:51 ` Jesper Dangaard Brouer
2017-07-11 20:02   ` Daniel Borkmann
2017-07-12  3:51 ` 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).