Skip to contentSkip to conversation

Fix: reply to version check even on protocol mismatch

PATCH New Julien Desfossez 1 participant 1 message Feb 14, 2018 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/2 Fix: reply to version check even on protocol mismatch

In the relay, we currently put the connection when we detect the major version from the session daemon is not compatible. We don't reply to the version check message. The relay still holds a reference on the connection so it is not closed and the session daemon is left blocking in recvmsg.

The relay now replies to the version check so the session daemon knows it is not compatible, and the relay completely closes the connection on its side and removes the FD from the poll set.

---
 src/bin/lttng-relayd/main.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
src/bin/lttng-relayd/main.c +7 -3
index 61f206f..cd4f058 100644
@@ -1601,6 +1601,7 @@ static int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr,
 {
 	int ret;
 	struct lttcomm_relayd_version reply, msg;
+	bool compatible = true;
 
 	conn->version_check_done = 1;
 
@@ -1625,9 +1626,7 @@ static int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr,
 	if (reply.major != be32toh(msg.major)) {
 		DBG("Incompatible major versions (%u vs %u), deleting session",
 				reply.major, be32toh(msg.major));
-		connection_put(conn);
-		ret = 0;
-		goto end;
+		compatible = false;
 	}
 
 	conn->major = reply.major;
@@ -1646,6 +1645,11 @@ static int relay_send_version(struct lttcomm_relayd_hdr *recv_hdr,
 		ERR("Relay sending version");
 	}
 
+	if (!compatible) {
+		ret = -1;
+		goto end;
+	}
+
 	DBG("Version check done using protocol %u.%u", conn->major,
 			conn->minor);
 
Signature · 6 lines
2.7.4

_______________________________________________
lttng-dev mailing list
[email protected]
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev