425d11
import bcc-0.25.0-2.el8
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
059187f62e915eb74ea7b18e19fcb185f9d18255 SOURCES/bcc-0.25.0.tar.gz
|
@@ -1 +1 @@
|
|
1
|
-
SOURCES/bcc-0.
|
1
|
+
SOURCES/bcc-0.25.0.tar.gz
|
@@ -1,324 +0,0 @@
|
|
1
|
-
From 8f2951559127ffb93c3e36d5fc9d870768826ae9 Mon Sep 17 00:00:00 2001
|
2
|
-
From: Jerome Marchand <jmarchan@redhat.com>
|
3
|
-
Date: Thu, 24 Mar 2022 16:08:17 +0100
|
4
|
-
Subject: [PATCH 2/2] RHEL: libbpf version fixes
|
5
|
-
|
6
|
-
Revert "bcc: Replace deprecated libbpf APIs" since the libbpf version
|
7
|
-
provided in RHEL 8 doesn't provide the new APIs.
|
8
|
-
|
9
|
-
Remove BPF_MAP_TYPE_BLOOM_FILTER from bps since the libbpf version in
|
10
|
-
RHEL 8, doesn't provide bloom filter map.
|
11
|
-
|
12
|
-
Rename btf__load_vmlinux_btf into libbpf_find_kernel_btf. The function
|
13
|
-
has been renamed upstream for naming consistency, but RHEL 8 libbpf
|
14
|
-
still uses the old name.
|
15
|
-
|
16
|
-
Add definition of struct bpf_core_relo.
|
17
|
-
---
|
18
|
-
introspection/bps.c | 1 -
|
19
|
-
libbpf-tools/ksnoop.c | 2 +-
|
20
|
-
src/cc/bcc_btf.cc | 73 ++++++++++++++++++++++++++++++++++++-
|
21
|
-
src/cc/libbpf.c | 84 +++++++------------------------------------
|
22
|
-
4 files changed, 85 insertions(+), 75 deletions(-)
|
23
|
-
|
24
|
-
diff --git a/introspection/bps.c b/introspection/bps.c
|
25
|
-
index 232b23d4..6ec02e6c 100644
|
26
|
-
--- a/introspection/bps.c
|
27
|
-
+++ b/introspection/bps.c
|
28
|
-
@@ -80,7 +80,6 @@ static const char * const map_type_strings[] = {
|
29
|
-
[BPF_MAP_TYPE_RINGBUF] = "ringbuf",
|
30
|
-
[BPF_MAP_TYPE_INODE_STORAGE] = "inode_storage",
|
31
|
-
[BPF_MAP_TYPE_TASK_STORAGE] = "task_storage",
|
32
|
-
- [BPF_MAP_TYPE_BLOOM_FILTER] = "bloom_filter",
|
33
|
-
};
|
34
|
-
|
35
|
-
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
36
|
-
diff --git a/libbpf-tools/ksnoop.c b/libbpf-tools/ksnoop.c
|
37
|
-
index 69c58403..a6ea6107 100644
|
38
|
-
--- a/libbpf-tools/ksnoop.c
|
39
|
-
+++ b/libbpf-tools/ksnoop.c
|
40
|
-
@@ -347,7 +347,7 @@ static struct btf *get_btf(const char *name)
|
41
|
-
name && strlen(name) > 0 ? name : "vmlinux");
|
42
|
-
|
43
|
-
if (!vmlinux_btf) {
|
44
|
-
- vmlinux_btf = btf__load_vmlinux_btf();
|
45
|
-
+ vmlinux_btf = libbpf_find_kernel_btf();
|
46
|
-
if (!vmlinux_btf) {
|
47
|
-
err = -errno;
|
48
|
-
p_err("No BTF, cannot determine type info: %s", strerror(-err));
|
49
|
-
diff --git a/src/cc/bcc_btf.cc b/src/cc/bcc_btf.cc
|
50
|
-
index 7f551ae8..c78ba823 100644
|
51
|
-
--- a/src/cc/bcc_btf.cc
|
52
|
-
+++ b/src/cc/bcc_btf.cc
|
53
|
-
@@ -170,6 +170,77 @@ static int btf_ext_setup_line_info(struct btf_ext *btf_ext)
|
54
|
-
return btf_ext_setup_info(btf_ext, ¶m);
|
55
|
-
}
|
56
|
-
|
57
|
-
+/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value
|
58
|
-
+ * has to be adjusted by relocations.
|
59
|
-
+ */
|
60
|
-
+enum bpf_core_relo_kind {
|
61
|
-
+ BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */
|
62
|
-
+ BPF_FIELD_BYTE_SIZE = 1, /* field size in bytes */
|
63
|
-
+ BPF_FIELD_EXISTS = 2, /* field existence in target kernel */
|
64
|
-
+ BPF_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */
|
65
|
-
+ BPF_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */
|
66
|
-
+ BPF_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */
|
67
|
-
+ BPF_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */
|
68
|
-
+ BPF_TYPE_ID_TARGET = 7, /* type ID in target kernel */
|
69
|
-
+ BPF_TYPE_EXISTS = 8, /* type existence in target kernel */
|
70
|
-
+ BPF_TYPE_SIZE = 9, /* type size in bytes */
|
71
|
-
+ BPF_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */
|
72
|
-
+ BPF_ENUMVAL_VALUE = 11, /* enum value integer value */
|
73
|
-
+};
|
74
|
-
+
|
75
|
-
+/* The minimum bpf_core_relo checked by the loader
|
76
|
-
+ *
|
77
|
-
+ * CO-RE relocation captures the following data:
|
78
|
-
+ * - insn_off - instruction offset (in bytes) within a BPF program that needs
|
79
|
-
+ * its insn->imm field to be relocated with actual field info;
|
80
|
-
+ * - type_id - BTF type ID of the "root" (containing) entity of a relocatable
|
81
|
-
+ * type or field;
|
82
|
-
+ * - access_str_off - offset into corresponding .BTF string section. String
|
83
|
-
+ * interpretation depends on specific relocation kind:
|
84
|
-
+ * - for field-based relocations, string encodes an accessed field using
|
85
|
-
+ * a sequence of field and array indices, separated by colon (:). It's
|
86
|
-
+ * conceptually very close to LLVM's getelementptr ([0]) instruction's
|
87
|
-
+ * arguments for identifying offset to a field.
|
88
|
-
+ * - for type-based relocations, strings is expected to be just "0";
|
89
|
-
+ * - for enum value-based relocations, string contains an index of enum
|
90
|
-
+ * value within its enum type;
|
91
|
-
+ *
|
92
|
-
+ * Example to provide a better feel.
|
93
|
-
+ *
|
94
|
-
+ * struct sample {
|
95
|
-
+ * int a;
|
96
|
-
+ * struct {
|
97
|
-
+ * int b[10];
|
98
|
-
+ * };
|
99
|
-
+ * };
|
100
|
-
+ *
|
101
|
-
+ * struct sample *s = ...;
|
102
|
-
+ * int x = &s->a; // encoded as "0:0" (a is field #0)
|
103
|
-
+ * int y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1,
|
104
|
-
+ * // b is field #0 inside anon struct, accessing elem #5)
|
105
|
-
+ * int z = &s[10]->b; // encoded as "10:1" (ptr is used as an array)
|
106
|
-
+ *
|
107
|
-
+ * type_id for all relocs in this example will capture BTF type id of
|
108
|
-
+ * `struct sample`.
|
109
|
-
+ *
|
110
|
-
+ * Such relocation is emitted when using __builtin_preserve_access_index()
|
111
|
-
+ * Clang built-in, passing expression that captures field address, e.g.:
|
112
|
-
+ *
|
113
|
-
+ * bpf_probe_read(&dst, sizeof(dst),
|
114
|
-
+ * __builtin_preserve_access_index(&src->a.b.c));
|
115
|
-
+ *
|
116
|
-
+ * In this case Clang will emit field relocation recording necessary data to
|
117
|
-
+ * be able to find offset of embedded `a.b.c` field within `src` struct.
|
118
|
-
+ *
|
119
|
-
+ * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction
|
120
|
-
+ */
|
121
|
-
+struct bpf_core_relo {
|
122
|
-
+ __u32 insn_off;
|
123
|
-
+ __u32 type_id;
|
124
|
-
+ __u32 access_str_off;
|
125
|
-
+ enum bpf_core_relo_kind kind;
|
126
|
-
+};
|
127
|
-
+
|
128
|
-
static int btf_ext_setup_core_relos(struct btf_ext *btf_ext)
|
129
|
-
{
|
130
|
-
struct btf_ext_sec_setup_param param = {
|
131
|
-
@@ -597,7 +668,7 @@ int BTF::load(uint8_t *btf_sec, uintptr_t btf_sec_size,
|
132
|
-
return -1;
|
133
|
-
}
|
134
|
-
|
135
|
-
- if (btf__load_into_kernel(btf)) {
|
136
|
-
+ if (btf__load(btf)) {
|
137
|
-
btf__free(btf);
|
138
|
-
warning("Loading .BTF section failed\n");
|
139
|
-
return -1;
|
140
|
-
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
|
141
|
-
index e6403299..7410ae1a 100644
|
142
|
-
--- a/src/cc/libbpf.c
|
143
|
-
+++ b/src/cc/libbpf.c
|
144
|
-
@@ -297,25 +297,6 @@ static uint64_t ptr_to_u64(void *ptr)
|
145
|
-
return (uint64_t) (unsigned long) ptr;
|
146
|
-
}
|
147
|
-
|
148
|
-
-static int libbpf_bpf_map_create(struct bpf_create_map_attr *create_attr)
|
149
|
-
-{
|
150
|
-
- LIBBPF_OPTS(bpf_map_create_opts, p);
|
151
|
-
-
|
152
|
-
- p.map_flags = create_attr->map_flags;
|
153
|
-
- p.numa_node = create_attr->numa_node;
|
154
|
-
- p.btf_fd = create_attr->btf_fd;
|
155
|
-
- p.btf_key_type_id = create_attr->btf_key_type_id;
|
156
|
-
- p.btf_value_type_id = create_attr->btf_value_type_id;
|
157
|
-
- p.map_ifindex = create_attr->map_ifindex;
|
158
|
-
- if (create_attr->map_type == BPF_MAP_TYPE_STRUCT_OPS)
|
159
|
-
- p.btf_vmlinux_value_type_id = create_attr->btf_vmlinux_value_type_id;
|
160
|
-
- else
|
161
|
-
- p.inner_map_fd = create_attr->inner_map_fd;
|
162
|
-
-
|
163
|
-
- return bpf_map_create(create_attr->map_type, create_attr->name, create_attr->key_size,
|
164
|
-
- create_attr->value_size, create_attr->max_entries, &p);
|
165
|
-
-}
|
166
|
-
-
|
167
|
-
int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit)
|
168
|
-
{
|
169
|
-
unsigned name_len = attr->name ? strlen(attr->name) : 0;
|
170
|
-
@@ -323,7 +304,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit)
|
171
|
-
|
172
|
-
memcpy(map_name, attr->name, min(name_len, BPF_OBJ_NAME_LEN - 1));
|
173
|
-
attr->name = map_name;
|
174
|
-
- int ret = libbpf_bpf_map_create(attr);
|
175
|
-
+ int ret = bpf_create_map_xattr(attr);
|
176
|
-
|
177
|
-
if (ret < 0 && errno == EPERM) {
|
178
|
-
if (!allow_rlimit)
|
179
|
-
@@ -335,7 +316,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit)
|
180
|
-
rl.rlim_max = RLIM_INFINITY;
|
181
|
-
rl.rlim_cur = rl.rlim_max;
|
182
|
-
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
183
|
-
- ret = libbpf_bpf_map_create(attr);
|
184
|
-
+ ret = bpf_create_map_xattr(attr);
|
185
|
-
}
|
186
|
-
}
|
187
|
-
|
188
|
-
@@ -345,12 +326,12 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit)
|
189
|
-
attr->btf_fd = 0;
|
190
|
-
attr->btf_key_type_id = 0;
|
191
|
-
attr->btf_value_type_id = 0;
|
192
|
-
- ret = libbpf_bpf_map_create(attr);
|
193
|
-
+ ret = bpf_create_map_xattr(attr);
|
194
|
-
}
|
195
|
-
|
196
|
-
if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) {
|
197
|
-
map_name[0] = '\0';
|
198
|
-
- ret = libbpf_bpf_map_create(attr);
|
199
|
-
+ ret = bpf_create_map_xattr(attr);
|
200
|
-
}
|
201
|
-
|
202
|
-
if (ret < 0 && errno == EPERM) {
|
203
|
-
@@ -363,7 +344,7 @@ int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit)
|
204
|
-
rl.rlim_max = RLIM_INFINITY;
|
205
|
-
rl.rlim_cur = rl.rlim_max;
|
206
|
-
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
207
|
-
- ret = libbpf_bpf_map_create(attr);
|
208
|
-
+ ret = bpf_create_map_xattr(attr);
|
209
|
-
}
|
210
|
-
}
|
211
|
-
return ret;
|
212
|
-
@@ -627,47 +608,6 @@ int bpf_prog_get_tag(int fd, unsigned long long *ptag)
|
213
|
-
return 0;
|
214
|
-
}
|
215
|
-
|
216
|
-
-static int libbpf_bpf_prog_load(const struct bpf_load_program_attr *load_attr,
|
217
|
-
- char *log_buf, size_t log_buf_sz)
|
218
|
-
-{
|
219
|
-
- LIBBPF_OPTS(bpf_prog_load_opts, p);
|
220
|
-
-
|
221
|
-
- if (!load_attr || !log_buf != !log_buf_sz) {
|
222
|
-
- errno = EINVAL;
|
223
|
-
- return -EINVAL;
|
224
|
-
- }
|
225
|
-
-
|
226
|
-
- p.expected_attach_type = load_attr->expected_attach_type;
|
227
|
-
- switch (load_attr->prog_type) {
|
228
|
-
- case BPF_PROG_TYPE_STRUCT_OPS:
|
229
|
-
- case BPF_PROG_TYPE_LSM:
|
230
|
-
- p.attach_btf_id = load_attr->attach_btf_id;
|
231
|
-
- break;
|
232
|
-
- case BPF_PROG_TYPE_TRACING:
|
233
|
-
- case BPF_PROG_TYPE_EXT:
|
234
|
-
- p.attach_btf_id = load_attr->attach_btf_id;
|
235
|
-
- p.attach_prog_fd = load_attr->attach_prog_fd;
|
236
|
-
- break;
|
237
|
-
- default:
|
238
|
-
- p.prog_ifindex = load_attr->prog_ifindex;
|
239
|
-
- p.kern_version = load_attr->kern_version;
|
240
|
-
- }
|
241
|
-
- p.log_level = load_attr->log_level;
|
242
|
-
- p.log_buf = log_buf;
|
243
|
-
- p.log_size = log_buf_sz;
|
244
|
-
- p.prog_btf_fd = load_attr->prog_btf_fd;
|
245
|
-
- p.func_info_rec_size = load_attr->func_info_rec_size;
|
246
|
-
- p.func_info_cnt = load_attr->func_info_cnt;
|
247
|
-
- p.func_info = load_attr->func_info;
|
248
|
-
- p.line_info_rec_size = load_attr->line_info_rec_size;
|
249
|
-
- p.line_info_cnt = load_attr->line_info_cnt;
|
250
|
-
- p.line_info = load_attr->line_info;
|
251
|
-
- p.prog_flags = load_attr->prog_flags;
|
252
|
-
-
|
253
|
-
- return bpf_prog_load(load_attr->prog_type, load_attr->name, load_attr->license,
|
254
|
-
- load_attr->insns, load_attr->insns_cnt, &p);
|
255
|
-
-}
|
256
|
-
-
|
257
|
-
int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
258
|
-
char *log_buf, unsigned log_buf_size, bool allow_rlimit)
|
259
|
-
{
|
260
|
-
@@ -750,7 +690,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
261
|
-
attr->name = prog_name;
|
262
|
-
}
|
263
|
-
|
264
|
-
- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size);
|
265
|
-
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
266
|
-
|
267
|
-
// func_info/line_info may not be supported in old kernels.
|
268
|
-
if (ret < 0 && attr->func_info && errno == EINVAL) {
|
269
|
-
@@ -761,14 +701,14 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
270
|
-
attr->line_info = NULL;
|
271
|
-
attr->line_info_cnt = 0;
|
272
|
-
attr->line_info_rec_size = 0;
|
273
|
-
- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size);
|
274
|
-
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
275
|
-
}
|
276
|
-
|
277
|
-
// BPF object name is not supported on older Kernels.
|
278
|
-
// If we failed due to this, clear the name and try again.
|
279
|
-
if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) {
|
280
|
-
prog_name[0] = '\0';
|
281
|
-
- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size);
|
282
|
-
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
283
|
-
}
|
284
|
-
|
285
|
-
if (ret < 0 && errno == EPERM) {
|
286
|
-
@@ -787,7 +727,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
287
|
-
rl.rlim_max = RLIM_INFINITY;
|
288
|
-
rl.rlim_cur = rl.rlim_max;
|
289
|
-
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
290
|
-
- ret = libbpf_bpf_prog_load(attr, attr_log_buf, attr_log_buf_size);
|
291
|
-
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
292
|
-
}
|
293
|
-
}
|
294
|
-
|
295
|
-
@@ -805,7 +745,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
296
|
-
// If logging is not already enabled, enable it and do the syscall again.
|
297
|
-
if (attr->log_level == 0) {
|
298
|
-
attr->log_level = 1;
|
299
|
-
- ret = libbpf_bpf_prog_load(attr, log_buf, log_buf_size);
|
300
|
-
+ ret = bpf_load_program_xattr(attr, log_buf, log_buf_size);
|
301
|
-
}
|
302
|
-
// Print the log message and return.
|
303
|
-
bpf_print_hints(ret, log_buf);
|
304
|
-
@@ -829,7 +769,7 @@ int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
305
|
-
goto return_result;
|
306
|
-
}
|
307
|
-
tmp_log_buf[0] = 0;
|
308
|
-
- ret = libbpf_bpf_prog_load(attr, tmp_log_buf, tmp_log_buf_size);
|
309
|
-
+ ret = bpf_load_program_xattr(attr, tmp_log_buf, tmp_log_buf_size);
|
310
|
-
if (ret < 0 && errno == ENOSPC) {
|
311
|
-
// Temporary buffer size is not enough. Double it and try again.
|
312
|
-
free(tmp_log_buf);
|
313
|
-
@@ -1369,7 +1309,7 @@ int kernel_struct_has_field(const char *struct_name, const char *field_name)
|
314
|
-
struct btf *btf;
|
315
|
-
int i, ret, btf_id;
|
316
|
-
|
317
|
-
- btf = btf__load_vmlinux_btf();
|
318
|
-
+ btf = libbpf_find_kernel_btf();
|
319
|
-
ret = libbpf_get_error(btf);
|
320
|
-
if (ret)
|
321
|
-
return -1;
|
322
|
-
--
|
323
|
-
2.35.3
|
324
|
-
|
@@ -0,0 +1,77 @@
|
|
1
|
+
From 728005aac7c23590a406ac67235d915e416bff5d Mon Sep 17 00:00:00 2001
|
2
|
+
From: Yonghong Song <yhs@fb.com>
|
3
|
+
Date: Sat, 13 Aug 2022 17:50:07 -0700
|
4
|
+
Subject: [PATCH 1/2] Fix bpf_pseudo_fd() type conversion error
|
5
|
+
|
6
|
+
With llvm15 and llvm16, the following command line
|
7
|
+
sudo ./trace.py 'smp_call_function_single "%K", arg1'
|
8
|
+
will cause error:
|
9
|
+
/virtual/main.c:60:36: error: incompatible integer to pointer conversion passing 'u64'
|
10
|
+
(aka 'unsigned long long') to parameter of type 'void *' [-Wint-conversion]
|
11
|
+
bpf_perf_event_output(ctx, bpf_pseudo_fd(1, -1), CUR_CPU_IDENTIFIER, &__data, sizeof(__data));
|
12
|
+
^~~~~~~~~~~~~~~~~~~~
|
13
|
+
1 error generated.
|
14
|
+
Failed to compile BPF module <text>
|
15
|
+
|
16
|
+
In helpers.h, we have
|
17
|
+
u64 bpf_pseudo_fd(u64, u64) asm("llvm.bpf.pseudo");
|
18
|
+
Apparently, <= llvm14 can tolerate u64 -> 'void *' conversion, but
|
19
|
+
llvm15 by default will cause an error.
|
20
|
+
|
21
|
+
Let us explicitly convert bpf_pseudo_fd to 'void *' to avoid
|
22
|
+
such errors.
|
23
|
+
|
24
|
+
Signed-off-by: Yonghong Song <yhs@fb.com>
|
25
|
+
---
|
26
|
+
src/cc/frontends/clang/b_frontend_action.cc | 10 +++++-----
|
27
|
+
1 file changed, 5 insertions(+), 5 deletions(-)
|
28
|
+
|
29
|
+
diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc
|
30
|
+
index a4e05b16..dbeba3e4 100644
|
31
|
+
--- a/src/cc/frontends/clang/b_frontend_action.cc
|
32
|
+
+++ b/src/cc/frontends/clang/b_frontend_action.cc
|
33
|
+
@@ -957,7 +957,7 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
34
|
+
string arg0 = rewriter_.getRewrittenText(expansionRange(Call->getArg(0)->getSourceRange()));
|
35
|
+
string args_other = rewriter_.getRewrittenText(expansionRange(SourceRange(GET_BEGINLOC(Call->getArg(1)),
|
36
|
+
GET_ENDLOC(Call->getArg(2)))));
|
37
|
+
- txt = "bpf_perf_event_output(" + arg0 + ", bpf_pseudo_fd(1, " + fd + ")";
|
38
|
+
+ txt = "bpf_perf_event_output(" + arg0 + ", (void *)bpf_pseudo_fd(1, " + fd + ")";
|
39
|
+
txt += ", CUR_CPU_IDENTIFIER, " + args_other + ")";
|
40
|
+
|
41
|
+
// e.g.
|
42
|
+
@@ -986,7 +986,7 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
43
|
+
string meta_len = rewriter_.getRewrittenText(expansionRange(Call->getArg(3)->getSourceRange()));
|
44
|
+
txt = "bpf_perf_event_output(" +
|
45
|
+
skb + ", " +
|
46
|
+
- "bpf_pseudo_fd(1, " + fd + "), " +
|
47
|
+
+ "(void *)bpf_pseudo_fd(1, " + fd + "), " +
|
48
|
+
"((__u64)" + skb_len + " << 32) | BPF_F_CURRENT_CPU, " +
|
49
|
+
meta + ", " +
|
50
|
+
meta_len + ");";
|
51
|
+
@@ -1006,12 +1006,12 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
52
|
+
string keyp = rewriter_.getRewrittenText(expansionRange(Call->getArg(1)->getSourceRange()));
|
53
|
+
string flag = rewriter_.getRewrittenText(expansionRange(Call->getArg(2)->getSourceRange()));
|
54
|
+
txt = "bpf_" + string(memb_name) + "(" + ctx + ", " +
|
55
|
+
- "bpf_pseudo_fd(1, " + fd + "), " + keyp + ", " + flag + ");";
|
56
|
+
+ "(void *)bpf_pseudo_fd(1, " + fd + "), " + keyp + ", " + flag + ");";
|
57
|
+
} else if (memb_name == "ringbuf_output") {
|
58
|
+
string name = string(Ref->getDecl()->getName());
|
59
|
+
string args = rewriter_.getRewrittenText(expansionRange(SourceRange(GET_BEGINLOC(Call->getArg(0)),
|
60
|
+
GET_ENDLOC(Call->getArg(2)))));
|
61
|
+
- txt = "bpf_ringbuf_output(bpf_pseudo_fd(1, " + fd + ")";
|
62
|
+
+ txt = "bpf_ringbuf_output((void *)bpf_pseudo_fd(1, " + fd + ")";
|
63
|
+
txt += ", " + args + ")";
|
64
|
+
|
65
|
+
// e.g.
|
66
|
+
@@ -1033,7 +1033,7 @@ bool BTypeVisitor::VisitCallExpr(CallExpr *Call) {
|
67
|
+
} else if (memb_name == "ringbuf_reserve") {
|
68
|
+
string name = string(Ref->getDecl()->getName());
|
69
|
+
string arg0 = rewriter_.getRewrittenText(expansionRange(Call->getArg(0)->getSourceRange()));
|
70
|
+
- txt = "bpf_ringbuf_reserve(bpf_pseudo_fd(1, " + fd + ")";
|
71
|
+
+ txt = "bpf_ringbuf_reserve((void *)bpf_pseudo_fd(1, " + fd + ")";
|
72
|
+
txt += ", " + arg0 + ", 0)"; // Flags in reserve are meaningless
|
73
|
+
} else if (memb_name == "ringbuf_discard") {
|
74
|
+
string name = string(Ref->getDecl()->getName());
|
75
|
+
--
|
76
|
+
2.38.1
|
77
|
+
|
@@ -0,0 +1,96 @@
|
|
1
|
+
From f5a6c22f613d0566ba542f38f349be379e3844e8 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Jerome Marchand <jmarchan@redhat.com>
|
3
|
+
Date: Wed, 26 Oct 2022 14:41:54 +0200
|
4
|
+
Subject: [PATCH 2/2] Fix clang 15 int to pointer conversion errors
|
5
|
+
|
6
|
+
Since version 15, clang issues error for implicit conversion of
|
7
|
+
integer to pointer. Several tools are broken. This patch add explicit
|
8
|
+
pointer cast where needed.
|
9
|
+
|
10
|
+
Fixes the following errors:
|
11
|
+
/virtual/main.c:37:18: error: incompatible integer to pointer conversion initializing 'struct request *' with an expression of type 'unsigned long' [-Wint-conversion]
|
12
|
+
struct request *req = ctx->di;
|
13
|
+
^ ~~~~~~~
|
14
|
+
/virtual/main.c:49:18: error: incompatible integer to pointer conversion initializing 'struct request *' with an expression of type 'unsigned long' [-Wint-conversion]
|
15
|
+
struct request *req = ctx->di;
|
16
|
+
^ ~~~~~~~
|
17
|
+
2 errors generated.
|
18
|
+
|
19
|
+
/virtual/main.c:73:19: error: incompatible integer to pointer conversion initializing 'struct pt_regs *' with an expression of type 'unsigned long' [-Wint-conversion]
|
20
|
+
struct pt_regs * __ctx = ctx->di;
|
21
|
+
^ ~~~~~~~
|
22
|
+
/virtual/main.c:100:240: error: incompatible integer to pointer conversion passing 'u64' (aka 'unsigned long long') to parameter of type 'const void *' [-Wint-conversion]
|
23
|
+
data.ppid = ({ typeof(pid_t) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&({ typeof(struct task_struct *) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&task->real_parent); _val; })->tgid); _val; });
|
24
|
+
^~~~~~~~~~~~~~~~~~~~~~~
|
25
|
+
/virtual/main.c:100:118: error: incompatible integer to pointer conversion passing 'u64' (aka 'unsigned long long') to parameter of type 'const void *' [-Wint-conversion]
|
26
|
+
data.ppid = ({ typeof(pid_t) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&({ typeof(struct task_struct *) _val; __builtin_memset(&_val, 0, sizeof(_val)); bpf_probe_read(&_val, sizeof(_val), (u64)&task->real_parent); _val; })->tgid); _val; });
|
27
|
+
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
28
|
+
|
29
|
+
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
30
|
+
---
|
31
|
+
src/cc/frontends/clang/b_frontend_action.cc | 18 +++++++++---------
|
32
|
+
1 file changed, 9 insertions(+), 9 deletions(-)
|
33
|
+
|
34
|
+
diff --git a/src/cc/frontends/clang/b_frontend_action.cc b/src/cc/frontends/clang/b_frontend_action.cc
|
35
|
+
index dbeba3e4..c0582464 100644
|
36
|
+
--- a/src/cc/frontends/clang/b_frontend_action.cc
|
37
|
+
+++ b/src/cc/frontends/clang/b_frontend_action.cc
|
38
|
+
@@ -517,9 +517,9 @@ bool ProbeVisitor::VisitUnaryOperator(UnaryOperator *E) {
|
39
|
+
string pre, post;
|
40
|
+
pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));";
|
41
|
+
if (cannot_fall_back_safely)
|
42
|
+
- pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (u64)";
|
43
|
+
+ pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (void *)";
|
44
|
+
else
|
45
|
+
- pre += " bpf_probe_read(&_val, sizeof(_val), (u64)";
|
46
|
+
+ pre += " bpf_probe_read(&_val, sizeof(_val), (void *)";
|
47
|
+
post = "); _val; })";
|
48
|
+
rewriter_.ReplaceText(expansionLoc(E->getOperatorLoc()), 1, pre);
|
49
|
+
rewriter_.InsertTextAfterToken(expansionLoc(GET_ENDLOC(sub)), post);
|
50
|
+
@@ -581,9 +581,9 @@ bool ProbeVisitor::VisitMemberExpr(MemberExpr *E) {
|
51
|
+
string pre, post;
|
52
|
+
pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));";
|
53
|
+
if (cannot_fall_back_safely)
|
54
|
+
- pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (u64)&";
|
55
|
+
+ pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (void *)&";
|
56
|
+
else
|
57
|
+
- pre += " bpf_probe_read(&_val, sizeof(_val), (u64)&";
|
58
|
+
+ pre += " bpf_probe_read(&_val, sizeof(_val), (void *)&";
|
59
|
+
post = rhs + "); _val; })";
|
60
|
+
rewriter_.InsertText(expansionLoc(GET_BEGINLOC(E)), pre);
|
61
|
+
rewriter_.ReplaceText(expansionRange(SourceRange(member, GET_ENDLOC(E))), post);
|
62
|
+
@@ -635,9 +635,9 @@ bool ProbeVisitor::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
|
63
|
+
|
64
|
+
pre = "({ typeof(" + E->getType().getAsString() + ") _val; __builtin_memset(&_val, 0, sizeof(_val));";
|
65
|
+
if (cannot_fall_back_safely)
|
66
|
+
- pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (u64)((";
|
67
|
+
+ pre += " bpf_probe_read_kernel(&_val, sizeof(_val), (void *)((";
|
68
|
+
else
|
69
|
+
- pre += " bpf_probe_read(&_val, sizeof(_val), (u64)((";
|
70
|
+
+ pre += " bpf_probe_read(&_val, sizeof(_val), (void *)((";
|
71
|
+
if (isMemberDereference(base)) {
|
72
|
+
pre += "&";
|
73
|
+
// If the base of the array subscript is a member dereference, we'll rewrite
|
74
|
+
@@ -747,8 +747,8 @@ void BTypeVisitor::genParamDirectAssign(FunctionDecl *D, string& preamble,
|
75
|
+
arg->addAttr(UnavailableAttr::CreateImplicit(C, "ptregs"));
|
76
|
+
size_t d = idx - 1;
|
77
|
+
const char *reg = calling_conv_regs[d];
|
78
|
+
- preamble += " " + text + " = " + fn_args_[0]->getName().str() + "->" +
|
79
|
+
- string(reg) + ";";
|
80
|
+
+ preamble += " " + text + " = (" + arg->getType().getAsString() + ")" +
|
81
|
+
+ fn_args_[0]->getName().str() + "->" + string(reg) + ";";
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
@@ -762,7 +762,7 @@ void BTypeVisitor::genParamIndirectAssign(FunctionDecl *D, string& preamble,
|
86
|
+
|
87
|
+
if (idx == 0) {
|
88
|
+
new_ctx = "__" + arg->getName().str();
|
89
|
+
- preamble += " struct pt_regs * " + new_ctx + " = " +
|
90
|
+
+ preamble += " struct pt_regs * " + new_ctx + " = (void *)" +
|
91
|
+
arg->getName().str() + "->" +
|
92
|
+
string(calling_conv_regs[0]) + ";";
|
93
|
+
} else {
|
94
|
+
--
|
95
|
+
2.38.1
|
96
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
From c27899b15bca6188d34c0b87b3389eeda2a90cb5 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Jerome Marchand <jmarchan@redhat.com>
|
3
|
+
Date: Mon, 9 Jan 2023 18:17:20 +0100
|
4
|
+
Subject: [PATCH] Fix get_kprobe_functions
|
5
|
+
|
6
|
+
get_kprobe_functions will not only return a function that matches the
|
7
|
+
regular expression, but also any function that starts with a
|
8
|
+
substrings that matches it. This is obviously not the intended
|
9
|
+
behavior.
|
10
|
+
The issue is easily fixed by replacing re.match by re.fullmatch.
|
11
|
+
---
|
12
|
+
src/python/bcc/__init__.py | 2 +-
|
13
|
+
1 file changed, 1 insertion(+), 1 deletion(-)
|
14
|
+
|
15
|
+
diff --git a/src/python/bcc/__init__.py b/src/python/bcc/__init__.py
|
16
|
+
index 7175b98e..970ddcc2 100644
|
17
|
+
--- a/src/python/bcc/__init__.py
|
18
|
+
+++ b/src/python/bcc/__init__.py
|
19
|
+
@@ -745,7 +745,7 @@ DEBUG_BTF = 0x20
|
20
|
+
# Exclude all gcc 8's extra .cold functions
|
21
|
+
elif re.match(b'^.*\.cold(\.\d+)?$', fn):
|
22
|
+
continue
|
23
|
+
- if (t.lower() in [b't', b'w']) and re.match(event_re, fn) \
|
24
|
+
+ if (t.lower() in [b't', b'w']) and re.fullmatch(event_re, fn) \
|
25
|
+
and fn not in blacklist:
|
26
|
+
fns.append(fn)
|
27
|
+
return set(fns) # Some functions may appear more than once
|
28
|
+
--
|
29
|
+
2.38.1
|
30
|
+
|
@@ -1,7 +1,7 @@
|
|
1
|
-
From
|
1
|
+
From ce407eab95f96badd1879c9c7342eeabcfd17311 Mon Sep 17 00:00:00 2001
|
2
2
|
From: Jerome Marchand <jmarchan@redhat.com>
|
3
3
|
Date: Tue, 6 Aug 2019 14:44:33 +0200
|
4
|
-
Subject: [PATCH] Manpages: remove unstable statement
|
4
|
+
Subject: [PATCH 1/3] Manpages: remove unstable statement
|
5
5
|
|
6
6
|
The tools are tested before each release. They should be stable
|
7
7
|
enough.
|
@@ -11,6 +11,7 @@ enough.
|
|
11
11
|
man/man8/bindsnoop.8 | 2 --
|
12
12
|
man/man8/biolatency.8 | 2 --
|
13
13
|
man/man8/biolatpcts.8 | 2 --
|
14
|
+
man/man8/biopattern.8 | 2 --
|
14
15
|
man/man8/biosnoop.8 | 2 --
|
15
16
|
man/man8/biotop.8 | 2 --
|
16
17
|
man/man8/bitesize.8 | 2 --
|
@@ -81,6 +82,7 @@ enough.
|
|
81
82
|
man/man8/syncsnoop.8 | 2 --
|
82
83
|
man/man8/syscount.8 | 2 --
|
83
84
|
man/man8/tcpaccept.8 | 2 --
|
85
|
+
man/man8/tcpcong.8 | 2 --
|
84
86
|
man/man8/tcpconnect.8 | 2 --
|
85
87
|
man/man8/tcpconnlat.8 | 2 --
|
86
88
|
man/man8/tcpdrop.8 | 2 --
|
@@ -110,10 +112,10 @@ enough.
|
|
110
112
|
man/man8/xfsslower.8 | 2 --
|
111
113
|
man/man8/zfsdist.8 | 2 --
|
112
114
|
man/man8/zfsslower.8 | 2 --
|
113
|
-
|
115
|
+
106 files changed, 214 deletions(-)
|
114
116
|
|
115
117
|
diff --git a/man/man8/argdist.8 b/man/man8/argdist.8
|
116
|
-
index
|
118
|
+
index 75b7fe63..99291521 100644
|
117
119
|
--- a/man/man8/argdist.8
|
118
120
|
+++ b/man/man8/argdist.8
|
119
121
|
@@ -191,7 +191,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -151,17 +153,17 @@ index f8fa1850..05ed95a7 100644
|
|
151
153
|
Pavel Dubovitsky
|
152
154
|
.SH SEE ALSO
|
153
155
|
diff --git a/man/man8/biolatency.8 b/man/man8/biolatency.8
|
154
|
-
index
|
156
|
+
index db2ef484..21c3930e 100644
|
155
157
|
--- a/man/man8/biolatency.8
|
156
158
|
+++ b/man/man8/biolatency.8
|
157
|
-
@@ -
|
159
|
+
@@ -108,8 +108,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
158
160
|
example usage, output, and commentary for this tool.
|
159
161
|
.SH OS
|
160
162
|
Linux
|
161
163
|
-.SH STABILITY
|
162
164
|
-Unstable - in development.
|
163
165
|
.SH AUTHOR
|
164
|
-
Brendan Gregg
|
166
|
+
Brendan Gregg, Rocky Xing
|
165
167
|
.SH SEE ALSO
|
166
168
|
diff --git a/man/man8/biolatpcts.8 b/man/man8/biolatpcts.8
|
167
169
|
index 7a06a11d..9dd41d08 100644
|
@@ -176,34 +178,47 @@ index 7a06a11d..9dd41d08 100644
|
|
176
178
|
.SH AUTHOR
|
177
179
|
Tejun Heo
|
178
180
|
.SH SEE ALSO
|
181
|
+
diff --git a/man/man8/biopattern.8 b/man/man8/biopattern.8
|
182
|
+
index 451d667f..70ba73e7 100644
|
183
|
+
--- a/man/man8/biopattern.8
|
184
|
+
+++ b/man/man8/biopattern.8
|
185
|
+
@@ -70,8 +70,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
186
|
+
example usage, output, and commentary for this tool.
|
187
|
+
.SH OS
|
188
|
+
Linux
|
189
|
+
-.SH STABILITY
|
190
|
+
-Unstable - in development.
|
191
|
+
.SH AUTHOR
|
192
|
+
Rocky Xing
|
193
|
+
.SH SEE ALSO
|
179
194
|
diff --git a/man/man8/biosnoop.8 b/man/man8/biosnoop.8
|
180
|
-
index
|
195
|
+
index 24f19edf..06a85757 100644
|
181
196
|
--- a/man/man8/biosnoop.8
|
182
197
|
+++ b/man/man8/biosnoop.8
|
183
|
-
@@ -
|
198
|
+
@@ -82,8 +82,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
184
199
|
example usage, output, and commentary for this tool.
|
185
200
|
.SH OS
|
186
201
|
Linux
|
187
202
|
-.SH STABILITY
|
188
203
|
-Unstable - in development.
|
189
204
|
.SH AUTHOR
|
190
|
-
Brendan Gregg
|
205
|
+
Brendan Gregg, Rocky Xing
|
191
206
|
.SH SEE ALSO
|
192
207
|
diff --git a/man/man8/biotop.8 b/man/man8/biotop.8
|
193
|
-
index
|
208
|
+
index 47392bc7..ac71d34e 100644
|
194
209
|
--- a/man/man8/biotop.8
|
195
210
|
+++ b/man/man8/biotop.8
|
196
|
-
@@ -
|
211
|
+
@@ -98,8 +98,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
197
212
|
example usage, output, and commentary for this tool.
|
198
213
|
.SH OS
|
199
214
|
Linux
|
200
215
|
-.SH STABILITY
|
201
216
|
-Unstable - in development.
|
202
217
|
.SH AUTHOR
|
203
|
-
Brendan Gregg
|
218
|
+
Brendan Gregg, Rocky Xing
|
204
219
|
.SH INSPIRATION
|
205
220
|
diff --git a/man/man8/bitesize.8 b/man/man8/bitesize.8
|
206
|
-
index
|
221
|
+
index 655f69e7..314560b8 100644
|
207
222
|
--- a/man/man8/bitesize.8
|
208
223
|
+++ b/man/man8/bitesize.8
|
209
224
|
@@ -43,8 +43,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -279,17 +294,17 @@ index 172194d4..575941fc 100644
|
|
279
294
|
Allan McAleavy
|
280
295
|
.SH SEE ALSO
|
281
296
|
diff --git a/man/man8/cachetop.8 b/man/man8/cachetop.8
|
282
|
-
index
|
297
|
+
index bb7bb3cc..079b3cbf 100644
|
283
298
|
--- a/man/man8/cachetop.8
|
284
299
|
+++ b/man/man8/cachetop.8
|
285
|
-
@@ -
|
300
|
+
@@ -90,8 +90,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
286
301
|
example usage, output, and commentary for this tool.
|
287
302
|
.SH OS
|
288
303
|
Linux
|
289
304
|
-.SH STABILITY
|
290
305
|
-Unstable - in development.
|
291
306
|
.SH AUTHOR
|
292
|
-
Emmanuel Bretelle
|
307
|
+
Emmanuel Bretelle, Rocky Xing
|
293
308
|
.SH SEE ALSO
|
294
309
|
diff --git a/man/man8/capable.8 b/man/man8/capable.8
|
295
310
|
index 342946f8..2b7d13ba 100644
|
@@ -317,17 +332,17 @@ index a2933d7a..c1339579 100644
|
|
317
332
|
.SH AUTHOR
|
318
333
|
Wenbo Zhang
|
319
334
|
diff --git a/man/man8/cpudist.8 b/man/man8/cpudist.8
|
320
|
-
index
|
335
|
+
index 59937baa..1d6a7198 100644
|
321
336
|
--- a/man/man8/cpudist.8
|
322
337
|
+++ b/man/man8/cpudist.8
|
323
|
-
@@ -
|
338
|
+
@@ -115,8 +115,6 @@ Also look in the bcc distribution for a companion _example.txt file containing
|
324
339
|
example usage, output, and commentary for this tool.
|
325
340
|
.SH OS
|
326
341
|
Linux
|
327
342
|
-.SH STABILITY
|
328
343
|
-Unstable - in development.
|
329
344
|
.SH AUTHOR
|
330
|
-
Sasha Goldshtein
|
345
|
+
Sasha Goldshtein, Rocky Xing
|
331
346
|
.SH SEE ALSO
|
332
347
|
diff --git a/man/man8/cpuunclaimed.8 b/man/man8/cpuunclaimed.8
|
333
348
|
index 674be499..107ff67b 100644
|
@@ -433,10 +448,10 @@ index cc61a676..9a0fd3d9 100644
|
|
433
448
|
Erwan Velu
|
434
449
|
.SH INSPIRATION
|
435
450
|
diff --git a/man/man8/drsnoop.8 b/man/man8/drsnoop.8
|
436
|
-
index
|
451
|
+
index 90ca901f..64cc1c68 100644
|
437
452
|
--- a/man/man8/drsnoop.8
|
438
453
|
+++ b/man/man8/drsnoop.8
|
439
|
-
@@ -
|
454
|
+
@@ -107,7 +107,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
440
455
|
example usage, output, and commentary for this tool.
|
441
456
|
.SH OS
|
442
457
|
Linux
|
@@ -523,7 +538,7 @@ index fe912436..d567986b 100644
|
|
523
538
|
Brendan Gregg
|
524
539
|
.SH SEE ALSO
|
525
540
|
diff --git a/man/man8/filetop.8 b/man/man8/filetop.8
|
526
|
-
index
|
541
|
+
index 2d5f191d..6b588ef9 100644
|
527
542
|
--- a/man/man8/filetop.8
|
528
543
|
+++ b/man/man8/filetop.8
|
529
544
|
@@ -111,8 +111,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -536,7 +551,7 @@ index ba0cbd6e..1f818d68 100644
|
|
536
551
|
Brendan Gregg
|
537
552
|
.SH INSPIRATION
|
538
553
|
diff --git a/man/man8/funccount.8 b/man/man8/funccount.8
|
539
|
-
index
|
554
|
+
index b2cb8575..9e019d92 100644
|
540
555
|
--- a/man/man8/funccount.8
|
541
556
|
+++ b/man/man8/funccount.8
|
542
557
|
@@ -104,8 +104,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -549,7 +564,7 @@ index 16ce4fc0..1c7b71c1 100644
|
|
549
564
|
Brendan Gregg, Sasha Goldshtein
|
550
565
|
.SH SEE ALSO
|
551
566
|
diff --git a/man/man8/funcinterval.8 b/man/man8/funcinterval.8
|
552
|
-
index
|
567
|
+
index 77128290..f76ff315 100644
|
553
568
|
--- a/man/man8/funcinterval.8
|
554
569
|
+++ b/man/man8/funcinterval.8
|
555
570
|
@@ -114,8 +114,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -562,10 +577,10 @@ index 8a603998..39be3377 100755
|
|
562
577
|
Edward Wu
|
563
578
|
.SH SEE ALSO
|
564
579
|
diff --git a/man/man8/funclatency.8 b/man/man8/funclatency.8
|
565
|
-
index
|
580
|
+
index 9012b832..088b26cd 100644
|
566
581
|
--- a/man/man8/funclatency.8
|
567
582
|
+++ b/man/man8/funclatency.8
|
568
|
-
@@ -
|
583
|
+
@@ -131,8 +131,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
569
584
|
example usage, output, and commentary for this tool.
|
570
585
|
.SH OS
|
571
586
|
Linux
|
@@ -601,17 +616,17 @@ index a9d18e07..876f3983 100644
|
|
601
616
|
Brendan Gregg
|
602
617
|
.SH SEE ALSO
|
603
618
|
diff --git a/man/man8/hardirqs.8 b/man/man8/hardirqs.8
|
604
|
-
index
|
619
|
+
index aa9afb84..e74d56b3 100644
|
605
620
|
--- a/man/man8/hardirqs.8
|
606
621
|
+++ b/man/man8/hardirqs.8
|
607
|
-
@@ -
|
622
|
+
@@ -95,8 +95,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
608
623
|
example usage, output, and commentary for this tool.
|
609
624
|
.SH OS
|
610
625
|
Linux
|
611
626
|
-.SH STABILITY
|
612
627
|
-Unstable - in development.
|
613
628
|
.SH AUTHOR
|
614
|
-
Brendan Gregg, Hengqi Chen
|
629
|
+
Brendan Gregg, Hengqi Chen, Rocky Xing
|
615
630
|
.SH SEE ALSO
|
616
631
|
diff --git a/man/man8/inject.8 b/man/man8/inject.8
|
617
632
|
index 2ab80dbb..85b36b6e 100644
|
@@ -666,10 +681,10 @@ index c0cb4c98..0b56cecc 100644
|
|
666
681
|
.SH AUTHOR
|
667
682
|
Fei Li <lifei.shirley@bytedance.com>
|
668
683
|
diff --git a/man/man8/llcstat.8 b/man/man8/llcstat.8
|
669
|
-
index
|
684
|
+
index 5a28d338..7440fe3b 100644
|
670
685
|
--- a/man/man8/llcstat.8
|
671
686
|
+++ b/man/man8/llcstat.8
|
672
|
-
@@ -
|
687
|
+
@@ -66,8 +66,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
673
688
|
example usage, output, and commentary for this tool.
|
674
689
|
.SH OS
|
675
690
|
Linux
|
@@ -679,7 +694,7 @@ index 36dbed7d..2b554c46 100644
|
|
679
694
|
Teng Qin
|
680
695
|
.SH SEE ALSO
|
681
696
|
diff --git a/man/man8/mdflush.8 b/man/man8/mdflush.8
|
682
|
-
index
|
697
|
+
index e22c46b3..66939b25 100644
|
683
698
|
--- a/man/man8/mdflush.8
|
684
699
|
+++ b/man/man8/mdflush.8
|
685
700
|
@@ -49,8 +49,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -781,10 +796,10 @@ index be5387b9..270991d8 100644
|
|
781
796
|
Brendan Gregg
|
782
797
|
.SH SEE ALSO
|
783
798
|
diff --git a/man/man8/offwaketime.8 b/man/man8/offwaketime.8
|
784
|
-
index
|
799
|
+
index 44e3b684..4f4880e3 100644
|
785
800
|
--- a/man/man8/offwaketime.8
|
786
801
|
+++ b/man/man8/offwaketime.8
|
787
|
-
@@ -
|
802
|
+
@@ -110,8 +110,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
788
803
|
example usage, output, and commentary for this tool.
|
789
804
|
.SH OS
|
790
805
|
Linux
|
@@ -833,7 +848,7 @@ index 2164ffaf..9d272c81 100644
|
|
833
848
|
Brendan Gregg
|
834
849
|
.SH SEE ALSO
|
835
850
|
diff --git a/man/man8/profile.8 b/man/man8/profile.8
|
836
|
-
index
|
851
|
+
index 916224a9..6339dbfa 100644
|
837
852
|
--- a/man/man8/profile.8
|
838
853
|
+++ b/man/man8/profile.8
|
839
854
|
@@ -148,8 +148,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -946,17 +961,17 @@ index cd3ffa27..94432544 100644
|
|
946
961
|
-.SH STABILITY
|
947
962
|
-Unstable - in development.
|
948
963
|
diff --git a/man/man8/softirqs.8 b/man/man8/softirqs.8
|
949
|
-
index
|
964
|
+
index fa475f78..311fd0e6 100644
|
950
965
|
--- a/man/man8/softirqs.8
|
951
966
|
+++ b/man/man8/softirqs.8
|
952
|
-
@@ -
|
967
|
+
@@ -99,8 +99,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
953
968
|
example usage, output, and commentary for this tool.
|
954
969
|
.SH OS
|
955
970
|
Linux
|
956
971
|
-.SH STABILITY
|
957
972
|
-Unstable - in development.
|
958
973
|
.SH AUTHORS
|
959
|
-
Brendan Gregg, Sasha Goldshtein
|
974
|
+
Brendan Gregg, Sasha Goldshtein, Rocky Xing
|
960
975
|
.SH SEE ALSO
|
961
976
|
diff --git a/man/man8/solisten.8 b/man/man8/solisten.8
|
962
977
|
index 4d8ffe95..fd863447 100644
|
@@ -982,10 +997,10 @@ index ffad57c5..df80437f 100644
|
|
982
997
|
Jiri Olsa
|
983
998
|
.SH SEE ALSO
|
984
999
|
diff --git a/man/man8/sslsniff.8 b/man/man8/sslsniff.8
|
985
|
-
index
|
1000
|
+
index 4b80191a..86219f8a 100644
|
986
1001
|
--- a/man/man8/sslsniff.8
|
987
1002
|
+++ b/man/man8/sslsniff.8
|
988
|
-
@@ -
|
1003
|
+
@@ -108,8 +108,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
989
1004
|
example usage, output, and commentary for this tool.
|
990
1005
|
.SH OS
|
991
1006
|
Linux
|
@@ -1021,10 +1036,10 @@ index c0555043..d1560b3c 100644
|
|
1021
1036
|
Brendan Gregg
|
1022
1037
|
.SH SEE ALSO
|
1023
1038
|
diff --git a/man/man8/swapin.8 b/man/man8/swapin.8
|
1024
|
-
index
|
1039
|
+
index 9ef2eb9c..7347899d 100644
|
1025
1040
|
--- a/man/man8/swapin.8
|
1026
1041
|
+++ b/man/man8/swapin.8
|
1027
|
-
@@ -
|
1042
|
+
@@ -56,8 +56,6 @@ Also look in the bcc distribution for a companion _examples.txt file
|
1028
1043
|
containing example usage, output, and commentary for this tool.
|
1029
1044
|
.SH OS
|
1030
1045
|
Linux
|
@@ -1047,17 +1062,17 @@ index 8543f213..cd7b0629 100644
|
|
1047
1062
|
Brendan Gregg
|
1048
1063
|
.SH SEE ALSO
|
1049
1064
|
diff --git a/man/man8/syscount.8 b/man/man8/syscount.8
|
1050
|
-
index
|
1065
|
+
index 8c245dd8..54f9fe66 100644
|
1051
1066
|
--- a/man/man8/syscount.8
|
1052
1067
|
+++ b/man/man8/syscount.8
|
1053
|
-
@@ -
|
1068
|
+
@@ -108,8 +108,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
1054
1069
|
example usage, output, and commentary for this tool.
|
1055
1070
|
.SH OS
|
1056
1071
|
Linux
|
1057
1072
|
-.SH STABILITY
|
1058
1073
|
-Unstable - in development.
|
1059
1074
|
.SH AUTHOR
|
1060
|
-
Sasha Goldshtein
|
1075
|
+
Sasha Goldshtein, Rocky Xing
|
1061
1076
|
.SH SEE ALSO
|
1062
1077
|
diff --git a/man/man8/tcpaccept.8 b/man/man8/tcpaccept.8
|
1063
1078
|
index 05b79693..6dd35301 100644
|
@@ -1072,6 +1087,19 @@ index 05b79693..6dd35301 100644
|
|
1072
1087
|
.SH AUTHOR
|
1073
1088
|
Brendan Gregg
|
1074
1089
|
.SH SEE ALSO
|
1090
|
+
diff --git a/man/man8/tcpcong.8 b/man/man8/tcpcong.8
|
1091
|
+
index 877ed805..3fd0a253 100644
|
1092
|
+
--- a/man/man8/tcpcong.8
|
1093
|
+
+++ b/man/man8/tcpcong.8
|
1094
|
+
@@ -128,8 +128,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
1095
|
+
example usage, output, and commentary for this tool.
|
1096
|
+
.SH OS
|
1097
|
+
Linux
|
1098
|
+
-.SH STABILITY
|
1099
|
+
-Unstable - in development.
|
1100
|
+
.SH AUTHOR
|
1101
|
+
jacky gan
|
1102
|
+
.SH SEE ALSO
|
1075
1103
|
diff --git a/man/man8/tcpconnect.8 b/man/man8/tcpconnect.8
|
1076
1104
|
index 0ea84686..04952d74 100644
|
1077
1105
|
--- a/man/man8/tcpconnect.8
|
@@ -1138,7 +1166,7 @@ index 0b643d11..aebdab73 100644
|
|
1138
1166
|
Brendan Gregg
|
1139
1167
|
.SH SEE ALSO
|
1140
1168
|
diff --git a/man/man8/tcprtt.8 b/man/man8/tcprtt.8
|
1141
|
-
index
|
1169
|
+
index fcd8bfe9..4ee6b8b5 100644
|
1142
1170
|
--- a/man/man8/tcprtt.8
|
1143
1171
|
+++ b/man/man8/tcprtt.8
|
1144
1172
|
@@ -95,8 +95,6 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
@@ -1241,10 +1269,10 @@ index da5edf37..f7e459da 100644
|
|
1241
1269
|
.SH AUTHOR
|
1242
1270
|
Sasha Goldshtein
|
1243
1271
|
diff --git a/man/man8/trace.8 b/man/man8/trace.8
|
1244
|
-
index
|
1272
|
+
index c4417e5f..bd1b11b2 100644
|
1245
1273
|
--- a/man/man8/trace.8
|
1246
1274
|
+++ b/man/man8/trace.8
|
1247
|
-
@@ -
|
1275
|
+
@@ -217,7 +217,5 @@ Also look in the bcc distribution for a companion _examples.txt file containing
|
1248
1276
|
example usage, output, and commentary for this tool.
|
1249
1277
|
.SH OS
|
1250
1278
|
Linux
|
@@ -1448,5 +1476,5 @@ index d1e2f9c1..31d382f6 100644
|
|
1448
1476
|
Brendan Gregg
|
1449
1477
|
.SH SEE ALSO
|
1450
1478
|
--
|
1451
|
-
2.
|
1479
|
+
2.38.1
|
1452
1480
|
|
@@ -0,0 +1,684 @@
|
|
1
|
+
From 66d9bffa99738bbed50b3d5b2d87990cdb5e4a58 Mon Sep 17 00:00:00 2001
|
2
|
+
From: Jerome Marchand <jmarchan@redhat.com>
|
3
|
+
Date: Mon, 28 Nov 2022 12:23:59 +0100
|
4
|
+
Subject: [PATCH] RHEL: libbpf version fixes
|
5
|
+
|
6
|
+
Revert "[bcc] stop using deprecated `bpf_load_program_attr`"
|
7
|
+
Revert "backport `struct bpf_create_map_attr`"
|
8
|
+
Revert "bcc: Replace deprecated libbpf API"
|
9
|
+
|
10
|
+
Revert "bcc: Replace deprecated libbpf APIs" since the libbpf version
|
11
|
+
provided in RHEL 8 doesn't provide the new APIs.
|
12
|
+
|
13
|
+
Remove BPF_MAP_TYPE_BLOOM_FILTER from bps since the libbpf version in
|
14
|
+
RHEL 8, doesn't provide bloom filter map.
|
15
|
+
|
16
|
+
Rename btf__load_vmlinux_btf into libbpf_find_kernel_btf. The function
|
17
|
+
has been renamed upstream for naming consistency, but RHEL 8 libbpf
|
18
|
+
still uses the old name.
|
19
|
+
|
20
|
+
Also use the older btf__get_nr_types() instead of btf__type_cnt() for
|
21
|
+
the same reason.
|
22
|
+
|
23
|
+
Add definition of struct bpf_core_relo.
|
24
|
+
---
|
25
|
+
introspection/bps.c | 1 -
|
26
|
+
libbpf-tools/ksnoop.c | 4 +-
|
27
|
+
src/cc/bcc_btf.cc | 73 +++++++++++++++-
|
28
|
+
src/cc/bpf_module.cc | 38 ++++----
|
29
|
+
src/cc/common.cc | 4 +-
|
30
|
+
src/cc/libbpf.c | 196 +++++++++++++++---------------------------
|
31
|
+
src/cc/libbpf.h | 28 ++----
|
32
|
+
7 files changed, 169 insertions(+), 175 deletions(-)
|
33
|
+
|
34
|
+
diff --git a/introspection/bps.c b/introspection/bps.c
|
35
|
+
index 232b23d4..6ec02e6c 100644
|
36
|
+
--- a/introspection/bps.c
|
37
|
+
+++ b/introspection/bps.c
|
38
|
+
@@ -80,7 +80,6 @@ static const char * const map_type_strings[] = {
|
39
|
+
[BPF_MAP_TYPE_RINGBUF] = "ringbuf",
|
40
|
+
[BPF_MAP_TYPE_INODE_STORAGE] = "inode_storage",
|
41
|
+
[BPF_MAP_TYPE_TASK_STORAGE] = "task_storage",
|
42
|
+
- [BPF_MAP_TYPE_BLOOM_FILTER] = "bloom_filter",
|
43
|
+
};
|
44
|
+
|
45
|
+
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
46
|
+
diff --git a/libbpf-tools/ksnoop.c b/libbpf-tools/ksnoop.c
|
47
|
+
index 87fe175c..960e901b 100644
|
48
|
+
--- a/libbpf-tools/ksnoop.c
|
49
|
+
+++ b/libbpf-tools/ksnoop.c
|
50
|
+
@@ -347,7 +347,7 @@ static struct btf *get_btf(const char *name)
|
51
|
+
name && strlen(name) > 0 ? name : "vmlinux");
|
52
|
+
|
53
|
+
if (!vmlinux_btf) {
|
54
|
+
- vmlinux_btf = btf__load_vmlinux_btf();
|
55
|
+
+ vmlinux_btf = libbpf_find_kernel_btf();
|
56
|
+
if (!vmlinux_btf) {
|
57
|
+
err = -errno;
|
58
|
+
p_err("No BTF, cannot determine type info: %s", strerror(-err));
|
59
|
+
@@ -357,7 +357,7 @@ static struct btf *get_btf(const char *name)
|
60
|
+
if (!name || strlen(name) == 0)
|
61
|
+
return vmlinux_btf;
|
62
|
+
|
63
|
+
- mod_btf = btf__load_module_btf(name, vmlinux_btf);
|
64
|
+
+ mod_btf = libbpf_find_kernel_btf(name, vmlinux_btf);
|
65
|
+
if (!mod_btf) {
|
66
|
+
err = -errno;
|
67
|
+
p_err("No BTF for module '%s': %s", name, strerror(-err));
|
68
|
+
diff --git a/src/cc/bcc_btf.cc b/src/cc/bcc_btf.cc
|
69
|
+
index be248612..74fc902c 100644
|
70
|
+
--- a/src/cc/bcc_btf.cc
|
71
|
+
+++ b/src/cc/bcc_btf.cc
|
72
|
+
@@ -170,6 +170,77 @@ static int btf_ext_setup_line_info(struct btf_ext *btf_ext)
|
73
|
+
return btf_ext_setup_info(btf_ext, ¶m);
|
74
|
+
}
|
75
|
+
|
76
|
+
+/* bpf_core_relo_kind encodes which aspect of captured field/type/enum value
|
77
|
+
+ * has to be adjusted by relocations.
|
78
|
+
+ */
|
79
|
+
+enum bpf_core_relo_kind {
|
80
|
+
+ BPF_FIELD_BYTE_OFFSET = 0, /* field byte offset */
|
81
|
+
+ BPF_FIELD_BYTE_SIZE = 1, /* field size in bytes */
|
82
|
+
+ BPF_FIELD_EXISTS = 2, /* field existence in target kernel */
|
83
|
+
+ BPF_FIELD_SIGNED = 3, /* field signedness (0 - unsigned, 1 - signed) */
|
84
|
+
+ BPF_FIELD_LSHIFT_U64 = 4, /* bitfield-specific left bitshift */
|
85
|
+
+ BPF_FIELD_RSHIFT_U64 = 5, /* bitfield-specific right bitshift */
|
86
|
+
+ BPF_TYPE_ID_LOCAL = 6, /* type ID in local BPF object */
|
87
|
+
+ BPF_TYPE_ID_TARGET = 7, /* type ID in target kernel */
|
88
|
+
+ BPF_TYPE_EXISTS = 8, /* type existence in target kernel */
|
89
|
+
+ BPF_TYPE_SIZE = 9, /* type size in bytes */
|
90
|
+
+ BPF_ENUMVAL_EXISTS = 10, /* enum value existence in target kernel */
|
91
|
+
+ BPF_ENUMVAL_VALUE = 11, /* enum value integer value */
|
92
|
+
+};
|
93
|
+
+
|
94
|
+
+/* The minimum bpf_core_relo checked by the loader
|
95
|
+
+ *
|
96
|
+
+ * CO-RE relocation captures the following data:
|
97
|
+
+ * - insn_off - instruction offset (in bytes) within a BPF program that needs
|
98
|
+
+ * its insn->imm field to be relocated with actual field info;
|
99
|
+
+ * - type_id - BTF type ID of the "root" (containing) entity of a relocatable
|
100
|
+
+ * type or field;
|
101
|
+
+ * - access_str_off - offset into corresponding .BTF string section. String
|
102
|
+
+ * interpretation depends on specific relocation kind:
|
103
|
+
+ * - for field-based relocations, string encodes an accessed field using
|
104
|
+
+ * a sequence of field and array indices, separated by colon (:). It's
|
105
|
+
+ * conceptually very close to LLVM's getelementptr ([0]) instruction's
|
106
|
+
+ * arguments for identifying offset to a field.
|
107
|
+
+ * - for type-based relocations, strings is expected to be just "0";
|
108
|
+
+ * - for enum value-based relocations, string contains an index of enum
|
109
|
+
+ * value within its enum type;
|
110
|
+
+ *
|
111
|
+
+ * Example to provide a better feel.
|
112
|
+
+ *
|
113
|
+
+ * struct sample {
|
114
|
+
+ * int a;
|
115
|
+
+ * struct {
|
116
|
+
+ * int b[10];
|
117
|
+
+ * };
|
118
|
+
+ * };
|
119
|
+
+ *
|
120
|
+
+ * struct sample *s = ...;
|
121
|
+
+ * int x = &s->a; // encoded as "0:0" (a is field #0)
|
122
|
+
+ * int y = &s->b[5]; // encoded as "0:1:0:5" (anon struct is field #1,
|
123
|
+
+ * // b is field #0 inside anon struct, accessing elem #5)
|
124
|
+
+ * int z = &s[10]->b; // encoded as "10:1" (ptr is used as an array)
|
125
|
+
+ *
|
126
|
+
+ * type_id for all relocs in this example will capture BTF type id of
|
127
|
+
+ * `struct sample`.
|
128
|
+
+ *
|
129
|
+
+ * Such relocation is emitted when using __builtin_preserve_access_index()
|
130
|
+
+ * Clang built-in, passing expression that captures field address, e.g.:
|
131
|
+
+ *
|
132
|
+
+ * bpf_probe_read(&dst, sizeof(dst),
|
133
|
+
+ * __builtin_preserve_access_index(&src->a.b.c));
|
134
|
+
+ *
|
135
|
+
+ * In this case Clang will emit field relocation recording necessary data to
|
136
|
+
+ * be able to find offset of embedded `a.b.c` field within `src` struct.
|
137
|
+
+ *
|
138
|
+
+ * [0] https://llvm.org/docs/LangRef.html#getelementptr-instruction
|
139
|
+
+ */
|
140
|
+
+struct bpf_core_relo {
|
141
|
+
+ __u32 insn_off;
|
142
|
+
+ __u32 type_id;
|
143
|
+
+ __u32 access_str_off;
|
144
|
+
+ enum bpf_core_relo_kind kind;
|
145
|
+
+};
|
146
|
+
+
|
147
|
+
static int btf_ext_setup_core_relos(struct btf_ext *btf_ext)
|
148
|
+
{
|
149
|
+
struct btf_ext_sec_setup_param param = {
|
150
|
+
@@ -597,7 +668,7 @@ int BTF::load(uint8_t *btf_sec, uintptr_t btf_sec_size,
|
151
|
+
return -1;
|
152
|
+
}
|
153
|
+
|
154
|
+
- if (btf__load_into_kernel(btf)) {
|
155
|
+
+ if (btf__load(btf)) {
|
156
|
+
btf__free(btf);
|
157
|
+
warning("Loading .BTF section failed\n");
|
158
|
+
return -1;
|
159
|
+
diff --git a/src/cc/bpf_module.cc b/src/cc/bpf_module.cc
|
160
|
+
index 86f6a228..490fffe8 100644
|
161
|
+
--- a/src/cc/bpf_module.cc
|
162
|
+
+++ b/src/cc/bpf_module.cc
|
163
|
+
@@ -407,7 +407,7 @@ int BPFModule::create_maps(std::map<std::string, std::pair<int, int>> &map_tids,
|
164
|
+
}
|
165
|
+
|
166
|
+
if (pinned_id <= 0) {
|
167
|
+
- struct bcc_create_map_attr attr = {};
|
168
|
+
+ struct bpf_create_map_attr attr = {};
|
169
|
+
attr.map_type = (enum bpf_map_type)map_type;
|
170
|
+
attr.name = map_name;
|
171
|
+
attr.key_size = key_size;
|
172
|
+
@@ -982,22 +982,26 @@ int BPFModule::bcc_func_load(int prog_type, const char *name,
|
173
|
+
const char *license, unsigned kern_version,
|
174
|
+
int log_level, char *log_buf, unsigned log_buf_size,
|
175
|
+
const char *dev_name, unsigned flags, int expected_attach_type) {
|
176
|
+
- struct bpf_prog_load_opts opts = {};
|
177
|
+
+ struct bpf_load_program_attr attr = {};
|
178
|
+
unsigned func_info_cnt, line_info_cnt, finfo_rec_size, linfo_rec_size;
|
179
|
+
void *func_info = NULL, *line_info = NULL;
|
180
|
+
int ret;
|
181
|
+
|
182
|
+
+ attr.prog_type = (enum bpf_prog_type)prog_type;
|
183
|
+
if (expected_attach_type != -1) {
|
184
|
+
- opts.expected_attach_type = (enum bpf_attach_type)expected_attach_type;
|
185
|
+
+ attr.expected_attach_type = (enum bpf_attach_type)expected_attach_type;
|
186
|
+
}
|
187
|
+
- if (prog_type != BPF_PROG_TYPE_TRACING &&
|
188
|
+
- prog_type != BPF_PROG_TYPE_EXT) {
|
189
|
+
- opts.kern_version = kern_version;
|
190
|
+
+ attr.name = name;
|
191
|
+
+ attr.insns = insns;
|
192
|
+
+ attr.license = license;
|
193
|
+
+ if (attr.prog_type != BPF_PROG_TYPE_TRACING &&
|
194
|
+
+ attr.prog_type != BPF_PROG_TYPE_EXT) {
|
195
|
+
+ attr.kern_version = kern_version;
|
196
|
+
}
|
197
|
+
- opts.prog_flags = flags;
|
198
|
+
- opts.log_level = log_level;
|
199
|
+
+ attr.prog_flags = flags;
|
200
|
+
+ attr.log_level = log_level;
|
201
|
+
if (dev_name)
|
202
|
+
- opts.prog_ifindex = if_nametoindex(dev_name);
|
203
|
+
+ attr.prog_ifindex = if_nametoindex(dev_name);
|
204
|
+
|
205
|
+
if (btf_) {
|
206
|
+
int btf_fd = btf_->get_fd();
|
207
|
+
@@ -1008,17 +1012,17 @@ int BPFModule::bcc_func_load(int prog_type, const char *name,
|
208
|
+
&finfo_rec_size, &line_info,
|
209
|
+
&line_info_cnt, &linfo_rec_size);
|
210
|
+
if (!ret) {
|
211
|
+
- opts.prog_btf_fd = btf_fd;
|
212
|
+
- opts.func_info = func_info;
|
213
|
+
- opts.func_info_cnt = func_info_cnt;
|
214
|
+
- opts.func_info_rec_size = finfo_rec_size;
|
215
|
+
- opts.line_info = line_info;
|
216
|
+
- opts.line_info_cnt = line_info_cnt;
|
217
|
+
- opts.line_info_rec_size = linfo_rec_size;
|
218
|
+
+ attr.prog_btf_fd = btf_fd;
|
219
|
+
+ attr.func_info = func_info;
|
220
|
+
+ attr.func_info_cnt = func_info_cnt;
|
221
|
+
+ attr.func_info_rec_size = finfo_rec_size;
|
222
|
+
+ attr.line_info = line_info;
|
223
|
+
+ attr.line_info_cnt = line_info_cnt;
|
224
|
+
+ attr.line_info_rec_size = linfo_rec_size;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
- ret = bcc_prog_load_xattr((enum bpf_prog_type)prog_type, name, license, insns, &opts, prog_len, log_buf, log_buf_size, allow_rlimit_);
|
229
|
+
+ ret = bcc_prog_load_xattr(&attr, prog_len, log_buf, log_buf_size, allow_rlimit_);
|
230
|
+
if (btf_) {
|
231
|
+
free(func_info);
|
232
|
+
free(line_info);
|
233
|
+
diff --git a/src/cc/common.cc b/src/cc/common.cc
|
234
|
+
index 3143adb0..11970275 100644
|
235
|
+
--- a/src/cc/common.cc
|
236
|
+
+++ b/src/cc/common.cc
|
237
|
+
@@ -34,11 +34,11 @@ using std::experimental::optional;
|
238
|
+
static optional<int32_t> get_enum_val_from_btf(const char *name) {
|
239
|
+
optional<int32_t> val;
|
240
|
+
|
241
|
+
- auto btf = btf__load_vmlinux_btf();
|
242
|
+
+ auto btf = libbpf_find_kernel_btf();
|
243
|
+
if (libbpf_get_error(btf))
|
244
|
+
return {};
|
245
|
+
|
246
|
+
- for (size_t i = 1; i < btf__type_cnt(btf); i++) {
|
247
|
+
+ for (size_t i = 1; i <= btf__get_nr_types(btf); i++) {
|
248
|
+
auto t = btf__type_by_id(btf, i);
|
249
|
+
if (btf_kind(t) != BTF_KIND_ENUM)
|
250
|
+
continue;
|
251
|
+
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
|
252
|
+
index 0c09f9b3..7042c792 100644
|
253
|
+
--- a/src/cc/libbpf.c
|
254
|
+
+++ b/src/cc/libbpf.c
|
255
|
+
@@ -319,33 +319,14 @@ static uint64_t ptr_to_u64(void *ptr)
|
256
|
+
return (uint64_t) (unsigned long) ptr;
|
257
|
+
}
|
258
|
+
|
259
|
+
-static int libbpf_bpf_map_create(struct bcc_create_map_attr *create_attr)
|
260
|
+
-{
|
261
|
+
- LIBBPF_OPTS(bpf_map_create_opts, p);
|
262
|
+
-
|
263
|
+
- p.map_flags = create_attr->map_flags;
|
264
|
+
- p.numa_node = create_attr->numa_node;
|
265
|
+
- p.btf_fd = create_attr->btf_fd;
|
266
|
+
- p.btf_key_type_id = create_attr->btf_key_type_id;
|
267
|
+
- p.btf_value_type_id = create_attr->btf_value_type_id;
|
268
|
+
- p.map_ifindex = create_attr->map_ifindex;
|
269
|
+
- if (create_attr->map_type == BPF_MAP_TYPE_STRUCT_OPS)
|
270
|
+
- p.btf_vmlinux_value_type_id = create_attr->btf_vmlinux_value_type_id;
|
271
|
+
- else
|
272
|
+
- p.inner_map_fd = create_attr->inner_map_fd;
|
273
|
+
-
|
274
|
+
- return bpf_map_create(create_attr->map_type, create_attr->name, create_attr->key_size,
|
275
|
+
- create_attr->value_size, create_attr->max_entries, &p);
|
276
|
+
-}
|
277
|
+
-
|
278
|
+
-int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
279
|
+
+int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit)
|
280
|
+
{
|
281
|
+
unsigned name_len = attr->name ? strlen(attr->name) : 0;
|
282
|
+
char map_name[BPF_OBJ_NAME_LEN] = {};
|
283
|
+
|
284
|
+
memcpy(map_name, attr->name, min(name_len, BPF_OBJ_NAME_LEN - 1));
|
285
|
+
attr->name = map_name;
|
286
|
+
- int ret = libbpf_bpf_map_create(attr);
|
287
|
+
+ int ret = bpf_create_map_xattr(attr);
|
288
|
+
|
289
|
+
if (ret < 0 && errno == EPERM) {
|
290
|
+
if (!allow_rlimit)
|
291
|
+
@@ -357,7 +338,7 @@ int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
292
|
+
rl.rlim_max = RLIM_INFINITY;
|
293
|
+
rl.rlim_cur = rl.rlim_max;
|
294
|
+
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
295
|
+
- ret = libbpf_bpf_map_create(attr);
|
296
|
+
+ ret = bpf_create_map_xattr(attr);
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
@@ -367,12 +348,12 @@ int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
301
|
+
attr->btf_fd = 0;
|
302
|
+
attr->btf_key_type_id = 0;
|
303
|
+
attr->btf_value_type_id = 0;
|
304
|
+
- ret = libbpf_bpf_map_create(attr);
|
305
|
+
+ ret = bpf_create_map_xattr(attr);
|
306
|
+
}
|
307
|
+
|
308
|
+
if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) {
|
309
|
+
map_name[0] = '\0';
|
310
|
+
- ret = libbpf_bpf_map_create(attr);
|
311
|
+
+ ret = bpf_create_map_xattr(attr);
|
312
|
+
}
|
313
|
+
|
314
|
+
if (ret < 0 && errno == EPERM) {
|
315
|
+
@@ -385,7 +366,7 @@ int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit)
|
316
|
+
rl.rlim_max = RLIM_INFINITY;
|
317
|
+
rl.rlim_cur = rl.rlim_max;
|
318
|
+
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
319
|
+
- ret = libbpf_bpf_map_create(attr);
|
320
|
+
+ ret = bpf_create_map_xattr(attr);
|
321
|
+
}
|
322
|
+
}
|
323
|
+
return ret;
|
324
|
+
@@ -395,7 +376,7 @@ int bcc_create_map(enum bpf_map_type map_type, const char *name,
|
325
|
+
int key_size, int value_size,
|
326
|
+
int max_entries, int map_flags)
|
327
|
+
{
|
328
|
+
- struct bcc_create_map_attr attr = {};
|
329
|
+
+ struct bpf_create_map_attr attr = {};
|
330
|
+
|
331
|
+
attr.map_type = map_type;
|
332
|
+
attr.name = name;
|
333
|
+
@@ -644,70 +625,24 @@ int bpf_prog_get_tag(int fd, unsigned long long *ptag)
|
334
|
+
return -2;
|
335
|
+
}
|
336
|
+
|
337
|
+
-static int libbpf_bpf_prog_load(enum bpf_prog_type prog_type,
|
338
|
+
- const char *prog_name, const char *license,
|
339
|
+
- const struct bpf_insn *insns, size_t insn_cnt,
|
340
|
+
- struct bpf_prog_load_opts *opts,
|
341
|
+
- char *log_buf, size_t log_buf_sz)
|
342
|
+
-{
|
343
|
+
-
|
344
|
+
- LIBBPF_OPTS(bpf_prog_load_opts, p);
|
345
|
+
-
|
346
|
+
- if (!opts || !log_buf != !log_buf_sz) {
|
347
|
+
- errno = EINVAL;
|
348
|
+
- return -EINVAL;
|
349
|
+
- }
|
350
|
+
-
|
351
|
+
- p.expected_attach_type = opts->expected_attach_type;
|
352
|
+
- switch (prog_type) {
|
353
|
+
- case BPF_PROG_TYPE_STRUCT_OPS:
|
354
|
+
- case BPF_PROG_TYPE_LSM:
|
355
|
+
- p.attach_btf_id = opts->attach_btf_id;
|
356
|
+
- break;
|
357
|
+
- case BPF_PROG_TYPE_TRACING:
|
358
|
+
- case BPF_PROG_TYPE_EXT:
|
359
|
+
- p.attach_btf_id = opts->attach_btf_id;
|
360
|
+
- p.attach_prog_fd = opts->attach_prog_fd;
|
361
|
+
- break;
|
362
|
+
- default:
|
363
|
+
- p.prog_ifindex = opts->prog_ifindex;
|
364
|
+
- p.kern_version = opts->kern_version;
|
365
|
+
- }
|
366
|
+
- p.log_level = opts->log_level;
|
367
|
+
- p.log_buf = log_buf;
|
368
|
+
- p.log_size = log_buf_sz;
|
369
|
+
- p.prog_btf_fd = opts->prog_btf_fd;
|
370
|
+
- p.func_info_rec_size = opts->func_info_rec_size;
|
371
|
+
- p.func_info_cnt = opts->func_info_cnt;
|
372
|
+
- p.func_info = opts->func_info;
|
373
|
+
- p.line_info_rec_size = opts->line_info_rec_size;
|
374
|
+
- p.line_info_cnt = opts->line_info_cnt;
|
375
|
+
- p.line_info = opts->line_info;
|
376
|
+
- p.prog_flags = opts->prog_flags;
|
377
|
+
-
|
378
|
+
- return bpf_prog_load(prog_type, prog_name, license,
|
379
|
+
- insns, insn_cnt, &p);
|
380
|
+
-}
|
381
|
+
-
|
382
|
+
-int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
383
|
+
- const char *license, const struct bpf_insn *insns,
|
384
|
+
- struct bpf_prog_load_opts *opts, int prog_len,
|
385
|
+
+int bcc_prog_load_xattr(struct bpf_load_program_attr *attr, int prog_len,
|
386
|
+
char *log_buf, unsigned log_buf_size, bool allow_rlimit)
|
387
|
+
{
|
388
|
+
- unsigned name_len = prog_name ? strlen(prog_name) : 0;
|
389
|
+
- char *tmp_log_buf = NULL, *opts_log_buf = NULL;
|
390
|
+
- unsigned tmp_log_buf_size = 0, opts_log_buf_size = 0;
|
391
|
+
+ unsigned name_len = attr->name ? strlen(attr->name) : 0;
|
392
|
+
+ char *tmp_log_buf = NULL, *attr_log_buf = NULL;
|
393
|
+
+ unsigned tmp_log_buf_size = 0, attr_log_buf_size = 0;
|
394
|
+
int ret = 0, name_offset = 0, expected_attach_type = 0;
|
395
|
+
- char new_prog_name[BPF_OBJ_NAME_LEN] = {};
|
396
|
+
+ char prog_name[BPF_OBJ_NAME_LEN] = {};
|
397
|
+
|
398
|
+
unsigned insns_cnt = prog_len / sizeof(struct bpf_insn);
|
399
|
+
+ attr->insns_cnt = insns_cnt;
|
400
|
+
|
401
|
+
- if (opts->log_level > 0) {
|
402
|
+
+ if (attr->log_level > 0) {
|
403
|
+
if (log_buf_size > 0) {
|
404
|
+
// Use user-provided log buffer if available.
|
405
|
+
log_buf[0] = 0;
|
406
|
+
- opts_log_buf = log_buf;
|
407
|
+
- opts_log_buf_size = log_buf_size;
|
408
|
+
+ attr_log_buf = log_buf;
|
409
|
+
+ attr_log_buf_size = log_buf_size;
|
410
|
+
} else {
|
411
|
+
// Create and use temporary log buffer if user didn't provide one.
|
412
|
+
tmp_log_buf_size = LOG_BUF_SIZE;
|
413
|
+
@@ -715,82 +650,82 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
414
|
+
if (!tmp_log_buf) {
|
415
|
+
fprintf(stderr, "bpf: Failed to allocate temporary log buffer: %s\n\n",
|
416
|
+
strerror(errno));
|
417
|
+
- opts->log_level = 0;
|
418
|
+
+ attr->log_level = 0;
|
419
|
+
} else {
|
420
|
+
tmp_log_buf[0] = 0;
|
421
|
+
- opts_log_buf = tmp_log_buf;
|
422
|
+
- opts_log_buf_size = tmp_log_buf_size;
|
423
|
+
+ attr_log_buf = tmp_log_buf;
|
424
|
+
+ attr_log_buf_size = tmp_log_buf_size;
|
425
|
+
}
|
426
|
+
}
|
427
|
+
}
|
428
|
+
|
429
|
+
-
|
430
|
+
if (name_len) {
|
431
|
+
- if (strncmp(prog_name, "kprobe__", 8) == 0)
|
432
|
+
+ if (strncmp(attr->name, "kprobe__", 8) == 0)
|
433
|
+
name_offset = 8;
|
434
|
+
- else if (strncmp(prog_name, "kretprobe__", 11) == 0)
|
435
|
+
+ else if (strncmp(attr->name, "kretprobe__", 11) == 0)
|
436
|
+
name_offset = 11;
|
437
|
+
- else if (strncmp(prog_name, "tracepoint__", 12) == 0)
|
438
|
+
+ else if (strncmp(attr->name, "tracepoint__", 12) == 0)
|
439
|
+
name_offset = 12;
|
440
|
+
- else if (strncmp(prog_name, "raw_tracepoint__", 16) == 0)
|
441
|
+
+ else if (strncmp(attr->name, "raw_tracepoint__", 16) == 0)
|
442
|
+
name_offset = 16;
|
443
|
+
- else if (strncmp(prog_name, "kfunc__", 7) == 0) {
|
444
|
+
+ else if (strncmp(attr->name, "kfunc__", 7) == 0) {
|
445
|
+
name_offset = 7;
|
446
|
+
expected_attach_type = BPF_TRACE_FENTRY;
|
447
|
+
- } else if (strncmp(prog_name, "kmod_ret__", 10) == 0) {
|
448
|
+
+ } else if (strncmp(attr->name, "kmod_ret__", 10) == 0) {
|
449
|
+
name_offset = 10;
|
450
|
+
expected_attach_type = BPF_MODIFY_RETURN;
|
451
|
+
- } else if (strncmp(prog_name, "kretfunc__", 10) == 0) {
|
452
|
+
+ } else if (strncmp(attr->name, "kretfunc__", 10) == 0) {
|
453
|
+
name_offset = 10;
|
454
|
+
expected_attach_type = BPF_TRACE_FEXIT;
|
455
|
+
- } else if (strncmp(prog_name, "lsm__", 5) == 0) {
|
456
|
+
+ } else if (strncmp(attr->name, "lsm__", 5) == 0) {
|
457
|
+
name_offset = 5;
|
458
|
+
expected_attach_type = BPF_LSM_MAC;
|
459
|
+
- } else if (strncmp(prog_name, "bpf_iter__", 10) == 0) {
|
460
|
+
+ } else if (strncmp(attr->name, "bpf_iter__", 10) == 0) {
|
461
|
+
name_offset = 10;
|
462
|
+
expected_attach_type = BPF_TRACE_ITER;
|
463
|
+
}
|
464
|
+
|
465
|
+
- if (prog_type == BPF_PROG_TYPE_TRACING ||
|
466
|
+
- prog_type == BPF_PROG_TYPE_LSM) {
|
467
|
+
- ret = libbpf_find_vmlinux_btf_id(prog_name + name_offset,
|
468
|
+
+ if (attr->prog_type == BPF_PROG_TYPE_TRACING ||
|
469
|
+
+ attr->prog_type == BPF_PROG_TYPE_LSM) {
|
470
|
+
+ ret = libbpf_find_vmlinux_btf_id(attr->name + name_offset,
|
471
|
+
expected_attach_type);
|
472
|
+
if (ret == -EINVAL) {
|
473
|
+
fprintf(stderr, "bpf: vmlinux BTF is not found\n");
|
474
|
+
return ret;
|
475
|
+
} else if (ret < 0) {
|
476
|
+
fprintf(stderr, "bpf: %s is not found in vmlinux BTF\n",
|
477
|
+
- prog_name + name_offset);
|
478
|
+
+ attr->name + name_offset);
|
479
|
+
return ret;
|
480
|
+
}
|
481
|
+
|
482
|
+
- opts->attach_btf_id = ret;
|
483
|
+
- opts->expected_attach_type = expected_attach_type;
|
484
|
+
+ attr->attach_btf_id = ret;
|
485
|
+
+ attr->expected_attach_type = expected_attach_type;
|
486
|
+
}
|
487
|
+
|
488
|
+
- memcpy(new_prog_name, prog_name + name_offset,
|
489
|
+
+ memcpy(prog_name, attr->name + name_offset,
|
490
|
+
min(name_len - name_offset, BPF_OBJ_NAME_LEN - 1));
|
491
|
+
+ attr->name = prog_name;
|
492
|
+
}
|
493
|
+
|
494
|
+
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
495
|
+
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
496
|
+
|
497
|
+
// func_info/line_info may not be supported in old kernels.
|
498
|
+
- if (ret < 0 && opts->func_info && errno == EINVAL) {
|
499
|
+
- opts->prog_btf_fd = 0;
|
500
|
+
- opts->func_info = NULL;
|
501
|
+
- opts->func_info_cnt = 0;
|
502
|
+
- opts->func_info_rec_size = 0;
|
503
|
+
- opts->line_info = NULL;
|
504
|
+
- opts->line_info_cnt = 0;
|
505
|
+
- opts->line_info_rec_size = 0;
|
506
|
+
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
507
|
+
+ if (ret < 0 && attr->func_info && errno == EINVAL) {
|
508
|
+
+ attr->prog_btf_fd = 0;
|
509
|
+
+ attr->func_info = NULL;
|
510
|
+
+ attr->func_info_cnt = 0;
|
511
|
+
+ attr->func_info_rec_size = 0;
|
512
|
+
+ attr->line_info = NULL;
|
513
|
+
+ attr->line_info_cnt = 0;
|
514
|
+
+ attr->line_info_rec_size = 0;
|
515
|
+
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
516
|
+
}
|
517
|
+
|
518
|
+
// BPF object name is not supported on older Kernels.
|
519
|
+
// If we failed due to this, clear the name and try again.
|
520
|
+
if (ret < 0 && name_len && (errno == E2BIG || errno == EINVAL)) {
|
521
|
+
- new_prog_name[0] = '\0';
|
522
|
+
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
523
|
+
+ prog_name[0] = '\0';
|
524
|
+
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
525
|
+
}
|
526
|
+
|
527
|
+
if (ret < 0 && errno == EPERM) {
|
528
|
+
@@ -809,14 +744,14 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
529
|
+
rl.rlim_max = RLIM_INFINITY;
|
530
|
+
rl.rlim_cur = rl.rlim_max;
|
531
|
+
if (setrlimit(RLIMIT_MEMLOCK, &rl) == 0)
|
532
|
+
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, opts_log_buf, opts_log_buf_size);
|
533
|
+
+ ret = bpf_load_program_xattr(attr, attr_log_buf, attr_log_buf_size);
|
534
|
+
}
|
535
|
+
}
|
536
|
+
|
537
|
+
if (ret < 0 && errno == E2BIG) {
|
538
|
+
fprintf(stderr,
|
539
|
+
"bpf: %s. Program %s too large (%u insns), at most %d insns\n\n",
|
540
|
+
- strerror(errno), new_prog_name, insns_cnt, BPF_MAXINSNS);
|
541
|
+
+ strerror(errno), attr->name, insns_cnt, BPF_MAXINSNS);
|
542
|
+
return -1;
|
543
|
+
}
|
544
|
+
|
545
|
+
@@ -825,9 +760,9 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
546
|
+
// User has provided a log buffer.
|
547
|
+
if (log_buf_size) {
|
548
|
+
// If logging is not already enabled, enable it and do the syscall again.
|
549
|
+
- if (opts->log_level == 0) {
|
550
|
+
- opts->log_level = 1;
|
551
|
+
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, log_buf, log_buf_size);
|
552
|
+
+ if (attr->log_level == 0) {
|
553
|
+
+ attr->log_level = 1;
|
554
|
+
+ ret = bpf_load_program_xattr(attr, log_buf, log_buf_size);
|
555
|
+
}
|
556
|
+
// Print the log message and return.
|
557
|
+
bpf_print_hints(ret, log_buf);
|
558
|
+
@@ -841,8 +776,8 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
559
|
+
if (tmp_log_buf)
|
560
|
+
free(tmp_log_buf);
|
561
|
+
tmp_log_buf_size = LOG_BUF_SIZE;
|
562
|
+
- if (opts->log_level == 0)
|
563
|
+
- opts->log_level = 1;
|
564
|
+
+ if (attr->log_level == 0)
|
565
|
+
+ attr->log_level = 1;
|
566
|
+
for (;;) {
|
567
|
+
tmp_log_buf = malloc(tmp_log_buf_size);
|
568
|
+
if (!tmp_log_buf) {
|
569
|
+
@@ -851,7 +786,7 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
570
|
+
goto return_result;
|
571
|
+
}
|
572
|
+
tmp_log_buf[0] = 0;
|
573
|
+
- ret = libbpf_bpf_prog_load(prog_type, new_prog_name, license, insns, insns_cnt, opts, tmp_log_buf, tmp_log_buf_size);
|
574
|
+
+ ret = bpf_load_program_xattr(attr, tmp_log_buf, tmp_log_buf_size);
|
575
|
+
if (ret < 0 && errno == ENOSPC) {
|
576
|
+
// Temporary buffer size is not enough. Double it and try again.
|
577
|
+
free(tmp_log_buf);
|
578
|
+
@@ -865,7 +800,7 @@ int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
579
|
+
|
580
|
+
// Check if we should print the log message if log_level is not 0,
|
581
|
+
// either specified by user or set due to error.
|
582
|
+
- if (opts->log_level > 0) {
|
583
|
+
+ if (attr->log_level > 0) {
|
584
|
+
// Don't print if user enabled logging and provided log buffer,
|
585
|
+
// but there is no error.
|
586
|
+
if (log_buf && ret < 0)
|
587
|
+
@@ -885,13 +820,16 @@ int bcc_prog_load(enum bpf_prog_type prog_type, const char *name,
|
588
|
+
const char *license, unsigned kern_version,
|
589
|
+
int log_level, char *log_buf, unsigned log_buf_size)
|
590
|
+
{
|
591
|
+
- struct bpf_prog_load_opts opts = {};
|
592
|
+
-
|
593
|
+
+ struct bpf_load_program_attr attr = {};
|
594
|
+
|
595
|
+
+ attr.prog_type = prog_type;
|
596
|
+
+ attr.name = name;
|
597
|
+
+ attr.insns = insns;
|
598
|
+
+ attr.license = license;
|
599
|
+
if (prog_type != BPF_PROG_TYPE_TRACING && prog_type != BPF_PROG_TYPE_EXT)
|
600
|
+
- opts.kern_version = kern_version;
|
601
|
+
- opts.log_level = log_level;
|
602
|
+
- return bcc_prog_load_xattr(prog_type, name, license, insns, &opts, prog_len, log_buf, log_buf_size, true);
|
603
|
+
+ attr.kern_version = kern_version;
|
604
|
+
+ attr.log_level = log_level;
|
605
|
+
+ return bcc_prog_load_xattr(&attr, prog_len, log_buf, log_buf_size, true);
|
606
|
+
}
|
607
|
+
|
608
|
+
int bpf_open_raw_sock(const char *name)
|
609
|
+
@@ -1388,7 +1326,7 @@ int kernel_struct_has_field(const char *struct_name, const char *field_name)
|
610
|
+
struct btf *btf;
|
611
|
+
int i, ret, btf_id;
|
612
|
+
|
613
|
+
- btf = btf__load_vmlinux_btf();
|
614
|
+
+ btf = libbpf_find_kernel_btf();
|
615
|
+
ret = libbpf_get_error(btf);
|
616
|
+
if (ret)
|
617
|
+
return -1;
|
618
|
+
@@ -1565,7 +1503,7 @@ int bpf_attach_xdp(const char *dev_name, int progfd, uint32_t flags) {
|
619
|
+
return -1;
|
620
|
+
}
|
621
|
+
|
622
|
+
- ret = bpf_xdp_attach(ifindex, progfd, flags, NULL);
|
623
|
+
+ ret = bpf_set_link_xdp_fd(ifindex, progfd, flags);
|
624
|
+
if (ret) {
|
625
|
+
libbpf_strerror(ret, err_buf, sizeof(err_buf));
|
626
|
+
fprintf(stderr, "bpf: Attaching prog to %s: %s\n", dev_name, err_buf);
|
627
|
+
diff --git a/src/cc/libbpf.h b/src/cc/libbpf.h
|
628
|
+
index dd86f0a9..e001d740 100644
|
629
|
+
--- a/src/cc/libbpf.h
|
630
|
+
+++ b/src/cc/libbpf.h
|
631
|
+
|
632
|
+
extern "C" {
|
633
|
+
#endif
|
634
|
+
|
635
|
+
-struct bcc_create_map_attr {
|
636
|
+
- const char *name;
|
637
|
+
- enum bpf_map_type map_type;
|
638
|
+
- __u32 map_flags;
|
639
|
+
- __u32 key_size;
|
640
|
+
- __u32 value_size;
|
641
|
+
- __u32 max_entries;
|
642
|
+
- __u32 numa_node;
|
643
|
+
- __u32 btf_fd;
|
644
|
+
- __u32 btf_key_type_id;
|
645
|
+
- __u32 btf_value_type_id;
|
646
|
+
- __u32 map_ifindex;
|
647
|
+
- union {
|
648
|
+
- __u32 inner_map_fd;
|
649
|
+
- __u32 btf_vmlinux_value_type_id;
|
650
|
+
- };
|
651
|
+
-};
|
652
|
+
-
|
653
|
+
-struct bpf_prog_load_opts;
|
654
|
+
+struct bpf_create_map_attr;
|
655
|
+
+struct bpf_load_program_attr;
|
656
|
+
|
657
|
+
enum bpf_probe_attach_type {
|
658
|
+
BPF_PROBE_ENTRY,
|
659
|
+
@@ -61,7 +44,7 @@ struct bcc_perf_buffer_opts {
|
660
|
+
int bcc_create_map(enum bpf_map_type map_type, const char *name,
|
661
|
+
int key_size, int value_size, int max_entries,
|
662
|
+
int map_flags);
|
663
|
+
-int bcc_create_map_xattr(struct bcc_create_map_attr *attr, bool allow_rlimit);
|
664
|
+
+int bcc_create_map_xattr(struct bpf_create_map_attr *attr, bool allow_rlimit);
|
665
|
+
int bpf_update_elem(int fd, void *key, void *value, unsigned long long flags);
|
666
|
+
int bpf_lookup_elem(int fd, void *key, void *value);
|
667
|
+
int bpf_delete_elem(int fd, void *key);
|
668
|
+
@@ -89,11 +72,10 @@ int bcc_prog_load(enum bpf_prog_type prog_type, const char *name,
|
669
|
+
const struct bpf_insn *insns, int prog_len,
|
670
|
+
const char *license, unsigned kern_version,
|
671
|
+
int log_level, char *log_buf, unsigned log_buf_size);
|
672
|
+
-int bcc_prog_load_xattr(enum bpf_prog_type prog_type, const char *prog_name,
|
673
|
+
- const char *license, const struct bpf_insn *insns,
|
674
|
+
- struct bpf_prog_load_opts *opts,
|
675
|
+
+int bcc_prog_load_xattr(struct bpf_load_program_attr *attr,
|
676
|
+
int prog_len, char *log_buf,
|
677
|
+
unsigned log_buf_size, bool allow_rlimit);
|
678
|
+
+
|
679
|
+
int bpf_attach_socket(int sockfd, int progfd);
|
680
|
+
|
681
|
+
/* create RAW socket. If name is not NULL/a non-empty null-terminated string,
|
682
|
+
--
|
683
|
+
2.38.1
|
684
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
From acee5d39d24b102e8ed09a242cb1c53246a1fb7f Mon Sep 17 00:00:00 2001
|
2
|
+
From: Jerome Marchand <jmarchan@redhat.com>
|
3
|
+
Date: Tue, 29 Nov 2022 15:33:49 +0100
|
4
|
+
Subject: [PATCH] Revert "tools/tcpaccept: Fix support for v5.6+ kernels"
|
5
|
+
|
6
|
+
This reverts commit 28955512d991ee3849c2a9accfc54bef9cd35f21.
|
7
|
+
|
8
|
+
It breaks tcpaccept on RHEL 8 kernel.
|
9
|
+
---
|
10
|
+
tools/tcpaccept.py | 9 ++-------
|
11
|
+
1 file changed, 2 insertions(+), 7 deletions(-)
|
12
|
+
|
13
|
+
diff --git a/tools/tcpaccept.py b/tools/tcpaccept.py
|
14
|
+
index b2ace4fa..d3e44143 100755
|
15
|
+
--- a/tools/tcpaccept.py
|
16
|
+
+++ b/tools/tcpaccept.py
|
17
|
+
@@ -116,7 +116,7 @@ int kretprobe__inet_csk_accept(struct pt_regs *ctx)
|
18
|
+
return 0;
|
19
|
+
|
20
|
+
// check this is TCP
|
21
|
+
- u16 protocol = 0;
|
22
|
+
+ u8 protocol = 0;
|
23
|
+
// workaround for reading the sk_protocol bitfield:
|
24
|
+
|
25
|
+
// Following comments add by Joe Yin:
|
26
|
+
@@ -132,12 +132,7 @@ int kretprobe__inet_csk_accept(struct pt_regs *ctx)
|
27
|
+
int gso_max_segs_offset = offsetof(struct sock, sk_gso_max_segs);
|
28
|
+
int sk_lingertime_offset = offsetof(struct sock, sk_lingertime);
|
29
|
+
|
30
|
+
-
|
31
|
+
- // Since kernel v5.6 sk_protocol is its own u16 field and gso_max_segs
|
32
|
+
- // precedes sk_lingertime.
|
33
|
+
- if (sk_lingertime_offset - gso_max_segs_offset == 2)
|
34
|
+
- protocol = newsk->sk_protocol;
|
35
|
+
- else if (sk_lingertime_offset - gso_max_segs_offset == 4)
|
36
|
+
+ if (sk_lingertime_offset - gso_max_segs_offset == 4)
|
37
|
+
// 4.10+ with little endian
|
38
|
+
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
39
|
+
protocol = *(u8 *)((u64)&newsk->sk_gso_max_segs - 3);
|
40
|
+
--
|
41
|
+
2.38.1
|
42
|
+
|
@@ -1,24 +1,30 @@
|
|
1
|
-
From
|
1
|
+
From 16277e3910c9281d807fc6d3b4ce41c62d7d265e Mon Sep 17 00:00:00 2001
|
2
2
|
From: Jerome Marchand <jmarchan@redhat.com>
|
3
3
|
Date: Thu, 19 May 2022 16:37:40 +0200
|
4
4
|
Subject: [PATCH 3/3] libbpf: Allow kernel_struct_has_field to reach field in
|
5
5
|
unnamed struct or union
|
6
6
|
|
7
|
-
Some
|
8
|
-
|
9
|
-
|
7
|
+
Some fields can belong to unnamed struct or union (e.g. rcu and
|
8
|
+
rcu_users fields of task_struct). In C, they are accessed as if their
|
9
|
+
belong directly to the parent of the unnamed struct or union but this
|
10
|
+
is not the case for BTF.
|
10
11
|
|
11
12
|
When looking for a field, kernel_struct_has_field should also look
|
12
|
-
reccursively into unnamed structs or unions.
|
13
|
+
reccursively into unnamed structs or unions. That allows code such as
|
14
|
+
the following to work as expected:
|
15
|
+
|
16
|
+
BPF.kernel_struct_has_field('task_struct', 'rcu')
|
17
|
+
|
18
|
+
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
13
19
|
---
|
14
20
|
src/cc/libbpf.c | 28 ++++++++++++++++++----------
|
15
21
|
1 file changed, 18 insertions(+), 10 deletions(-)
|
16
22
|
|
17
23
|
diff --git a/src/cc/libbpf.c b/src/cc/libbpf.c
|
18
|
-
index
|
24
|
+
index 5f7a3f68..bdfde1f5 100644
|
19
25
|
--- a/src/cc/libbpf.c
|
20
26
|
+++ b/src/cc/libbpf.c
|
21
|
-
@@ -
|
27
|
+
@@ -1319,12 +1319,27 @@ bool bpf_has_kernel_btf(void)
|
22
28
|
return true;
|
23
29
|
}
|
24
30
|
|
@@ -48,7 +54,7 @@ index 7410ae1a..e98b8852 100644
|
|
48
54
|
|
49
55
|
btf = libbpf_find_kernel_btf();
|
50
56
|
ret = libbpf_get_error(btf);
|
51
|
-
@@ -
|
57
|
+
@@ -1338,14 +1353,7 @@ int kernel_struct_has_field(const char *struct_name, const char *field_name)
|
52
58
|
}
|
53
59
|
|
54
60
|
btf_type = btf__type_by_id(btf, btf_id);
|
@@ -65,5 +71,5 @@ index 7410ae1a..e98b8852 100644
|
|
65
71
|
cleanup:
|
66
72
|
btf__free(btf);
|
67
73
|
--
|
68
|
-
2.
|
74
|
+
2.38.1
|
69
75
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
%endif
|
9
9
|
|
10
10
|
Name: bcc
|
11
|
-
Version: 0.
|
11
|
+
Version: 0.25.0
|
12
12
|
Release: 2%{?dist}
|
13
13
|
Summary: BPF Compiler Collection (BCC)
|
14
14
|
License: ASL 2.0
|
@@ -17,6 +17,10 @@ Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
|
17
17
|
Patch0: %{name}-%{version}-Manpages-remove-unstable-statement.patch
|
18
18
|
Patch1: %{name}-%{version}-RHEL-libbpf-version-fixes.patch
|
19
19
|
Patch2: %{name}-%{version}-libbpf-Allow-kernel_struct_has_field-to-reach-field-.patch
|
20
|
+
Patch3: %{name}-%{version}-Fix-bpf_pseudo_fd-type-conversion-error.patch
|
21
|
+
Patch4: %{name}-%{version}-Fix-clang-15-int-to-pointer-conversion-errors.patch
|
22
|
+
Patch5: %{name}-%{version}-Revert-tools-tcpaccept-Fix-support-for-v5.6-kernels.patch
|
23
|
+
Patch6: %{name}-%{version}-Fix-get_kprobe_functions.patch
|
20
24
|
|
21
25
|
# Arches will be included as upstream support is added and dependencies are
|
22
26
|
# satisfied in the respective arches
|
@@ -214,6 +218,13 @@ done
|
|
214
218
|
|
215
219
|
|
216
220
|
%changelog
|
221
|
+
* Tue Jan 10 2023 Jerome Marchand <jmarchan@redhat.com> - 0.25.0-2
|
222
|
+
- Fix tcpdrop tool
|
223
|
+
|
224
|
+
* Wed Nov 30 2022 Jerome Marchand <jmarchan@redhat.com> - 0.25.0-1
|
225
|
+
- Rebase to bcc-0.25.0
|
226
|
+
- Rebuild on LLVM 15
|
227
|
+
|
217
228
|
* Thu Jun 23 2022 Jerome Marchand <jmarchan@redhat.com> - 0.24.0-2
|
218
229
|
- Rebuild on libbpf 0.5.0
|
219
230
|
|