diff options
| author | Alexei Starovoitov <ast@fb.com> | 2016-02-17 22:58:58 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2016-02-20 00:21:44 -0500 |
| commit | d5a3b1f691865be576c2bffa708549b8cdccda19 (patch) | |
| tree | 12f6009f168baee6889a0fde07d60ac3f5c12aac /include/uapi/linux | |
| parent | 568b329a02f75ed3aaae5eb2cca384cb9e09cb29 (diff) | |
bpf: introduce BPF_MAP_TYPE_STACK_TRACE
add new map type to store stack traces and corresponding helper
bpf_get_stackid(ctx, map, flags) - walk user or kernel stack and return id
@ctx: struct pt_regs*
@map: pointer to stack_trace map
@flags: bits 0-7 - numer of stack frames to skip
bit 8 - collect user stack instead of kernel
bit 9 - compare stacks by hash only
bit 10 - if two different stacks hash into the same stackid
discard old
other bits - reserved
Return: >= 0 stackid on success or negative error
stackid is a 32-bit integer handle that can be further combined with
other data (including other stackid) and used as a key into maps.
Userspace will access stackmap using standard lookup/delete syscall commands to
retrieve full stack trace for given stackid.
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/uapi/linux')
| -rw-r--r-- | include/uapi/linux/bpf.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index 2ee0fde1bf96..d3e77da8e9e8 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h | |||
| @@ -83,6 +83,7 @@ enum bpf_map_type { | |||
| 83 | BPF_MAP_TYPE_PERF_EVENT_ARRAY, | 83 | BPF_MAP_TYPE_PERF_EVENT_ARRAY, |
| 84 | BPF_MAP_TYPE_PERCPU_HASH, | 84 | BPF_MAP_TYPE_PERCPU_HASH, |
| 85 | BPF_MAP_TYPE_PERCPU_ARRAY, | 85 | BPF_MAP_TYPE_PERCPU_ARRAY, |
| 86 | BPF_MAP_TYPE_STACK_TRACE, | ||
| 86 | }; | 87 | }; |
| 87 | 88 | ||
| 88 | enum bpf_prog_type { | 89 | enum bpf_prog_type { |
| @@ -272,6 +273,20 @@ enum bpf_func_id { | |||
| 272 | */ | 273 | */ |
| 273 | BPF_FUNC_perf_event_output, | 274 | BPF_FUNC_perf_event_output, |
| 274 | BPF_FUNC_skb_load_bytes, | 275 | BPF_FUNC_skb_load_bytes, |
| 276 | |||
| 277 | /** | ||
| 278 | * bpf_get_stackid(ctx, map, flags) - walk user or kernel stack and return id | ||
| 279 | * @ctx: struct pt_regs* | ||
| 280 | * @map: pointer to stack_trace map | ||
| 281 | * @flags: bits 0-7 - numer of stack frames to skip | ||
| 282 | * bit 8 - collect user stack instead of kernel | ||
| 283 | * bit 9 - compare stacks by hash only | ||
| 284 | * bit 10 - if two different stacks hash into the same stackid | ||
| 285 | * discard old | ||
| 286 | * other bits - reserved | ||
| 287 | * Return: >= 0 stackid on success or negative error | ||
| 288 | */ | ||
| 289 | BPF_FUNC_get_stackid, | ||
| 275 | __BPF_FUNC_MAX_ID, | 290 | __BPF_FUNC_MAX_ID, |
| 276 | }; | 291 | }; |
| 277 | 292 | ||
| @@ -294,6 +309,12 @@ enum bpf_func_id { | |||
| 294 | /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ | 309 | /* BPF_FUNC_skb_set_tunnel_key and BPF_FUNC_skb_get_tunnel_key flags. */ |
| 295 | #define BPF_F_TUNINFO_IPV6 (1ULL << 0) | 310 | #define BPF_F_TUNINFO_IPV6 (1ULL << 0) |
| 296 | 311 | ||
| 312 | /* BPF_FUNC_get_stackid flags. */ | ||
| 313 | #define BPF_F_SKIP_FIELD_MASK 0xffULL | ||
| 314 | #define BPF_F_USER_STACK (1ULL << 8) | ||
| 315 | #define BPF_F_FAST_STACK_CMP (1ULL << 9) | ||
| 316 | #define BPF_F_REUSE_STACKID (1ULL << 10) | ||
| 317 | |||
| 297 | /* user accessible mirror of in-kernel sk_buff. | 318 | /* user accessible mirror of in-kernel sk_buff. |
| 298 | * new fields can only be added to the end of this structure | 319 | * new fields can only be added to the end of this structure |
| 299 | */ | 320 | */ |
