All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] tools/bpftool: copy uapi/linux/tc_act/tc_bpf.h to tools directory
@ 2018-11-08  1:00 Yonghong Song
  2018-11-08  1:15 ` Li Zhijian
  0 siblings, 1 reply; 3+ messages in thread
From: Yonghong Song @ 2018-11-08  1:00 UTC (permalink / raw)
  To: ast, kafai, daniel, netdev, rong.a.chen, zhijianx.li; +Cc: kernel-team

Commit f6f3bac08ff9 ("tools/bpf: bpftool: add net support")
added certain networking support to bpftool.
The implementation relies on a relatively recent uapi header file
linux/tc_act/tc_bpf.h on the host which contains the marco
definition of TCA_ACT_BPF_ID.

Unfortunately, this is not the case for all distributions.
See the email message below where rhel-7.2 does not have
an up-to-date linux/tc_act/tc_bpf.h.
  https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1799211.html

This patch fixed the issue by copying linux/tc_act/tc_bpf.h from
kernel include/uapi directory to tools/include/uapi directory so
building the bpftool does not depend on host system for this file.

Fixes: f6f3bac08ff9 ("tools/bpf: bpftool: add net support")
Reported-by: kernel test robot <rong.a.chen@intel.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
---
 tools/include/uapi/linux/tc_act/tc_bpf.h | 37 ++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 tools/include/uapi/linux/tc_act/tc_bpf.h

diff --git a/tools/include/uapi/linux/tc_act/tc_bpf.h b/tools/include/uapi/linux/tc_act/tc_bpf.h
new file mode 100644
index 000000000000..6e89a5df49a4
--- /dev/null
+++ b/tools/include/uapi/linux/tc_act/tc_bpf.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * Copyright (c) 2015 Jiri Pirko <jiri@resnulli.us>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __LINUX_TC_BPF_H
+#define __LINUX_TC_BPF_H
+
+#include <linux/pkt_cls.h>
+
+#define TCA_ACT_BPF 13
+
+struct tc_act_bpf {
+	tc_gen;
+};
+
+enum {
+	TCA_ACT_BPF_UNSPEC,
+	TCA_ACT_BPF_TM,
+	TCA_ACT_BPF_PARMS,
+	TCA_ACT_BPF_OPS_LEN,
+	TCA_ACT_BPF_OPS,
+	TCA_ACT_BPF_FD,
+	TCA_ACT_BPF_NAME,
+	TCA_ACT_BPF_PAD,
+	TCA_ACT_BPF_TAG,
+	TCA_ACT_BPF_ID,
+	__TCA_ACT_BPF_MAX,
+};
+#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)
+
+#endif
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] tools/bpftool: copy uapi/linux/tc_act/tc_bpf.h to tools directory
  2018-11-08  1:00 [PATCH bpf] tools/bpftool: copy uapi/linux/tc_act/tc_bpf.h to tools directory Yonghong Song
@ 2018-11-08  1:15 ` Li Zhijian
  2018-11-08  1:47   ` Yonghong Song
  0 siblings, 1 reply; 3+ messages in thread
From: Li Zhijian @ 2018-11-08  1:15 UTC (permalink / raw)
  To: Yonghong Song, ast, kafai, daniel, netdev, rong.a.chen; +Cc: kernel-team

On 11/8/2018 9:00 AM, Yonghong Song wrote:
> Commit f6f3bac08ff9 ("tools/bpf: bpftool: add net support")
> added certain networking support to bpftool.
> The implementation relies on a relatively recent uapi header file
> linux/tc_act/tc_bpf.h on the host which contains the marco
> definition of TCA_ACT_BPF_ID.
>
> Unfortunately, this is not the case for all distributions.
> See the email message below where rhel-7.2 does not have
> an up-to-date linux/tc_act/tc_bpf.h.
>    https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg1799211.html

i have not tested this patch, but basing on the early commit
6f3bac08ff9 ("tools/bpf: bpftool: add net support")
i cooked up similar patch locally, but i noticed that it also requires an
up-to-date linux/pkt_cls.h as well to avoid compiling errors:

root@lkp-bdw-ep3 ~/linux-f6f3bac08f/tools/bpf/bpftool# make V=1
[...snip...]
gcc -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ -I/root/linux-f6f3bac08f/kernel/bpf/ -I/root/linux-f6f3bac08f/tools/include -I/root/linux-f6f3bac08f/tools/include/uapi -I/root/linux-f6f3bac08f/tools/lib/bpf -I/root/linux-f6f3bac08f/tools/perf -DBPFTOOL_VERSION='"4.19.0-rc2"' -DCOMPAT_NEED_REALLOCARRAY   -c -MMD -o netlink_dumper.o netlink_dumper.c
make -C /root/linux-f6f3bac08f/tools/lib/bpf/ OUTPUT= libbpf.a
make[1]: Entering directory '/root/linux-f6f3bac08f/tools/lib/bpf'
netlink_dumper.c: In function 'do_bpf_filter_dump':
netlink_dumper.c:153:9: error: 'TCA_BPF_ID' undeclared (first use in this function)
   if (tb[TCA_BPF_ID])
          ^~~~~~~~~~
netlink_dumper.c:153:9: note: each undeclared identifier is reported only once for each function it appears in
netlink_dumper.c:155:9: error: 'TCA_BPF_TAG' undeclared (first use in this function)
   if (tb[TCA_BPF_TAG])
          ^~~~~~~~~~~
Makefile:96: recipe for target 'netlink_dumper.o' failed
make: *** [netlink_dumper.o] Error 1
make: *** Waiting for unfinished jobs....
make -f /root/linux-f6f3bac08f/tools/build/Makefile.build dir=. obj=libbpf
make[1]: Leaving directory '/root/linux-f6f3bac08f/tools/lib/bpf'

Thanks
Zhijian

>
> This patch fixed the issue by copying linux/tc_act/tc_bpf.h from
> kernel include/uapi directory to tools/include/uapi directory so
> building the bpftool does not depend on host system for this file.
>
> Fixes: f6f3bac08ff9 ("tools/bpf: bpftool: add net support")
> Reported-by: kernel test robot <rong.a.chen@intel.com>
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
>   tools/include/uapi/linux/tc_act/tc_bpf.h | 37 ++++++++++++++++++++++++
>   1 file changed, 37 insertions(+)
>   create mode 100644 tools/include/uapi/linux/tc_act/tc_bpf.h
>
> diff --git a/tools/include/uapi/linux/tc_act/tc_bpf.h b/tools/include/uapi/linux/tc_act/tc_bpf.h
> new file mode 100644
> index 000000000000..6e89a5df49a4
> --- /dev/null
> +++ b/tools/include/uapi/linux/tc_act/tc_bpf.h
> @@ -0,0 +1,37 @@
> +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
> +/*
> + * Copyright (c) 2015 Jiri Pirko <jiri@resnulli.us>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#ifndef __LINUX_TC_BPF_H
> +#define __LINUX_TC_BPF_H
> +
> +#include <linux/pkt_cls.h>
> +
> +#define TCA_ACT_BPF 13
> +
> +struct tc_act_bpf {
> +	tc_gen;
> +};
> +
> +enum {
> +	TCA_ACT_BPF_UNSPEC,
> +	TCA_ACT_BPF_TM,
> +	TCA_ACT_BPF_PARMS,
> +	TCA_ACT_BPF_OPS_LEN,
> +	TCA_ACT_BPF_OPS,
> +	TCA_ACT_BPF_FD,
> +	TCA_ACT_BPF_NAME,
> +	TCA_ACT_BPF_PAD,
> +	TCA_ACT_BPF_TAG,
> +	TCA_ACT_BPF_ID,
> +	__TCA_ACT_BPF_MAX,
> +};
> +#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)
> +
> +#endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH bpf] tools/bpftool: copy uapi/linux/tc_act/tc_bpf.h to tools directory
  2018-11-08  1:15 ` Li Zhijian
@ 2018-11-08  1:47   ` Yonghong Song
  0 siblings, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2018-11-08  1:47 UTC (permalink / raw)
  To: Li Zhijian, Alexei Starovoitov, Martin Lau, daniel, netdev, rong.a.chen
  Cc: Kernel Team



On 11/7/18 5:15 PM, Li Zhijian wrote:
> On 11/8/2018 9:00 AM, Yonghong Song wrote:
>> Commit f6f3bac08ff9 ("tools/bpf: bpftool: add net support")
>> added certain networking support to bpftool.
>> The implementation relies on a relatively recent uapi header file
>> linux/tc_act/tc_bpf.h on the host which contains the marco
>> definition of TCA_ACT_BPF_ID.
>>
>> Unfortunately, this is not the case for all distributions.
>> See the email message below where rhel-7.2 does not have
>> an up-to-date linux/tc_act/tc_bpf.h.
>>    
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mail-2Darchive.com_linux-2Dkernel-40vger.kernel.org_msg1799211.html&d=DwICaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=DA8e1B5r073vIqRrFz7MRA&m=BQIJZUzQfMmUkyvlAHMs7zygIFBysR_MlkAyHN59-7E&s=pVed3MjGDG_PMeBrhrqb3m57NRinnlcdL1QjAOj4iLA&e= 
>>
> 
> i have not tested this patch, but basing on the early commit
> 6f3bac08ff9 ("tools/bpf: bpftool: add net support")
> i cooked up similar patch locally, but i noticed that it also requires an
> up-to-date linux/pkt_cls.h as well to avoid compiling errors:

Thanks for testing. I will add linux/pkt_cls.h as well for the
version 2.

> 
> root@lkp-bdw-ep3 ~/linux-f6f3bac08f/tools/bpf/bpftool# make V=1
> [...snip...]
> gcc -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow 
> -Wno-missing-field-initializers -DPACKAGE='"bpftool"' 
> -D__EXPORTED_HEADERS__ -I/root/linux-f6f3bac08f/kernel/bpf/ 
> -I/root/linux-f6f3bac08f/tools/include 
> -I/root/linux-f6f3bac08f/tools/include/uapi 
> -I/root/linux-f6f3bac08f/tools/lib/bpf 
> -I/root/linux-f6f3bac08f/tools/perf -DBPFTOOL_VERSION='"4.19.0-rc2"' 
> -DCOMPAT_NEED_REALLOCARRAY   -c -MMD -o netlink_dumper.o netlink_dumper.c
> make -C /root/linux-f6f3bac08f/tools/lib/bpf/ OUTPUT= libbpf.a
> make[1]: Entering directory '/root/linux-f6f3bac08f/tools/lib/bpf'
> netlink_dumper.c: In function 'do_bpf_filter_dump':
> netlink_dumper.c:153:9: error: 'TCA_BPF_ID' undeclared (first use in 
> this function)
>    if (tb[TCA_BPF_ID])
>           ^~~~~~~~~~
> netlink_dumper.c:153:9: note: each undeclared identifier is reported 
> only once for each function it appears in
> netlink_dumper.c:155:9: error: 'TCA_BPF_TAG' undeclared (first use in 
> this function)
>    if (tb[TCA_BPF_TAG])
>           ^~~~~~~~~~~
> Makefile:96: recipe for target 'netlink_dumper.o' failed
> make: *** [netlink_dumper.o] Error 1
> make: *** Waiting for unfinished jobs....
> make -f /root/linux-f6f3bac08f/tools/build/Makefile.build dir=. obj=libbpf
> make[1]: Leaving directory '/root/linux-f6f3bac08f/tools/lib/bpf'
> 
> Thanks
> Zhijian
> 
>>
>> This patch fixed the issue by copying linux/tc_act/tc_bpf.h from
>> kernel include/uapi directory to tools/include/uapi directory so
>> building the bpftool does not depend on host system for this file.
>>
>> Fixes: f6f3bac08ff9 ("tools/bpf: bpftool: add net support")
>> Reported-by: kernel test robot <rong.a.chen@intel.com>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
>> ---
>>   tools/include/uapi/linux/tc_act/tc_bpf.h | 37 ++++++++++++++++++++++++
>>   1 file changed, 37 insertions(+)
>>   create mode 100644 tools/include/uapi/linux/tc_act/tc_bpf.h
>>
>> diff --git a/tools/include/uapi/linux/tc_act/tc_bpf.h 
>> b/tools/include/uapi/linux/tc_act/tc_bpf.h
>> new file mode 100644
>> index 000000000000..6e89a5df49a4
>> --- /dev/null
>> +++ b/tools/include/uapi/linux/tc_act/tc_bpf.h
>> @@ -0,0 +1,37 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
>> +/*
>> + * Copyright (c) 2015 Jiri Pirko <jiri@resnulli.us>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License as published by
>> + * the Free Software Foundation; either version 2 of the License, or
>> + * (at your option) any later version.
>> + */
>> +
>> +#ifndef __LINUX_TC_BPF_H
>> +#define __LINUX_TC_BPF_H
>> +
>> +#include <linux/pkt_cls.h>
>> +
>> +#define TCA_ACT_BPF 13
>> +
>> +struct tc_act_bpf {
>> +    tc_gen;
>> +};
>> +
>> +enum {
>> +    TCA_ACT_BPF_UNSPEC,
>> +    TCA_ACT_BPF_TM,
>> +    TCA_ACT_BPF_PARMS,
>> +    TCA_ACT_BPF_OPS_LEN,
>> +    TCA_ACT_BPF_OPS,
>> +    TCA_ACT_BPF_FD,
>> +    TCA_ACT_BPF_NAME,
>> +    TCA_ACT_BPF_PAD,
>> +    TCA_ACT_BPF_TAG,
>> +    TCA_ACT_BPF_ID,
>> +    __TCA_ACT_BPF_MAX,
>> +};
>> +#define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)
>> +
>> +#endif

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-11-08 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-08  1:00 [PATCH bpf] tools/bpftool: copy uapi/linux/tc_act/tc_bpf.h to tools directory Yonghong Song
2018-11-08  1:15 ` Li Zhijian
2018-11-08  1:47   ` Yonghong Song

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.