1 | // SPDX-License-Identifier: GPL-2.0 |
---|---|
2 | /* Copyright (c) 2019 Carlos Neira cneirabustos@gmail.com */ |
3 | |
4 | #include <linux/bpf.h> |
5 | #include <stdint.h> |
6 | #include <bpf/bpf_helpers.h> |
7 | |
8 | __u64 user_pid = 0; |
9 | __u64 user_tgid = 0; |
10 | __u64 dev = 0; |
11 | __u64 ino = 0; |
12 | |
13 | SEC("tracepoint/syscalls/sys_enter_nanosleep") |
14 | int handler(const void *ctx) |
15 | { |
16 | struct bpf_pidns_info nsdata; |
17 | |
18 | if (bpf_get_ns_current_pid_tgid(dev, ino, &nsdata, sizeof(struct bpf_pidns_info))) |
19 | return 0; |
20 | |
21 | user_pid = nsdata.pid; |
22 | user_tgid = nsdata.tgid; |
23 | |
24 | return 0; |
25 | } |
26 | |
27 | char _license[] SEC("license") = "GPL"; |
28 |