Skip to content

Commit f03b15d

Browse files
iamkafaiborkmann
authored andcommitted
bpf: btf: Sync bpf.h and btf.h to tools
This patch sync the uapi bpf.h and btf.h to tools. Signed-off-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 9b2cf32 commit f03b15d

2 files changed

Lines changed: 15 additions & 30 deletions

File tree

‎tools/include/uapi/linux/bpf.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ union bpf_attr {
284284
char map_name[BPF_OBJ_NAME_LEN];
285285
__u32 map_ifindex; /* ifindex of netdev to create on */
286286
__u32 btf_fd; /* fd pointing to a BTF type data */
287-
__u32 btf_key_id; /* BTF type_id of the key */
288-
__u32 btf_value_id; /* BTF type_id of the value */
287+
__u32 btf_key_type_id; /* BTF type_id of the key */
288+
__u32 btf_value_type_id; /* BTF type_id of the value */
289289
};
290290

291291
struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
@@ -2219,8 +2219,8 @@ struct bpf_map_info {
22192219
__u64 netns_dev;
22202220
__u64 netns_ino;
22212221
__u32 btf_id;
2222-
__u32 btf_key_id;
2223-
__u32 btf_value_id;
2222+
__u32 btf_key_type_id;
2223+
__u32 btf_value_type_id;
22242224
} __attribute__((aligned(8)));
22252225

22262226
struct bpf_btf_info {

‎tools/include/uapi/linux/btf.h‎

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,29 @@ struct btf_header {
1212
__u16 magic;
1313
__u8 version;
1414
__u8 flags;
15-
16-
__u32 parent_label;
17-
__u32 parent_name;
15+
__u32 hdr_len;
1816

1917
/* All offsets are in bytes relative to the end of this header */
20-
__u32 label_off; /* offset of label section */
21-
__u32 object_off; /* offset of data object section*/
22-
__u32 func_off; /* offset of function section */
2318
__u32 type_off; /* offset of type section */
19+
__u32 type_len; /* length of type section */
2420
__u32 str_off; /* offset of string section */
2521
__u32 str_len; /* length of string section */
2622
};
2723

2824
/* Max # of type identifier */
29-
#define BTF_MAX_TYPE 0x7fffffff
25+
#define BTF_MAX_TYPE 0x0000ffff
3026
/* Max offset into the string section */
31-
#define BTF_MAX_NAME_OFFSET 0x7fffffff
27+
#define BTF_MAX_NAME_OFFSET 0x0000ffff
3228
/* Max # of struct/union/enum members or func args */
3329
#define BTF_MAX_VLEN 0xffff
3430

35-
/* The type id is referring to a parent BTF */
36-
#define BTF_TYPE_PARENT(id) (((id) >> 31) & 0x1)
37-
#define BTF_TYPE_ID(id) ((id) & BTF_MAX_TYPE)
38-
39-
/* String is in the ELF string section */
40-
#define BTF_STR_TBL_ELF_ID(ref) (((ref) >> 31) & 0x1)
41-
#define BTF_STR_OFFSET(ref) ((ref) & BTF_MAX_NAME_OFFSET)
42-
4331
struct btf_type {
4432
__u32 name_off;
4533
/* "info" bits arrangement
4634
* bits 0-15: vlen (e.g. # of struct's members)
4735
* bits 16-23: unused
48-
* bits 24-28: kind (e.g. int, ptr, array...etc)
49-
* bits 29-30: unused
50-
* bits 31: root
36+
* bits 24-27: kind (e.g. int, ptr, array...etc)
37+
* bits 28-31: unused
5138
*/
5239
__u32 info;
5340
/* "size" is used by INT, ENUM, STRUCT and UNION.
@@ -62,8 +49,7 @@ struct btf_type {
6249
};
6350
};
6451

65-
#define BTF_INFO_KIND(info) (((info) >> 24) & 0x1f)
66-
#define BTF_INFO_ISROOT(info) (!!(((info) >> 24) & 0x80))
52+
#define BTF_INFO_KIND(info) (((info) >> 24) & 0x0f)
6753
#define BTF_INFO_VLEN(info) ((info) & 0xffff)
6854

6955
#define BTF_KIND_UNKN 0 /* Unknown */
@@ -88,15 +74,14 @@ struct btf_type {
8874
/* BTF_KIND_INT is followed by a u32 and the following
8975
* is the 32 bits arrangement:
9076
*/
91-
#define BTF_INT_ENCODING(VAL) (((VAL) & 0xff000000) >> 24)
77+
#define BTF_INT_ENCODING(VAL) (((VAL) & 0x0f000000) >> 24)
9278
#define BTF_INT_OFFSET(VAL) (((VAL & 0x00ff0000)) >> 16)
9379
#define BTF_INT_BITS(VAL) ((VAL) & 0x0000ffff)
9480

9581
/* Attributes stored in the BTF_INT_ENCODING */
96-
#define BTF_INT_SIGNED 0x1
97-
#define BTF_INT_CHAR 0x2
98-
#define BTF_INT_BOOL 0x4
99-
#define BTF_INT_VARARGS 0x8
82+
#define BTF_INT_SIGNED (1 << 0)
83+
#define BTF_INT_CHAR (1 << 1)
84+
#define BTF_INT_BOOL (1 << 2)
10085

10186
/* BTF_KIND_ENUM is followed by multiple "struct btf_enum".
10287
* The exact number of btf_enum is stored in the vlen (of the

0 commit comments

Comments
 (0)