Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

src/python: fix filtering by containers when kfunc are supported #7

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/python/bcc/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,22 @@

static inline u64 get_mntns_id() {
struct task_struct *current_task;
struct nsproxy *nsproxy;
struct mnt_namespace *mnt_ns;
unsigned int inum;

current_task = (struct task_struct *)bpf_get_current_task();
return current_task->nsproxy->mnt_ns->ns.inum;

if (bpf_probe_read_kernel(&nsproxy, sizeof(nsproxy), &current_task->nsproxy))
return 0;

if (bpf_probe_read_kernel(&mnt_ns, sizeof(mnt_ns), &nsproxy->mnt_ns))
return 0;

if (bpf_probe_read_kernel(&inum, sizeof(inum), &mnt_ns->ns.inum))
return 0;

return (u64) inum;
}
#endif // __GET_MTN_NS_ID
"""
Expand Down