return 0;
}
+static __always_inline unsigned int pid_namespace(struct task_struct *task)
+{
+ struct pid *pid;
+ unsigned int level;
+ struct upid upid;
+ unsigned int inum;
+
+ /* get the pid namespace by following task_active_pid_ns(),
+ * pid->numbers[pid->level].ns
+ */
+ pid = BPF_CORE_READ(task, thread_pid);
+ level = BPF_CORE_READ(pid, level);
+ bpf_core_read(&upid, sizeof(upid), &pid->numbers[level]);
+ inum = BPF_CORE_READ(upid.ns, ns.inum);
+
+ return inum;
+}
+
SEC("tp_btf/sched_wakeup")
int BPF_PROG(sched_wakeup, struct task_struct *p)
{
else if (targ_per_thread)
hkey = pid;
else if (targ_per_pidns)
- hkey = next->nsproxy->pid_ns_for_children->ns.inum;
+ hkey = pid_namespace(next);
else
hkey = -1;
histp = bpf_map_lookup_or_try_init(&hists, &hkey, &zero);