From 9474416fd76b18db4642bc60b15451b87d74e5d5 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Fri, 19 Sep 2014 13:58:31 -0400 Subject: [PATCH] Add version to agent registration message Signed-off-by: David Goulet --- src/bin/lttng-sessiond/agent-thread.c | 13 +++++++++++++ src/bin/lttng-sessiond/agent.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/bin/lttng-sessiond/agent-thread.c b/src/bin/lttng-sessiond/agent-thread.c index 6790a63c6..0e827a445 100644 --- a/src/bin/lttng-sessiond/agent-thread.c +++ b/src/bin/lttng-sessiond/agent-thread.c @@ -198,6 +198,7 @@ static int handle_registration(struct lttcomm_sock *reg_sock, { int ret; pid_t pid; + uint32_t major_version, minor_version; ssize_t size; enum lttng_domain_type domain; struct agent_app *app; @@ -219,6 +220,18 @@ static int handle_registration(struct lttcomm_sock *reg_sock, } domain = be32toh(msg.domain); pid = be32toh(msg.pid); + major_version = be32toh(msg.major_version); + minor_version = be32toh(msg.minor_version); + + /* Test communication protocol version of the registring agent. */ + if (major_version != AGENT_MAJOR_VERSION) { + ret = -EINVAL; + goto error_socket; + } + if (minor_version != AGENT_MINOR_VERSION) { + ret = -EINVAL; + goto error_socket; + } DBG2("[agent-thread] New registration for pid %d domain %d on socket %d", pid, domain, new_sock->fd); diff --git a/src/bin/lttng-sessiond/agent.h b/src/bin/lttng-sessiond/agent.h index f8d9ca6ea..6564b88c8 100644 --- a/src/bin/lttng-sessiond/agent.h +++ b/src/bin/lttng-sessiond/agent.h @@ -24,6 +24,10 @@ #include #include +/* Agent protocol version that is verified during the agent registration. */ +#define AGENT_MAJOR_VERSION 1 +#define AGENT_MINOR_VERSION 0 + /* * Hash table that contains the agent app created upon registration indexed by * socket. @@ -43,6 +47,8 @@ struct agent_register_msg { /* This maps to a lttng_domain_type. */ uint32_t domain; uint32_t pid; + uint32_t major_version; + uint32_t minor_version; }; /* -- 2.34.1