+ * Starting from 2.11, RELAYD_CREATE_SESSION payload (session_name,
+ * hostname, and base_path) have no length restriction on the sender side.
+ * Length for both payloads is stored in the msg struct. A new dynamic size
+ * payload size is introduced.
+ */
+static int relayd_create_session_2_11(struct lttcomm_relayd_sock *rsock,
+ const char *session_name, const char *hostname,
+ const char *base_path, int session_live_timer,
+ unsigned int snapshot, uint64_t sessiond_session_id,
+ const lttng_uuid sessiond_uuid, const uint64_t *current_chunk_id,
+ time_t creation_time, bool session_name_contains_creation_time,
+ struct lttcomm_relayd_create_session_reply_2_11 *reply,
+ char *output_path)
+{
+ int ret;
+ struct lttcomm_relayd_create_session_2_11 *msg = NULL;
+ size_t session_name_len;
+ size_t hostname_len;
+ size_t base_path_len;
+ size_t msg_length;
+ char *dst;
+
+ if (!base_path) {
+ base_path = "";
+ }
+ /* The three names are sent with a '\0' delimiter between them. */
+ session_name_len = strlen(session_name) + 1;
+ hostname_len = strlen(hostname) + 1;
+ base_path_len = strlen(base_path) + 1;
+
+ msg_length = sizeof(*msg) + session_name_len + hostname_len + base_path_len;
+ msg = zmalloc(msg_length);
+ if (!msg) {
+ PERROR("zmalloc create_session_2_11 command message");
+ ret = -1;
+ goto error;
+ }
+
+ assert(session_name_len <= UINT32_MAX);
+ msg->session_name_len = htobe32(session_name_len);
+
+ assert(hostname_len <= UINT32_MAX);
+ msg->hostname_len = htobe32(hostname_len);
+
+ assert(base_path_len <= UINT32_MAX);
+ msg->base_path_len = htobe32(base_path_len);
+
+ dst = msg->names;
+ if (lttng_strncpy(dst, session_name, session_name_len)) {
+ ret = -1;
+ goto error;
+ }
+ dst += session_name_len;
+ if (lttng_strncpy(dst, hostname, hostname_len)) {
+ ret = -1;
+ goto error;
+ }
+ dst += hostname_len;
+ if (lttng_strncpy(dst, base_path, base_path_len)) {
+ ret = -1;
+ goto error;
+ }
+
+ msg->live_timer = htobe32(session_live_timer);
+ msg->snapshot = !!snapshot;
+
+ lttng_uuid_copy(msg->sessiond_uuid, sessiond_uuid);
+ msg->session_id = htobe64(sessiond_session_id);
+ msg->session_name_contains_creation_time = session_name_contains_creation_time;
+ if (current_chunk_id) {
+ LTTNG_OPTIONAL_SET(&msg->current_chunk_id,
+ htobe64(*current_chunk_id));
+ }
+
+ msg->creation_time = htobe64((uint64_t) creation_time);
+
+ /* Send command */
+ ret = send_command(rsock, RELAYD_CREATE_SESSION, msg, msg_length, 0);
+ if (ret < 0) {
+ goto error;
+ }
+ /* Receive response */
+ ret = recv_reply(rsock, reply, sizeof(*reply));
+ if (ret < 0) {
+ goto error;
+ }
+ reply->generic.session_id = be64toh(reply->generic.session_id);
+ reply->generic.ret_code = be32toh(reply->generic.ret_code);
+ reply->output_path_length = be32toh(reply->output_path_length);
+ if (reply->output_path_length >= LTTNG_PATH_MAX) {
+ ERR("Invalid session output path length in reply (%" PRIu32 " bytes) exceeds maximal allowed length (%d bytes)",
+ reply->output_path_length, LTTNG_PATH_MAX);
+ ret = -1;
+ goto error;
+ }
+ ret = recv_reply(rsock, output_path, reply->output_path_length);
+ if (ret < 0) {
+ goto error;
+ }
+error:
+ free(msg);
+ return ret;
+}
+/*
+ * From 2.4 to 2.10, RELAYD_CREATE_SESSION takes additional parameters to