Skip to content

Commit b5ac15b

Browse files
authored
Merge pull request #24 from qmonnet/bpf_helpers_update
Update bpf_helpers.rst
2 parents 12f84ac + 03b2238 commit b5ac15b

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

bpf_helpers.rst

+44-10
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,12 @@ HELPERS
502502

503503
Also, be aware that the newer helper
504504
**bpf_perf_event_read_value**\ () is recommended over
505-
**bpf_perf_event_read*\ () in general. The latter has some ABI
505+
**bpf_perf_event_read**\ () in general. The latter has some ABI
506506
quirks where error and counter value are used as a return code
507507
(which is wrong to do since ranges may overlap). This issue is
508-
fixed with bpf_perf_event_read_value(), which at the same time
509-
provides more features over the **bpf_perf_event_read**\ ()
510-
interface. Please refer to the description of
508+
fixed with **bpf_perf_event_read_value**\ (), which at the same
509+
time provides more features over the **bpf_perf_event_read**\
510+
() interface. Please refer to the description of
511511
**bpf_perf_event_read_value**\ () for details.
512512
Return
513513
The value of the perf event counter read from the map, or a
@@ -1036,7 +1036,7 @@ HELPERS
10361036
Return
10371037
0
10381038

1039-
**int bpf_setsockopt(struct bpf_sock_ops_kern \***\ *bpf_socket*\ **, int** *level*\ **, int** *optname*\ **, char \***\ *optval*\ **, int** *optlen*\ **)**
1039+
**int bpf_setsockopt(struct bpf_sock_ops \***\ *bpf_socket*\ **, int** *level*\ **, int** *optname*\ **, char \***\ *optval*\ **, int** *optlen*\ **)**
10401040
Description
10411041
Emulate a call to **setsockopt()** on the socket associated to
10421042
*bpf_socket*, which must be a full socket. The *level* at
@@ -1110,7 +1110,7 @@ HELPERS
11101110
Return
11111111
**SK_PASS** on success, or **SK_DROP** on error.
11121112

1113-
**int bpf_sock_map_update(struct bpf_sock_ops_kern \***\ *skops*\ **, struct bpf_map \***\ *map*\ **, void \***\ *key*\ **, u64** *flags*\ **)**
1113+
**int bpf_sock_map_update(struct bpf_sock_ops \***\ *skops*\ **, struct bpf_map \***\ *map*\ **, void \***\ *key*\ **, u64** *flags*\ **)**
11141114
Description
11151115
Add an entry to, or update a *map* referencing sockets. The
11161116
*skops* is used as a new value for the entry associated to
@@ -1208,7 +1208,7 @@ HELPERS
12081208
Return
12091209
0 on success, or a negative error in case of failure.
12101210

1211-
**int bpf_perf_prog_read_value(struct bpf_perf_event_data_kern \***\ *ctx*\ **, struct bpf_perf_event_value \***\ *buf*\ **, u32** *buf_size*\ **)**
1211+
**int bpf_perf_prog_read_value(struct bpf_perf_event_data \***\ *ctx*\ **, struct bpf_perf_event_value \***\ *buf*\ **, u32** *buf_size*\ **)**
12121212
Description
12131213
For en eBPF program attached to a perf event, retrieve the
12141214
value of the event counter associated to *ctx* and store it in
@@ -1219,7 +1219,7 @@ HELPERS
12191219
Return
12201220
0 on success, or a negative error in case of failure.
12211221

1222-
**int bpf_getsockopt(struct bpf_sock_ops_kern \***\ *bpf_socket*\ **, int** *level*\ **, int** *optname*\ **, char \***\ *optval*\ **, int** *optlen*\ **)**
1222+
**int bpf_getsockopt(struct bpf_sock_ops \***\ *bpf_socket*\ **, int** *level*\ **, int** *optname*\ **, char \***\ *optval*\ **, int** *optlen*\ **)**
12231223
Description
12241224
Emulate a call to **getsockopt()** on the socket associated to
12251225
*bpf_socket*, which must be a full socket. The *level* at
@@ -1263,7 +1263,7 @@ HELPERS
12631263
Return
12641264
0
12651265

1266-
**int bpf_sock_ops_cb_flags_set(struct bpf_sock_ops_kern \***\ *bpf_sock*\ **, int** *argval*\ **)**
1266+
**int bpf_sock_ops_cb_flags_set(struct bpf_sock_ops \***\ *bpf_sock*\ **, int** *argval*\ **)**
12671267
Description
12681268
Attempt to set the value of the **bpf_sock_ops_cb_flags** field
12691269
for the full TCP socket associated to *bpf_sock_ops* to
@@ -1396,7 +1396,7 @@ HELPERS
13961396
Return
13971397
0 on success, or a negative error in case of failure.
13981398

1399-
**int bpf_bind(struct bpf_sock_addr_kern \***\ *ctx*\ **, struct sockaddr \***\ *addr*\ **, int** *addr_len*\ **)**
1399+
**int bpf_bind(struct bpf_sock_addr \***\ *ctx*\ **, struct sockaddr \***\ *addr*\ **, int** *addr_len*\ **)**
14001400
Description
14011401
Bind the socket associated to *ctx* to the address pointed by
14021402
*addr*, of length *addr_len*. This allows for making outgoing
@@ -1443,6 +1443,40 @@ HELPERS
14431443
Return
14441444
0 on success, or a negative error in case of failure.
14451445

1446+
**int bpf_get_stack(struct pt_regs \***\ *regs*\ **, void \***\ *buf*\ **, u32** *size*\ **, u64** *flags*\ **)**
1447+
Description
1448+
Return a user or a kernel stack in bpf program provided buffer.
1449+
To achieve this, the helper needs *ctx*, which is a pointer
1450+
to the context on which the tracing program is executed.
1451+
To store the stacktrace, the bpf program provides *buf* with
1452+
a nonnegative *size*.
1453+
1454+
The last argument, *flags*, holds the number of stack frames to
1455+
skip (from 0 to 255), masked with
1456+
**BPF_F_SKIP_FIELD_MASK**. The next bits can be used to set
1457+
the following flags:
1458+
1459+
**BPF_F_USER_STACK**
1460+
Collect a user space stack instead of a kernel stack.
1461+
**BPF_F_USER_BUILD_ID**
1462+
Collect buildid+offset instead of ips for user stack,
1463+
only valid if **BPF_F_USER_STACK** is also specified.
1464+
1465+
**bpf_get_stack**\ () can collect up to
1466+
**PERF_MAX_STACK_DEPTH** both kernel and user frames, subject
1467+
to sufficient large buffer size. Note that
1468+
this limit can be controlled with the **sysctl** program, and
1469+
that it should be manually increased in order to profile long
1470+
user stacks (such as stacks for Java programs). To do so, use:
1471+
1472+
::
1473+
1474+
# sysctl kernel.perf_event_max_stack=<new value>
1475+
1476+
Return
1477+
a non-negative value equal to or less than size on success, or
1478+
a negative error in case of failure.
1479+
14461480

14471481
EXAMPLES
14481482
========

0 commit comments

Comments
 (0)