Skip to content

Commit

Permalink
sync with libbpf repo
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
yonghong-song committed Aug 22, 2020
1 parent fecd934 commit 43910c4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cc/bcc_btf.cc
Expand Up @@ -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,
Expand Down
17 changes: 17 additions & 0 deletions src/cc/bcc_btf.h
Expand Up @@ -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();
Expand Down
17 changes: 12 additions & 5 deletions src/cc/compat/linux/virtual_bpf.h
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 43910c4

Please sign in to comment.