eBPF has a graceful approach: it must successfully compile on all Linux
distributions. If a specific kernel cannot support eBPF it will gracefully
refuse the eBPF netlink message sent to it.
The kernel header file linux/bpf.h (if present) on different Linux
distributions may not include all definitions required for TAP
compilation.
In order to guarantee a successful eBPF compilation everywhere all the
required definitions for TAP have been locally added instead of including
file <linux/bpf.h>
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Tested-by: Harry van Haaren <harry.van.haaren@intel.com>
linux/tc_act/tc_bpf.h \
enum TCA_ACT_BPF_FD \
$(AUTOCONF_OUTPUT)
- $Q sh -- '$<' '$@' \
- HAVE_BPF_PROG_LOAD \
- linux/bpf.h \
- enum BPF_PROG_LOAD \
- $(AUTOCONF_OUTPUT)
# Create tap_autoconf.h or update it in case it differs from the new one.
#include <tap_autoconf.h>
-#ifdef HAVE_BPF_PROG_LOAD
-#include <linux/bpf.h>
-#else
+/* Do not #include <linux/bpf.h> since eBPF must compile on different
+ * distros which may include partial definitions for eBPF (while the
+ * kernel itself may support eBPF). Instead define here all that is needed
+ */
+
/* BPF_MAP_UPDATE_ELEM command flags */
#define BPF_ANY 0 /* create a new element or update an existing */
__u32 prog_flags;
};
} __attribute__((aligned(8)));
-#endif
#ifndef __NR_bpf
# if defined(__i386__)