* more bpf samples build breakage...
@ 2017-05-01 19:30 David Miller
2017-05-01 19:44 ` David Miller
2017-05-01 20:38 ` Daniel Borkmann
0 siblings, 2 replies; 4+ messages in thread
From: David Miller @ 2017-05-01 19:30 UTC (permalink / raw)
To: daniel; +Cc: netdev
Inlcuding bpf_util.h into test_pkt_access.c et al. broke the build even
more so than it already is on sparc.
The problem is we end up including all the stdio.h bits and eventually
hit things like:
In file included from /usr/include/stdio.h:933:
/usr/include/bits/stdio-ldbl.h:28:20: error: cannot apply asm label to function after its first use
__LDBL_REDIR_DECL (vfprintf)
~~~~~~~~~~~~~~~~~~~^~~~~~~~~
/usr/include/sys/cdefs.h:373:26: note: expanded from macro '__LDBL_REDIR_DECL'
extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
So please let's put CLANG compiled helpers into header files
specifically meant to be included by CLANG compiled BPF programs
rather than the host build environment.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: more bpf samples build breakage...
2017-05-01 19:30 more bpf samples build breakage David Miller
@ 2017-05-01 19:44 ` David Miller
2017-05-01 20:38 ` Daniel Borkmann
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2017-05-01 19:44 UTC (permalink / raw)
To: daniel; +Cc: netdev
From: David Miller <davem@davemloft.net>
Date: Mon, 01 May 2017 15:30:05 -0400 (EDT)
>
> Inlcuding bpf_util.h into test_pkt_access.c et al. broke the build even
> more so than it already is on sparc.
>
> The problem is we end up including all the stdio.h bits and eventually
> hit things like:
>
> In file included from /usr/include/stdio.h:933:
> /usr/include/bits/stdio-ldbl.h:28:20: error: cannot apply asm label to function after its first use
> __LDBL_REDIR_DECL (vfprintf)
> ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
> /usr/include/sys/cdefs.h:373:26: note: expanded from macro '__LDBL_REDIR_DECL'
> extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
>
> So please let's put CLANG compiled helpers into header files
> specifically meant to be included by CLANG compiled BPF programs
> rather than the host build environment.
I'm pushing the following quick fix for this for now:
>From bc1bafbbe9b3558d7789ff151ef4f185b6ad21f3 Mon Sep 17 00:00:00 2001
From: "David S. Miller" <davem@davemloft.net>
Date: Mon, 1 May 2017 12:43:49 -0700
Subject: [PATCH] bpf: Move endianness BPF helpers out of bpf_util.h
We do not want to include things like stdio.h and friends into
eBPF program builds. bpf_util.h is for host compiled programs,
so eBPF C-code helpers don't really belong there.
Add a new bpf_endian.h as a quick fix for this for now.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
tools/testing/selftests/bpf/bpf_endian.h | 23 +++++++++++++++++++++++
tools/testing/selftests/bpf/bpf_util.h | 19 -------------------
tools/testing/selftests/bpf/test_l4lb.c | 2 +-
tools/testing/selftests/bpf/test_pkt_access.c | 2 +-
4 files changed, 25 insertions(+), 21 deletions(-)
create mode 100644 tools/testing/selftests/bpf/bpf_endian.h
diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h
new file mode 100644
index 0000000..19d0604
--- /dev/null
+++ b/tools/testing/selftests/bpf/bpf_endian.h
@@ -0,0 +1,23 @@
+#ifndef __BPF_ENDIAN__
+#define __BPF_ENDIAN__
+
+#include <asm/byteorder.h>
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define __bpf_ntohs(x) __builtin_bswap16(x)
+# define __bpf_htons(x) __builtin_bswap16(x)
+#elif __BYTE_ORDER == __BIG_ENDIAN
+# define __bpf_ntohs(x) (x)
+# define __bpf_htons(x) (x)
+#else
+# error "Fix your __BYTE_ORDER?!"
+#endif
+
+#define bpf_htons(x) \
+ (__builtin_constant_p(x) ? \
+ __constant_htons(x) : __bpf_htons(x))
+#define bpf_ntohs(x) \
+ (__builtin_constant_p(x) ? \
+ __constant_ntohs(x) : __bpf_ntohs(x))
+
+#endif
diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
index 369e7d7..20ecbaa 100644
--- a/tools/testing/selftests/bpf/bpf_util.h
+++ b/tools/testing/selftests/bpf/bpf_util.h
@@ -6,25 +6,6 @@
#include <string.h>
#include <errno.h>
-#include <asm/byteorder.h>
-
-#if __BYTE_ORDER == __LITTLE_ENDIAN
-# define __bpf_ntohs(x) __builtin_bswap16(x)
-# define __bpf_htons(x) __builtin_bswap16(x)
-#elif __BYTE_ORDER == __BIG_ENDIAN
-# define __bpf_ntohs(x) (x)
-# define __bpf_htons(x) (x)
-#else
-# error "Fix your __BYTE_ORDER?!"
-#endif
-
-#define bpf_htons(x) \
- (__builtin_constant_p(x) ? \
- __constant_htons(x) : __bpf_htons(x))
-#define bpf_ntohs(x) \
- (__builtin_constant_p(x) ? \
- __constant_ntohs(x) : __bpf_ntohs(x))
-
static inline unsigned int bpf_num_possible_cpus(void)
{
static const char *fcpu = "/sys/devices/system/cpu/possible";
diff --git a/tools/testing/selftests/bpf/test_l4lb.c b/tools/testing/selftests/bpf/test_l4lb.c
index b68b212..1e10c95 100644
--- a/tools/testing/selftests/bpf/test_l4lb.c
+++ b/tools/testing/selftests/bpf/test_l4lb.c
@@ -19,7 +19,7 @@
#include <linux/udp.h>
#include "bpf_helpers.h"
#include "test_iptunnel_common.h"
-#include "bpf_util.h"
+#include "bpf_endian.h"
int _version SEC("version") = 1;
diff --git a/tools/testing/selftests/bpf/test_pkt_access.c b/tools/testing/selftests/bpf/test_pkt_access.c
index 7113005..39387bb 100644
--- a/tools/testing/selftests/bpf/test_pkt_access.c
+++ b/tools/testing/selftests/bpf/test_pkt_access.c
@@ -14,7 +14,7 @@
#include <linux/tcp.h>
#include <linux/pkt_cls.h>
#include "bpf_helpers.h"
-#include "bpf_util.h"
+#include "bpf_endian.h"
#define barrier() __asm__ __volatile__("": : :"memory")
int _version SEC("version") = 1;
--
2.1.2.532.g19b5d50
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: more bpf samples build breakage...
2017-05-01 19:30 more bpf samples build breakage David Miller
2017-05-01 19:44 ` David Miller
@ 2017-05-01 20:38 ` Daniel Borkmann
2017-05-01 20:45 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Daniel Borkmann @ 2017-05-01 20:38 UTC (permalink / raw)
To: David Miller; +Cc: netdev
On 05/01/2017 09:30 PM, David Miller wrote:
>
> Inlcuding bpf_util.h into test_pkt_access.c et al. broke the build even
> more so than it already is on sparc.
>
> The problem is we end up including all the stdio.h bits and eventually
> hit things like:
>
> In file included from /usr/include/stdio.h:933:
> /usr/include/bits/stdio-ldbl.h:28:20: error: cannot apply asm label to function after its first use
> __LDBL_REDIR_DECL (vfprintf)
> ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
> /usr/include/sys/cdefs.h:373:26: note: expanded from macro '__LDBL_REDIR_DECL'
> extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
>
> So please let's put CLANG compiled helpers into header files
> specifically meant to be included by CLANG compiled BPF programs
> rather than the host build environment.
Argh, sorry for that and thanks for the quick fix. When I tested
this on x86_64, I didn't hit a compilation issue.
BPF selftests:
[root@apoc bpf]# make > /dev/null
Warning: tools/include/uapi/linux/bpf.h differs from kernel
[root@apoc bpf]# ./test_progs
test_pkt_access:PASS:ipv4 401 nsec
test_pkt_access:PASS:ipv6 271 nsec
test_xdp:PASS:ipv4 4617 nsec
test_xdp:PASS:ipv6 2979 nsec
test_l4lb:PASS:ipv4 921 nsec
test_l4lb:PASS:ipv6 717 nsec
Summary: 6 PASSED, 0 FAILED
[root@apoc bpf]#
BPF samples:
[root@apoc bpf]# make > /dev/null
In file included from /root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:54:0:
/root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c: In function ‘prog_load’:
/root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:119:5: warning: overflow in implicit constant conversion [-Woverflow]
-32 + offsetof(struct stats, uid)),
^
/root/cilium/net-next/samples/bpf/libbpf.h:135:12: note: in definition of macro ‘BPF_STX_MEM’
.off = OFF, \
^
/root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:121:5: warning: overflow in implicit constant conversion [-Woverflow]
-32 + offsetof(struct stats, packets), 1),
^
/root/cilium/net-next/samples/bpf/libbpf.h:155:12: note: in definition of macro ‘BPF_ST_MEM’
.off = OFF, \
^
/root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:129:5: warning: overflow in implicit constant conversion [-Woverflow]
-32 + offsetof(struct stats, bytes)),
^
/root/cilium/net-next/samples/bpf/libbpf.h:135:12: note: in definition of macro ‘BPF_STX_MEM’
.off = OFF, \
^
[root@apoc bpf]#
Above warning is from 51570a5ab2b7 ("A Sample of using socket
cookie and uid for traffic monitoring"). I can see to send a
fix for it.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: more bpf samples build breakage...
2017-05-01 20:38 ` Daniel Borkmann
@ 2017-05-01 20:45 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-05-01 20:45 UTC (permalink / raw)
To: daniel; +Cc: netdev
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Mon, 01 May 2017 22:38:58 +0200
> BPF samples:
>
> [root@apoc bpf]# make > /dev/null
> In file included from
> /root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:54:0:
> /root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c: In
> function ‘prog_load’:
> /root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:119:5:
> warning: overflow in implicit constant conversion [-Woverflow]
> -32 + offsetof(struct stats, uid)),
> ^
> /root/cilium/net-next/samples/bpf/libbpf.h:135:12: note: in definition
> of macro ‘BPF_STX_MEM’
> .off = OFF, \
> ^
> /root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:121:5:
> warning: overflow in implicit constant conversion [-Woverflow]
> -32 + offsetof(struct stats, packets), 1),
> ^
> /root/cilium/net-next/samples/bpf/libbpf.h:155:12: note: in definition
> of macro ‘BPF_ST_MEM’
> .off = OFF, \
> ^
> /root/cilium/net-next/samples/bpf/cookie_uid_helper_example.c:129:5:
> warning: overflow in implicit constant conversion [-Woverflow]
> -32 + offsetof(struct stats, bytes)),
> ^
> /root/cilium/net-next/samples/bpf/libbpf.h:135:12: note: in definition
> of macro ‘BPF_STX_MEM’
> .off = OFF, \
> ^
> [root@apoc bpf]#
>
> Above warning is from 51570a5ab2b7 ("A Sample of using socket
> cookie and uid for traffic monitoring"). I can see to send a
> fix for it.
Please do, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-01 20:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-01 19:30 more bpf samples build breakage David Miller
2017-05-01 19:44 ` David Miller
2017-05-01 20:38 ` Daniel Borkmann
2017-05-01 20:45 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.