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