bcc/SOURCES/bcc-0.16.0-sync-with-libbpf...

122 lines
4.1 KiB
Diff

From da9ec2b1673ddf6b956304dca6ed6918d89d4631 Mon Sep 17 00:00:00 2001
From: Yonghong Song <yhs@fb.com>
Date: Sat, 22 Aug 2020 15:19:46 -0700
Subject: [PATCH] sync with libbpf repo
sync with latest libbpf repo.
Strut definition for btf_ext_header is defined in libbpf/src/btf.h
previously and used by bcc. Now, the struct is moved to
libbpf/src/libbpf_internal.h and not available to bcc.
We do not want to include libbpf/src/libbpf_internal.h as
it is really libbpf internal. Let us define bcc version
of btf_ext_header with struct name bcc_btf_ext_header.
The new name is to avoid conflict when compiling with
old libbpf package.
Signed-off-by: Yonghong Song <yhs@fb.com>
---
src/cc/bcc_btf.cc | 2 +-
src/cc/bcc_btf.h | 17 +++++++++++++++++
src/cc/compat/linux/virtual_bpf.h | 17 ++++++++++++-----
4 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/src/cc/bcc_btf.cc b/src/cc/bcc_btf.cc
index e220f117..1056950c 100644
--- a/src/cc/bcc_btf.cc
+++ b/src/cc/bcc_btf.cc
@@ -185,7 +185,7 @@ void BTF::adjust(uint8_t *btf_sec, uintptr_t btf_sec_size,
}
struct btf_header *hdr = (struct btf_header *)btf_sec;
- struct btf_ext_header *ehdr = (struct btf_ext_header *)btf_ext_sec;
+ struct bcc_btf_ext_header *ehdr = (struct bcc_btf_ext_header *)btf_ext_sec;
// Fixup btf for old kernels or kernel requirements.
fixup_btf(btf_sec + hdr->hdr_len + hdr->type_off, hdr->type_len,
diff --git a/src/cc/bcc_btf.h b/src/cc/bcc_btf.h
index 438c1f73..75b47cc3 100644
--- a/src/cc/bcc_btf.h
+++ b/src/cc/bcc_btf.h
@@ -45,6 +45,23 @@ class BTFStringTable {
};
class BTF {
+ struct bcc_btf_ext_header {
+ uint16_t magic;
+ uint8_t version;
+ uint8_t flags;
+ uint32_t hdr_len;
+
+ /* All offsets are in bytes relative to the end of this header */
+ uint32_t func_info_off;
+ uint32_t func_info_len;
+ uint32_t line_info_off;
+ uint32_t line_info_len;
+
+ /* optional part of .BTF.ext header */
+ uint32_t core_relo_off;
+ uint32_t core_relo_len;
+};
+
public:
BTF(bool debug, sec_map_def &sections);
~BTF();
diff --git a/src/cc/compat/linux/virtual_bpf.h b/src/cc/compat/linux/virtual_bpf.h
index 38262630..0387b970 100644
--- a/src/cc/compat/linux/virtual_bpf.h
+++ b/src/cc/compat/linux/virtual_bpf.h
@@ -768,7 +768,7 @@ union bpf_attr {
*
* Also, note that **bpf_trace_printk**\ () is slow, and should
* only be used for debugging purposes. For this reason, a notice
- * bloc (spanning several lines) is printed to kernel logs and
+ * block (spanning several lines) is printed to kernel logs and
* states that the helper should not be used "for production use"
* the first time this helper is used (or more precisely, when
* **trace_printk**\ () buffers are allocated). For passing values
@@ -1034,14 +1034,14 @@ union bpf_attr {
*
* int ret;
* struct bpf_tunnel_key key = {};
- *
+ *
* ret = bpf_skb_get_tunnel_key(skb, &key, sizeof(key), 0);
* if (ret < 0)
* return TC_ACT_SHOT; // drop packet
- *
+ *
* if (key.remote_ipv4 != 0x0a000001)
* return TC_ACT_SHOT; // drop packet
- *
+ *
* return TC_ACT_OK; // accept packet
*
* This interface can also be used with all encapsulation devices
@@ -1148,7 +1148,7 @@ union bpf_attr {
* Description
* Retrieve the realm or the route, that is to say the
* **tclassid** field of the destination for the *skb*. The
- * indentifier retrieved is a user-provided tag, similar to the
+ * identifier retrieved is a user-provided tag, similar to the
* one used with the net_cls cgroup (see description for
* **bpf_get_cgroup_classid**\ () helper), but here this tag is
* held by a route (a destination entry), not by a task.
@@ -4072,6 +4072,13 @@ struct bpf_link_info {
__u64 cgroup_id;
__u32 attach_type;
} cgroup;
+ struct {
+ __aligned_u64 target_name; /* in/out: target_name buffer ptr */
+ __u32 target_name_len; /* in/out: target_name buffer len */
+ union {
+ __u32 map_id;
+ } map;
+ } iter;
struct {
__u32 netns_ino;
__u32 attach_type;
--
2.29.2