LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/5] samples/bpf: fix test_lru_dist build
@ 2019-05-18 0:46 Matteo Croce
2019-05-18 0:46 ` [PATCH 2/5] libbpf: add missing typedef Matteo Croce
` (4 more replies)
0 siblings, 5 replies; 15+ messages in thread
From: Matteo Croce @ 2019-05-18 0:46 UTC (permalink / raw)
To: xdp-newbies, bpf
Cc: linux-kernel, netdev, Alexei Starovoitov, Daniel Borkmann
Fix the following error by removing a duplicate struct definition:
samples/bpf/test_lru_dist.c:39:8: error: redefinition of ‘struct list_head’
39 | struct list_head {
| ^~~~~~~~~
In file included from samples/bpf/test_lru_dist.c:9:
./tools/include/linux/types.h:69:8: note: originally defined here
69 | struct list_head {
| ^~~~~~~~~
make[2]: *** [scripts/Makefile.host:92: samples/bpf/test_lru_dist] Error 1
make[1]: *** [Makefile:1763: samples/bpf/] Error 2
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
samples/bpf/test_lru_dist.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/samples/bpf/test_lru_dist.c b/samples/bpf/test_lru_dist.c
index eec3e2509ce8..f532b894654b 100644
--- a/samples/bpf/test_lru_dist.c
+++ b/samples/bpf/test_lru_dist.c
@@ -36,10 +36,6 @@ static int nr_cpus;
static unsigned long long *dist_keys;
static unsigned int dist_key_counts;
-struct list_head {
- struct list_head *next, *prev;
-};
-
static inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
--
2.21.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/5] libbpf: add missing typedef
2019-05-18 0:46 [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
@ 2019-05-18 0:46 ` Matteo Croce
2019-05-20 16:53 ` Stanislav Fomichev
2019-05-18 0:46 ` [PATCH 3/5] samples/bpf: fix xdpsock_user build error Matteo Croce
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Matteo Croce @ 2019-05-18 0:46 UTC (permalink / raw)
To: xdp-newbies, bpf
Cc: linux-kernel, netdev, Alexei Starovoitov, Daniel Borkmann
Sync tools/include/linux/types.h with the UAPI one to fix this build error:
make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
HOSTCC samples/bpf/sock_example
In file included from samples/bpf/sock_example.c:27:
/usr/include/linux/ip.h:102:2: error: unknown type name ‘__sum16’
102 | __sum16 check;
| ^~~~~~~
make[2]: *** [scripts/Makefile.host:92: samples/bpf/sock_example] Error 1
make[1]: *** [Makefile:1763: samples/bpf/] Error 2
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
tools/include/linux/types.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
index 154eb4e3ca7c..5266dbfee945 100644
--- a/tools/include/linux/types.h
+++ b/tools/include/linux/types.h
@@ -58,6 +58,9 @@ typedef __u32 __bitwise __be32;
typedef __u64 __bitwise __le64;
typedef __u64 __bitwise __be64;
+typedef __u16 __bitwise __sum16;
+typedef __u32 __bitwise __wsum;
+
typedef struct {
int counter;
} atomic_t;
--
2.21.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/5] samples/bpf: fix xdpsock_user build error
2019-05-18 0:46 [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
2019-05-18 0:46 ` [PATCH 2/5] libbpf: add missing typedef Matteo Croce
@ 2019-05-18 0:46 ` Matteo Croce
2019-05-18 0:46 ` [PATCH 4/5] samples/bpf: fix tracex5_user " Matteo Croce
` (2 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: Matteo Croce @ 2019-05-18 0:46 UTC (permalink / raw)
To: xdp-newbies, bpf
Cc: linux-kernel, netdev, Alexei Starovoitov, Daniel Borkmann
Remove duplicate typedef, and use PRIu64 to be both 32 and 64 bit aware.
Fix the following error:
samples/bpf/xdpsock_user.c:52:15: error: conflicting types for ‘u64’
52 | typedef __u64 u64;
| ^~~
In file included from ./tools/include/linux/compiler.h:87,
from ./tools/include/asm/barrier.h:2,
from samples/bpf/xdpsock_user.c:4:
./tools/include/linux/types.h:30:18: note: previous declaration of ‘u64’ was here
30 | typedef uint64_t u64;
| ^~~
make[2]: *** [scripts/Makefile.host:109: samples/bpf/xdpsock_user.o] Error 1
make[1]: *** [Makefile:1763: samples/bpf/] Error 2
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
samples/bpf/xdpsock_user.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index d08ee1ab7bb4..a4cd42c2f0b0 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -24,6 +24,7 @@
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/types.h>
+#include <inttypes.h>
#include <time.h>
#include <unistd.h>
@@ -49,9 +50,6 @@
#define DEBUG_HEXDUMP 0
#define MAX_SOCKS 8
-typedef __u64 u64;
-typedef __u32 u32;
-
static unsigned long prev_time;
enum benchmark_type {
@@ -243,7 +241,7 @@ static void hex_dump(void *pkt, size_t length, u64 addr)
if (!DEBUG_HEXDUMP)
return;
- sprintf(buf, "addr=%llu", addr);
+ sprintf(buf, "addr=%" PRIu64, addr);
printf("length = %zu\n", length);
printf("%s | ", buf);
while (length-- > 0) {
--
2.21.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/5] samples/bpf: fix tracex5_user build error
2019-05-18 0:46 [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
2019-05-18 0:46 ` [PATCH 2/5] libbpf: add missing typedef Matteo Croce
2019-05-18 0:46 ` [PATCH 3/5] samples/bpf: fix xdpsock_user build error Matteo Croce
@ 2019-05-18 0:46 ` Matteo Croce
2019-05-21 15:22 ` Daniel Borkmann
2019-05-18 0:46 ` [PATCH 5/5] samples/bpf: fix hbm " Matteo Croce
2019-05-20 17:46 ` [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
4 siblings, 1 reply; 15+ messages in thread
From: Matteo Croce @ 2019-05-18 0:46 UTC (permalink / raw)
To: xdp-newbies, bpf
Cc: linux-kernel, netdev, Alexei Starovoitov, Daniel Borkmann
Add missing symbols to tools/include/linux/filter.h to fix a build failure:
make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
HOSTCC samples/bpf/tracex5_user.o
samples/bpf/tracex5_user.c: In function ‘install_accept_all_seccomp’:
samples/bpf/tracex5_user.c:17:21: error: array type has incomplete element type ‘struct sock_filter’
17 | struct sock_filter filter[] = {
| ^~~~~~
samples/bpf/tracex5_user.c:18:3: warning: implicit declaration of function ‘BPF_STMT’; did you mean ‘BPF_STX’? [-Wimplicit-function-declaration]
18 | BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
| ^~~~~~~~
| BPF_STX
samples/bpf/tracex5_user.c:20:9: error: variable ‘prog’ has initializer but incomplete type
20 | struct sock_fprog prog = {
| ^~~~~~~~~~
samples/bpf/tracex5_user.c:21:4: error: ‘struct sock_fprog’ has no member named ‘len’
21 | .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
| ^~~
samples/bpf/tracex5_user.c:21:10: warning: excess elements in struct initializer
21 | .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
| ^
samples/bpf/tracex5_user.c:21:10: note: (near initialization for ‘prog’)
samples/bpf/tracex5_user.c:22:4: error: ‘struct sock_fprog’ has no member named ‘filter’
22 | .filter = filter,
| ^~~~~~
samples/bpf/tracex5_user.c:22:13: warning: excess elements in struct initializer
22 | .filter = filter,
| ^~~~~~
samples/bpf/tracex5_user.c:22:13: note: (near initialization for ‘prog’)
samples/bpf/tracex5_user.c:20:20: error: storage size of ‘prog’ isn’t known
20 | struct sock_fprog prog = {
| ^~~~
samples/bpf/tracex5_user.c:20:20: warning: unused variable ‘prog’ [-Wunused-variable]
samples/bpf/tracex5_user.c:17:21: warning: unused variable ‘filter’ [-Wunused-variable]
17 | struct sock_filter filter[] = {
| ^~~~~~
make[2]: *** [scripts/Makefile.host:109: samples/bpf/tracex5_user.o] Error 1
make[1]: *** [Makefile:1763: samples/bpf/] Error 2
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
tools/include/linux/filter.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tools/include/linux/filter.h b/tools/include/linux/filter.h
index ca28b6ab8db7..6b2ed7eccfa5 100644
--- a/tools/include/linux/filter.h
+++ b/tools/include/linux/filter.h
@@ -7,6 +7,33 @@
#include <linux/bpf.h>
+/*
+ * Try and keep these values and structures similar to BSD, especially
+ * the BPF code definitions which need to match so you can share filters
+ */
+
+struct sock_filter { /* Filter block */
+ __u16 code; /* Actual filter code */
+ __u8 jt; /* Jump true */
+ __u8 jf; /* Jump false */
+ __u32 k; /* Generic multiuse field */
+};
+
+struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
+ unsigned short len; /* Number of filter blocks */
+ struct sock_filter __user *filter;
+};
+
+/*
+ * Macros for filter block array initializers.
+ */
+#ifndef BPF_STMT
+#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
+#endif
+#ifndef BPF_JUMP
+#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
+#endif
+
/* ArgX, context and stack frame pointer register positions. Note,
* Arg1, Arg2, Arg3, etc are used as argument mappings of function
* calls in BPF_CALL instruction.
--
2.21.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/5] samples/bpf: fix hbm build error
2019-05-18 0:46 [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
` (2 preceding siblings ...)
2019-05-18 0:46 ` [PATCH 4/5] samples/bpf: fix tracex5_user " Matteo Croce
@ 2019-05-18 0:46 ` Matteo Croce
2019-05-20 17:46 ` [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
4 siblings, 0 replies; 15+ messages in thread
From: Matteo Croce @ 2019-05-18 0:46 UTC (permalink / raw)
To: xdp-newbies, bpf
Cc: linux-kernel, netdev, Alexei Starovoitov, Daniel Borkmann
Fix the following build error by declaring bpf_spin_lock in hbm.c.
Including the UAPI header generates tons of redefined symbol errors,
and including it in hbm.h breaks hbm_out_kern.c.
make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
HOSTCC samples/bpf/hbm.o
In file included from samples/bpf/hbm.c:49:
samples/bpf/hbm.h:12:23: error: field ‘lock’ has incomplete type
12 | struct bpf_spin_lock lock;
| ^~~~
make[2]: *** [scripts/Makefile.host:109: samples/bpf/hbm.o] Error 1
make[1]: *** [Makefile:1763: samples/bpf/] Error 2
Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
samples/bpf/hbm.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/samples/bpf/hbm.c b/samples/bpf/hbm.c
index a79828ab273f..ca8e567b63c3 100644
--- a/samples/bpf/hbm.c
+++ b/samples/bpf/hbm.c
@@ -40,17 +40,22 @@
#include <fcntl.h>
#include <linux/unistd.h>
-#include <linux/bpf.h>
#include <bpf/bpf.h>
+#include <linux/bpf.h>
#include "bpf_load.h"
#include "bpf_rlimit.h"
#include "cgroup_helpers.h"
-#include "hbm.h"
#include "bpf_util.h"
#include "bpf/bpf.h"
#include "bpf/libbpf.h"
+struct bpf_spin_lock {
+ __u32 val;
+};
+
+#include "hbm.h"
+
bool outFlag = true;
int minRate = 1000; /* cgroup rate limit in Mbps */
int rate = 1000; /* can grow if rate conserving is enabled */
--
2.21.0
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/5] libbpf: add missing typedef
2019-05-18 0:46 ` [PATCH 2/5] libbpf: add missing typedef Matteo Croce
@ 2019-05-20 16:53 ` Stanislav Fomichev
2019-05-20 17:43 ` Matteo Croce
0 siblings, 1 reply; 15+ messages in thread
From: Stanislav Fomichev @ 2019-05-20 16:53 UTC (permalink / raw)
To: Matteo Croce
Cc: xdp-newbies, bpf, linux-kernel, netdev, Alexei Starovoitov,
Daniel Borkmann
On 05/18, Matteo Croce wrote:
> Sync tools/include/linux/types.h with the UAPI one to fix this build error:
>
> make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
> HOSTCC samples/bpf/sock_example
> In file included from samples/bpf/sock_example.c:27:
> /usr/include/linux/ip.h:102:2: error: unknown type name ‘__sum16’
> 102 | __sum16 check;
> | ^~~~~~~
> make[2]: *** [scripts/Makefile.host:92: samples/bpf/sock_example] Error 1
> make[1]: *** [Makefile:1763: samples/bpf/] Error 2
>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
> ---
> tools/include/linux/types.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
> index 154eb4e3ca7c..5266dbfee945 100644
> --- a/tools/include/linux/types.h
> +++ b/tools/include/linux/types.h
> @@ -58,6 +58,9 @@ typedef __u32 __bitwise __be32;
> typedef __u64 __bitwise __le64;
> typedef __u64 __bitwise __be64;
>
> +typedef __u16 __bitwise __sum16;
> +typedef __u32 __bitwise __wsum;
If you do that, you should probably remove 'typedef __u16 __sum16;'
from test_progs.h:
https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/tree/tools/testing/selftests/bpf/test_progs.h#n13
> +
> typedef struct {
> int counter;
> } atomic_t;
> --
> 2.21.0
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/5] libbpf: add missing typedef
2019-05-20 16:53 ` Stanislav Fomichev
@ 2019-05-20 17:43 ` Matteo Croce
2019-05-20 18:25 ` Stanislav Fomichev
0 siblings, 1 reply; 15+ messages in thread
From: Matteo Croce @ 2019-05-20 17:43 UTC (permalink / raw)
To: Stanislav Fomichev
Cc: xdp-newbies, bpf, LKML, netdev, Alexei Starovoitov, Daniel Borkmann
On Mon, May 20, 2019 at 6:53 PM Stanislav Fomichev <sdf@fomichev.me> wrote:
>
> On 05/18, Matteo Croce wrote:
> > Sync tools/include/linux/types.h with the UAPI one to fix this build error:
> >
> > make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
> > HOSTCC samples/bpf/sock_example
> > In file included from samples/bpf/sock_example.c:27:
> > /usr/include/linux/ip.h:102:2: error: unknown type name ‘__sum16’
> > 102 | __sum16 check;
> > | ^~~~~~~
> > make[2]: *** [scripts/Makefile.host:92: samples/bpf/sock_example] Error 1
> > make[1]: *** [Makefile:1763: samples/bpf/] Error 2
> >
> > Signed-off-by: Matteo Croce <mcroce@redhat.com>
> > ---
> > tools/include/linux/types.h | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
> > index 154eb4e3ca7c..5266dbfee945 100644
> > --- a/tools/include/linux/types.h
> > +++ b/tools/include/linux/types.h
> > @@ -58,6 +58,9 @@ typedef __u32 __bitwise __be32;
> > typedef __u64 __bitwise __le64;
> > typedef __u64 __bitwise __be64;
> >
> > +typedef __u16 __bitwise __sum16;
> > +typedef __u32 __bitwise __wsum;
> If you do that, you should probably remove 'typedef __u16 __sum16;'
> from test_progs.h:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/tree/tools/testing/selftests/bpf/test_progs.h#n13
>
> > +
> > typedef struct {
> > int counter;
> > } atomic_t;
> > --
> > 2.21.0
> >
Hi,
I see test_progs.h only included in tools/testing/selftests/bpf/prog_tests/*,
so maybe it's unreladed to my change in samples/bpf/.
Maybe in a different patchset.
Bye,
--
Matteo Croce
per aspera ad upstream
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5] samples/bpf: fix test_lru_dist build
2019-05-18 0:46 [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
` (3 preceding siblings ...)
2019-05-18 0:46 ` [PATCH 5/5] samples/bpf: fix hbm " Matteo Croce
@ 2019-05-20 17:46 ` Matteo Croce
2019-05-20 20:38 ` Jakub Kicinski
4 siblings, 1 reply; 15+ messages in thread
From: Matteo Croce @ 2019-05-20 17:46 UTC (permalink / raw)
To: xdp-newbies, bpf; +Cc: LKML, netdev, Alexei Starovoitov, Daniel Borkmann
On Sat, May 18, 2019 at 2:46 AM Matteo Croce <mcroce@redhat.com> wrote:
>
> Fix the following error by removing a duplicate struct definition:
>
Hi all,
I forget to send a cover letter for this series, but basically what I
wanted to say is that while patches 1-3 are very straightforward,
patches 4-5 are a bit rough and I accept suggstions to make a cleaner
work.
Regards,
--
Matteo Croce
per aspera ad upstream
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/5] libbpf: add missing typedef
2019-05-20 17:43 ` Matteo Croce
@ 2019-05-20 18:25 ` Stanislav Fomichev
0 siblings, 0 replies; 15+ messages in thread
From: Stanislav Fomichev @ 2019-05-20 18:25 UTC (permalink / raw)
To: Matteo Croce
Cc: xdp-newbies, bpf, LKML, netdev, Alexei Starovoitov, Daniel Borkmann
On 05/20, Matteo Croce wrote:
> On Mon, May 20, 2019 at 6:53 PM Stanislav Fomichev <sdf@fomichev.me> wrote:
> >
> > On 05/18, Matteo Croce wrote:
> > > Sync tools/include/linux/types.h with the UAPI one to fix this build error:
> > >
> > > make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
> > > HOSTCC samples/bpf/sock_example
> > > In file included from samples/bpf/sock_example.c:27:
> > > /usr/include/linux/ip.h:102:2: error: unknown type name ‘__sum16’
> > > 102 | __sum16 check;
> > > | ^~~~~~~
> > > make[2]: *** [scripts/Makefile.host:92: samples/bpf/sock_example] Error 1
> > > make[1]: *** [Makefile:1763: samples/bpf/] Error 2
> > >
> > > Signed-off-by: Matteo Croce <mcroce@redhat.com>
> > > ---
> > > tools/include/linux/types.h | 3 +++
> > > 1 file changed, 3 insertions(+)
> > >
> > > diff --git a/tools/include/linux/types.h b/tools/include/linux/types.h
> > > index 154eb4e3ca7c..5266dbfee945 100644
> > > --- a/tools/include/linux/types.h
> > > +++ b/tools/include/linux/types.h
> > > @@ -58,6 +58,9 @@ typedef __u32 __bitwise __be32;
> > > typedef __u64 __bitwise __le64;
> > > typedef __u64 __bitwise __be64;
> > >
> > > +typedef __u16 __bitwise __sum16;
> > > +typedef __u32 __bitwise __wsum;
> > If you do that, you should probably remove 'typedef __u16 __sum16;'
> > from test_progs.h:
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/tree/tools/testing/selftests/bpf/test_progs.h#n13
> >
> > > +
> > > typedef struct {
> > > int counter;
> > > } atomic_t;
> > > --
> > > 2.21.0
> > >
>
> Hi,
>
> I see test_progs.h only included in tools/testing/selftests/bpf/prog_tests/*,
> so maybe it's unreladed to my change in samples/bpf/.
> Maybe in a different patchset.
Yes, I'm just saying that now that you have __sum16 defined in
tools/include/linux/types.h you can have another patch to remove
that custom __sum16 typedef from tests_progs.h
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5] samples/bpf: fix test_lru_dist build
2019-05-20 17:46 ` [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
@ 2019-05-20 20:38 ` Jakub Kicinski
2019-05-21 15:20 ` Daniel Borkmann
0 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2019-05-20 20:38 UTC (permalink / raw)
To: Matteo Croce
Cc: xdp-newbies, bpf, LKML, netdev, Alexei Starovoitov, Daniel Borkmann
On Mon, 20 May 2019 19:46:27 +0200, Matteo Croce wrote:
> On Sat, May 18, 2019 at 2:46 AM Matteo Croce <mcroce@redhat.com> wrote:
> >
> > Fix the following error by removing a duplicate struct definition:
> >
>
> Hi all,
>
> I forget to send a cover letter for this series, but basically what I
> wanted to say is that while patches 1-3 are very straightforward,
> patches 4-5 are a bit rough and I accept suggstions to make a cleaner
> work.
samples depend on headers being locally installed:
make headers_install
Are you intending to change that?
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5] samples/bpf: fix test_lru_dist build
2019-05-20 20:38 ` Jakub Kicinski
@ 2019-05-21 15:20 ` Daniel Borkmann
2019-05-21 15:36 ` Matteo Croce
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Borkmann @ 2019-05-21 15:20 UTC (permalink / raw)
To: Jakub Kicinski, Matteo Croce
Cc: xdp-newbies, bpf, LKML, netdev, Alexei Starovoitov
On 05/20/2019 10:38 PM, Jakub Kicinski wrote:
> On Mon, 20 May 2019 19:46:27 +0200, Matteo Croce wrote:
>> On Sat, May 18, 2019 at 2:46 AM Matteo Croce <mcroce@redhat.com> wrote:
>>>
>>> Fix the following error by removing a duplicate struct definition:
>>
>> Hi all,
>>
>> I forget to send a cover letter for this series, but basically what I
>> wanted to say is that while patches 1-3 are very straightforward,
>> patches 4-5 are a bit rough and I accept suggstions to make a cleaner
>> work.
>
> samples depend on headers being locally installed:
>
> make headers_install
>
> Are you intending to change that?
+1, Matteo, could you elaborate?
On latest bpf tree, everything compiles just fine:
[root@linux bpf]# make headers_install
[root@linux bpf]# make -C samples/bpf/
make: Entering directory '/home/darkstar/trees/bpf/samples/bpf'
make -C ../../ /home/darkstar/trees/bpf/samples/bpf/ BPF_SAMPLES_PATH=/home/darkstar/trees/bpf/samples/bpf
make[1]: Entering directory '/home/darkstar/trees/bpf'
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
make -C /home/darkstar/trees/bpf/samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=/home/darkstar/trees/bpf/samples/bpf/../../ O=
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_lru_dist
HOSTCC /home/darkstar/trees/bpf/samples/bpf/sock_example
HOSTCC /home/darkstar/trees/bpf/samples/bpf/fds_example.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/fds_example
HOSTCC /home/darkstar/trees/bpf/samples/bpf/sockex1_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/sockex1
HOSTCC /home/darkstar/trees/bpf/samples/bpf/sockex2_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/sockex2
HOSTCC /home/darkstar/trees/bpf/samples/bpf/bpf_load.o
HOSTCC /home/darkstar/trees/bpf/samples/bpf/sockex3_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/sockex3
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tracex1_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tracex1
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tracex2_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tracex2
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tracex3_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tracex3
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tracex4_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tracex4
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tracex5_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tracex5
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tracex6_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tracex6
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tracex7_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tracex7
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_probe_write_user_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_probe_write_user
HOSTCC /home/darkstar/trees/bpf/samples/bpf/trace_output_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/trace_output
HOSTCC /home/darkstar/trees/bpf/samples/bpf/lathist_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/lathist
HOSTCC /home/darkstar/trees/bpf/samples/bpf/offwaketime_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/offwaketime
HOSTCC /home/darkstar/trees/bpf/samples/bpf/spintest_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/spintest
HOSTCC /home/darkstar/trees/bpf/samples/bpf/map_perf_test_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/map_perf_test
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_overhead_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_overhead
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_array_pin.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_array_pin
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_attach.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_attach
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_attach2.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_attach2
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_sock.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_sock
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_sock2.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_sock2
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp1_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp1
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp2
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_router_ipv4_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_router_ipv4
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_current_task_under_cgroup_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_current_task_under_cgroup
HOSTCC /home/darkstar/trees/bpf/samples/bpf/trace_event_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/trace_event
HOSTCC /home/darkstar/trees/bpf/samples/bpf/sampleip_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/sampleip
HOSTCC /home/darkstar/trees/bpf/samples/bpf/tc_l2_redirect_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/tc_l2_redirect
HOSTCC /home/darkstar/trees/bpf/samples/bpf/lwt_len_hist_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/lwt_len_hist
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_tx_iptunnel_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_tx_iptunnel
HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_map_in_map_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/test_map_in_map
HOSTCC /home/darkstar/trees/bpf/samples/bpf/cookie_uid_helper_example.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/per_socket_stats_example
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_redirect
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_map_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_map
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_cpu_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_cpu
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_monitor_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_monitor
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_rxq_info_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_rxq_info
HOSTCC /home/darkstar/trees/bpf/samples/bpf/syscall_tp_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/syscall_tp
HOSTCC /home/darkstar/trees/bpf/samples/bpf/cpustat_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/cpustat
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_adjust_tail_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_adjust_tail
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdpsock_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdpsock
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_fwd_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_fwd
HOSTCC /home/darkstar/trees/bpf/samples/bpf/task_fd_query_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/task_fd_query
HOSTCC /home/darkstar/trees/bpf/samples/bpf/xdp_sample_pkts_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/xdp_sample_pkts
HOSTCC /home/darkstar/trees/bpf/samples/bpf/ibumad_user.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/ibumad
HOSTCC /home/darkstar/trees/bpf/samples/bpf/hbm.o
HOSTLD /home/darkstar/trees/bpf/samples/bpf/hbm
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/sockex1_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/sockex1_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/sockex2_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/sockex2_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/sockex3_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/sockex3_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tracex1_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tracex1_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tracex2_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tracex2_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tracex3_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tracex3_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tracex4_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tracex4_kern.o
CC /home/darkstar/trees/bpf/samples/bpf/syscall_nrs.s
UPD /home/darkstar/trees/bpf/samples/bpf/syscall_nrs.h
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tracex5_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tracex5_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tracex6_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tracex6_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tracex7_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tracex7_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/sock_flags_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/sock_flags_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/test_probe_write_user_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/test_probe_write_user_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/trace_output_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/trace_output_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcbpf1_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcbpf1_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tc_l2_redirect_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tc_l2_redirect_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/lathist_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/lathist_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/offwaketime_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/offwaketime_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/spintest_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/spintest_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/map_perf_test_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/map_perf_test_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/test_overhead_tp_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/test_overhead_tp_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/test_overhead_raw_tp_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/test_overhead_raw_tp_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/test_overhead_kprobe_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/test_overhead_kprobe_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/parse_varlen.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/parse_varlen.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/parse_simple.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/parse_simple.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/parse_ldabs.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/parse_ldabs.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_tc_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/test_cgrp2_tc_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp1_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp1_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp2_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp2_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_router_ipv4_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_router_ipv4_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/test_current_task_under_cgroup_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/test_current_task_under_cgroup_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/trace_event_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/trace_event_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/sampleip_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/sampleip_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/lwt_len_hist_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/lwt_len_hist_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_tx_iptunnel_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_tx_iptunnel_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/test_map_in_map_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/test_map_in_map_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_synrto_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_synrto_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_rwnd_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_rwnd_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_bufs_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_bufs_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_cong_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_cong_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_iw_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_iw_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_clamp_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_clamp_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_basertt_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_basertt_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/tcp_tos_reflect_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/tcp_tos_reflect_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_map_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_map_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_cpu_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_redirect_cpu_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_monitor_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_monitor_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_rxq_info_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_rxq_info_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp2skb_meta_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp2skb_meta_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/syscall_tp_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/syscall_tp_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/cpustat_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/cpustat_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_adjust_tail_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_adjust_tail_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_fwd_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_fwd_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/task_fd_query_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/task_fd_query_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/xdp_sample_pkts_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/xdp_sample_pkts_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/ibumad_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/ibumad_kern.o
CLANG-bpf /home/darkstar/trees/bpf/samples/bpf/hbm_out_kern.o
pahole -J /home/darkstar/trees/bpf/samples/bpf/hbm_out_kern.o
make[1]: Leaving directory '/home/darkstar/trees/bpf'
make: Leaving directory '/home/darkstar/trees/bpf/samples/bpf'
[root@linux bpf]#
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 4/5] samples/bpf: fix tracex5_user build error
2019-05-18 0:46 ` [PATCH 4/5] samples/bpf: fix tracex5_user " Matteo Croce
@ 2019-05-21 15:22 ` Daniel Borkmann
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Borkmann @ 2019-05-21 15:22 UTC (permalink / raw)
To: Matteo Croce, xdp-newbies, bpf; +Cc: linux-kernel, netdev, Alexei Starovoitov
On 05/18/2019 02:46 AM, Matteo Croce wrote:
> Add missing symbols to tools/include/linux/filter.h to fix a build failure:
>
> make -C samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=samples/bpf/../../ O=
> HOSTCC samples/bpf/tracex5_user.o
> samples/bpf/tracex5_user.c: In function ‘install_accept_all_seccomp’:
> samples/bpf/tracex5_user.c:17:21: error: array type has incomplete element type ‘struct sock_filter’
> 17 | struct sock_filter filter[] = {
> | ^~~~~~
> samples/bpf/tracex5_user.c:18:3: warning: implicit declaration of function ‘BPF_STMT’; did you mean ‘BPF_STX’? [-Wimplicit-function-declaration]
> 18 | BPF_STMT(BPF_RET+BPF_K, SECCOMP_RET_ALLOW),
> | ^~~~~~~~
> | BPF_STX
> samples/bpf/tracex5_user.c:20:9: error: variable ‘prog’ has initializer but incomplete type
> 20 | struct sock_fprog prog = {
> | ^~~~~~~~~~
> samples/bpf/tracex5_user.c:21:4: error: ‘struct sock_fprog’ has no member named ‘len’
> 21 | .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
> | ^~~
> samples/bpf/tracex5_user.c:21:10: warning: excess elements in struct initializer
> 21 | .len = (unsigned short)(sizeof(filter)/sizeof(filter[0])),
> | ^
> samples/bpf/tracex5_user.c:21:10: note: (near initialization for ‘prog’)
> samples/bpf/tracex5_user.c:22:4: error: ‘struct sock_fprog’ has no member named ‘filter’
> 22 | .filter = filter,
> | ^~~~~~
> samples/bpf/tracex5_user.c:22:13: warning: excess elements in struct initializer
> 22 | .filter = filter,
> | ^~~~~~
> samples/bpf/tracex5_user.c:22:13: note: (near initialization for ‘prog’)
> samples/bpf/tracex5_user.c:20:20: error: storage size of ‘prog’ isn’t known
> 20 | struct sock_fprog prog = {
> | ^~~~
> samples/bpf/tracex5_user.c:20:20: warning: unused variable ‘prog’ [-Wunused-variable]
> samples/bpf/tracex5_user.c:17:21: warning: unused variable ‘filter’ [-Wunused-variable]
> 17 | struct sock_filter filter[] = {
> | ^~~~~~
> make[2]: *** [scripts/Makefile.host:109: samples/bpf/tracex5_user.o] Error 1
> make[1]: *** [Makefile:1763: samples/bpf/] Error 2
>
> Signed-off-by: Matteo Croce <mcroce@redhat.com>
> ---
> tools/include/linux/filter.h | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/tools/include/linux/filter.h b/tools/include/linux/filter.h
> index ca28b6ab8db7..6b2ed7eccfa5 100644
> --- a/tools/include/linux/filter.h
> +++ b/tools/include/linux/filter.h
> @@ -7,6 +7,33 @@
>
> #include <linux/bpf.h>
This here is also mixing UAPI code below into non-UAPI headers in
tooling infrastructure ..
> +/*
> + * Try and keep these values and structures similar to BSD, especially
> + * the BPF code definitions which need to match so you can share filters
> + */
> +
> +struct sock_filter { /* Filter block */
> + __u16 code; /* Actual filter code */
> + __u8 jt; /* Jump true */
> + __u8 jf; /* Jump false */
> + __u32 k; /* Generic multiuse field */
> +};
> +
> +struct sock_fprog { /* Required for SO_ATTACH_FILTER. */
> + unsigned short len; /* Number of filter blocks */
> + struct sock_filter __user *filter;
> +};
> +
> +/*
> + * Macros for filter block array initializers.
> + */
> +#ifndef BPF_STMT
> +#define BPF_STMT(code, k) { (unsigned short)(code), 0, 0, k }
> +#endif
> +#ifndef BPF_JUMP
> +#define BPF_JUMP(code, k, jt, jf) { (unsigned short)(code), jt, jf, k }
> +#endif
> +
> /* ArgX, context and stack frame pointer register positions. Note,
> * Arg1, Arg2, Arg3, etc are used as argument mappings of function
> * calls in BPF_CALL instruction.
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5] samples/bpf: fix test_lru_dist build
2019-05-21 15:20 ` Daniel Borkmann
@ 2019-05-21 15:36 ` Matteo Croce
2019-05-21 17:06 ` Jakub Kicinski
0 siblings, 1 reply; 15+ messages in thread
From: Matteo Croce @ 2019-05-21 15:36 UTC (permalink / raw)
To: Daniel Borkmann
Cc: Jakub Kicinski, xdp-newbies, bpf, LKML, netdev, Alexei Starovoitov
On Tue, May 21, 2019 at 5:21 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
>
> On 05/20/2019 10:38 PM, Jakub Kicinski wrote:
> > On Mon, 20 May 2019 19:46:27 +0200, Matteo Croce wrote:
> >> On Sat, May 18, 2019 at 2:46 AM Matteo Croce <mcroce@redhat.com> wrote:
> >>>
> >>> Fix the following error by removing a duplicate struct definition:
> >>
> >> Hi all,
> >>
> >> I forget to send a cover letter for this series, but basically what I
> >> wanted to say is that while patches 1-3 are very straightforward,
> >> patches 4-5 are a bit rough and I accept suggstions to make a cleaner
> >> work.
> >
> > samples depend on headers being locally installed:
> >
> > make headers_install
> >
> > Are you intending to change that?
>
> +1, Matteo, could you elaborate?
>
> On latest bpf tree, everything compiles just fine:
>
> [root@linux bpf]# make headers_install
> [root@linux bpf]# make -C samples/bpf/
> make: Entering directory '/home/darkstar/trees/bpf/samples/bpf'
> make -C ../../ /home/darkstar/trees/bpf/samples/bpf/ BPF_SAMPLES_PATH=/home/darkstar/trees/bpf/samples/bpf
> make[1]: Entering directory '/home/darkstar/trees/bpf'
> CALL scripts/checksyscalls.sh
> CALL scripts/atomic/check-atomics.sh
> DESCEND objtool
> make -C /home/darkstar/trees/bpf/samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=/home/darkstar/trees/bpf/samples/bpf/../../ O=
> HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_lru_dist
> HOSTCC /home/darkstar/trees/bpf/samples/bpf/sock_example
>
Hi all,
I have kernel-headers installed from master, but yet the samples fail to build:
matteo@turbo:~/src/linux/samples/bpf$ rpm -q kernel-headers
kernel-headers-5.2.0_rc1-38.x86_64
matteo@turbo:~/src/linux/samples/bpf$ git describe HEAD
v5.2-rc1-97-g5bdd9ad875b6
matteo@turbo:~/src/linux/samples/bpf$ make
make -C ../../ /home/matteo/src/linux/samples/bpf/
BPF_SAMPLES_PATH=/home/matteo/src/linux/samples/bpf
make[1]: Entering directory '/home/matteo/src/linux'
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
make -C /home/matteo/src/linux/samples/bpf/../../tools/lib/bpf/ RM='rm
-rf' LDFLAGS= srctree=/home/matteo/src/linux/samples/bpf/../../ O=
HOSTCC /home/matteo/src/linux/samples/bpf/test_lru_dist
/home/matteo/src/linux/samples/bpf/test_lru_dist.c:39:8: error:
redefinition of ‘struct list_head’
39 | struct list_head {
| ^~~~~~~~~
In file included from /home/matteo/src/linux/samples/bpf/test_lru_dist.c:9:
./tools/include/linux/types.h:69:8: note: originally defined here
69 | struct list_head {
| ^~~~~~~~~
make[2]: *** [scripts/Makefile.host:90:
/home/matteo/src/linux/samples/bpf/test_lru_dist] Error 1
make[1]: *** [Makefile:1762: /home/matteo/src/linux/samples/bpf/] Error 2
make[1]: Leaving directory '/home/matteo/src/linux'
make: *** [Makefile:231: all] Error 2
Am I missing something obvious?
Regards,
--
Matteo Croce
per aspera ad upstream
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5] samples/bpf: fix test_lru_dist build
2019-05-21 15:36 ` Matteo Croce
@ 2019-05-21 17:06 ` Jakub Kicinski
2019-05-21 23:32 ` Matteo Croce
0 siblings, 1 reply; 15+ messages in thread
From: Jakub Kicinski @ 2019-05-21 17:06 UTC (permalink / raw)
To: Matteo Croce
Cc: Daniel Borkmann, xdp-newbies, bpf, LKML, netdev, Alexei Starovoitov
On Tue, 21 May 2019 17:36:17 +0200, Matteo Croce wrote:
> On Tue, May 21, 2019 at 5:21 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
> >
> > On 05/20/2019 10:38 PM, Jakub Kicinski wrote:
> > > On Mon, 20 May 2019 19:46:27 +0200, Matteo Croce wrote:
> > >> On Sat, May 18, 2019 at 2:46 AM Matteo Croce <mcroce@redhat.com> wrote:
> > >>>
> > >>> Fix the following error by removing a duplicate struct definition:
> > >>
> > >> Hi all,
> > >>
> > >> I forget to send a cover letter for this series, but basically what I
> > >> wanted to say is that while patches 1-3 are very straightforward,
> > >> patches 4-5 are a bit rough and I accept suggstions to make a cleaner
> > >> work.
> > >
> > > samples depend on headers being locally installed:
> > >
> > > make headers_install
> > >
> > > Are you intending to change that?
> >
> > +1, Matteo, could you elaborate?
> >
> > On latest bpf tree, everything compiles just fine:
> >
> > [root@linux bpf]# make headers_install
> > [root@linux bpf]# make -C samples/bpf/
> > make: Entering directory '/home/darkstar/trees/bpf/samples/bpf'
> > make -C ../../ /home/darkstar/trees/bpf/samples/bpf/ BPF_SAMPLES_PATH=/home/darkstar/trees/bpf/samples/bpf
> > make[1]: Entering directory '/home/darkstar/trees/bpf'
> > CALL scripts/checksyscalls.sh
> > CALL scripts/atomic/check-atomics.sh
> > DESCEND objtool
> > make -C /home/darkstar/trees/bpf/samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=/home/darkstar/trees/bpf/samples/bpf/../../ O=
> > HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_lru_dist
> > HOSTCC /home/darkstar/trees/bpf/samples/bpf/sock_example
> >
>
> Hi all,
>
> I have kernel-headers installed from master, but yet the samples fail to build:
>
> matteo@turbo:~/src/linux/samples/bpf$ rpm -q kernel-headers
> kernel-headers-5.2.0_rc1-38.x86_64
>
> matteo@turbo:~/src/linux/samples/bpf$ git describe HEAD
> v5.2-rc1-97-g5bdd9ad875b6
>
> matteo@turbo:~/src/linux/samples/bpf$ make
> make -C ../../ /home/matteo/src/linux/samples/bpf/
> BPF_SAMPLES_PATH=/home/matteo/src/linux/samples/bpf
> make[1]: Entering directory '/home/matteo/src/linux'
> CALL scripts/checksyscalls.sh
> CALL scripts/atomic/check-atomics.sh
> DESCEND objtool
> make -C /home/matteo/src/linux/samples/bpf/../../tools/lib/bpf/ RM='rm
> -rf' LDFLAGS= srctree=/home/matteo/src/linux/samples/bpf/../../ O=
> HOSTCC /home/matteo/src/linux/samples/bpf/test_lru_dist
> /home/matteo/src/linux/samples/bpf/test_lru_dist.c:39:8: error:
> redefinition of ‘struct list_head’
> 39 | struct list_head {
> | ^~~~~~~~~
> In file included from /home/matteo/src/linux/samples/bpf/test_lru_dist.c:9:
> ./tools/include/linux/types.h:69:8: note: originally defined here
> 69 | struct list_head {
> | ^~~~~~~~~
> make[2]: *** [scripts/Makefile.host:90:
> /home/matteo/src/linux/samples/bpf/test_lru_dist] Error 1
> make[1]: *** [Makefile:1762: /home/matteo/src/linux/samples/bpf/] Error 2
> make[1]: Leaving directory '/home/matteo/src/linux'
> make: *** [Makefile:231: all] Error 2
>
> Am I missing something obvious?
Yes ;) Samples use a local installation of headers in $objtree/usr (I
think, maybe $srctree/usr). So you need to do make headers_install in
your kernel source tree, otherwise the include path from tools/ takes
priority over your global /usr/include and causes these issues. I had
this path in my tree for some time, but I don't like enough to post it:
commit 35fb614049e93d46af708c0eaae6601df54017b3
Author: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Mon Dec 3 15:00:24 2018 -0800
bpf: maybe warn ppl about hrds_install
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 4f0a1cdbfe7c..f79a4ed2f9f7 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -208,6 +208,15 @@ HOSTCC = $(CROSS_COMPILE)gcc
CLANG_ARCH_ARGS = -target $(ARCH)
endif
+HDR_PROBE := $(shell echo "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \
+ gcc $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \
+ echo okay)
+
+ifeq ($(HDR_PROBE),)
+$(warning Detected possible issues with include path.)
+$(warning Please install kernel headers locally (make headers_install))
+endif
+
BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5] samples/bpf: fix test_lru_dist build
2019-05-21 17:06 ` Jakub Kicinski
@ 2019-05-21 23:32 ` Matteo Croce
0 siblings, 0 replies; 15+ messages in thread
From: Matteo Croce @ 2019-05-21 23:32 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Daniel Borkmann, xdp-newbies, bpf, LKML, netdev, Alexei Starovoitov
On Tue, May 21, 2019 at 7:07 PM Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:
>
> On Tue, 21 May 2019 17:36:17 +0200, Matteo Croce wrote:
> > On Tue, May 21, 2019 at 5:21 PM Daniel Borkmann <daniel@iogearbox.net> wrote:
> > >
> > > On 05/20/2019 10:38 PM, Jakub Kicinski wrote:
> > > > On Mon, 20 May 2019 19:46:27 +0200, Matteo Croce wrote:
> > > >> On Sat, May 18, 2019 at 2:46 AM Matteo Croce <mcroce@redhat.com> wrote:
> > > >>>
> > > >>> Fix the following error by removing a duplicate struct definition:
> > > >>
> > > >> Hi all,
> > > >>
> > > >> I forget to send a cover letter for this series, but basically what I
> > > >> wanted to say is that while patches 1-3 are very straightforward,
> > > >> patches 4-5 are a bit rough and I accept suggstions to make a cleaner
> > > >> work.
> > > >
> > > > samples depend on headers being locally installed:
> > > >
> > > > make headers_install
> > > >
> > > > Are you intending to change that?
> > >
> > > +1, Matteo, could you elaborate?
> > >
> > > On latest bpf tree, everything compiles just fine:
> > >
> > > [root@linux bpf]# make headers_install
> > > [root@linux bpf]# make -C samples/bpf/
> > > make: Entering directory '/home/darkstar/trees/bpf/samples/bpf'
> > > make -C ../../ /home/darkstar/trees/bpf/samples/bpf/ BPF_SAMPLES_PATH=/home/darkstar/trees/bpf/samples/bpf
> > > make[1]: Entering directory '/home/darkstar/trees/bpf'
> > > CALL scripts/checksyscalls.sh
> > > CALL scripts/atomic/check-atomics.sh
> > > DESCEND objtool
> > > make -C /home/darkstar/trees/bpf/samples/bpf/../../tools/lib/bpf/ RM='rm -rf' LDFLAGS= srctree=/home/darkstar/trees/bpf/samples/bpf/../../ O=
> > > HOSTCC /home/darkstar/trees/bpf/samples/bpf/test_lru_dist
> > > HOSTCC /home/darkstar/trees/bpf/samples/bpf/sock_example
> > >
> >
> > Hi all,
> >
> > I have kernel-headers installed from master, but yet the samples fail to build:
> >
> > matteo@turbo:~/src/linux/samples/bpf$ rpm -q kernel-headers
> > kernel-headers-5.2.0_rc1-38.x86_64
> >
> > matteo@turbo:~/src/linux/samples/bpf$ git describe HEAD
> > v5.2-rc1-97-g5bdd9ad875b6
> >
> > matteo@turbo:~/src/linux/samples/bpf$ make
> > make -C ../../ /home/matteo/src/linux/samples/bpf/
> > BPF_SAMPLES_PATH=/home/matteo/src/linux/samples/bpf
> > make[1]: Entering directory '/home/matteo/src/linux'
> > CALL scripts/checksyscalls.sh
> > CALL scripts/atomic/check-atomics.sh
> > DESCEND objtool
> > make -C /home/matteo/src/linux/samples/bpf/../../tools/lib/bpf/ RM='rm
> > -rf' LDFLAGS= srctree=/home/matteo/src/linux/samples/bpf/../../ O=
> > HOSTCC /home/matteo/src/linux/samples/bpf/test_lru_dist
> > /home/matteo/src/linux/samples/bpf/test_lru_dist.c:39:8: error:
> > redefinition of ‘struct list_head’
> > 39 | struct list_head {
> > | ^~~~~~~~~
> > In file included from /home/matteo/src/linux/samples/bpf/test_lru_dist.c:9:
> > ./tools/include/linux/types.h:69:8: note: originally defined here
> > 69 | struct list_head {
> > | ^~~~~~~~~
> > make[2]: *** [scripts/Makefile.host:90:
> > /home/matteo/src/linux/samples/bpf/test_lru_dist] Error 1
> > make[1]: *** [Makefile:1762: /home/matteo/src/linux/samples/bpf/] Error 2
> > make[1]: Leaving directory '/home/matteo/src/linux'
> > make: *** [Makefile:231: all] Error 2
> >
> > Am I missing something obvious?
>
> Yes ;) Samples use a local installation of headers in $objtree/usr (I
> think, maybe $srctree/usr). So you need to do make headers_install in
> your kernel source tree, otherwise the include path from tools/ takes
> priority over your global /usr/include and causes these issues. I had
> this path in my tree for some time, but I don't like enough to post it:
>
> commit 35fb614049e93d46af708c0eaae6601df54017b3
> Author: Jakub Kicinski <jakub.kicinski@netronome.com>
> Date: Mon Dec 3 15:00:24 2018 -0800
>
> bpf: maybe warn ppl about hrds_install
>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>
> diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
> index 4f0a1cdbfe7c..f79a4ed2f9f7 100644
> --- a/samples/bpf/Makefile
> +++ b/samples/bpf/Makefile
> @@ -208,6 +208,15 @@ HOSTCC = $(CROSS_COMPILE)gcc
> CLANG_ARCH_ARGS = -target $(ARCH)
> endif
>
> +HDR_PROBE := $(shell echo "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \
> + gcc $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \
> + echo okay)
> +
> +ifeq ($(HDR_PROBE),)
> +$(warning Detected possible issues with include path.)
> +$(warning Please install kernel headers locally (make headers_install))
> +endif
> +
> BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
> BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
> BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
Hi Jakub,
I see now, It worked, thanks. This is a bit error prone IMHO, if you
ever think about sending this patch, consider it ACKed by me.
Thanks,
--
Matteo Croce
per aspera ad upstream
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2019-05-21 23:33 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-18 0:46 [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
2019-05-18 0:46 ` [PATCH 2/5] libbpf: add missing typedef Matteo Croce
2019-05-20 16:53 ` Stanislav Fomichev
2019-05-20 17:43 ` Matteo Croce
2019-05-20 18:25 ` Stanislav Fomichev
2019-05-18 0:46 ` [PATCH 3/5] samples/bpf: fix xdpsock_user build error Matteo Croce
2019-05-18 0:46 ` [PATCH 4/5] samples/bpf: fix tracex5_user " Matteo Croce
2019-05-21 15:22 ` Daniel Borkmann
2019-05-18 0:46 ` [PATCH 5/5] samples/bpf: fix hbm " Matteo Croce
2019-05-20 17:46 ` [PATCH 1/5] samples/bpf: fix test_lru_dist build Matteo Croce
2019-05-20 20:38 ` Jakub Kicinski
2019-05-21 15:20 ` Daniel Borkmann
2019-05-21 15:36 ` Matteo Croce
2019-05-21 17:06 ` Jakub Kicinski
2019-05-21 23:32 ` Matteo Croce
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).