From 3e38c8b3e3cd13b047d471b6b910473997ca76bb Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Fri, 6 May 2022 16:39:45 -0400 Subject: [PATCH] Add `--disallow-ctf2` to lttng-relayd FIXME: do we want to limit this to live? TODO: Doc Signed-off-by: Jonathan Rajotte Change-Id: I41cba9b08958c6d26e132328429a24dad97b6752 --- src/bin/lttng-relayd/main.cpp | 27 +++++++++++++++++++++++++++ src/common/defaults.hpp | 1 + 2 files changed, 28 insertions(+) diff --git a/src/bin/lttng-relayd/main.cpp b/src/bin/lttng-relayd/main.cpp index e2d947cc6..d7b65cbac 100644 --- a/src/bin/lttng-relayd/main.cpp +++ b/src/bin/lttng-relayd/main.cpp @@ -95,6 +95,7 @@ enum relay_connection_status { /* command line options */ char *opt_output_path, *opt_working_directory; static int opt_daemon, opt_background, opt_print_version, opt_allow_clear = 1; +static int opt_allow_ctf2 = 1; enum relay_group_output_by opt_group_output_by = RELAYD_GROUP_OUTPUT_BY_UNKNOWN; /* Argument variables */ @@ -198,6 +199,7 @@ static struct option long_options[] = { { "group-output-by-session", 0, 0, 's', }, { "group-output-by-host", 0, 0, 'p', }, { "disallow-clear", 0, 0, 'x' }, + { "disallow-ctf2", 0, 0, 'y' }, { NULL, 0, 0, 0, }, }; @@ -218,6 +220,8 @@ static void relayd_config_log(void) if (EXTRA_VERSION_PATCHES[0] != '\0') { DBG("LTTng-relayd extra patches:\n\t" EXTRA_VERSION_PATCHES "\n"); } + + DBG("Trace format supported: %s%s", "ctf1", opt_allow_ctf2 ? ", ctf2" : ""); } /* @@ -386,6 +390,10 @@ static int set_option(int opt, const char *arg, const char *optname) /* Disallow clear */ opt_allow_clear = 0; break; + case 'y': + /* Disallow clear */ + opt_allow_ctf2 = 0; + break; default: /* Unknown option or other error. * Error is printed by getopt, just return */ @@ -664,6 +672,21 @@ static int set_options(int argc, char **argv) } } + if (opt_allow_ctf2) { + /* Check if env variable exists. */ + const char *value = lttng_secure_getenv(DEFAULT_LTTNG_RELAYD_DISALLOW_CTF2_ENV); + if (value) { + ret = config_parse_value(value); + if (ret < 0) { + ERR("Invalid value for %s specified", + DEFAULT_LTTNG_RELAYD_DISALLOW_CTF2_ENV); + retval = -1; + goto exit; + } + opt_allow_ctf2 = !ret; + } + } + exit: free(config_path); free(optstring); @@ -3305,6 +3328,10 @@ static int relay_get_configuration( msg = (typeof(msg)) header_view.data; query_flags = be64toh(msg->query_flags); + /* FIXME: Do we want to return invalid protocol or do we want to return + * an array of lttcomm_relayd_get_configuration_specialized_query_reply + * for each unknown query bit ? + */ if (query_flags & ~LTTCOMM_RELAYD_CONFIGURATION_QUERY_FLAG_MASK) { ret = LTTNG_ERR_INVALID_PROTOCOL; goto reply; diff --git a/src/common/defaults.hpp b/src/common/defaults.hpp index 61e2891a1..4cb839272 100644 --- a/src/common/defaults.hpp +++ b/src/common/defaults.hpp @@ -355,6 +355,7 @@ #define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_PROBE_INTERVAL" #define DEFAULT_LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD_ENV "LTTNG_RELAYD_TCP_KEEP_ALIVE_ABORT_THRESHOLD" #define DEFAULT_LTTNG_RELAYD_DISALLOW_CLEAR_ENV "LTTNG_RELAYD_DISALLOW_CLEAR" +#define DEFAULT_LTTNG_RELAYD_DISALLOW_CTF2_ENV "LTTNG_RELAYD_DISALLOW_CTF2" #define DEFAULT_LTTNG_RELAYD_WORKING_DIRECTORY_ENV "LTTNG_RELAYD_WORKING_DIRECTORY" -- 2.34.1