Add kernel namespace contexts
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 12 Feb 2019 16:51:05 +0000 (11:51 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 23 Oct 2019 17:29:26 +0000 (13:29 -0400)
Add the following kernel namespace contexts:

  - cgroup_ns
    Cgroup root directory namespace: inode number of the current
    cgroup namespace in the proc filesystem.

  - ipc_ns
    System V IPC, POSIX message queues namespace: inode number of the
    current IPC namespace in the proc filesystem.

  - mnt_ns
    Mount points namespace: inode number of the current mount
    namespace in the proc filesystem.

  - net_ns
    Network devices, stacks, ports namespace: inode number of the
    current network namespace in the proc filesystem.

  - pid_ns
    Process IDs namespace: inode number of the current pid namespace
    in the proc filesystem.

  - user_ns
    User and group IDs namespace: inode number of the current user
    namespace in the proc filesystem.

  - uts_ns
    Hostname and NIS domain name namespace: inode number of the
    current uts namespace in the proc filesystem.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/event.h
src/bin/lttng-sessiond/context.c
src/bin/lttng-sessiond/save.c
src/bin/lttng/commands/add_context.c
src/common/config/config-session-abi.h
src/common/config/session-config.c
src/common/lttng-kernel.h

index 0f75245c91e95f9075a6a147f7cbbf0f6d7d48cf..35c8d96f59486b7e22fbf36340e7f6718ca4d467 100644 (file)
@@ -146,6 +146,13 @@ enum lttng_event_context_type {
        LTTNG_EVENT_CONTEXT_MIGRATABLE          = 19,
        LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL    = 20,
        LTTNG_EVENT_CONTEXT_CALLSTACK_USER      = 21, /* Supported on x86_32 and x86_64 only. */
+       LTTNG_EVENT_CONTEXT_CGROUP_NS           = 22,
+       LTTNG_EVENT_CONTEXT_IPC_NS              = 23,
+       LTTNG_EVENT_CONTEXT_MNT_NS              = 24,
+       LTTNG_EVENT_CONTEXT_NET_NS              = 25,
+       LTTNG_EVENT_CONTEXT_PID_NS              = 26,
+       LTTNG_EVENT_CONTEXT_USER_NS             = 27,
+       LTTNG_EVENT_CONTEXT_UTS_NS              = 28,
 };
 
 enum lttng_event_field_type {
index 8a43cb7c14e9ab5f336f867d8f88df6e7a71cf11..8f473cd3f39fd2ab7298f98db51e941f4879dfdd 100644 (file)
@@ -267,6 +267,27 @@ int context_kernel_add(struct ltt_kernel_session *ksession,
        case LTTNG_EVENT_CONTEXT_CALLSTACK_USER:
                kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_CALLSTACK_USER;
                break;
+       case LTTNG_EVENT_CONTEXT_CGROUP_NS:
+               kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_CGROUP_NS;
+               break;
+       case LTTNG_EVENT_CONTEXT_IPC_NS:
+               kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_IPC_NS;
+               break;
+       case LTTNG_EVENT_CONTEXT_MNT_NS:
+               kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_MNT_NS;
+               break;
+       case LTTNG_EVENT_CONTEXT_NET_NS:
+               kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_NET_NS;
+               break;
+       case LTTNG_EVENT_CONTEXT_PID_NS:
+               kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_PID_NS;
+               break;
+       case LTTNG_EVENT_CONTEXT_USER_NS:
+               kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_USER_NS;
+               break;
+       case LTTNG_EVENT_CONTEXT_UTS_NS:
+               kctx->ctx.ctx = LTTNG_KERNEL_CONTEXT_UTS_NS;
+               break;
        default:
                ret = LTTNG_ERR_KERN_CONTEXT_FAIL;
                goto error;
index cdeb4004d6b4f99e8ef5c6b5a99f9d9f55dd2c7a..f3cd9bca99b51cf25b6b3dd2ae68a80659b8686b 100644 (file)
@@ -294,6 +294,27 @@ const char *get_kernel_context_type_string(
        case LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL:
                context_type_string = config_event_context_callstack_kernel;
                break;
+       case LTTNG_KERNEL_CONTEXT_CGROUP_NS:
+               context_type_string = config_event_context_cgroup_ns;
+               break;
+       case LTTNG_KERNEL_CONTEXT_IPC_NS:
+               context_type_string = config_event_context_ipc_ns;
+               break;
+       case LTTNG_KERNEL_CONTEXT_MNT_NS:
+               context_type_string = config_event_context_mnt_ns;
+               break;
+       case LTTNG_KERNEL_CONTEXT_NET_NS:
+               context_type_string = config_event_context_net_ns;
+               break;
+       case LTTNG_KERNEL_CONTEXT_PID_NS:
+               context_type_string = config_event_context_pid_ns;
+               break;
+       case LTTNG_KERNEL_CONTEXT_USER_NS:
+               context_type_string = config_event_context_user_ns;
+               break;
+       case LTTNG_KERNEL_CONTEXT_UTS_NS:
+               context_type_string = config_event_context_uts_ns;
+               break;
        default:
                context_type_string = NULL;
        }
index 7aef4d50f7dd575e34c704f5b2a82896af8f5db1..a9ef0ddade83a96b87d77eceebc2cc69e1ca764e 100644 (file)
@@ -86,6 +86,13 @@ enum context_type {
        CONTEXT_MIGRATABLE   = 19,
        CONTEXT_CALLSTACK_KERNEL = 20,
        CONTEXT_CALLSTACK_USER = 21,
+       CONTEXT_CGROUP_NS    = 22,
+       CONTEXT_IPC_NS       = 23,
+       CONTEXT_MNT_NS       = 24,
+       CONTEXT_NET_NS       = 25,
+       CONTEXT_PID_NS       = 26,
+       CONTEXT_USER_NS      = 27,
+       CONTEXT_UTS_NS       = 28,
 };
 
 /*
@@ -246,6 +253,13 @@ const struct ctx_opts {
 #if HAVE_MODULES_USERSPACE_CALLSTACK_CONTEXT
        { "callstack-user", CONTEXT_CALLSTACK_USER },
 #endif
+       { "cgroup_ns", CONTEXT_CGROUP_NS },
+       { "ipc_ns", CONTEXT_IPC_NS },
+       { "mnt_ns", CONTEXT_MNT_NS },
+       { "net_ns", CONTEXT_NET_NS },
+       { "pid_ns", CONTEXT_PID_NS },
+       { "user_ns", CONTEXT_USER_NS },
+       { "uts_ns", CONTEXT_UTS_NS },
 
        /* Perf options */
 
index 950efa5f96811cf0cc9c4ce420915b5fefc521d6..ced35254d45b837b415deee138710f9bff900e4f 100644 (file)
@@ -151,5 +151,12 @@ extern const char * const config_element_rotation_schedule_periodic;
 extern const char * const config_element_rotation_schedule_periodic_time_us;
 extern const char * const config_element_rotation_schedule_size_threshold;
 extern const char * const config_element_rotation_schedule_size_threshold_bytes;
+extern const char * const config_event_context_cgroup_ns;
+extern const char * const config_event_context_ipc_ns;
+extern const char * const config_event_context_mnt_ns;
+extern const char * const config_event_context_net_ns;
+extern const char * const config_event_context_pid_ns;
+extern const char * const config_event_context_user_ns;
+extern const char * const config_event_context_uts_ns;
 
 #endif /* CONFIG_SESSION_INTERNAL_H */
index b1fa992fe0f65c02f922ea99d4d6d3c632d23b1c..01f39d8bec250757d3eaede00b8b27b0f83ee70c 100644 (file)
@@ -205,6 +205,13 @@ LTTNG_HIDDEN const char * const config_event_context_need_reschedule = "NEED_RES
 LTTNG_HIDDEN const char * const config_event_context_migratable = "MIGRATABLE";
 LTTNG_HIDDEN const char * const config_event_context_callstack_user= "CALLSTACK_USER";
 LTTNG_HIDDEN const char * const config_event_context_callstack_kernel = "CALLSTACK_KERNEL";
+LTTNG_HIDDEN const char * const config_event_context_cgroup_ns = "CGROUP_NS";
+LTTNG_HIDDEN const char * const config_event_context_ipc_ns = "IPC_NS";
+LTTNG_HIDDEN const char * const config_event_context_mnt_ns = "MNT_NS";
+LTTNG_HIDDEN const char * const config_event_context_net_ns = "NET_NS";
+LTTNG_HIDDEN const char * const config_event_context_pid_ns = "PID_NS";
+LTTNG_HIDDEN const char * const config_event_context_user_ns = "USER_NS";
+LTTNG_HIDDEN const char * const config_event_context_uts_ns = "UTS_NS";
 
 /* Deprecated symbols */
 const char * const config_element_perf;
@@ -1047,6 +1054,27 @@ int get_context_type(xmlChar *context_type)
        } else if (!strcmp((char *) context_type,
                config_event_context_callstack_kernel)) {
                ret = LTTNG_EVENT_CONTEXT_CALLSTACK_KERNEL;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_cgroup_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_CGROUP_NS;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_ipc_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_IPC_NS;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_mnt_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_MNT_NS;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_net_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_NET_NS;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_pid_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_PID_NS;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_user_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_USER_NS;
+       } else if (!strcmp((char *) context_type,
+               config_event_context_uts_ns)) {
+               ret = LTTNG_EVENT_CONTEXT_UTS_NS;
        } else {
                goto error;
        }
index 2fd14dc1e76db698ba9a89b0ea23476693e8b19b..be7de5268ecef15ab76ed849f721dd5c3194d585 100644 (file)
@@ -66,6 +66,13 @@ enum lttng_kernel_context_type {
        LTTNG_KERNEL_CONTEXT_MIGRATABLE     = 15,
        LTTNG_KERNEL_CONTEXT_CALLSTACK_KERNEL = 16,
        LTTNG_KERNEL_CONTEXT_CALLSTACK_USER   = 17,
+       LTTNG_KERNEL_CONTEXT_CGROUP_NS      = 18,
+       LTTNG_KERNEL_CONTEXT_IPC_NS         = 19,
+       LTTNG_KERNEL_CONTEXT_MNT_NS         = 20,
+       LTTNG_KERNEL_CONTEXT_NET_NS         = 21,
+       LTTNG_KERNEL_CONTEXT_PID_NS         = 22,
+       LTTNG_KERNEL_CONTEXT_USER_NS        = 23,
+       LTTNG_KERNEL_CONTEXT_UTS_NS         = 24,
 };
 
 /* Perf counter attributes */
This page took 0.031293 seconds and 5 git commands to generate.