bpftool: fix compilation failure for net.o with older glibc
Subsystems (4)
PATCH 1/1 bpftool: fix compilation failure for net.o with older glibc
For older glibc ~2.17, #include'ing both linux/if.h and net/if.h fails due to complaints about redefinition of interface flags:
CC net.o
In file included from net.c:13:0:/usr/include/linux/if.h:71:2: error: redeclaration of enumerator ‘IFF_UP’
IFF_UP = 1<<0, /* sysfs */
^/usr/include/net/if.h:44:5: note: previous definition of ‘IFF_UP’ was here
IFF_UP = 0x1, /* Interface is up. */
The issue was fixed in kernel headers in [1], but since compilation of net.c picks up system headers the problem can recur.
Dropping #include <linux/if.h> resolves the issue and it is not needed for compilation anyhow.
--- tools/bpf/bpftool/net.c | 1 - 1 file changed, 1 deletion(-)
tools/bpf/bpftool/net.c +0 -1
@@ -11,7 +11,6 @@#include <bpf/bpf.h> #include <bpf/libbpf.h> #include <net/if.h> -#include <linux/if.h> #include <linux/rtnetlink.h> #include <linux/socket.h> #include <linux/tc_act/tc_bpf.h>
Signature · 1 line
1.8.3.1
Quoted 9 lines · Alan Maguire
For older glibc ~2.17, #include'ing both
linux/if.handnet/if.hfails due to complaints about redefinition of interface flags:CC net.o
In file included from net.c:13:0:/usr/include/linux/if.h:71:2: error: redeclaration of enumerator ‘IFF_UP’
IFF_UP= 1<<0, /* sysfs */
^/usr/include/net/if.h:44:5: note: previous definition of ‘IFF_UP’ was here
Quoted 7 lines
IFF_UP = 0x1, /* Interface is up. */The issue was fixed in kernel headers in [1], but since compilation of
net.cpicks up system headers the problem can recur.Dropping #include <
linux/if.h> resolves the issue and it is not needed for compilation anyhow.
This patch was applied to bpf/bpf.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
Quoted 9 lines · On Wed, 6 Jan 2021 15:59:06 +0000 you wrote:
For older glibc ~2.17, #include'ing both
linux/if.handnet/if.hfails due to complaints about redefinition of interface flags:CC net.o
In file included from net.c:13:0:/usr/include/linux/if.h:71:2: error: redeclaration of enumerator ‘IFF_UP’
IFF_UP= 1<<0, /* sysfs */
^/usr/include/net/if.h:44:5: note: previous definition of ‘IFF_UP’ was here
Quoted 3 lines
IFF_UP = 0x1, /* Interface is up. */[...]
Here is the summary with links:
- [bpf] bpftool: fix compilation failure for net.o with older glibc
https://git.kernel.org/bpf/bpf/c/6f02b540d759
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html