* [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME
@ 2016-10-25 22:37 Daniel Borkmann
2016-10-26 1:17 ` Alexei Starovoitov
2016-10-29 18:46 ` David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Borkmann @ 2016-10-25 22:37 UTC (permalink / raw)
To: davem; +Cc: alexei.starovoitov, netdev, Daniel Borkmann
Some of the sample files are causing issues when they are loaded with tc
and cls_bpf, meaning tc bails out while trying to parse the resulting ELF
file as program/map/etc sections are not present, which can be easily
spotted with readelf(1).
Currently, BPF samples are including some of the kernel headers and mid
term we should change them to refrain from this, really. When dynamic
debugging is enabled, we bail out due to undeclared KBUILD_MODNAME, which
is easily overlooked in the build as clang spills this along with other
noisy warnings from various header includes, and llc still generates an
ELF file with mentioned characteristics. For just playing around with BPF
examples, this can be a bit of a hurdle to take.
Just add a fake KBUILD_MODNAME as a band-aid to fix the issue, same is
done in xdp*_kern samples already.
Fixes: 65d472fb007d ("samples/bpf: add 'pointer to packet' tests")
Fixes: 6afb1e28b859 ("samples/bpf: Add tunnel set/get tests.")
Fixes: a3f74617340b ("cgroup: bpf: Add an example to do cgroup checking in BPF")
Reported-by: Chandrasekar Kannan <ckannan@console.to>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
samples/bpf/parse_ldabs.c | 1 +
samples/bpf/parse_simple.c | 1 +
samples/bpf/parse_varlen.c | 1 +
samples/bpf/tcbpf1_kern.c | 1 +
samples/bpf/tcbpf2_kern.c | 1 +
samples/bpf/test_cgrp2_tc_kern.c | 1 +
6 files changed, 6 insertions(+)
diff --git a/samples/bpf/parse_ldabs.c b/samples/bpf/parse_ldabs.c
index d175501..6db6b21 100644
--- a/samples/bpf/parse_ldabs.c
+++ b/samples/bpf/parse_ldabs.c
@@ -4,6 +4,7 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
+#define KBUILD_MODNAME "foo"
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/in.h>
diff --git a/samples/bpf/parse_simple.c b/samples/bpf/parse_simple.c
index cf2511c..10af53d 100644
--- a/samples/bpf/parse_simple.c
+++ b/samples/bpf/parse_simple.c
@@ -4,6 +4,7 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
+#define KBUILD_MODNAME "foo"
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/in.h>
diff --git a/samples/bpf/parse_varlen.c b/samples/bpf/parse_varlen.c
index edab34d..95c1632 100644
--- a/samples/bpf/parse_varlen.c
+++ b/samples/bpf/parse_varlen.c
@@ -4,6 +4,7 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
+#define KBUILD_MODNAME "foo"
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
diff --git a/samples/bpf/tcbpf1_kern.c b/samples/bpf/tcbpf1_kern.c
index fa051b3..274c884 100644
--- a/samples/bpf/tcbpf1_kern.c
+++ b/samples/bpf/tcbpf1_kern.c
@@ -1,3 +1,4 @@
+#define KBUILD_MODNAME "foo"
#include <uapi/linux/bpf.h>
#include <uapi/linux/if_ether.h>
#include <uapi/linux/if_packet.h>
diff --git a/samples/bpf/tcbpf2_kern.c b/samples/bpf/tcbpf2_kern.c
index 3303bb8..9c823a6 100644
--- a/samples/bpf/tcbpf2_kern.c
+++ b/samples/bpf/tcbpf2_kern.c
@@ -5,6 +5,7 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
+#define KBUILD_MODNAME "foo"
#include <uapi/linux/bpf.h>
#include <uapi/linux/if_ether.h>
#include <uapi/linux/if_packet.h>
diff --git a/samples/bpf/test_cgrp2_tc_kern.c b/samples/bpf/test_cgrp2_tc_kern.c
index 10ff734..1547b36 100644
--- a/samples/bpf/test_cgrp2_tc_kern.c
+++ b/samples/bpf/test_cgrp2_tc_kern.c
@@ -4,6 +4,7 @@
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
+#define KBUILD_MODNAME "foo"
#include <uapi/linux/if_ether.h>
#include <uapi/linux/in6.h>
#include <uapi/linux/ipv6.h>
--
1.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME
2016-10-25 22:37 [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME Daniel Borkmann
@ 2016-10-26 1:17 ` Alexei Starovoitov
2016-10-26 7:01 ` Daniel Borkmann
2016-10-29 18:46 ` David Miller
1 sibling, 1 reply; 5+ messages in thread
From: Alexei Starovoitov @ 2016-10-26 1:17 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: davem, netdev
On Wed, Oct 26, 2016 at 12:37:53AM +0200, Daniel Borkmann wrote:
> Some of the sample files are causing issues when they are loaded with tc
> and cls_bpf, meaning tc bails out while trying to parse the resulting ELF
> file as program/map/etc sections are not present, which can be easily
> spotted with readelf(1).
>
> Currently, BPF samples are including some of the kernel headers and mid
> term we should change them to refrain from this, really. When dynamic
> debugging is enabled, we bail out due to undeclared KBUILD_MODNAME, which
> is easily overlooked in the build as clang spills this along with other
> noisy warnings from various header includes, and llc still generates an
> ELF file with mentioned characteristics. For just playing around with BPF
> examples, this can be a bit of a hurdle to take.
>
> Just add a fake KBUILD_MODNAME as a band-aid to fix the issue, same is
> done in xdp*_kern samples already.
>
> Fixes: 65d472fb007d ("samples/bpf: add 'pointer to packet' tests")
> Fixes: 6afb1e28b859 ("samples/bpf: Add tunnel set/get tests.")
> Fixes: a3f74617340b ("cgroup: bpf: Add an example to do cgroup checking in BPF")
> Reported-by: Chandrasekar Kannan <ckannan@console.to>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
> samples/bpf/parse_ldabs.c | 1 +
> samples/bpf/parse_simple.c | 1 +
> samples/bpf/parse_varlen.c | 1 +
> samples/bpf/tcbpf1_kern.c | 1 +
> samples/bpf/tcbpf2_kern.c | 1 +
> samples/bpf/test_cgrp2_tc_kern.c | 1 +
> 6 files changed, 6 insertions(+)
It's also needed for all of tracex*_kern.c, right?
For networking samlpes we probably should get rid of kernel headers.
I guess they were there by copy-paste mistake from tracing, since
tracing samples actually need to include them, since they do bpf_probe_read
into kernel data structures.
For this patch in the mean time:
Acked-by: Alexei Starovoitov <ast@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME
2016-10-26 1:17 ` Alexei Starovoitov
@ 2016-10-26 7:01 ` Daniel Borkmann
2016-10-26 16:44 ` Alexei Starovoitov
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Borkmann @ 2016-10-26 7:01 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, netdev
[-- Attachment #1: Type: text/plain, Size: 1884 bytes --]
On 10/26/2016 03:17 AM, Alexei Starovoitov wrote:
> On Wed, Oct 26, 2016 at 12:37:53AM +0200, Daniel Borkmann wrote:
>> Some of the sample files are causing issues when they are loaded with tc
>> and cls_bpf, meaning tc bails out while trying to parse the resulting ELF
>> file as program/map/etc sections are not present, which can be easily
>> spotted with readelf(1).
>>
>> Currently, BPF samples are including some of the kernel headers and mid
>> term we should change them to refrain from this, really. When dynamic
>> debugging is enabled, we bail out due to undeclared KBUILD_MODNAME, which
>> is easily overlooked in the build as clang spills this along with other
>> noisy warnings from various header includes, and llc still generates an
>> ELF file with mentioned characteristics. For just playing around with BPF
>> examples, this can be a bit of a hurdle to take.
>>
>> Just add a fake KBUILD_MODNAME as a band-aid to fix the issue, same is
>> done in xdp*_kern samples already.
>>
>> Fixes: 65d472fb007d ("samples/bpf: add 'pointer to packet' tests")
>> Fixes: 6afb1e28b859 ("samples/bpf: Add tunnel set/get tests.")
>> Fixes: a3f74617340b ("cgroup: bpf: Add an example to do cgroup checking in BPF")
>> Reported-by: Chandrasekar Kannan <ckannan@console.to>
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>> ---
>> samples/bpf/parse_ldabs.c | 1 +
>> samples/bpf/parse_simple.c | 1 +
>> samples/bpf/parse_varlen.c | 1 +
>> samples/bpf/tcbpf1_kern.c | 1 +
>> samples/bpf/tcbpf2_kern.c | 1 +
>> samples/bpf/test_cgrp2_tc_kern.c | 1 +
>> 6 files changed, 6 insertions(+)
>
> It's also needed for all of tracex*_kern.c, right?
Rest compiles just fine for me and readelf output looks good on all
tracex*_kern.o, too.
I see just warnings coming from various kernel header inclusions (see
log), but no errors anymore.
[-- Attachment #2: log --]
[-- Type: text/plain, Size: 19109 bytes --]
/home/darkstar/net/samples/bpf/trace_output_user.c:64:6: warning: no previous prototype for ‘perf_event_read’ [-Wmissing-prototypes]
void perf_event_read(print_fn fn)
^
In file included from /home/darkstar/net/samples/bpf/sockex2_kern.c:8:
In file included from ./include/uapi/linux/if_tunnel.h:6:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/sockex2_kern.c:8:
In file included from ./include/uapi/linux/if_tunnel.h:6:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/sockex3_kern.c:14:
In file included from ./include/uapi/linux/if_tunnel.h:6:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/sockex3_kern.c:14:
In file included from ./include/uapi/linux/if_tunnel.h:6:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/tracex1_kern.c:7:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/tracex1_kern.c:7:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/tracex2_kern.c:7:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/tracex2_kern.c:7:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/tracex3_kern.c:7:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/tracex3_kern.c:7:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/tracex4_kern.c:7:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/tracex5_kern.c:7:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/tracex6_kern.c:1:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/test_probe_write_user_kern.c:7:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/test_probe_write_user_kern.c:7:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/trace_output_kern.c:1:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/tcbpf2_kern.c:18:
In file included from ./include/net/ipv6.h:16:
In file included from ./include/linux/ipv6.h:76:
In file included from ./include/linux/icmpv6.h:4:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/tcbpf2_kern.c:18:
In file included from ./include/net/ipv6.h:16:
In file included from ./include/linux/ipv6.h:76:
In file included from ./include/linux/icmpv6.h:4:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/lathist_kern.c:9:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/offwaketime_kern.c:12:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/spintest_kern.c:7:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/spintest_kern.c:7:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/map_perf_test_kern.c:7:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/map_perf_test_kern.c:7:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/test_overhead_kprobe_kern.c:8:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/parse_varlen.c:8:
In file included from ./include/linux/if_ether.h:23:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/parse_varlen.c:8:
In file included from ./include/linux/if_ether.h:23:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/parse_simple.c:8:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/parse_simple.c:8:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/parse_ldabs.c:8:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/parse_ldabs.c:8:
In file included from ./include/linux/ip.h:20:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/xdp1_kern.c:10:
In file included from ./include/linux/if_ether.h:23:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/xdp1_kern.c:10:
In file included from ./include/linux/if_ether.h:23:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/xdp2_kern.c:10:
In file included from ./include/linux/if_ether.h:23:
In file included from ./include/linux/skbuff.h:29:
In file included from ./include/linux/net.h:28:
./include/linux/fs.h:2693:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (id < 0 || id >= READING_MAX_ID)
~~ ^ ~
In file included from /home/darkstar/net/samples/bpf/xdp2_kern.c:10:
In file included from ./include/linux/if_ether.h:23:
In file included from ./include/linux/skbuff.h:30:
In file included from ./include/linux/textsearch.h:8:
In file included from ./include/linux/slab.h:118:
In file included from ./include/linux/kasan.h:4:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
2 warnings generated.
In file included from /home/darkstar/net/samples/bpf/test_current_task_under_cgroup_kern.c:8:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/trace_event_kern.c:7:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
In file included from /home/darkstar/net/samples/bpf/sampleip_kern.c:8:
In file included from ./include/linux/ptrace.h:5:
In file included from ./include/linux/sched.h:61:
./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
struct cgroup cgrp;
^
1 warning generated.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME
2016-10-26 7:01 ` Daniel Borkmann
@ 2016-10-26 16:44 ` Alexei Starovoitov
0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2016-10-26 16:44 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: davem, netdev
On Wed, Oct 26, 2016 at 09:01:48AM +0200, Daniel Borkmann wrote:
> On 10/26/2016 03:17 AM, Alexei Starovoitov wrote:
> >On Wed, Oct 26, 2016 at 12:37:53AM +0200, Daniel Borkmann wrote:
> >>Some of the sample files are causing issues when they are loaded with tc
> >>and cls_bpf, meaning tc bails out while trying to parse the resulting ELF
> >>file as program/map/etc sections are not present, which can be easily
> >>spotted with readelf(1).
> >>
> >>Currently, BPF samples are including some of the kernel headers and mid
> >>term we should change them to refrain from this, really. When dynamic
> >>debugging is enabled, we bail out due to undeclared KBUILD_MODNAME, which
> >>is easily overlooked in the build as clang spills this along with other
> >>noisy warnings from various header includes, and llc still generates an
> >>ELF file with mentioned characteristics. For just playing around with BPF
> >>examples, this can be a bit of a hurdle to take.
> >>
> >>Just add a fake KBUILD_MODNAME as a band-aid to fix the issue, same is
> >>done in xdp*_kern samples already.
> >>
> >>Fixes: 65d472fb007d ("samples/bpf: add 'pointer to packet' tests")
> >>Fixes: 6afb1e28b859 ("samples/bpf: Add tunnel set/get tests.")
> >>Fixes: a3f74617340b ("cgroup: bpf: Add an example to do cgroup checking in BPF")
> >>Reported-by: Chandrasekar Kannan <ckannan@console.to>
> >>Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> >>---
> >> samples/bpf/parse_ldabs.c | 1 +
> >> samples/bpf/parse_simple.c | 1 +
> >> samples/bpf/parse_varlen.c | 1 +
> >> samples/bpf/tcbpf1_kern.c | 1 +
> >> samples/bpf/tcbpf2_kern.c | 1 +
> >> samples/bpf/test_cgrp2_tc_kern.c | 1 +
> >> 6 files changed, 6 insertions(+)
> >
> >It's also needed for all of tracex*_kern.c, right?
>
> Rest compiles just fine for me and readelf output looks good on all
> tracex*_kern.o, too.
>
> I see just warnings coming from various kernel header inclusions (see
> log), but no errors anymore.
ahh. good to know. I guess networking examples include some header
with dynamic debug that tracing examples don't.
Thanks for checking.
> ./include/linux/cgroup-defs.h:322:16: warning: field 'cgrp' with variable sized type 'struct cgroup' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
> struct cgroup cgrp;
> ^
> 2 warnings generated.
this cgroup warning is crazy annoying and would have to be fixed anyway
for kernel to be compiled with clang.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME
2016-10-25 22:37 [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME Daniel Borkmann
2016-10-26 1:17 ` Alexei Starovoitov
@ 2016-10-29 18:46 ` David Miller
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2016-10-29 18:46 UTC (permalink / raw)
To: daniel; +Cc: alexei.starovoitov, netdev
From: Daniel Borkmann <daniel@iogearbox.net>
Date: Wed, 26 Oct 2016 00:37:53 +0200
> Some of the sample files are causing issues when they are loaded with tc
> and cls_bpf, meaning tc bails out while trying to parse the resulting ELF
> file as program/map/etc sections are not present, which can be easily
> spotted with readelf(1).
>
> Currently, BPF samples are including some of the kernel headers and mid
> term we should change them to refrain from this, really. When dynamic
> debugging is enabled, we bail out due to undeclared KBUILD_MODNAME, which
> is easily overlooked in the build as clang spills this along with other
> noisy warnings from various header includes, and llc still generates an
> ELF file with mentioned characteristics. For just playing around with BPF
> examples, this can be a bit of a hurdle to take.
>
> Just add a fake KBUILD_MODNAME as a band-aid to fix the issue, same is
> done in xdp*_kern samples already.
>
> Fixes: 65d472fb007d ("samples/bpf: add 'pointer to packet' tests")
> Fixes: 6afb1e28b859 ("samples/bpf: Add tunnel set/get tests.")
> Fixes: a3f74617340b ("cgroup: bpf: Add an example to do cgroup checking in BPF")
> Reported-by: Chandrasekar Kannan <ckannan@console.to>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-29 18:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-25 22:37 [PATCH net] bpf: fix samples to add fake KBUILD_MODNAME Daniel Borkmann
2016-10-26 1:17 ` Alexei Starovoitov
2016-10-26 7:01 ` Daniel Borkmann
2016-10-26 16:44 ` Alexei Starovoitov
2016-10-29 18:46 ` David Miller
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).