2 * Copyright (C) 2012 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
16 #include <common/common.hpp>
17 #include <common/compat/endian.hpp>
18 #include <common/compat/string.hpp>
19 #include <common/defaults.hpp>
20 #include <common/index/ctf-index.hpp>
21 #include <common/sessiond-comm/relayd.hpp>
22 #include <common/string-utils/format.hpp>
23 #include <common/trace-chunk.hpp>
24 #include <lttng/trace-format-descriptor-internal.hpp>
29 bool relayd_supports_chunks(const struct lttcomm_relayd_sock
*sock
)
31 if (sock
->major
> 2) {
33 } else if (sock
->major
== 2 && sock
->minor
>= 11) {
40 bool relayd_supports_get_configuration(const struct lttcomm_relayd_sock
*sock
)
42 if (sock
->major
> 2) {
44 } else if (sock
->major
== 2 && sock
->minor
>= 12) {
50 static bool relayd_supports_get_configuration_trace_format(const struct lttcomm_relayd_sock
*sock
)
52 if (sock
->major
> 2) {
54 } else if (sock
->major
== 2 && sock
->minor
>= 15) {
61 * Send command. Fill up the header and append the data.
63 static int send_command(struct lttcomm_relayd_sock
*rsock
,
64 enum lttcomm_relayd_command cmd
, const void *data
, size_t size
,
68 struct lttcomm_relayd_hdr header
;
70 uint64_t buf_size
= sizeof(header
);
72 if (rsock
->sock
.fd
< 0) {
80 buf
= calloc
<char>(buf_size
);
82 PERROR("zmalloc relayd send command buf");
87 memset(&header
, 0, sizeof(header
));
88 header
.cmd
= htobe32(cmd
);
89 header
.data_size
= htobe64(size
);
91 /* Zeroed for now since not used. */
92 header
.cmd_version
= 0;
93 header
.circuit_id
= 0;
95 /* Prepare buffer to send. */
96 memcpy(buf
, &header
, sizeof(header
));
98 memcpy(buf
+ sizeof(header
), data
, size
);
101 DBG3("Relayd sending command %s of size %" PRIu64
,
102 lttcomm_relayd_command_str(cmd
), buf_size
);
103 ret
= rsock
->sock
.ops
->sendmsg(&rsock
->sock
, buf
, buf_size
, flags
);
105 PERROR("Failed to send command %s of size %" PRIu64
,
106 lttcomm_relayd_command_str(cmd
), buf_size
);
117 * Receive reply data on socket. This MUST be call after send_command or else
118 * could result in unexpected behavior(s).
120 static int recv_reply(struct lttcomm_relayd_sock
*rsock
, void *data
, size_t size
)
124 if (rsock
->sock
.fd
< 0) {
128 DBG3("Relayd waiting for reply of size %zu", size
);
130 ret
= rsock
->sock
.ops
->recvmsg(&rsock
->sock
, data
, size
, 0);
131 if (ret
<= 0 || ret
!= size
) {
133 /* Orderly shutdown. */
134 DBG("Socket %d has performed an orderly shutdown", rsock
->sock
.fd
);
136 DBG("Receiving reply failed on sock %d for size %zu with ret %d",
137 rsock
->sock
.fd
, size
, ret
);
139 /* Always return -1 here and the caller can use errno. */
149 * Starting from 2.15, the trace format for the session is sent to lttng-relayd
152 static int relayd_create_session_2_15(struct lttcomm_relayd_sock
*rsock
,
153 const char *session_name
,
154 const char *hostname
,
155 const char *base_path
,
156 int session_live_timer
,
157 unsigned int snapshot
,
158 uint64_t sessiond_session_id
,
159 const lttng_uuid
& sessiond_uuid
,
160 const uint64_t *current_chunk_id
,
161 time_t creation_time
,
162 bool session_name_contains_creation_time
,
163 lttcomm_relayd_create_session_reply_2_15
*reply
,
165 const lttng::trace_format_descriptor
& trace_format
)
168 struct lttcomm_relayd_create_session_2_15
*msg
= NULL
;
169 size_t session_name_len
;
171 size_t base_path_len
;
178 /* The three names are sent with a '\0' delimiter between them. */
179 session_name_len
= strlen(session_name
) + 1;
180 hostname_len
= strlen(hostname
) + 1;
181 base_path_len
= strlen(base_path
) + 1;
183 msg_length
= sizeof(*msg
) + session_name_len
+ hostname_len
+ base_path_len
;
184 msg
= zmalloc
<lttcomm_relayd_create_session_2_15
>(msg_length
);
186 PERROR("zmalloc create_session_2_11 command message");
191 LTTNG_ASSERT(session_name_len
<= UINT32_MAX
);
192 msg
->session_name_len
= htobe32(session_name_len
);
194 LTTNG_ASSERT(hostname_len
<= UINT32_MAX
);
195 msg
->hostname_len
= htobe32(hostname_len
);
197 LTTNG_ASSERT(base_path_len
<= UINT32_MAX
);
198 msg
->base_path_len
= htobe32(base_path_len
);
201 if (lttng_strncpy(dst
, session_name
, session_name_len
)) {
205 dst
+= session_name_len
;
206 if (lttng_strncpy(dst
, hostname
, hostname_len
)) {
211 if (lttng_strncpy(dst
, base_path
, base_path_len
)) {
216 msg
->live_timer
= htobe32(session_live_timer
);
217 msg
->snapshot
= !!snapshot
;
219 std::copy(sessiond_uuid
.begin(), sessiond_uuid
.end(), msg
->sessiond_uuid
);
220 msg
->session_id
= htobe64(sessiond_session_id
);
221 msg
->session_name_contains_creation_time
= session_name_contains_creation_time
;
222 msg
->trace_format
= (uint8_t) trace_format
.relayd_type();
223 if (current_chunk_id
) {
224 LTTNG_OPTIONAL_SET(&msg
->current_chunk_id
, htobe64(*current_chunk_id
));
227 msg
->creation_time
= htobe64((uint64_t) creation_time
);
230 ret
= send_command(rsock
, RELAYD_CREATE_SESSION
, msg
, msg_length
, 0);
234 /* Receive response */
235 ret
= recv_reply(rsock
, reply
, sizeof(*reply
));
239 reply
->generic
.session_id
= be64toh(reply
->generic
.session_id
);
240 reply
->generic
.ret_code
= be32toh(reply
->generic
.ret_code
);
241 reply
->output_path_length
= be32toh(reply
->output_path_length
);
242 if (reply
->output_path_length
>= LTTNG_PATH_MAX
) {
243 ERR("Invalid session output path length in reply (%" PRIu32
244 " bytes) exceeds maximal allowed length (%d bytes)",
245 reply
->output_path_length
, LTTNG_PATH_MAX
);
249 ret
= recv_reply(rsock
, output_path
, reply
->output_path_length
);
259 * Starting from 2.11, RELAYD_CREATE_SESSION payload (session_name,
260 * hostname, and base_path) have no length restriction on the sender side.
261 * Length for both payloads is stored in the msg struct. A new dynamic size
262 * payload size is introduced.
264 static int relayd_create_session_2_11(struct lttcomm_relayd_sock
*rsock
,
265 const char *session_name
, const char *hostname
,
266 const char *base_path
, int session_live_timer
,
267 unsigned int snapshot
, uint64_t sessiond_session_id
,
268 const lttng_uuid
& sessiond_uuid
, const uint64_t *current_chunk_id
,
269 time_t creation_time
, bool session_name_contains_creation_time
,
270 struct lttcomm_relayd_create_session_reply_2_11
*reply
,
274 struct lttcomm_relayd_create_session_2_11
*msg
= NULL
;
275 size_t session_name_len
;
277 size_t base_path_len
;
284 /* The three names are sent with a '\0' delimiter between them. */
285 session_name_len
= strlen(session_name
) + 1;
286 hostname_len
= strlen(hostname
) + 1;
287 base_path_len
= strlen(base_path
) + 1;
289 msg_length
= sizeof(*msg
) + session_name_len
+ hostname_len
+ base_path_len
;
290 msg
= zmalloc
<lttcomm_relayd_create_session_2_11
>(msg_length
);
292 PERROR("zmalloc create_session_2_11 command message");
297 LTTNG_ASSERT(session_name_len
<= UINT32_MAX
);
298 msg
->session_name_len
= htobe32(session_name_len
);
300 LTTNG_ASSERT(hostname_len
<= UINT32_MAX
);
301 msg
->hostname_len
= htobe32(hostname_len
);
303 LTTNG_ASSERT(base_path_len
<= UINT32_MAX
);
304 msg
->base_path_len
= htobe32(base_path_len
);
307 if (lttng_strncpy(dst
, session_name
, session_name_len
)) {
311 dst
+= session_name_len
;
312 if (lttng_strncpy(dst
, hostname
, hostname_len
)) {
317 if (lttng_strncpy(dst
, base_path
, base_path_len
)) {
322 msg
->live_timer
= htobe32(session_live_timer
);
323 msg
->snapshot
= !!snapshot
;
325 std::copy(sessiond_uuid
.begin(), sessiond_uuid
.end(), msg
->sessiond_uuid
);
326 msg
->session_id
= htobe64(sessiond_session_id
);
327 msg
->session_name_contains_creation_time
= session_name_contains_creation_time
;
328 if (current_chunk_id
) {
329 LTTNG_OPTIONAL_SET(&msg
->current_chunk_id
,
330 htobe64(*current_chunk_id
));
333 msg
->creation_time
= htobe64((uint64_t) creation_time
);
336 ret
= send_command(rsock
, RELAYD_CREATE_SESSION
, msg
, msg_length
, 0);
340 /* Receive response */
341 ret
= recv_reply(rsock
, reply
, sizeof(*reply
));
345 reply
->generic
.session_id
= be64toh(reply
->generic
.session_id
);
346 reply
->generic
.ret_code
= be32toh(reply
->generic
.ret_code
);
347 reply
->output_path_length
= be32toh(reply
->output_path_length
);
348 if (reply
->output_path_length
>= LTTNG_PATH_MAX
) {
349 ERR("Invalid session output path length in reply (%" PRIu32
" bytes) exceeds maximal allowed length (%d bytes)",
350 reply
->output_path_length
, LTTNG_PATH_MAX
);
354 ret
= recv_reply(rsock
, output_path
, reply
->output_path_length
);
363 * From 2.4 to 2.10, RELAYD_CREATE_SESSION takes additional parameters to
364 * support the live reading capability.
366 static int relayd_create_session_2_4(struct lttcomm_relayd_sock
*rsock
,
367 const char *session_name
, const char *hostname
,
368 int session_live_timer
, unsigned int snapshot
,
369 struct lttcomm_relayd_status_session
*reply
)
372 struct lttcomm_relayd_create_session_2_4 msg
;
374 if (lttng_strncpy(msg
.session_name
, session_name
,
375 sizeof(msg
.session_name
))) {
379 if (lttng_strncpy(msg
.hostname
, hostname
, sizeof(msg
.hostname
))) {
383 msg
.live_timer
= htobe32(session_live_timer
);
384 msg
.snapshot
= htobe32(snapshot
);
387 ret
= send_command(rsock
, RELAYD_CREATE_SESSION
, &msg
, sizeof(msg
), 0);
392 /* Receive response */
393 ret
= recv_reply(rsock
, reply
, sizeof(*reply
));
397 reply
->session_id
= be64toh(reply
->session_id
);
398 reply
->ret_code
= be32toh(reply
->ret_code
);
404 * RELAYD_CREATE_SESSION from 2.1 to 2.3.
406 static int relayd_create_session_2_1(struct lttcomm_relayd_sock
*rsock
,
407 struct lttcomm_relayd_status_session
*reply
)
412 ret
= send_command(rsock
, RELAYD_CREATE_SESSION
, NULL
, 0, 0);
417 /* Receive response */
418 ret
= recv_reply(rsock
, reply
, sizeof(*reply
));
422 reply
->session_id
= be64toh(reply
->session_id
);
423 reply
->ret_code
= be32toh(reply
->ret_code
);
429 * Send a RELAYD_CREATE_SESSION command to the relayd with the given socket and
430 * set session_id of the relayd if we have a successful reply from the relayd.
432 * On success, return 0 else a negative value which is either an errno error or
433 * a lttng error code from the relayd.
435 int relayd_create_session(struct lttcomm_relayd_sock
*rsock
,
436 uint64_t *relayd_session_id
,
437 const char *session_name
,
438 const char *hostname
,
439 const char *base_path
,
440 int session_live_timer
,
441 unsigned int snapshot
,
442 uint64_t sessiond_session_id
,
443 const lttng_uuid
& sessiond_uuid
,
444 const uint64_t *current_chunk_id
,
445 time_t creation_time
,
446 bool session_name_contains_creation_time
,
448 lttng::trace_format_descriptor
& trace_format
)
451 lttcomm_relayd_create_session_reply_2_15 reply
= {};
454 LTTNG_ASSERT(relayd_session_id
);
456 DBG("Relayd create session");
458 if (rsock
->minor
< 4) {
459 /* From 2.1 to 2.3 */
460 ret
= relayd_create_session_2_1(rsock
, &reply
.generic
);
461 } else if (rsock
->minor
>= 4 && rsock
->minor
< 11) {
462 /* From 2.4 to 2.10 */
463 ret
= relayd_create_session_2_4(rsock
, session_name
, hostname
, session_live_timer
,
464 snapshot
, &reply
.generic
);
465 } else if (rsock
->minor
< 15) {
466 /* From 2.11 to 2.14 */
467 ret
= relayd_create_session_2_11(rsock
, session_name
, hostname
, base_path
,
468 session_live_timer
, snapshot
, sessiond_session_id
, sessiond_uuid
,
469 current_chunk_id
, creation_time
,
470 session_name_contains_creation_time
, &reply
, output_path
);
472 ret
= relayd_create_session_2_15(rsock
, session_name
, hostname
, base_path
,
473 session_live_timer
, snapshot
, sessiond_session_id
, sessiond_uuid
,
474 current_chunk_id
, creation_time
,
475 session_name_contains_creation_time
, &reply
, output_path
,
483 /* Return session id or negative ret code. */
484 if (reply
.generic
.ret_code
!= LTTNG_OK
) {
486 ERR("Relayd create session replied error %d",
487 reply
.generic
.ret_code
);
491 *relayd_session_id
= reply
.generic
.session_id
;
494 DBG("Relayd session created with id %" PRIu64
, reply
.generic
.session_id
);
500 static int relayd_add_stream_2_1(struct lttcomm_relayd_sock
*rsock
,
501 const char *channel_name
, const char *pathname
)
504 struct lttcomm_relayd_add_stream msg
;
506 memset(&msg
, 0, sizeof(msg
));
507 if (lttng_strncpy(msg
.channel_name
, channel_name
,
508 sizeof(msg
.channel_name
))) {
513 if (lttng_strncpy(msg
.pathname
, pathname
,
514 sizeof(msg
.pathname
))) {
520 ret
= send_command(rsock
, RELAYD_ADD_STREAM
, (void *) &msg
, sizeof(msg
), 0);
530 static int relayd_add_stream_2_2(struct lttcomm_relayd_sock
*rsock
,
531 const char *channel_name
, const char *pathname
,
532 uint64_t tracefile_size
, uint64_t tracefile_count
)
535 struct lttcomm_relayd_add_stream_2_2 msg
;
537 memset(&msg
, 0, sizeof(msg
));
538 /* Compat with relayd 2.2 to 2.10 */
539 if (lttng_strncpy(msg
.channel_name
, channel_name
,
540 sizeof(msg
.channel_name
))) {
544 if (lttng_strncpy(msg
.pathname
, pathname
,
545 sizeof(msg
.pathname
))) {
549 msg
.tracefile_size
= htobe64(tracefile_size
);
550 msg
.tracefile_count
= htobe64(tracefile_count
);
553 ret
= send_command(rsock
, RELAYD_ADD_STREAM
, (void *) &msg
, sizeof(msg
), 0);
562 static int relayd_add_stream_2_11(struct lttcomm_relayd_sock
*rsock
,
563 const char *channel_name
, const char *pathname
,
564 uint64_t tracefile_size
, uint64_t tracefile_count
,
565 uint64_t trace_archive_id
)
568 struct lttcomm_relayd_add_stream_2_11
*msg
= NULL
;
569 size_t channel_name_len
;
573 /* The two names are sent with a '\0' delimiter between them. */
574 channel_name_len
= strlen(channel_name
) + 1;
575 pathname_len
= strlen(pathname
) + 1;
577 msg_length
= sizeof(*msg
) + channel_name_len
+ pathname_len
;
578 msg
= zmalloc
<lttcomm_relayd_add_stream_2_11
>(msg_length
);
580 PERROR("zmalloc add_stream_2_11 command message");
585 LTTNG_ASSERT(channel_name_len
<= UINT32_MAX
);
586 msg
->channel_name_len
= htobe32(channel_name_len
);
588 LTTNG_ASSERT(pathname_len
<= UINT32_MAX
);
589 msg
->pathname_len
= htobe32(pathname_len
);
591 if (lttng_strncpy(msg
->names
, channel_name
, channel_name_len
)) {
595 if (lttng_strncpy(msg
->names
+ channel_name_len
, pathname
, pathname_len
)) {
600 msg
->tracefile_size
= htobe64(tracefile_size
);
601 msg
->tracefile_count
= htobe64(tracefile_count
);
602 msg
->trace_chunk_id
= htobe64(trace_archive_id
);
605 ret
= send_command(rsock
, RELAYD_ADD_STREAM
, (void *) msg
, msg_length
, 0);
616 * Add stream on the relayd and assign stream handle to the stream_id argument.
618 * Chunks are not supported by relayd prior to 2.11, but are used to
619 * internally between session daemon and consumer daemon to keep track
620 * of the channel and stream output path.
622 * On success return 0 else return ret_code negative value.
624 int relayd_add_stream(struct lttcomm_relayd_sock
*rsock
, const char *channel_name
,
625 const char *domain_name
, const char *_pathname
, uint64_t *stream_id
,
626 uint64_t tracefile_size
, uint64_t tracefile_count
,
627 struct lttng_trace_chunk
*trace_chunk
)
630 struct lttcomm_relayd_status_stream reply
;
631 char pathname
[RELAYD_COMM_LTTNG_PATH_MAX
];
633 /* Code flow error. Safety net. */
635 LTTNG_ASSERT(channel_name
);
636 LTTNG_ASSERT(domain_name
);
637 LTTNG_ASSERT(_pathname
);
638 LTTNG_ASSERT(trace_chunk
);
640 DBG("Relayd adding stream for channel name %s", channel_name
);
642 /* Compat with relayd 2.1 */
643 if (rsock
->minor
== 1) {
645 ret
= relayd_add_stream_2_1(rsock
, channel_name
, _pathname
);
647 } else if (rsock
->minor
> 1 && rsock
->minor
< 11) {
648 /* From 2.2 to 2.10 */
649 ret
= relayd_add_stream_2_2(rsock
, channel_name
, _pathname
,
650 tracefile_size
, tracefile_count
);
652 const char *separator
;
653 enum lttng_trace_chunk_status chunk_status
;
656 if (_pathname
[0] == '\0') {
662 ret
= snprintf(pathname
, RELAYD_COMM_LTTNG_PATH_MAX
, "%s%s%s",
663 domain_name
, separator
, _pathname
);
664 if (ret
<= 0 || ret
>= RELAYD_COMM_LTTNG_PATH_MAX
) {
665 ERR("Failed to format stream path: %s",
666 ret
<= 0 ? "formatting error" :
667 "path exceeds maximal allowed length");
672 chunk_status
= lttng_trace_chunk_get_id(trace_chunk
,
674 LTTNG_ASSERT(chunk_status
== LTTNG_TRACE_CHUNK_STATUS_OK
);
676 /* From 2.11 to ...*/
677 ret
= relayd_add_stream_2_11(rsock
, channel_name
, pathname
,
678 tracefile_size
, tracefile_count
,
687 /* Waiting for reply */
688 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
693 /* Back to host bytes order. */
694 reply
.handle
= be64toh(reply
.handle
);
695 reply
.ret_code
= be32toh(reply
.ret_code
);
697 /* Return session id or negative ret code. */
698 if (reply
.ret_code
!= LTTNG_OK
) {
700 ERR("Relayd add stream replied error %d", reply
.ret_code
);
704 *stream_id
= reply
.handle
;
707 DBG("Relayd stream added successfully with handle %" PRIu64
,
715 * Inform the relay that all the streams for the current channel has been sent.
717 * On success return 0 else return ret_code negative value.
719 int relayd_streams_sent(struct lttcomm_relayd_sock
*rsock
)
722 struct lttcomm_relayd_generic_reply reply
;
724 /* Code flow error. Safety net. */
727 DBG("Relayd sending streams sent.");
729 /* This feature was introduced in 2.4, ignore it for earlier versions. */
730 if (rsock
->minor
< 4) {
736 ret
= send_command(rsock
, RELAYD_STREAMS_SENT
, NULL
, 0, 0);
741 /* Waiting for reply */
742 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
747 /* Back to host bytes order. */
748 reply
.ret_code
= be32toh(reply
.ret_code
);
750 /* Return session id or negative ret code. */
751 if (reply
.ret_code
!= LTTNG_OK
) {
753 ERR("Relayd streams sent replied error %d", reply
.ret_code
);
760 DBG("Relayd streams sent success");
768 * Check version numbers on the relayd.
769 * If major versions are compatible, we assign minor_to_use to the
770 * minor version of the procotol we are going to use for this session.
772 * Return 0 if the two daemons are compatible, LTTNG_ERR_RELAYD_VERSION_FAIL
773 * otherwise, or a negative value on network errors.
775 int relayd_version_check(struct lttcomm_relayd_sock
*rsock
)
778 struct lttcomm_relayd_version msg
;
780 /* Code flow error. Safety net. */
783 DBG("Relayd version check for major.minor %u.%u", rsock
->major
,
786 memset(&msg
, 0, sizeof(msg
));
787 /* Prepare network byte order before transmission. */
788 msg
.major
= htobe32(rsock
->major
);
789 msg
.minor
= htobe32(rsock
->minor
);
792 ret
= send_command(rsock
, RELAYD_VERSION
, (void *) &msg
, sizeof(msg
), 0);
797 /* Receive response */
798 ret
= recv_reply(rsock
, (void *) &msg
, sizeof(msg
));
803 /* Set back to host bytes order */
804 msg
.major
= be32toh(msg
.major
);
805 msg
.minor
= be32toh(msg
.minor
);
808 * Only validate the major version. If the other side is higher,
809 * communication is not possible. Only major version equal can talk to each
810 * other. If the minor version differs, the lowest version is used by both
813 if (msg
.major
!= rsock
->major
) {
815 ret
= LTTNG_ERR_RELAYD_VERSION_FAIL
;
816 DBG2("Relayd version is NOT compatible. Relayd version %u != %u (us)",
817 msg
.major
, rsock
->major
);
822 * If the relayd's minor version is higher, it will adapt to our version so
823 * we can continue to use the latest relayd communication data structure.
824 * If the received minor version is higher, the relayd should adapt to us.
826 if (rsock
->minor
> msg
.minor
) {
827 rsock
->minor
= msg
.minor
;
830 /* Version number compatible */
831 DBG2("Relayd version is compatible, using protocol version %u.%u",
832 rsock
->major
, rsock
->minor
);
840 * Add stream on the relayd and assign stream handle to the stream_id argument.
842 * On success return 0 else return ret_code negative value.
844 int relayd_send_metadata(struct lttcomm_relayd_sock
*rsock
, size_t len
)
848 /* Code flow error. Safety net. */
851 DBG("Relayd sending metadata of size %zu", len
);
854 ret
= send_command(rsock
, RELAYD_SEND_METADATA
, NULL
, len
, 0);
859 DBG2("Relayd metadata added successfully");
862 * After that call, the metadata data MUST be sent to the relayd so the
863 * receive size on the other end matches the len of the metadata packet
864 * header. This is why we don't wait for a reply here.
872 * Connect to relay daemon with an allocated lttcomm_relayd_sock.
874 int relayd_connect(struct lttcomm_relayd_sock
*rsock
)
876 /* Code flow error. Safety net. */
879 if (!rsock
->sock
.ops
) {
881 * Attempting a connect on a non-initialized socket.
886 DBG3("Relayd connect ...");
888 return rsock
->sock
.ops
->connect(&rsock
->sock
);
892 * Close relayd socket with an allocated lttcomm_relayd_sock.
894 * If no socket operations are found, simply return 0 meaning that everything
895 * is fine. Without operations, the socket can not possibly be opened or used.
896 * This is possible if the socket was allocated but not created. However, the
897 * caller could simply use it to store a valid file descriptor for instance
898 * passed over a Unix socket and call this to cleanup but still without a valid
901 * Return the close returned value. On error, a negative value is usually
902 * returned back from close(2).
904 int relayd_close(struct lttcomm_relayd_sock
*rsock
)
908 /* Code flow error. Safety net. */
911 /* An invalid fd is fine, return success. */
912 if (rsock
->sock
.fd
< 0) {
917 DBG3("Relayd closing socket %d", rsock
->sock
.fd
);
919 if (rsock
->sock
.ops
) {
920 ret
= rsock
->sock
.ops
->close(&rsock
->sock
);
922 /* Default call if no specific ops found. */
923 ret
= close(rsock
->sock
.fd
);
925 PERROR("relayd_close default close");
935 * Send data header structure to the relayd.
937 int relayd_send_data_hdr(struct lttcomm_relayd_sock
*rsock
,
938 struct lttcomm_relayd_data_hdr
*hdr
, size_t size
)
942 /* Code flow error. Safety net. */
946 if (rsock
->sock
.fd
< 0) {
950 DBG3("Relayd sending data header of size %zu", size
);
952 /* Again, safety net */
954 size
= sizeof(struct lttcomm_relayd_data_hdr
);
957 /* Only send data header. */
958 ret
= rsock
->sock
.ops
->sendmsg(&rsock
->sock
, hdr
, size
, 0);
965 * The data MUST be sent right after that command for the receive on the
966 * other end to match the size in the header.
974 * Send close stream command to the relayd.
976 int relayd_send_close_stream(struct lttcomm_relayd_sock
*rsock
, uint64_t stream_id
,
977 uint64_t last_net_seq_num
)
980 struct lttcomm_relayd_close_stream msg
;
981 struct lttcomm_relayd_generic_reply reply
;
983 /* Code flow error. Safety net. */
986 DBG("Relayd closing stream id %" PRIu64
, stream_id
);
988 memset(&msg
, 0, sizeof(msg
));
989 msg
.stream_id
= htobe64(stream_id
);
990 msg
.last_net_seq_num
= htobe64(last_net_seq_num
);
993 ret
= send_command(rsock
, RELAYD_CLOSE_STREAM
, (void *) &msg
, sizeof(msg
), 0);
998 /* Receive response */
999 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
1004 reply
.ret_code
= be32toh(reply
.ret_code
);
1006 /* Return session id or negative ret code. */
1007 if (reply
.ret_code
!= LTTNG_OK
) {
1009 ERR("Relayd close stream replied error %d", reply
.ret_code
);
1015 DBG("Relayd close stream id %" PRIu64
" successfully", stream_id
);
1022 * Check for data availability for a given stream id.
1024 * Return 0 if NOT pending, 1 if so and a negative value on error.
1026 int relayd_data_pending(struct lttcomm_relayd_sock
*rsock
, uint64_t stream_id
,
1027 uint64_t last_net_seq_num
)
1030 struct lttcomm_relayd_data_pending msg
;
1031 struct lttcomm_relayd_generic_reply reply
;
1033 /* Code flow error. Safety net. */
1034 LTTNG_ASSERT(rsock
);
1036 DBG("Relayd data pending for stream id %" PRIu64
, stream_id
);
1038 memset(&msg
, 0, sizeof(msg
));
1039 msg
.stream_id
= htobe64(stream_id
);
1040 msg
.last_net_seq_num
= htobe64(last_net_seq_num
);
1043 ret
= send_command(rsock
, RELAYD_DATA_PENDING
, (void *) &msg
,
1049 /* Receive response */
1050 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
1055 reply
.ret_code
= be32toh(reply
.ret_code
);
1057 /* Return session id or negative ret code. */
1058 if (reply
.ret_code
>= LTTNG_OK
) {
1059 ERR("Relayd data pending replied error %d", reply
.ret_code
);
1062 /* At this point, the ret code is either 1 or 0 */
1063 ret
= reply
.ret_code
;
1065 DBG("Relayd data is %s pending for stream id %" PRIu64
,
1066 ret
== 1 ? "" : "NOT", stream_id
);
1073 * Check on the relayd side for a quiescent state on the control socket.
1075 int relayd_quiescent_control(struct lttcomm_relayd_sock
*rsock
,
1076 uint64_t metadata_stream_id
)
1079 struct lttcomm_relayd_quiescent_control msg
;
1080 struct lttcomm_relayd_generic_reply reply
;
1082 /* Code flow error. Safety net. */
1083 LTTNG_ASSERT(rsock
);
1085 DBG("Relayd checking quiescent control state");
1087 memset(&msg
, 0, sizeof(msg
));
1088 msg
.stream_id
= htobe64(metadata_stream_id
);
1091 ret
= send_command(rsock
, RELAYD_QUIESCENT_CONTROL
, &msg
, sizeof(msg
), 0);
1096 /* Receive response */
1097 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
1102 reply
.ret_code
= be32toh(reply
.ret_code
);
1104 /* Return session id or negative ret code. */
1105 if (reply
.ret_code
!= LTTNG_OK
) {
1107 ERR("Relayd quiescent control replied error %d", reply
.ret_code
);
1111 /* Control socket is quiescent */
1119 * Begin a data pending command for a specific session id.
1121 int relayd_begin_data_pending(struct lttcomm_relayd_sock
*rsock
, uint64_t id
)
1124 struct lttcomm_relayd_begin_data_pending msg
;
1125 struct lttcomm_relayd_generic_reply reply
;
1127 /* Code flow error. Safety net. */
1128 LTTNG_ASSERT(rsock
);
1130 DBG("Relayd begin data pending");
1132 memset(&msg
, 0, sizeof(msg
));
1133 msg
.session_id
= htobe64(id
);
1136 ret
= send_command(rsock
, RELAYD_BEGIN_DATA_PENDING
, &msg
, sizeof(msg
), 0);
1141 /* Receive response */
1142 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
1147 reply
.ret_code
= be32toh(reply
.ret_code
);
1149 /* Return session id or negative ret code. */
1150 if (reply
.ret_code
!= LTTNG_OK
) {
1152 ERR("Relayd begin data pending replied error %d", reply
.ret_code
);
1163 * End a data pending command for a specific session id.
1165 * Return 0 on success and set is_data_inflight to 0 if no data is being
1166 * streamed or 1 if it is the case.
1168 int relayd_end_data_pending(struct lttcomm_relayd_sock
*rsock
, uint64_t id
,
1169 unsigned int *is_data_inflight
)
1172 struct lttcomm_relayd_end_data_pending msg
;
1173 struct lttcomm_relayd_generic_reply reply
;
1175 /* Code flow error. Safety net. */
1176 LTTNG_ASSERT(rsock
);
1178 DBG("Relayd end data pending");
1180 memset(&msg
, 0, sizeof(msg
));
1181 msg
.session_id
= htobe64(id
);
1184 ret
= send_command(rsock
, RELAYD_END_DATA_PENDING
, &msg
, sizeof(msg
), 0);
1189 /* Receive response */
1190 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
1195 recv_ret
= be32toh(reply
.ret_code
);
1201 *is_data_inflight
= recv_ret
;
1203 DBG("Relayd end data pending is data inflight: %d", recv_ret
);
1212 * Send index to the relayd.
1214 int relayd_send_index(struct lttcomm_relayd_sock
*rsock
,
1215 struct ctf_packet_index
*index
, uint64_t relay_stream_id
,
1216 uint64_t net_seq_num
)
1219 struct lttcomm_relayd_index msg
;
1220 struct lttcomm_relayd_generic_reply reply
;
1222 /* Code flow error. Safety net. */
1223 LTTNG_ASSERT(rsock
);
1225 if (rsock
->minor
< 4) {
1226 DBG("Not sending indexes before protocol 2.4");
1231 DBG("Relayd sending index for stream ID %" PRIu64
, relay_stream_id
);
1233 memset(&msg
, 0, sizeof(msg
));
1234 msg
.relay_stream_id
= htobe64(relay_stream_id
);
1235 msg
.net_seq_num
= htobe64(net_seq_num
);
1237 /* The index is already in big endian. */
1238 msg
.packet_size
= index
->packet_size
;
1239 msg
.content_size
= index
->content_size
;
1240 msg
.timestamp_begin
= index
->timestamp_begin
;
1241 msg
.timestamp_end
= index
->timestamp_end
;
1242 msg
.events_discarded
= index
->events_discarded
;
1243 msg
.stream_id
= index
->stream_id
;
1245 if (rsock
->minor
>= 8) {
1246 msg
.stream_instance_id
= index
->stream_instance_id
;
1247 msg
.packet_seq_num
= index
->packet_seq_num
;
1251 ret
= send_command(rsock
, RELAYD_SEND_INDEX
, &msg
,
1252 lttcomm_relayd_index_len(lttng_to_index_major(rsock
->major
,
1254 lttng_to_index_minor(rsock
->major
, rsock
->minor
)),
1260 /* Receive response */
1261 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
1266 reply
.ret_code
= be32toh(reply
.ret_code
);
1268 /* Return session id or negative ret code. */
1269 if (reply
.ret_code
!= LTTNG_OK
) {
1271 ERR("Relayd send index replied error %d", reply
.ret_code
);
1282 * Ask the relay to reset the metadata trace file (regeneration).
1284 int relayd_reset_metadata(struct lttcomm_relayd_sock
*rsock
,
1285 uint64_t stream_id
, uint64_t version
)
1288 struct lttcomm_relayd_reset_metadata msg
;
1289 struct lttcomm_relayd_generic_reply reply
;
1291 /* Code flow error. Safety net. */
1292 LTTNG_ASSERT(rsock
);
1294 /* Should have been prevented by the sessiond. */
1295 if (rsock
->minor
< 8) {
1296 ERR("Metadata regeneration unsupported before 2.8");
1301 DBG("Relayd reset metadata stream id %" PRIu64
, stream_id
);
1303 memset(&msg
, 0, sizeof(msg
));
1304 msg
.stream_id
= htobe64(stream_id
);
1305 msg
.version
= htobe64(version
);
1308 ret
= send_command(rsock
, RELAYD_RESET_METADATA
, (void *) &msg
, sizeof(msg
), 0);
1313 /* Receive response */
1314 ret
= recv_reply(rsock
, (void *) &reply
, sizeof(reply
));
1319 reply
.ret_code
= be32toh(reply
.ret_code
);
1321 /* Return session id or negative ret code. */
1322 if (reply
.ret_code
!= LTTNG_OK
) {
1324 ERR("Relayd reset metadata replied error %d", reply
.ret_code
);
1330 DBG("Relayd reset metadata stream id %" PRIu64
" successfully", stream_id
);
1336 int relayd_rotate_streams(struct lttcomm_relayd_sock
*sock
,
1337 unsigned int stream_count
, const uint64_t *new_chunk_id
,
1338 const struct relayd_stream_rotation_position
*positions
)
1342 struct lttng_dynamic_buffer payload
;
1343 struct lttcomm_relayd_generic_reply reply
= {};
1344 struct lttcomm_relayd_rotate_streams msg
;
1345 char new_chunk_id_buf
[MAX_INT_DEC_LEN(*new_chunk_id
)] = {};
1346 const char *new_chunk_id_str
;
1348 msg
.stream_count
= htobe32((uint32_t) stream_count
);
1349 msg
.new_chunk_id
= (typeof(msg
.new_chunk_id
)){
1350 .is_set
= !!new_chunk_id
,
1351 .value
= htobe64(new_chunk_id
? *new_chunk_id
: 0),
1354 if (!relayd_supports_chunks(sock
)) {
1355 DBG("Refusing to rotate remote streams: relayd does not support chunks");
1359 lttng_dynamic_buffer_init(&payload
);
1361 /* Code flow error. Safety net. */
1365 ret
= snprintf(new_chunk_id_buf
, sizeof(new_chunk_id_buf
),
1366 "%" PRIu64
, *new_chunk_id
);
1367 if (ret
== -1 || ret
>= sizeof(new_chunk_id_buf
)) {
1368 new_chunk_id_str
= "formatting error";
1370 new_chunk_id_str
= new_chunk_id_buf
;
1373 new_chunk_id_str
= "none";
1376 DBG("Preparing \"rotate streams\" command payload: new_chunk_id = %s, stream_count = %u",
1377 new_chunk_id_str
, stream_count
);
1379 ret
= lttng_dynamic_buffer_append(&payload
, &msg
, sizeof(msg
));
1381 ERR("Failed to allocate \"rotate streams\" command payload");
1385 for (i
= 0; i
< stream_count
; i
++) {
1386 const struct relayd_stream_rotation_position
*position
=
1388 const struct lttcomm_relayd_stream_rotation_position comm_position
= {
1389 .stream_id
= htobe64(position
->stream_id
),
1390 .rotate_at_seq_num
= htobe64(
1391 position
->rotate_at_seq_num
),
1394 DBG("Rotate stream %" PRIu64
" at sequence number %" PRIu64
,
1395 position
->stream_id
,
1396 position
->rotate_at_seq_num
);
1397 ret
= lttng_dynamic_buffer_append(&payload
, &comm_position
,
1398 sizeof(comm_position
));
1400 ERR("Failed to allocate \"rotate streams\" command payload");
1406 ret
= send_command(sock
, RELAYD_ROTATE_STREAMS
, payload
.data
,
1409 ERR("Failed to send \"rotate stream\" command");
1413 /* Receive response. */
1414 ret
= recv_reply(sock
, &reply
, sizeof(reply
));
1416 ERR("Failed to receive \"rotate streams\" command reply");
1420 reply
.ret_code
= be32toh(reply
.ret_code
);
1421 if (reply
.ret_code
!= LTTNG_OK
) {
1423 ERR("Relayd rotate streams replied error %d", reply
.ret_code
);
1427 DBG("Relayd rotated streams successfully");
1431 lttng_dynamic_buffer_reset(&payload
);
1435 int relayd_create_trace_chunk(struct lttcomm_relayd_sock
*sock
,
1436 struct lttng_trace_chunk
*chunk
)
1439 enum lttng_trace_chunk_status status
;
1440 struct lttcomm_relayd_create_trace_chunk msg
= {};
1441 struct lttcomm_relayd_generic_reply reply
= {};
1442 struct lttng_dynamic_buffer payload
;
1444 time_t creation_timestamp
;
1445 const char *chunk_name
;
1446 size_t chunk_name_length
;
1447 bool overridden_name
;
1449 lttng_dynamic_buffer_init(&payload
);
1451 if (!relayd_supports_chunks(sock
)) {
1452 DBG("Refusing to create remote trace chunk: relayd does not support chunks");
1456 status
= lttng_trace_chunk_get_id(chunk
, &chunk_id
);
1457 if (status
!= LTTNG_TRACE_CHUNK_STATUS_OK
) {
1462 status
= lttng_trace_chunk_get_creation_timestamp(
1463 chunk
, &creation_timestamp
);
1464 if (status
!= LTTNG_TRACE_CHUNK_STATUS_OK
) {
1469 status
= lttng_trace_chunk_get_name(
1470 chunk
, &chunk_name
, &overridden_name
);
1471 if (status
!= LTTNG_TRACE_CHUNK_STATUS_OK
&&
1472 status
!= LTTNG_TRACE_CHUNK_STATUS_NONE
) {
1477 chunk_name_length
= overridden_name
? (strlen(chunk_name
) + 1) : 0;
1478 msg
.chunk_id
= htobe64(chunk_id
);
1479 msg
.creation_timestamp
= htobe64((uint64_t) creation_timestamp
);
1480 msg
.override_name_length
= htobe32((uint32_t) chunk_name_length
);
1482 ret
= lttng_dynamic_buffer_append(&payload
, &msg
, sizeof(msg
));
1486 if (chunk_name_length
) {
1487 ret
= lttng_dynamic_buffer_append(
1488 &payload
, chunk_name
, chunk_name_length
);
1494 ret
= send_command(sock
, RELAYD_CREATE_TRACE_CHUNK
, payload
.data
,
1497 ERR("Failed to send trace chunk creation command to relay daemon");
1501 ret
= recv_reply(sock
, &reply
, sizeof(reply
));
1503 ERR("Failed to receive relay daemon trace chunk creation command reply");
1507 reply
.ret_code
= be32toh(reply
.ret_code
);
1508 if (reply
.ret_code
!= LTTNG_OK
) {
1510 ERR("Relayd trace chunk create replied error %d",
1514 DBG("Relayd successfully created trace chunk: chunk_id = %" PRIu64
,
1519 lttng_dynamic_buffer_reset(&payload
);
1523 int relayd_close_trace_chunk(struct lttcomm_relayd_sock
*sock
,
1524 struct lttng_trace_chunk
*chunk
,
1528 enum lttng_trace_chunk_status status
;
1529 struct lttcomm_relayd_close_trace_chunk msg
= {};
1530 struct lttcomm_relayd_close_trace_chunk_reply reply
= {};
1532 time_t close_timestamp
;
1533 LTTNG_OPTIONAL(enum lttng_trace_chunk_command_type
) close_command
= {};
1535 if (!relayd_supports_chunks(sock
)) {
1536 DBG("Refusing to close remote trace chunk: relayd does not support chunks");
1540 status
= lttng_trace_chunk_get_id(chunk
, &chunk_id
);
1541 if (status
!= LTTNG_TRACE_CHUNK_STATUS_OK
) {
1542 ERR("Failed to get trace chunk id");
1547 status
= lttng_trace_chunk_get_close_timestamp(chunk
, &close_timestamp
);
1548 if (status
!= LTTNG_TRACE_CHUNK_STATUS_OK
) {
1549 ERR("Failed to get trace chunk close timestamp");
1554 status
= lttng_trace_chunk_get_close_command(chunk
,
1555 &close_command
.value
);
1557 case LTTNG_TRACE_CHUNK_STATUS_OK
:
1558 close_command
.is_set
= 1;
1560 case LTTNG_TRACE_CHUNK_STATUS_NONE
:
1563 ERR("Failed to get trace chunk close command");
1568 msg
= (typeof(msg
)){
1569 .chunk_id
= htobe64(chunk_id
),
1570 .close_timestamp
= htobe64((uint64_t) close_timestamp
),
1572 .is_set
= close_command
.is_set
,
1573 .value
= htobe32((uint32_t) close_command
.value
),
1577 ret
= send_command(sock
, RELAYD_CLOSE_TRACE_CHUNK
, &msg
, sizeof(msg
),
1580 ERR("Failed to send trace chunk close command to relay daemon");
1584 ret
= recv_reply(sock
, &reply
, sizeof(reply
));
1586 ERR("Failed to receive relay daemon trace chunk close command reply");
1590 reply
.path_length
= be32toh(reply
.path_length
);
1591 if (reply
.path_length
>= LTTNG_PATH_MAX
) {
1592 ERR("Chunk path too long");
1597 ret
= recv_reply(sock
, path
, reply
.path_length
);
1599 ERR("Failed to receive relay daemon trace chunk close command reply");
1602 if (path
[reply
.path_length
- 1] != '\0') {
1603 ERR("Invalid trace chunk path returned by relay daemon (not null-terminated)");
1608 reply
.generic
.ret_code
= be32toh(reply
.generic
.ret_code
);
1609 if (reply
.generic
.ret_code
!= LTTNG_OK
) {
1611 ERR("Relayd trace chunk close replied error %d",
1612 reply
.generic
.ret_code
);
1615 DBG("Relayd successfully closed trace chunk: chunk_id = %" PRIu64
,
1622 int relayd_trace_chunk_exists(struct lttcomm_relayd_sock
*sock
,
1623 uint64_t chunk_id
, bool *chunk_exists
)
1626 struct lttcomm_relayd_trace_chunk_exists msg
= {};
1627 struct lttcomm_relayd_trace_chunk_exists_reply reply
= {};
1629 if (!relayd_supports_chunks(sock
)) {
1630 DBG("Refusing to check for trace chunk existence: relayd does not support chunks");
1631 /* The chunk will never exist */
1632 *chunk_exists
= false;
1636 msg
= (typeof(msg
)){
1637 .chunk_id
= htobe64(chunk_id
),
1640 ret
= send_command(sock
, RELAYD_TRACE_CHUNK_EXISTS
, &msg
, sizeof(msg
),
1643 ERR("Failed to send trace chunk exists command to relay daemon");
1647 ret
= recv_reply(sock
, &reply
, sizeof(reply
));
1649 ERR("Failed to receive relay daemon trace chunk close command reply");
1653 reply
.generic
.ret_code
= be32toh(reply
.generic
.ret_code
);
1654 if (reply
.generic
.ret_code
!= LTTNG_OK
) {
1656 ERR("Relayd trace chunk close replied error %d",
1657 reply
.generic
.ret_code
);
1660 DBG("Relayd successfully checked trace chunk existence: chunk_id = %" PRIu64
1661 ", exists = %s", chunk_id
,
1662 reply
.trace_chunk_exists
? "true" : "false");
1663 *chunk_exists
= !!reply
.trace_chunk_exists
;
1669 enum lttng_error_code
relayd_get_configuration(struct lttcomm_relayd_sock
*sock
,
1670 uint64_t query_flags
,
1671 uint64_t& result_flags
,
1672 uint64_t *trace_format_query_results
)
1675 enum lttng_error_code ret_code
= LTTNG_OK
;
1676 struct lttcomm_relayd_get_configuration msg
= {};
1677 struct lttcomm_relayd_get_configuration_reply reply
= {};
1678 lttng_dynamic_buffer buffer
;
1679 bool requesting_trace_format
= query_flags
&
1680 LTTCOMM_RELAYD_CONFIGURATION_QUERY_FLAG_SUPPORTED_TRACE_FORMAT
;
1682 lttng_dynamic_buffer_init(&buffer
);
1684 assert(!(query_flags
& ~LTTCOMM_RELAYD_CONFIGURATION_QUERY_FLAG_MASK
));
1685 assert(!(requesting_trace_format
&& !trace_format_query_results
));
1687 if (!relayd_supports_get_configuration(sock
)) {
1688 DBG("Refusing to get relayd configuration (unsupported by relayd)");
1690 if (trace_format_query_results
) {
1691 *trace_format_query_results
=
1692 LTTCOMM_RELAYD_CONFIGURATION_TRACE_FORMAT_SUPPORTED_CTF1
;
1697 if (requesting_trace_format
&& !relayd_supports_get_configuration_trace_format(sock
)) {
1699 * Provide default value for that query since lttng-relayd does
1700 * not know this query type.
1702 if (trace_format_query_results
) {
1703 *trace_format_query_results
=
1704 LTTCOMM_RELAYD_CONFIGURATION_TRACE_FORMAT_SUPPORTED_CTF1
;
1706 /* Remove from the query set. */
1707 query_flags
&= ~LTTCOMM_RELAYD_CONFIGURATION_QUERY_FLAG_SUPPORTED_TRACE_FORMAT
;
1708 requesting_trace_format
= false;
1711 msg
.query_flags
= htobe64(query_flags
);
1713 ret
= send_command(sock
, RELAYD_GET_CONFIGURATION
, &msg
, sizeof(msg
), 0);
1715 ERR("Failed to send get configuration command to relay daemon");
1716 ret_code
= LTTNG_ERR_RELAYD_CONNECT_FAIL
;
1720 ret
= recv_reply(sock
, &reply
, sizeof(reply
));
1722 ERR("Failed to receive relay daemon get configuration command reply");
1723 ret_code
= LTTNG_ERR_RELAYD_CONNECT_FAIL
;
1727 ret_code
= static_cast<enum lttng_error_code
>(be32toh(reply
.generic
.ret_code
));
1728 if (ret_code
!= LTTNG_OK
) {
1729 ERR("Relayd get configuration replied error %d", ret_code
);
1733 result_flags
= be64toh(reply
.relayd_configuration_flags
);
1734 DBG("Relayd successfully got configuration: query_flags = %" PRIu64
1735 ", results_flags = %" PRIu64
,
1736 query_flags
, result_flags
);
1738 if (!requesting_trace_format
) {
1739 ret_code
= LTTNG_OK
;
1743 /* Receive trace formats */
1745 lttcomm_relayd_get_configuration_specialized_query_reply query_flag_reply
= {};
1746 ret
= recv_reply(sock
, &query_flag_reply
, sizeof(query_flag_reply
));
1748 ERR("Failed to receive relay daemon get configuration query flag data");
1749 ret_code
= LTTNG_ERR_RELAYD_CONNECT_FAIL
;
1753 query_flag_reply
.query_flag
= be64toh(query_flag_reply
.query_flag
);
1754 LTTNG_ASSERT(query_flag_reply
.query_flag
&
1755 LTTCOMM_RELAYD_CONFIGURATION_QUERY_FLAG_SUPPORTED_TRACE_FORMAT
);
1757 query_flag_reply
.payload_len
= be64toh(query_flag_reply
.payload_len
);
1758 LTTNG_ASSERT(query_flag_reply
.payload_len
== sizeof(uint64_t));
1760 lttng_dynamic_buffer_set_size(&buffer
, query_flag_reply
.payload_len
);
1762 ret
= recv_reply(sock
, buffer
.data
, query_flag_reply
.payload_len
);
1764 ret_code
= LTTNG_ERR_RELAYD_CONNECT_FAIL
;
1765 ERR("Failed to receive configuration dynamic payload for flag TODO");
1769 *trace_format_query_results
= be64toh(*(uint64_t *) buffer
.data
);
1772 ret_code
= LTTNG_OK
;
1775 lttng_dynamic_buffer_reset(&buffer
);