Fix: backward relayd: path contains a leading "ust" folder
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 13 Jan 2021 15:09:06 +0000 (10:09 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 13 Apr 2021 20:53:49 +0000 (16:53 -0400)
Observed issue
==============

test_output_path_relayd[lttng-tools-2.13-lttng-tools-2.10-uid] from
the lttng-ivc fails on path validation for the resulting trace.

Here lttng-sessiond is 2.13 and lttng-relayd is 2.10

Traces are generated and the following hierarchy is found in the
lttng-relayd trace folder.

 lttng_home
         └── lttng-traces
*            └── ust
                 └── joraj-alpa
                     ├── auto-20210113-165054
                     │   └── ust
                     │       └── uid

Note the extra "ust" (*) in the hierarchy.

The tests expects:
 lttng_home
         └── lttng-traces
                 └── joraj-alpa
                     ├── auto-20210113-165054
                     │   └── ust
                     │       └── uid

Cause
=====

Introduced by: 5da88b0f58d7f838068037ea449ddfb25d3e85ad [1]

relayd_add_stream now suffixes the domain_name to the pathname.
This is only necessary for cases where the corresponding
lttng-relayd version is greater than 2.10. In other cases, modification
of pathname is not necessary.

Solution
========

Perform domain suffixing only for relayd > 2.10.

Known drawbacks
=========

None.

References
==========

[1] https://github.com/lttng/lttng-tools/commit/5da88b0f58d7f838068037ea449ddfb25d3e85ad

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaca4667074aaf7f4f20b50ddb4778fbc02156b5a

src/common/relayd/relayd.c

index 1f98ac4c09e81452dd6df0a75f84477b650ca07e..22a1c44f800a4bb5302fe12d40c479a35e32e4c6 100644 (file)
@@ -499,7 +499,6 @@ int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_nam
        int ret;
        struct lttcomm_relayd_status_stream reply;
        char pathname[RELAYD_COMM_LTTNG_PATH_MAX];
-       const char *separator;
 
        /* Code flow error. Safety net. */
        assert(rsock);
@@ -510,32 +509,36 @@ int relayd_add_stream(struct lttcomm_relayd_sock *rsock, const char *channel_nam
 
        DBG("Relayd adding stream for channel name %s", channel_name);
 
-       if (_pathname[0] == '\0') {
-               separator = "";
-       } else {
-               separator = "/";
-       }
-       ret = snprintf(pathname, RELAYD_COMM_LTTNG_PATH_MAX, "%s%s%s",
-                       domain_name, separator, _pathname);
-       if (ret <= 0 || ret >= RELAYD_COMM_LTTNG_PATH_MAX) {
-               ERR("stream path too long.");
-               ret = -1;
-               goto error;
-       }
-
        /* Compat with relayd 2.1 */
        if (rsock->minor == 1) {
                /* For 2.1 */
-               ret = relayd_add_stream_2_1(rsock, channel_name, pathname);
+               ret = relayd_add_stream_2_1(rsock, channel_name, _pathname);
        
        } else if (rsock->minor > 1 && rsock->minor < 11) {
                /* From 2.2 to 2.10 */
-               ret = relayd_add_stream_2_2(rsock, channel_name, pathname,
+               ret = relayd_add_stream_2_2(rsock, channel_name, _pathname,
                                tracefile_size, tracefile_count);
        } else {
+               const char *separator;
                enum lttng_trace_chunk_status chunk_status;
                uint64_t chunk_id;
 
+               if (_pathname[0] == '\0') {
+                       separator = "";
+               } else {
+                       separator = "/";
+               }
+
+               ret = snprintf(pathname, RELAYD_COMM_LTTNG_PATH_MAX, "%s%s%s",
+                               domain_name, separator, _pathname);
+               if (ret <= 0 || ret >= RELAYD_COMM_LTTNG_PATH_MAX) {
+                       ERR("Failed to format stream path: %s",
+                                       ret <= 0 ? "formatting error" :
+                                                       "path exceeds maximal allowed length");
+                       ret = -1;
+                       goto error;
+               }
+
                chunk_status = lttng_trace_chunk_get_id(trace_chunk,
                                &chunk_id);
                assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
This page took 0.031907 seconds and 4 git commands to generate.