+ pathname = tmp_path;
+ DBG3("Kernel network consumer subdir path: %s", pathname);
+ }
+
+ /* Prep stream consumer message */
+ consumer_init_stream_comm_msg(&lkm, LTTNG_CONSUMER_ADD_STREAM,
+ channel->fd,
+ stream->fd,
+ stream->state,
+ channel->channel->attr.output,
+ 0, /* Kernel */
+ session->uid,
+ session->gid,
+ consumer->net_seq_index,
+ 0, /* Metadata flag unset */
+ stream->name,
+ pathname);
+
+ /* Send stream and file descriptor */
+ ret = consumer_send_stream(sock, consumer, &lkm, &stream->fd, 1);
+ if (ret < 0) {
+ goto error;
+ }
+
+error:
+ return ret;
+}
+
+/*
+ * Send all stream fds of kernel channel to the consumer.
+ */
+int kernel_consumer_send_channel_stream(int sock,
+ struct ltt_kernel_channel *channel, struct ltt_kernel_session *session)
+{
+ int ret;
+ struct ltt_kernel_stream *stream;
+
+ /* Safety net */
+ assert(channel);
+ assert(session);
+ assert(session->consumer);
+
+ /* Bail out if consumer is disabled */
+ if (!session->consumer->enabled) {
+ ret = LTTNG_OK;
+ goto error;
+ }
+
+ DBG("Sending streams of channel %s to kernel consumer",
+ channel->channel->name);
+
+ ret = kernel_consumer_add_channel(sock, channel);
+ if (ret < 0) {
+ goto error;
+ }
+
+ /* Send streams */
+ cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
+ if (!stream->fd) {
+ continue;
+ }