|
|
132810 |
From 0d45550a184cc5a9f10187a97b9ef8dc7fa13f31 Mon Sep 17 00:00:00 2001
|
|
|
132810 |
From: Serhei Makarov <smakarov@redhat.com>
|
|
|
132810 |
Date: Fri, 2 Nov 2018 16:49:23 -0400
|
|
|
132810 |
Subject: [PATCH 19/32] PR23829 :: fallback defines __BPF_FUNC_MAPPER and
|
|
|
132810 |
BPF_J{LT,LE,SLT,SLE} for older kernels
|
|
|
132810 |
|
|
|
132810 |
---
|
|
|
132810 |
bpf-base.cxx | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
132810 |
bpf-internal.h | 11 +++++++++++
|
|
|
132810 |
2 files changed, 70 insertions(+)
|
|
|
132810 |
|
|
|
132810 |
diff --git a/bpf-base.cxx b/bpf-base.cxx
|
|
|
132810 |
index 277927b72..210efa9aa 100644
|
|
|
132810 |
--- a/bpf-base.cxx
|
|
|
132810 |
+++ b/bpf-base.cxx
|
|
|
132810 |
@@ -140,6 +140,65 @@ is_commutative(opcode code)
|
|
|
132810 |
std::map<unsigned, const char *> bpf_func_name_map;
|
|
|
132810 |
std::map<std::string, bpf_func_id> bpf_func_id_map;
|
|
|
132810 |
|
|
|
132810 |
+/* PR23829: On older kernels, bpf.h does not define __BPF_FUNC_MAPPER.
|
|
|
132810 |
+ As a fallback, use the *earliest* __BPF_FUNC_MAPPER, so stapbpf
|
|
|
132810 |
+ will not try helpers that only exist on subsequent kernels.
|
|
|
132810 |
+
|
|
|
132810 |
+ TODO: This isn't perfect since even older kernels don't have
|
|
|
132810 |
+ some of these helpers.
|
|
|
132810 |
+
|
|
|
132810 |
+ XXX: Note the build limitation in that SystemTap must be compiled
|
|
|
132810 |
+ against a recent kernel to be able to use the helpers from that
|
|
|
132810 |
+ kernel. That's also the case when building against recent bpf.h
|
|
|
132810 |
+ with __BPF_FUNC_MAPPER, so this workaround is not the source of the
|
|
|
132810 |
+ problem. */
|
|
|
132810 |
+#ifndef __BPF_FUNC_MAPPER
|
|
|
132810 |
+#define __BPF_FUNC_MAPPER(FN) \
|
|
|
132810 |
+ FN(unspec), \
|
|
|
132810 |
+ FN(map_lookup_elem), \
|
|
|
132810 |
+ FN(map_update_elem), \
|
|
|
132810 |
+ FN(map_delete_elem), \
|
|
|
132810 |
+ FN(probe_read), \
|
|
|
132810 |
+ FN(ktime_get_ns), \
|
|
|
132810 |
+ FN(trace_printk), \
|
|
|
132810 |
+ FN(get_prandom_u32), \
|
|
|
132810 |
+ FN(get_smp_processor_id), \
|
|
|
132810 |
+ FN(skb_store_bytes), \
|
|
|
132810 |
+ FN(l3_csum_replace), \
|
|
|
132810 |
+ FN(l4_csum_replace), \
|
|
|
132810 |
+ FN(tail_call), \
|
|
|
132810 |
+ FN(clone_redirect), \
|
|
|
132810 |
+ FN(get_current_pid_tgid), \
|
|
|
132810 |
+ FN(get_current_uid_gid), \
|
|
|
132810 |
+ FN(get_current_comm), \
|
|
|
132810 |
+ FN(get_cgroup_classid), \
|
|
|
132810 |
+ FN(skb_vlan_push), \
|
|
|
132810 |
+ FN(skb_vlan_pop), \
|
|
|
132810 |
+ FN(skb_get_tunnel_key), \
|
|
|
132810 |
+ FN(skb_set_tunnel_key), \
|
|
|
132810 |
+ FN(perf_event_read), \
|
|
|
132810 |
+ FN(redirect), \
|
|
|
132810 |
+ FN(get_route_realm), \
|
|
|
132810 |
+ FN(perf_event_output), \
|
|
|
132810 |
+ FN(skb_load_bytes), \
|
|
|
132810 |
+ FN(get_stackid), \
|
|
|
132810 |
+ FN(csum_diff), \
|
|
|
132810 |
+ FN(skb_get_tunnel_opt), \
|
|
|
132810 |
+ FN(skb_set_tunnel_opt), \
|
|
|
132810 |
+ FN(skb_change_proto), \
|
|
|
132810 |
+ FN(skb_change_type), \
|
|
|
132810 |
+ FN(skb_under_cgroup), \
|
|
|
132810 |
+ FN(get_hash_recalc), \
|
|
|
132810 |
+ FN(get_current_task), \
|
|
|
132810 |
+ FN(probe_write_user), \
|
|
|
132810 |
+ FN(current_task_under_cgroup), \
|
|
|
132810 |
+ FN(skb_change_tail), \
|
|
|
132810 |
+ FN(skb_pull_data), \
|
|
|
132810 |
+ FN(csum_update), \
|
|
|
132810 |
+ FN(set_hash_invalid), \
|
|
|
132810 |
+
|
|
|
132810 |
+#endif
|
|
|
132810 |
+
|
|
|
132810 |
void
|
|
|
132810 |
init_bpf_helper_tables () // TODO call before script translation
|
|
|
132810 |
{
|
|
|
132810 |
diff --git a/bpf-internal.h b/bpf-internal.h
|
|
|
132810 |
index 3041bbdf5..82cba2c79 100644
|
|
|
132810 |
--- a/bpf-internal.h
|
|
|
132810 |
+++ b/bpf-internal.h
|
|
|
132810 |
@@ -21,6 +21,17 @@ extern "C" {
|
|
|
132810 |
#include <linux/bpf.h>
|
|
|
132810 |
}
|
|
|
132810 |
|
|
|
132810 |
+/* PR23829: These eBPF opcodes were added in recent kernels, and the
|
|
|
132810 |
+ following 'ad hoc' defines are only used by the embedded-code
|
|
|
132810 |
+ assembler. The code generator will convert these opcodes to
|
|
|
132810 |
+ equivalent operations valid for earlier eBPF. */
|
|
|
132810 |
+#ifndef BPF_JLT
|
|
|
132810 |
+#define BPF_JLT 0xa0 /* LT is unsigned, '<' */
|
|
|
132810 |
+#define BPF_JLE 0xb0 /* LE is unsigned, '<=' */
|
|
|
132810 |
+#define BPF_JSLT 0xc0 /* SLT is signed, '<' */
|
|
|
132810 |
+#define BPF_JSLE 0xd0 /* SLE is signed, '<=' */
|
|
|
132810 |
+#endif
|
|
|
132810 |
+
|
|
|
132810 |
struct systemtap_session;
|
|
|
132810 |
struct derived_probe;
|
|
|
132810 |
struct vardecl;
|
|
|
132810 |
--
|
|
|
132810 |
2.14.5
|
|
|
132810 |
|