On Wed, 2016-08-31 at 16:21 +0200, Mark Wielaard wrote:
> Thanks, that does look like the correct configure check.
> 
> But it seems that BPF_PSEUDO_MAP_FD is the only missing constant
> introduced since 3.18 (when linux/bpf.h was added) that we use.
> So maybe we could simply define it ourselves when not found. So we can
> build against any linux/bpf.h out there.
> 
> What do people think of the following?

I tested it against the latest stable kernel and headers from the 3.18
kernel and it seems to work fine. Any objections to commit the attached?

Thanks,

Mark
From 4f7b5ba9624489b5a2f714569c29ef865d4dcd6f Mon Sep 17 00:00:00 2001
From: Mark Wielaard <[email protected]>
Date: Mon, 5 Sep 2016 11:15:50 +0200
Subject: [PATCH] libcpu: Fix build of bpf_disasm.c for kernels < 3.20.

Before linux 3.20 the BPF_PSEUDO_MAP_FD constant wasn't defined.

Reported-by: Julian Ospald <[email protected]>
Signed-off-by: Mark Wielaard <[email protected]>
---
 libcpu/ChangeLog    | 4 ++++
 libcpu/bpf_disasm.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
index 9f3566c..9cce4e7 100644
--- a/libcpu/ChangeLog
+++ b/libcpu/ChangeLog
@@ -1,3 +1,7 @@
+2016-09-05  Mark Wielaard  <[email protected]>
+
+	* bpf_disasm.c: Define BPF_PSEUDO_MAP_FD if undefined.
+
 2016-08-10  Richard Henderson  <[email protected]>
 
 	* bpf_disasm.c (bpf_disasm): Rearrange the printing of instructions
diff --git a/libcpu/bpf_disasm.c b/libcpu/bpf_disasm.c
index 153dba9..e4bbae4 100644
--- a/libcpu/bpf_disasm.c
+++ b/libcpu/bpf_disasm.c
@@ -40,6 +40,10 @@
 #include "../libelf/common.h"
 #include "../libebl/libeblP.h"
 
+/* BPF_PSEUDO_MAP_FD was only introduced in linux 3.20.  */
+#ifndef BPF_PSEUDO_MAP_FD
+  #define BPF_PSEUDO_MAP_FD 1
+#endif
 
 static const char class_string[8][8] = {
   [BPF_LD]    = "ld",
-- 
1.8.3.1

Reply via email to