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
13SEC("tracepoint/syscalls/sys_enter_nanosleep")
14int 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
27char _license[] SEC("license") = "GPL";
28