From: Michael Jeanson Date: Tue, 12 Feb 2019 16:51:05 +0000 (-0500) Subject: Add kernel namespace contexts X-Git-Tag: v2.12.0-rc1~288 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=40e14884a7f6606e387cdfa00f66d49a54cf311c;p=lttng-tools.git Add kernel namespace contexts 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 Signed-off-by: Jérémie Galarneau --- diff --git a/include/lttng/event.h b/include/lttng/event.h index 0f75245c9..35c8d96f5 100644 --- a/include/lttng/event.h +++ b/include/lttng/event.h @@ -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 { diff --git a/src/bin/lttng-sessiond/context.c b/src/bin/lttng-sessiond/context.c index 8a43cb7c1..8f473cd3f 100644 --- a/src/bin/lttng-sessiond/context.c +++ b/src/bin/lttng-sessiond/context.c @@ -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; diff --git a/src/bin/lttng-sessiond/save.c b/src/bin/lttng-sessiond/save.c index cdeb4004d..f3cd9bca9 100644 --- a/src/bin/lttng-sessiond/save.c +++ b/src/bin/lttng-sessiond/save.c @@ -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; } diff --git a/src/bin/lttng/commands/add_context.c b/src/bin/lttng/commands/add_context.c index 7aef4d50f..a9ef0ddad 100644 --- a/src/bin/lttng/commands/add_context.c +++ b/src/bin/lttng/commands/add_context.c @@ -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 */ diff --git a/src/common/config/config-session-abi.h b/src/common/config/config-session-abi.h index 950efa5f9..ced35254d 100644 --- a/src/common/config/config-session-abi.h +++ b/src/common/config/config-session-abi.h @@ -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 */ diff --git a/src/common/config/session-config.c b/src/common/config/session-config.c index b1fa992fe..01f39d8be 100644 --- a/src/common/config/session-config.c +++ b/src/common/config/session-config.c @@ -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; } diff --git a/src/common/lttng-kernel.h b/src/common/lttng-kernel.h index 2fd14dc1e..be7de5268 100644 --- a/src/common/lttng-kernel.h +++ b/src/common/lttng-kernel.h @@ -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 */