samples/bpf: fix a build issue
Subsystems (5)
PATCH v2 1/1 samples/bpf: fix a build issue
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.
---
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%)samples/bpf/Makefile +1 -0
@@ -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 \
tools/testing/selftests/bpf/Makefile +0 -1
@@ -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 $@
tools/testing/selftests/bpf/bpf_endian.h +14 -0
@@ -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__ */
tools/testing/selftests/bpf/bpf_helpers.h renamed from samples/bpf/bpf_helpers.h +0 -0
Signature · 1 line
2.9.3
Quoted 14 lines · Yonghong Song
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.
====
Quoted 8 lines
net has the same issue.
Add support for ntohl and htonl in
tools/testing/selftests/bpf/bpf_endian.h. Also movebpf_helpers.hfromsamples/bpfto selftests/bpf and change compiler include logic so that programs insamples/bpfcan access the headers in selftests/bpf, but not the other way around.Signed-off-by Yonghong Song <[email protected]>
LGTM, thanks!
Lawrence Brakmo
Acked-byOn 7/10/17, 2:13 PM, "Daniel Borkmann" <[email protected]> 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 <[email protected]>
LGTM, thanks!
Acked-by: Daniel Borkmann [email protected]Quoted 11 lines · On Mon, 10 Jul 2017 14:04:28 -0700 Yonghong Song <[email protected]> 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 ^~~~~~~~~~~~~~
Quoted 6 lines
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.
Quoted 76 lines
Also move
bpf_helpers.hfromsamples/bpfto selftests/bpf and change compiler include logic so that programs insamples/bpfcan access the headers in selftests/bpf, but not the other way around.Signed-off-by Yonghong Song <[email protected]>--- 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%)samples/bpf/Makefile +1
-0@@ -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 \tools/testing/selftests/bpf/Makefile +0
-1@@ -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 $@tools/testing/selftests/bpf/bpf_endian.h +14
-0@@ -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__ */ tools/testing/selftests/bpf/bpf_helpers.h renamed from samples/bpf/bpf_helpers.h +0
-0
Signature · 4 lines
Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer
Daniel Borkmann
maintainerQuoted 16 lines · Jesper Dangaard Brouer
Quoted 14 lines · On Mon, 10 Jul 2017 14:04:28 -0700 Yonghong Song <[email protected]> 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.
====
Quoted 8 lines
Quoted 3 lines
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.
From: Yonghong Song <[email protected]>
Date: Mon, 10 Jul 2017 14:04:28 -0700
Quoted 14 lines
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.
====
Quoted 8 lines
net has the same issue.
Add support for ntohl and htonl in
tools/testing/selftests/bpf/bpf_endian.h. Also movebpf_helpers.hfromsamples/bpfto selftests/bpf and change compiler include logic so that programs insamples/bpfcan access the headers in selftests/bpf, but not the other way around.Signed-off-by Yonghong Song <[email protected]>
Applied, thanks.