From: Matteo Croce <mcroce@redhat.com>
To: xdp-newbies@vger.kernel.org, bpf@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH 4/5] samples/bpf: fix tracex5_user build error
Date: Sat, 18 May 2019 02:46:38 +0200 [thread overview]
Message-ID: <20190518004639.20648-4-mcroce@redhat.com> (raw)
In-Reply-To: <20190518004639.20648-1-mcroce@redhat.com>
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
next prev parent reply other threads:[~2019-05-18 0:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Matteo Croce [this message]
2019-05-21 15:22 ` [PATCH 4/5] samples/bpf: fix tracex5_user " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190518004639.20648-4-mcroce@redhat.com \
--to=mcroce@redhat.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=xdp-newbies@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®