libbpf: ensure F_DUPFD_CLOEXEC is defined
Subsystems (4)
PATCH 1/1 libbpf: ensure F_DUPFD_CLOEXEC is defined
This definition seems to be missing from some older toolchains.
Note that the fcntl.h in libbpf_internal.h is not a kernel header but rather a toolchain libc header.
Fixes:
libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?
fd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
^~~~~~~~~~~~~~~
FD_CLOEXEC--- tools/lib/bpf/libbpf_internal.h | 4 ++++ 1 file changed, 4 insertions(+)
tools/lib/bpf/libbpf_internal.h +4 -0
@@ -31,6 +31,10 @@#define EM_BPF 247#endif +#ifndef F_DUPFD_CLOEXEC +#define F_DUPFD_CLOEXEC 1030 +#endif +#ifndef R_BPF_64_64 #define R_BPF_64_64 1#endif
Signature · 1 line
2.25.1
Daniel Borkmann
maintainerHi James,
Quoted 5 lines · James Hilliard
This definition seems to be missing from some older toolchains.
Note that the
fcntl.hinlibbpf_internal.his not a kernel header but rather a toolchain libc header.
Quoted 7 lines
Fixes:
libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); ^~~~~~~~~~~~~~~ FD_CLOEXECSigned-off-by James Hilliard <[email protected]>
Do you have some more info on your env (e.g. libc)? Looks like F_DUPFD_CLOEXEC was added back in 2.6.24 kernel. When did libc add it?
Should we instead just add an include for <linux/fcntl.h> to libbpf_internal.h (given it defines F_DUPFD_CLOEXEC as well)?
Quoted 10 lines
--- tools/lib/bpf/libbpf_internal.h | 4 ++++ 1 file changed, 4 insertions(+)tools/lib/bpf/libbpf_internal.h +0
-0
tools/lib/bpf/libbpf_internal.h line 40
Quoted 10 lines
tools/lib/bpf/libbpf_internal.h +4
-0@@ -31,6 +31,10 @@#define EM_BPF 247#endif +#ifndef F_DUPFD_CLOEXEC +#define F_DUPFD_CLOEXEC 1030 +#endif +#ifndef R_BPF_64_64 #define R_BPF_64_64 1#endif
Thanks,
Daniel
Quoted 15 lines · Daniel Borkmann
Hi James,
Quoted 11 lines · James Hilliard
This definition seems to be missing from some older toolchains.
Note that the
fcntl.hinlibbpf_internal.his not a kernel header but rather a toolchain libc header.Fixes:
libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); ^~~~~~~~~~~~~~~ FD_CLOEXEC
Quoted 4 lines
Quoted 1 line
Signed-off-by James Hilliard <[email protected]>Do you have some more info on your env (e.g. libc)? Looks like
F_DUPFD_CLOEXECwas added back in 2.6.24 kernel. When did libc add it?
It seems like it's guarded by __USE_XOPEN2K8 in glibc (from a quick glance at glibc code). But it's been there since 2010 or so, at the very least.
Quoted 3 lines
Should we instead just add an include for <
linux/fcntl.h> tolibbpf_internal.h(given it definesF_DUPFD_CLOEXECas well)?
yep, this is UAPI header so we can use it easily (we'll need to sync it into Github repo, but that's not a problem)
Quoted 24 lines
Quoted 11 lines
--- tools/lib/bpf/libbpf_internal.h | 4 ++++ 1 file changed, 4 insertions(+)tools/lib/bpf/libbpf_internal.h +0
-0tools/lib/bpf/libbpf_internal.h line 40
Quoted 10 lines
tools/lib/bpf/libbpf_internal.h +4
-0@@ -31,6 +31,10 @@#define EM_BPF 247#endif +#ifndef F_DUPFD_CLOEXEC +#define F_DUPFD_CLOEXEC 1030 +#endif +#ifndef R_BPF_64_64 #define R_BPF_64_64 1#endif Thanks,
Daniel
Daniel Borkmann
maintainerQuoted 22 lines · Andrii Nakryiko
Quoted 12 lines · Daniel Borkmann
Quoted 11 lines · James Hilliard
This definition seems to be missing from some older toolchains.
Note that the
fcntl.hinlibbpf_internal.his not a kernel header but rather a toolchain libc header.Fixes:
libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); ^~~~~~~~~~~~~~~ FD_CLOEXECQuoted 4 lines
Quoted 1 line
Signed-off-by James Hilliard <[email protected]>Do you have some more info on your env (e.g. libc)? Looks like
F_DUPFD_CLOEXECwas added back in 2.6.24 kernel. When did libc add it?It seems like it's guarded by
__USE_XOPEN2K8in glibc (from a quick glance at glibc code). But it's been there since 2010 or so, at the very least.
Quoted 5 lines
Quoted 2 lines
Should we instead just add an include for <
linux/fcntl.h> tolibbpf_internal.h(given it definesF_DUPFD_CLOEXECas well)?yep, this is UAPI header so we can use it easily (we'll need to sync it into Github repo, but that's not a problem)
Sgtm, James, could you respin with using the include?
Thanks,
Daniel
Quoted 17 lines · Andrii Nakryiko
Quoted 15 lines · Daniel Borkmann
Hi James,
Quoted 11 lines · James Hilliard
This definition seems to be missing from some older toolchains.
Note that the
fcntl.hinlibbpf_internal.his not a kernel header but rather a toolchain libc header.Fixes:
libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); ^~~~~~~~~~~~~~~ FD_CLOEXEC
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by James Hilliard <[email protected]>Do you have some more info on your env (e.g. libc)? Looks like
F_DUPFD_CLOEXECwas added back in 2.6.24 kernel. When did libc add it?It seems like it's guarded by
__USE_XOPEN2K8in glibc (from a quick glance at glibc code). But it's been there since 2010 or so, at the very least.
The toolchain that hit this issue appears to be uclibc based which seems to have had some bugs with the F_DUPFD_CLOEXEC definition.
Quoted 33 lines
Quoted 4 lines
Should we instead just add an include for <
linux/fcntl.h> tolibbpf_internal.h(given it definesF_DUPFD_CLOEXECas well)?yep, this is UAPI header so we can use it easily (we'll need to sync it into Github repo, but that's not a problem)
Quoted 24 lines
Quoted 11 lines
--- tools/lib/bpf/libbpf_internal.h | 4 ++++ 1 file changed, 4 insertions(+)tools/lib/bpf/libbpf_internal.h +0
-0tools/lib/bpf/libbpf_internal.h line 40
Quoted 10 lines
tools/lib/bpf/libbpf_internal.h +4
-0@@ -31,6 +31,10 @@#define EM_BPF 247#endif +#ifndef F_DUPFD_CLOEXEC +#define F_DUPFD_CLOEXEC 1030 +#endif +#ifndef R_BPF_64_64 #define R_BPF_64_64 1#endif Thanks,
Daniel
Quoted 15 lines · Daniel Borkmann
Hi James,
Quoted 11 lines · James Hilliard
This definition seems to be missing from some older toolchains.
Note that the
fcntl.hinlibbpf_internal.his not a kernel header but rather a toolchain libc header.Fixes:
libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); ^~~~~~~~~~~~~~~ FD_CLOEXEC
Quoted 7 lines
Quoted 1 line
Signed-off-by James Hilliard <[email protected]>Do you have some more info on your env (e.g. libc)? Looks like
F_DUPFD_CLOEXECwas added back in 2.6.24 kernel. When did libc add it?Should we instead just add an include for <
linux/fcntl.h> tolibbpf_internal.h(given it definesF_DUPFD_CLOEXECas well)?
That seems to cause a conflict: error: redefinition of ‘struct flock’
Quoted 24 lines
Quoted 11 lines
--- tools/lib/bpf/libbpf_internal.h | 4 ++++ 1 file changed, 4 insertions(+)tools/lib/bpf/libbpf_internal.h +0
-0tools/lib/bpf/libbpf_internal.h line 40
Quoted 10 lines
tools/lib/bpf/libbpf_internal.h +4
-0@@ -31,6 +31,10 @@#define EM_BPF 247#endif +#ifndef F_DUPFD_CLOEXEC +#define F_DUPFD_CLOEXEC 1030 +#endif +#ifndef R_BPF_64_64 #define R_BPF_64_64 1#endif Thanks,
Daniel
Quoted 41 lines · James Hilliard
Quoted 15 lines · Daniel Borkmann
Hi James,
Quoted 11 lines · James Hilliard
This definition seems to be missing from some older toolchains.
Note that the
fcntl.hinlibbpf_internal.his not a kernel header but rather a toolchain libc header.Fixes:
libbpf_internal.h:521:18: error: 'F_DUPFD_CLOEXEC' undeclared (first use in this function); did you mean 'FD_CLOEXEC'?fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); ^~~~~~~~~~~~~~~ FD_CLOEXECQuoted 7 lines
Quoted 1 line
Signed-off-by James Hilliard <[email protected]>Do you have some more info on your env (e.g. libc)? Looks like
F_DUPFD_CLOEXECwas added back in 2.6.24 kernel. When did libc add it?Should we instead just add an include for <
linux/fcntl.h> tolibbpf_internal.h(given it definesF_DUPFD_CLOEXECas well)?That seems to cause a conflict: error: redefinition of ‘struct flock’
Quoted 13 lines
Quoted 13 lines
--- tools/lib/bpf/libbpf_internal.h | 4 ++++ 1 file changed, 4 insertions(+)tools/lib/bpf/libbpf_internal.h +0
-0@@ -31,6 +31,10 @@#define EM_BPF 247#endif
Quoted 3 lines
Quoted 3 lines
tools/lib/bpf/libbpf_internal.h line 36
Quoted 3 lines
tools/lib/bpf/libbpf_internal.h +3
-0+#ifndef F_DUPFD_CLOEXEC +#define F_DUPFD_CLOEXEC 1030 +#endif
Let's just do this then (assuming the value of F_DUPFD_CLOEXEC is architecture-independent)
Quoted 8 lines
Quoted 8 lines
tools/lib/bpf/libbpf_internal.h line 40
Quoted 5 lines
tools/lib/bpf/libbpf_internal.h +1
-0+#ifndef R_BPF_64_64 #define R_BPF_64_64 1#endif Thanks,
Daniel