github.com/castai/kvisor@v1.7.1-0.20240516114728-b3572a2607b5/pkg/ebpftracer/c/headers/common/namespaces.h (about)

     1  #ifndef __COMMON_NAMESPACES_H__
     2  #define __COMMON_NAMESPACES_H__
     3  
     4  #include <vmlinux.h>
     5  
     6  #include <common/common.h>
     7  
     8  // PROTOTYPES
     9  
    10  statfunc u32 get_mnt_ns_id(struct nsproxy *);
    11  statfunc u32 get_pid_ns_for_children_id(struct nsproxy *);
    12  statfunc u32 get_uts_ns_id(struct nsproxy *);
    13  statfunc u32 get_ipc_ns_id(struct nsproxy *);
    14  statfunc u32 get_net_ns_id(struct nsproxy *);
    15  statfunc u32 get_cgroup_ns_id(struct nsproxy *);
    16  
    17  // FUNCTIONS
    18  
    19  statfunc u32 get_mnt_ns_id(struct nsproxy *ns)
    20  {
    21      return BPF_CORE_READ(ns, mnt_ns, ns.inum);
    22  }
    23  
    24  statfunc u32 get_pid_ns_for_children_id(struct nsproxy *ns)
    25  {
    26      return BPF_CORE_READ(ns, pid_ns_for_children, ns.inum);
    27  }
    28  
    29  statfunc u32 get_uts_ns_id(struct nsproxy *ns)
    30  {
    31      return BPF_CORE_READ(ns, uts_ns, ns.inum);
    32  }
    33  
    34  statfunc u32 get_ipc_ns_id(struct nsproxy *ns)
    35  {
    36      return BPF_CORE_READ(ns, ipc_ns, ns.inum);
    37  }
    38  
    39  statfunc u32 get_net_ns_id(struct nsproxy *ns)
    40  {
    41      return BPF_CORE_READ(ns, net_ns, ns.inum);
    42  }
    43  
    44  statfunc u32 get_cgroup_ns_id(struct nsproxy *ns)
    45  {
    46      return BPF_CORE_READ(ns, cgroup_ns, ns.inum);
    47  }
    48  
    49  #endif