Fix: check the lttng-relayd protocol version
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 14 Jul 2014 21:11:30 +0000 (17:11 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 14 Jul 2014 21:25:39 +0000 (17:25 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/lttng-live/lttng-live-comm.c
formats/lttng-live/lttng-live.h

index 5b7f058aabdf493f82dff238afad69fe8b19587e..070674aa67c13298032d6b0fc5c4411ef03085f5 100644 (file)
@@ -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;
index cf47437bbd03e83f55331d2637833c987d1ae7ec..d7b0e860b14786950ca5dee227447d6b8dd35a83 100644 (file)
@@ -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;
This page took 0.025126 seconds and 4 git commands to generate.