From 0dfc7b628feb554b7379584a417bc65b6a84af73 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 14 Jul 2014 17:11:30 -0400 Subject: [PATCH] Fix: check the lttng-relayd protocol version Signed-off-by: Julien Desfossez Signed-off-by: Mathieu Desnoyers --- formats/lttng-live/lttng-live-comm.c | 12 ++++++++++++ formats/lttng-live/lttng-live.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/formats/lttng-live/lttng-live-comm.c b/formats/lttng-live/lttng-live-comm.c index 5b7f058a..070674aa 100644 --- a/formats/lttng-live/lttng-live-comm.c +++ b/formats/lttng-live/lttng-live-comm.c @@ -202,6 +202,18 @@ int lttng_live_establish_connection(struct lttng_live_ctx *ctx) be64toh(connect.viewer_session_id)); printf_verbose("Relayd version : %u.%u\n", be32toh(connect.major), be32toh(connect.minor)); + + if (LTTNG_LIVE_MAJOR != be32toh(connect.major)) { + fprintf(stderr, "[error] Incompatible lttng-relayd protocol\n"); + goto error; + } + /* Use the smallest protocol version implemented. */ + if (LTTNG_LIVE_MINOR > be32toh(connect.minor)) { + ctx->minor = be32toh(connect.minor); + } else { + ctx->minor = LTTNG_LIVE_MINOR; + } + ctx->major = LTTNG_LIVE_MAJOR; ret = 0; end: return ret; diff --git a/formats/lttng-live/lttng-live.h b/formats/lttng-live/lttng-live.h index cf47437b..d7b0e860 100644 --- a/formats/lttng-live/lttng-live.h +++ b/formats/lttng-live/lttng-live.h @@ -37,6 +37,9 @@ struct lttng_live_ctx { char relay_hostname[NAME_MAX]; int control_sock; int port; + /* Protocol version to use for this connection. */ + uint32_t major; + uint32_t minor; struct lttng_live_session *session; struct bt_context *bt_ctx; GArray *session_ids; -- 2.34.1