Skip to contentSkip to conversation

trace-cmd: Resend record --date fix

PATCH In review Slavomir Kaslev 2 participants 5 messages Dec 14, 2018

lore
Share & tools
lore
#0 lore raw

v4 cover trace-cmd: Resend record --date fix

Resending "trace-cmd record --date" fix while keeping backward compatibility.

Ideally those patches should land together since the last one assumes that all v3 listeners follow new behavior and don't write options in the trace file.

Changes in v4:
- split tracecmd_attach_cpu_data_fd into smaller functions
- reorder the patches per Steven's request

Changes in v3:
- added Signed-off-by

Changes in v2:
- split into 3 patches for easier reviewing
- fix tracecmd_msg_recv not reading cmd_size bytes it doesn't know about

Slavomir Kaslev (3):
trace-cmd: Prepare for protocol bump to version 3
trace-cmd: Fix record --date flag when sending tracing data to a
listener
trace-cmd: Bump protocol version to v3

 include/trace-cmd/trace-cmd.h |  16 ++-
 tracecmd/include/trace-msg.h  |   6 +-
 tracecmd/trace-listen.c       |  43 +++++---
 tracecmd/trace-msg.c          | 198 +++++++++++++++-------------------
 tracecmd/trace-output.c       |  78 +++++++-------
 tracecmd/trace-record.c       |  79 +++++++-------
 6 files changed, 210 insertions(+), 210 deletions(-)
Signature · 1 line
2.19.1
#1 lore raw

PATCH v4 1/3 trace-cmd: Prepare for protocol bump to version 3

This patch does the necessary renames to bump protocol to version 3.

No changes in behavior are introduced.

---
 include/trace-cmd/trace-cmd.h |  6 +++---
 tracecmd/include/trace-msg.h  |  6 +++---
 tracecmd/trace-listen.c       | 16 ++++++++--------
 tracecmd/trace-msg.c          |  8 ++++----
 tracecmd/trace-output.c       |  2 +-
 tracecmd/trace-record.c       | 24 ++++++++++++------------
 6 files changed, 31 insertions(+), 31 deletions(-)
include/trace-cmd/trace-cmd.h +3 -3
index 684ddb7..7cce592 100644
@@ -316,16 +316,16 @@ void tracecmd_msg_handle_close(struct tracecmd_msg_handle *msg_handle);
 /* for clients */
 int tracecmd_msg_send_init_data(struct tracecmd_msg_handle *msg_handle,
 				int **client_ports);
-int tracecmd_msg_metadata_send(struct tracecmd_msg_handle *msg_handle,
+int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
 			       const char *buf, int size);
-int tracecmd_msg_finish_sending_metadata(struct tracecmd_msg_handle *msg_handle);
+int tracecmd_msg_finish_sending_data(struct tracecmd_msg_handle *msg_handle);
 void tracecmd_msg_send_close_msg(struct tracecmd_msg_handle *msg_handle);
 
 /* for server */
 int tracecmd_msg_initial_setting(struct tracecmd_msg_handle *msg_handle);
 int tracecmd_msg_send_port_array(struct tracecmd_msg_handle *msg_handle,
 				 int *ports);
-int tracecmd_msg_collect_metadata(struct tracecmd_msg_handle *msg_handle, int ofd);
+int tracecmd_msg_collect_data(struct tracecmd_msg_handle *msg_handle, int ofd);
 bool tracecmd_msg_done(struct tracecmd_msg_handle *msg_handle);
 void tracecmd_msg_set_done(struct tracecmd_msg_handle *msg_handle);
 
tracecmd/include/trace-msg.h +3 -3
index bfd065c..722548a 100644
@@ -4,11 +4,11 @@
 #include <stdbool.h>
 
 #define UDP_MAX_PACKET	(65536 - 20)
-#define V2_MAGIC	"677768\0"
-#define V2_CPU		"-1V2"
+#define V3_MAGIC	"677768\0"
+#define V3_CPU		"-1V2"
 
 #define V1_PROTOCOL	1
-#define V2_PROTOCOL	2
+#define V3_PROTOCOL	2
 
 extern unsigned int page_size;
 
tracecmd/trace-listen.c +8 -8
index 5727c0e..a13b83b 100644
@@ -366,7 +366,7 @@ static int communicate_with_client(struct tracecmd_msg_handle *msg_handle)
 
 	/* Is the client using the new protocol? */
 	if (cpus == -1) {
-		if (memcmp(buf, V2_CPU, n) != 0) {
+		if (memcmp(buf, V3_CPU, n) != 0) {
 			/* If it did not send a version, then bail */
 			if (memcmp(buf, "-1V", 3)) {
 				plog("Unknown string %s\n", buf);
@@ -391,18 +391,18 @@ static int communicate_with_client(struct tracecmd_msg_handle *msg_handle)
 			goto try_again;
 		}
 
-		/* Let the client know we use v2 protocol */
+		/* Let the client know we use v3 protocol */
 		write(fd, "V2", 3);
 
 		/* read the rest of dummy data */
-		n = read(fd, buf, sizeof(V2_MAGIC));
-		if (memcmp(buf, V2_MAGIC, n) != 0)
+		n = read(fd, buf, sizeof(V3_MAGIC));
+		if (memcmp(buf, V3_MAGIC, n) != 0)
 			goto out;
 
 		/* We're off! */
 		write(fd, "OK", 2);
 
-		msg_handle->version = V2_PROTOCOL;
+		msg_handle->version = V3_PROTOCOL;
 
 		/* read the CPU count, the page size, and options */
 		if ((pagesize = tracecmd_msg_initial_setting(msg_handle)) < 0)
@@ -557,7 +557,7 @@ static int *create_all_readers(const char *node, const char *port,
 		start_port = udp_port + 1;
 	}
 
-	if (msg_handle->version == V2_PROTOCOL) {
+	if (msg_handle->version == V3_PROTOCOL) {
 		/* send set of port numbers to the client */
 		if (tracecmd_msg_send_port_array(msg_handle, port_array) < 0) {
 			plog("Failed sending port array\n");
@@ -674,8 +674,8 @@ static int process_client(struct tracecmd_msg_handle *msg_handle,
 	stop_msg_handle = msg_handle;
 
 	/* Now we are ready to start reading data from the client */
-	if (msg_handle->version == V2_PROTOCOL)
-		tracecmd_msg_collect_metadata(msg_handle, ofd);
+	if (msg_handle->version == V3_PROTOCOL)
+		tracecmd_msg_collect_data(msg_handle, ofd);
 	else
 		collect_metadata_from_client(msg_handle, ofd);
 
tracecmd/trace-msg.c +4 -4
index 8e1226b..b496935 100644
@@ -599,8 +599,8 @@ void tracecmd_msg_send_close_msg(struct tracecmd_msg_handle *msg_handle)
 	tracecmd_msg_send(msg_handle->fd, &msg);
 }
 
-int tracecmd_msg_metadata_send(struct tracecmd_msg_handle *msg_handle,
-			       const char *buf, int size)
+int tracecmd_msg_data_send(struct tracecmd_msg_handle *msg_handle,
+			   const char *buf, int size)
 {
 	struct tracecmd_msg msg;
 	int fd = msg_handle->fd;
@@ -638,7 +638,7 @@ int tracecmd_msg_metadata_send(struct tracecmd_msg_handle *msg_handle,
 	return ret;
 }
 
-int tracecmd_msg_finish_sending_metadata(struct tracecmd_msg_handle *msg_handle)
+int tracecmd_msg_finish_sending_data(struct tracecmd_msg_handle *msg_handle)
 {
 	struct tracecmd_msg msg;
 	int ret;
@@ -650,7 +650,7 @@ int tracecmd_msg_finish_sending_metadata(struct tracecmd_msg_handle *msg_handle)
 	return 0;
 }
 
-int tracecmd_msg_collect_metadata(struct tracecmd_msg_handle *msg_handle, int ofd)
+int tracecmd_msg_collect_data(struct tracecmd_msg_handle *msg_handle, int ofd)
 {
 	struct tracecmd_msg msg;
 	u32 t, n, cmd;
tracecmd/trace-output.c +1 -1
index 99493e6..78a8fe6 100644
@@ -74,7 +74,7 @@ static stsize_t
 do_write_check(struct tracecmd_output *handle, const void *data, tsize_t size)
 {
 	if (handle->msg_handle)
-		return tracecmd_msg_metadata_send(handle->msg_handle, data, size);
+		return tracecmd_msg_data_send(handle->msg_handle, data, size);
 
 	return __do_write_check(handle->fd, data, size);
 }
tracecmd/trace-record.c +12 -12
index 24580a4..129f36a 100644
@@ -2747,7 +2747,7 @@ static void communicate_with_listener_v1(struct tracecmd_msg_handle *msg_handle)
 	}
 }
 
-static void communicate_with_listener_v2(struct tracecmd_msg_handle *msg_handle)
+static void communicate_with_listener_v3(struct tracecmd_msg_handle *msg_handle)
 {
 	if (tracecmd_msg_send_init_data(msg_handle, &client_ports) < 0)
 		die("Cannot communicate with server");
@@ -2764,8 +2764,8 @@ static void check_protocol_version(struct tracecmd_msg_handle *msg_handle)
 	/*
 	 * Write the protocol version, the magic number, and the dummy
 	 * option(0) (in ASCII). The client understands whether the client
-	 * uses the v2 protocol or not by checking a reply message from the
-	 * server. If the message is "V2", the server uses v2 protocol. On the
+	 * uses the v3 protocol or not by checking a reply message from the
+	 * server. If the message is "V3", the server uses v3 protocol. On the
 	 * other hands, if the message is just number strings, the server
 	 * returned port numbers. So, in that time, the client understands the
 	 * server uses the v1 protocol. However, the old server tells the
@@ -2773,7 +2773,7 @@ static void check_protocol_version(struct tracecmd_msg_handle *msg_handle)
 	 * So, we add the dummy number (the magic number and 0 option) to the
 	 * first client message.
 	 */
-	write(fd, V2_CPU, sizeof(V2_CPU));
+	write(fd, V3_CPU, sizeof(V3_CPU));
 
 	buf[0] = 0;
 
@@ -2787,8 +2787,8 @@ static void check_protocol_version(struct tracecmd_msg_handle *msg_handle)
 	} else {
 		if (memcmp(buf, "V2", n) != 0)
 			die("Cannot handle the protocol %s", buf);
-		/* OK, let's use v2 protocol */
-		write(fd, V2_MAGIC, sizeof(V2_MAGIC));
+		/* OK, let's use v3 protocol */
+		write(fd, V3_MAGIC, sizeof(V3_MAGIC));
 
 		n = read(fd, buf, BUFSIZ - 1);
 		if (n != 2 || memcmp(buf, "OK", 2) != 0) {
@@ -2857,20 +2857,20 @@ again:
 			die("Failed to allocate message handle");
 
 		msg_handle->cpu_count = local_cpu_count;
-		msg_handle->version = V2_PROTOCOL;
+		msg_handle->version = V3_PROTOCOL;
 	}
 
 	if (use_tcp)
 		msg_handle->flags |= TRACECMD_MSG_FL_USE_TCP;
 
-	if (msg_handle->version == V2_PROTOCOL) {
+	if (msg_handle->version == V3_PROTOCOL) {
 		check_protocol_version(msg_handle);
 		if (msg_handle->version == V1_PROTOCOL) {
 			/* reconnect to the server for using the v1 protocol */
 			close(sfd);
 			goto again;
 		}
-		communicate_with_listener_v2(msg_handle);
+		communicate_with_listener_v3(msg_handle);
 	}
 
 	if (msg_handle->version == V1_PROTOCOL)
@@ -2888,9 +2888,9 @@ setup_connection(struct buffer_instance *instance)
 	msg_handle = setup_network();
 
 	/* Now create the handle through this socket */
-	if (msg_handle->version == V2_PROTOCOL) {
+	if (msg_handle->version == V3_PROTOCOL) {
 		network_handle = tracecmd_create_init_fd_msg(msg_handle, listed_events);
-		tracecmd_msg_finish_sending_metadata(msg_handle);
+		tracecmd_msg_finish_sending_data(msg_handle);
 	} else
 		network_handle = tracecmd_create_init_fd_glob(msg_handle->fd,
 							      listed_events);
@@ -2903,7 +2903,7 @@ setup_connection(struct buffer_instance *instance)
 
 static void finish_network(struct tracecmd_msg_handle *msg_handle)
 {
-	if (msg_handle->version == V2_PROTOCOL)
+	if (msg_handle->version == V3_PROTOCOL)
 		tracecmd_msg_send_close_msg(msg_handle);
 	tracecmd_msg_handle_close(msg_handle);
 	free(host);
Signature · 1 line
2.19.1
#2 lore raw

PATCH v4 2/3 trace-cmd: Fix record --date flag when sending tracing data to a listener

In reply to Slavomir Kaslev

Currently the trace-cmd record --date is not taken into account when tracing data is sent to a remote host with the -N flag.

This patch fixes this by the writing output buffer options from the recording side instead of on the listener side.

We also provide backward compatibility by falling back to previous behavior when we're not using protocol v3.

---
 include/trace-cmd/trace-cmd.h | 10 ++++-
 tracecmd/trace-listen.c       | 23 ++++++++---
 tracecmd/trace-output.c       | 76 +++++++++++++++++------------------
 tracecmd/trace-record.c       | 55 ++++++++++++++-----------
 4 files changed, 96 insertions(+), 68 deletions(-)
include/trace-cmd/trace-cmd.h +8 -2
index 7cce592..26c1180 100644
@@ -245,6 +245,9 @@ struct tracecmd_option *tracecmd_add_option(struct tracecmd_output *handle,
 					    const void *data);
 struct tracecmd_option *tracecmd_add_buffer_option(struct tracecmd_output *handle,
 						   const char *name, int cpus);
+
+int tracecmd_write_cpus(struct tracecmd_output *handle, int cpus);
+int tracecmd_write_options(struct tracecmd_output *handle);
 int tracecmd_update_option(struct tracecmd_output *handle,
 			   struct tracecmd_option *option, int size,
 			   const void *data);
@@ -252,13 +255,16 @@ void tracecmd_output_close(struct tracecmd_output *handle);
 void tracecmd_output_free(struct tracecmd_output *handle);
 struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle,
 				      const char *file);
+
+int tracecmd_write_cpu_data(struct tracecmd_output *handle,
+			    int cpus, char * const *cpu_data_files);
 int tracecmd_append_cpu_data(struct tracecmd_output *handle,
 			     int cpus, char * const *cpu_data_files);
 int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle,
 				    struct tracecmd_option *option,
 				    int cpus, char * const *cpu_data_files);
-int tracecmd_attach_cpu_data(char *file, int cpus, char * const *cpu_data_files);
-int tracecmd_attach_cpu_data_fd(int fd, int cpus, char * const *cpu_data_files);
+
+struct tracecmd_output *tracecmd_get_output_handle_fd(int fd);
 
 /* --- Reading the Fly Recorder Trace --- */
 
tracecmd/trace-listen.c +18 -5
index a13b83b..57151ba 100644
@@ -624,8 +624,9 @@ static void stop_all_readers(int cpus, int *pid_array)
 }
 
 static int put_together_file(int cpus, int ofd, const char *node,
-			      const char *port)
+			     const char *port, bool write_options)
 {
+	struct tracecmd_output *handle;
 	char **temp_files;
 	int cpu;
 	int ret = -ENOMEM;
@@ -641,9 +642,20 @@ static int put_together_file(int cpus, int ofd, const char *node,
 			goto out;
 	}
 
-	tracecmd_attach_cpu_data_fd(ofd, cpus, temp_files);
-	ret = 0;
- out:
+	handle = tracecmd_get_output_handle_fd(ofd);
+	if (!handle) {
+		ret = -1;
+		goto out;
+	}
+
+	if (write_options) {
+		tracecmd_write_cpus(handle, cpus);
+		tracecmd_write_options(handle);
+	}
+	ret = tracecmd_write_cpu_data(handle, cpus, temp_files);
+
+out:
+	tracecmd_output_close(handle);
 	for (cpu--; cpu >= 0; cpu--) {
 		put_temp_file(temp_files[cpu]);
 	}
@@ -692,7 +704,8 @@ static int process_client(struct tracecmd_msg_handle *msg_handle,
 	/* wait a little to have the readers clean up */
 	sleep(1);
 
-	ret = put_together_file(cpus, ofd, node, port);
+	ret = put_together_file(cpus, ofd, node, port,
+				msg_handle->version != 3);
 
 	destroy_all_readers(cpus, pid_array, node, port);
 
tracecmd/trace-output.c +38 -38

139 lines not on this page · raw message

tracecmd/trace-record.c +32 -23

104 lines not on this page · raw message

Signature · 1 line
2.19.1
#3 lore raw

Re: [PATCH v4 2/3] trace-cmd: Fix record --date flag when sending tracing data to a listener

Quoted 40 lines · On Fri, 14 Dec 2018 15:57:48 +0200 Slavomir Kaslev <[email protected]> wrote:
tracecmd/trace-listen.c +16 -4
index a13b83b..57151ba 100644
@@ -624,8 +624,9 @@ static void stop_all_readers(int cpus, int *pid_array)
 }
 
 static int put_together_file(int cpus, int ofd, const char *node,
-			      const char *port)
+			     const char *port, bool write_options)
 {
+	struct tracecmd_output *handle;
 	char **temp_files;
 	int cpu;
 	int ret = -ENOMEM;
@@ -641,9 +642,20 @@ static int put_together_file(int cpus, int ofd, const char *node,
 			goto out;
 	}
 
-	tracecmd_attach_cpu_data_fd(ofd, cpus, temp_files);
-	ret = 0;
- out:
+	handle = tracecmd_get_output_handle_fd(ofd);
+	if (!handle) {
+		ret = -1;
+		goto out;
+	}
+
+	if (write_options) {
+		tracecmd_write_cpus(handle, cpus);
+		tracecmd_write_options(handle);
+	}
+	ret = tracecmd_write_cpu_data(handle, cpus, temp_files);
+
+out:
+	tracecmd_output_close(handle);
 	for (cpu--; cpu >= 0; cpu--) {
 		put_temp_file(temp_files[cpu]);
 	}

tracecmd/trace-listen.c static int process_client(struct tracecmd_msg_handle *msg_handle, · line 708

Quoted 6 lines
tracecmd/trace-listen.c +2 -1
@@ -692,7 +704,8 @@ static int process_client(struct tracecmd_msg_handle *msg_handle,
 	/* wait a little to have the readers clean up */
 	sleep(1);
 
-	ret = put_together_file(cpus, ofd, node, port);
+	ret = put_together_file(cpus, ofd, node, port,
+				msg_handle->version != 3);

Couple of thing here. Just to have it be a bit more self explanatory, let's create a "write_options" variable for process_client(), set it, and pass that to put_together_file(). The compiler should optimize it out, so it's not going to affect code execution, but still is good to see why we are doing the above test.

Second, let's make it "< 3" instead of "!= 3", because I'm sure v4 will still do this too.

	write_options = msg_handle->version < 3;

	ret = put_together_file(cpus, ofd, node, port, write_options);
Quoted 22 lines
tracecmd/trace-listen.c +0 -0
 	destroy_all_readers(cpus, pid_array, node, port);
 
 
tracecmd/trace-record.c +3 -1
index 129f36a..f19341b 100644
@@ -2879,8 +2879,10 @@ again:
 	return msg_handle;
 }
 
+static void add_options(struct tracecmd_output *handle, char *date2ts, int flags);
+
 static struct tracecmd_msg_handle *
-setup_connection(struct buffer_instance *instance)
+setup_connection(struct buffer_instance *instance, char *date2ts, int flags)
 {
 	struct tracecmd_msg_handle *msg_handle;
 	struct tracecmd_output *network_handle;

tracecmd/trace-record.c setup_connection(struct buffer_instance *instance) · line 2895

Quoted 4 lines
tracecmd/trace-record.c +1 -0
@@ -2890,6 +2892,11 @@ setup_connection(struct buffer_instance *instance)
 	/* Now create the handle through this socket */
 	if (msg_handle->version == V3_PROTOCOL) {
 		network_handle = tracecmd_create_init_fd_msg(msg_handle, listed_events);
+		if (msg_handle->version == 3) {

Probably should add a comment here, as to why we are checking (for bisectability).

Since these are slight changes, I'll make the changes and add the patch, as Yordan needs these changes quickly. Unless...

I haven't taken a look at patch 3 yet, so if there's an issue there, then we can make these updates for v5.

-- Steve

Quoted 95 lines
tracecmd/trace-record.c +28 -22
+			add_options(network_handle, date2ts, flags);
+			tracecmd_write_cpus(network_handle, instance->cpu_count);
+			tracecmd_write_options(network_handle);
+		}
 		tracecmd_msg_finish_sending_data(msg_handle);
 	} else
 		network_handle = tracecmd_create_init_fd_glob(msg_handle->fd,
@@ -2909,7 +2916,7 @@ static void finish_network(struct tracecmd_msg_handle *msg_handle)
 	free(host);
 }
 
-void start_threads(enum trace_type type, int global)
+void start_threads(enum trace_type type, int global, char *date2ts, int flags)
 {
 	struct buffer_instance *instance;
 	int *brass = NULL;
@@ -2931,7 +2938,7 @@ void start_threads(enum trace_type type, int global)
 		int x, pid;
 
 		if (host) {
-			instance->msg_handle = setup_connection(instance);
+			instance->msg_handle = setup_connection(instance, date2ts, flags);
 			if (!instance->msg_handle)
 				die("Failed to make connection");
 		}
@@ -3085,6 +3092,26 @@ enum {
 	DATA_FL_OFFSET		= 2,
 };
 
+static void add_options(struct tracecmd_output *handle, char *date2ts, int flags)
+{
+	int type = 0;
+
+	if (date2ts) {
+		if (flags & DATA_FL_DATE)
+			type = TRACECMD_OPTION_DATE;
+		else if (flags & DATA_FL_OFFSET)
+			type = TRACECMD_OPTION_OFFSET;
+	}
+
+	if (type)
+		tracecmd_add_option(handle, type, strlen(date2ts)+1, date2ts);
+
+	tracecmd_add_option(handle, TRACECMD_OPTION_TRACECLOCK, 0, NULL);
+	add_option_hooks(handle);
+	add_uname(handle);
+
+}
+
 static void record_data(char *date2ts, int flags)
 {
 	struct tracecmd_option **buffer_options;
@@ -3140,18 +3167,7 @@ static void record_data(char *date2ts, int flags)
 		if (!handle)
 			die("Error creating output file");
 
-		if (date2ts) {
-			int type = 0;
-
-			if (flags & DATA_FL_DATE)
-				type = TRACECMD_OPTION_DATE;
-			else if (flags & DATA_FL_OFFSET)
-				type = TRACECMD_OPTION_OFFSET;
-
-			if (type)
-				tracecmd_add_option(handle, type,
-						    strlen(date2ts)+1, date2ts);
-		}
+		add_options(handle, date2ts, flags);
 
 		/* Only record the top instance under TRACECMD_OPTION_CPUSTAT*/
 		if (!no_top_instance() && !top_instance.msg_handle) {
@@ -3162,13 +3178,6 @@ static void record_data(char *date2ts, int flags)
 						    s[i].len+1, s[i].buffer);
 		}
 
-		tracecmd_add_option(handle, TRACECMD_OPTION_TRACECLOCK,
-				    0, NULL);
-
-		add_option_hooks(handle);
-
-		add_uname(handle);
-
 		if (buffers) {
 			buffer_options = malloc(sizeof(*buffer_options) * buffers);
 			if (!buffer_options)
@@ -4977,7 +4986,7 @@ static void record_trace(int argc, char **argv,
 	if (type & (TRACE_TYPE_RECORD | TRACE_TYPE_STREAM)) {
 		signal(SIGINT, finish);
 		if (!latency)
-			start_threads(type, ctx->global);
+			start_threads(type, ctx->global, ctx->date2ts, ctx->data_flags);
 	} else {
 		update_task_filter();
 		tracecmd_enable_tracing();
#4 lore raw

PATCH v4 3/3 trace-cmd: Bump protocol version to v3

In reply to Slavomir Kaslev

This patch bumps trace-cmd protocol to v3 while keeping backward compatibility by falling back to v1.

The new protocol works similarly to v2 but allows future extension of commands by saving the command size on the wire and having the client on the other side to only read the bytes it understands.

---
 tracecmd/include/trace-msg.h |   6 +-
 tracecmd/trace-listen.c      |   6 +-
 tracecmd/trace-msg.c         | 190 +++++++++++++++--------------------
 tracecmd/trace-record.c      |  10 +-
 4 files changed, 92 insertions(+), 120 deletions(-)
tracecmd/include/trace-msg.h +3 -3
index 722548a..b7fe10b 100644
@@ -4,11 +4,11 @@
 #include <stdbool.h>
 
 #define UDP_MAX_PACKET	(65536 - 20)
-#define V3_MAGIC	"677768\0"
-#define V3_CPU		"-1V2"
+#define V3_MAGIC	"766679\0"
+#define V3_CPU		"-1V3"
 
 #define V1_PROTOCOL	1
-#define V3_PROTOCOL	2
+#define V3_PROTOCOL	3
 
 extern unsigned int page_size;
 
tracecmd/trace-listen.c +3 -3
index 57151ba..8394b0f 100644
@@ -387,12 +387,12 @@ static int communicate_with_client(struct tracecmd_msg_handle *msg_handle)
 				last_proto[n] = 0;
 			}
 			/* Return the highest protocol we can use */
-			write(fd, "V2", 3);
+			write(fd, "V3", 3);
 			goto try_again;
 		}
 
 		/* Let the client know we use v3 protocol */
-		write(fd, "V2", 3);
+		write(fd, "V3", 3);
 
 		/* read the rest of dummy data */
 		n = read(fd, buf, sizeof(V3_MAGIC));
@@ -705,7 +705,7 @@ static int process_client(struct tracecmd_msg_handle *msg_handle,
 	sleep(1);
 
 	ret = put_together_file(cpus, ofd, node, port,
-				msg_handle->version != 3);
+				msg_handle->version != V3_PROTOCOL);
 
 	destroy_all_readers(cpus, pid_array, node, port);
 
tracecmd/trace-msg.c +82 -108

381 lines not on this page · raw message

tracecmd/trace-record.c +4 -6
index f19341b..e45a1f8 100644
@@ -2785,7 +2785,7 @@ static void check_protocol_version(struct tracecmd_msg_handle *msg_handle)
 		msg_handle->version = V1_PROTOCOL;
 		plog("Use the v1 protocol\n");
 	} else {
-		if (memcmp(buf, "V2", n) != 0)
+		if (memcmp(buf, "V3", n) != 0)
 			die("Cannot handle the protocol %s", buf);
 		/* OK, let's use v3 protocol */
 		write(fd, V3_MAGIC, sizeof(V3_MAGIC));
@@ -2892,11 +2892,9 @@ setup_connection(struct buffer_instance *instance, char *date2ts, int flags)
 	/* Now create the handle through this socket */
 	if (msg_handle->version == V3_PROTOCOL) {
 		network_handle = tracecmd_create_init_fd_msg(msg_handle, listed_events);
-		if (msg_handle->version == 3) {
-			add_options(network_handle, date2ts, flags);
-			tracecmd_write_cpus(network_handle, instance->cpu_count);
-			tracecmd_write_options(network_handle);
-		}
+		add_options(network_handle, date2ts, flags);
+		tracecmd_write_cpus(network_handle, instance->cpu_count);
+		tracecmd_write_options(network_handle);
 		tracecmd_msg_finish_sending_data(msg_handle);
 	} else
 		network_handle = tracecmd_create_init_fd_glob(msg_handle->fd,
Signature · 1 line
2.19.1