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

From: Yonghong Song <yhs@localhost.localdomain>

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
and move it to samples/bpf/ directory so that it can used by
both selftests/bpf and samples/bpf. The existing samples/bpf/bpf_helpers.h
is already used by both.

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

diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/samples/bpf/bpf_endian.h
similarity index 73%
rename from tools/testing/selftests/bpf/bpf_endian.h
rename to samples/bpf/bpf_endian.h
index 487cbfb..74af266 100644
--- a/tools/testing/selftests/bpf/bpf_endian.h
+++ b/samples/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/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 2ca51a8..f263c6b 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -8,7 +8,8 @@ ifneq ($(wildcard $(GENHDR)),)
   GENFLAGS := -DHAVE_GENHDR
 endif
 
-CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include
+CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include \
+	-I../../../../samples/bpf
 LDLIBS += -lcap -lelf
 
 TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
-- 
2.9.4

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

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

Thank you for fixing it.

On 7/10/17, 1:12 PM, "Yonghong Song" <yhs@fb.com> wrote:

    From: Yonghong Song <yhs@localhost.localdomain>
    
    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
    and move it to samples/bpf/ directory so that it can used by
    both selftests/bpf and samples/bpf. The existing samples/bpf/bpf_helpers.h
    is already used by both.
    
    Signed-off-by: Yonghong Song yhs@fb.com

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

    ---
     {tools/testing/selftests => samples}/bpf/bpf_endian.h | 14 ++++++++++++++
     tools/testing/selftests/bpf/Makefile                  |  3 ++-
     2 files changed, 16 insertions(+), 1 deletion(-)
     rename {tools/testing/selftests => samples}/bpf/bpf_endian.h (73%)
    
    diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/samples/bpf/bpf_endian.h
    similarity index 73%
    rename from tools/testing/selftests/bpf/bpf_endian.h
    rename to samples/bpf/bpf_endian.h
    index 487cbfb..74af266 100644
    --- a/tools/testing/selftests/bpf/bpf_endian.h
    +++ b/samples/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/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
    index 2ca51a8..f263c6b 100644
    --- a/tools/testing/selftests/bpf/Makefile
    +++ b/tools/testing/selftests/bpf/Makefile
    @@ -8,7 +8,8 @@ ifneq ($(wildcard $(GENHDR)),)
       GENFLAGS := -DHAVE_GENHDR
     endif
     
    -CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include
    +CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include \
    +	-I../../../../samples/bpf
     LDLIBS += -lcap -lelf
     
     TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
    -- 
    2.9.4
    
    


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

* Re: [PATCH net] samples/bpf: fix a build issue
  2017-07-10 20:12 [PATCH net] samples/bpf: fix a build issue Yonghong Song
  2017-07-10 20:21 ` Lawrence Brakmo
@ 2017-07-10 20:27 ` Daniel Borkmann
  2017-07-10 20:51   ` Yonghong Song
  1 sibling, 1 reply; 5+ messages in thread
From: Daniel Borkmann @ 2017-07-10 20:27 UTC (permalink / raw)
  To: Yonghong Song, ast, brakmo, netdev; +Cc: kernel-team, Yonghong Song

On 07/10/2017 10:12 PM, Yonghong Song wrote:
> From: Yonghong Song <yhs@localhost.localdomain>
>
> 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
> and move it to samples/bpf/ directory so that it can used by
> both selftests/bpf and samples/bpf. The existing samples/bpf/bpf_helpers.h
> is already used by both.
>
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
>   {tools/testing/selftests => samples}/bpf/bpf_endian.h | 14 ++++++++++++++

samples/bpf/Makefile already does:

   HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/

If needed we should rather extend the sample's Makefile to pull in
bpf_endian.h also for clang generated files, but not the other way
round. It's both kind of messy, but kernel selftests should not need
to include or depend upon some sample code.

Other than that looks good to me.

>   tools/testing/selftests/bpf/Makefile                  |  3 ++-
>   2 files changed, 16 insertions(+), 1 deletion(-)
>   rename {tools/testing/selftests => samples}/bpf/bpf_endian.h (73%)
>
> diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/samples/bpf/bpf_endian.h
> similarity index 73%
> rename from tools/testing/selftests/bpf/bpf_endian.h
> rename to samples/bpf/bpf_endian.h
> index 487cbfb..74af266 100644
> --- a/tools/testing/selftests/bpf/bpf_endian.h
> +++ b/samples/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/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
> index 2ca51a8..f263c6b 100644
> --- a/tools/testing/selftests/bpf/Makefile
> +++ b/tools/testing/selftests/bpf/Makefile
> @@ -8,7 +8,8 @@ ifneq ($(wildcard $(GENHDR)),)
>     GENFLAGS := -DHAVE_GENHDR
>   endif
>
> -CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include
> +CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) -I../../../include \
> +	-I../../../../samples/bpf
>   LDLIBS += -lcap -lelf
>
>   TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map test_progs \
>

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

* Re: [PATCH net] samples/bpf: fix a build issue
  2017-07-10 20:27 ` Daniel Borkmann
@ 2017-07-10 20:51   ` Yonghong Song
  2017-07-10 21:02     ` Daniel Borkmann
  0 siblings, 1 reply; 5+ messages in thread
From: Yonghong Song @ 2017-07-10 20:51 UTC (permalink / raw)
  To: Daniel Borkmann, ast, brakmo, netdev; +Cc: kernel-team, Yonghong Song



On 7/10/17 1:27 PM, Daniel Borkmann wrote:
> On 07/10/2017 10:12 PM, Yonghong Song wrote:
>> From: Yonghong Song <yhs@localhost.localdomain>
>>
>> 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
>> and move it to samples/bpf/ directory so that it can used by
>> both selftests/bpf and samples/bpf. The existing 
>> samples/bpf/bpf_helpers.h
>> is already used by both.
>>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
>> ---
>>   {tools/testing/selftests => samples}/bpf/bpf_endian.h | 14 
>> ++++++++++++++
> 
> samples/bpf/Makefile already does:
> 
>    HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
> 
> If needed we should rather extend the sample's Makefile to pull in
> bpf_endian.h also for clang generated files, but not the other way
> round. It's both kind of messy, but kernel selftests should not need
> to include or depend upon some sample code.

Sounds good. I will then move bpf_helpers.h to selftests as well so
samples/bpf will depend on selftests/bpf, but not the other way around.

> 
> Other than that looks good to me.
> 
>>   tools/testing/selftests/bpf/Makefile                  |  3 ++-
>>   2 files changed, 16 insertions(+), 1 deletion(-)
>>   rename {tools/testing/selftests => samples}/bpf/bpf_endian.h (73%)
>>
>> diff --git a/tools/testing/selftests/bpf/bpf_endian.h 
>> b/samples/bpf/bpf_endian.h
>> similarity index 73%
>> rename from tools/testing/selftests/bpf/bpf_endian.h
>> rename to samples/bpf/bpf_endian.h
>> index 487cbfb..74af266 100644
>> --- a/tools/testing/selftests/bpf/bpf_endian.h
>> +++ b/samples/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/tools/testing/selftests/bpf/Makefile 
>> b/tools/testing/selftests/bpf/Makefile
>> index 2ca51a8..f263c6b 100644
>> --- a/tools/testing/selftests/bpf/Makefile
>> +++ b/tools/testing/selftests/bpf/Makefile
>> @@ -8,7 +8,8 @@ ifneq ($(wildcard $(GENHDR)),)
>>     GENFLAGS := -DHAVE_GENHDR
>>   endif
>>
>> -CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) 
>> -I../../../include
>> +CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(GENDIR) $(GENFLAGS) 
>> -I../../../include \
>> +    -I../../../../samples/bpf
>>   LDLIBS += -lcap -lelf
>>
>>   TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map 
>> test_lpm_map test_progs \
>>
> 

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

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

On 07/10/2017 10:51 PM, Yonghong Song wrote:
> On 7/10/17 1:27 PM, Daniel Borkmann wrote:
>> On 07/10/2017 10:12 PM, Yonghong Song wrote:
>>> From: Yonghong Song <yhs@localhost.localdomain>
>>>
>>> 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
>>> and move it to samples/bpf/ directory so that it can used by
>>> both selftests/bpf and samples/bpf. The existing samples/bpf/bpf_helpers.h
>>> is already used by both.
>>>
>>> Signed-off-by: Yonghong Song <yhs@fb.com>
>>> ---
>>>   {tools/testing/selftests => samples}/bpf/bpf_endian.h | 14 ++++++++++++++
>>
>> samples/bpf/Makefile already does:
>>
>>    HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
>>
>> If needed we should rather extend the sample's Makefile to pull in
>> bpf_endian.h also for clang generated files, but not the other way
>> round. It's both kind of messy, but kernel selftests should not need
>> to include or depend upon some sample code.
>
> Sounds good. I will then move bpf_helpers.h to selftests as well so
> samples/bpf will depend on selftests/bpf, but not the other way around.

Okay, that's fine by me. (We can later also move some of the test
cases over to selftests, so that they get generally more coverage.)
Thanks, Yonghong!

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

end of thread, other threads:[~2017-07-10 21:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-10 20:12 [PATCH net] samples/bpf: fix a build issue Yonghong Song
2017-07-10 20:21 ` Lawrence Brakmo
2017-07-10 20:27 ` Daniel Borkmann
2017-07-10 20:51   ` Yonghong Song
2017-07-10 21:02     ` Daniel Borkmann

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).