From: Jérémie Galarneau Date: Thu, 4 Jul 2019 12:59:08 +0000 (-0400) Subject: Use a "comm" variant of the LTTNG_OPTIONAL helper in sessiond-comm X-Git-Tag: v2.12.0-rc1~539 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=0a30bf9be799ddb162530ea7581172e923055973 Use a "comm" variant of the LTTNG_OPTIONAL helper in sessiond-comm The LTTNG_OPTIONAL helper is currently communication safe (as long as LTTNG_PACKED is used). However, this could change in the future. An LTTNG_OPTIONAL_COMM alias is introduced in order to make it easier to change the layout of LTTNG_OPTIONAL should it become necessary in the future. Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/optional.h b/src/common/optional.h index 1da5fda5d..aee5fcc5e 100644 --- a/src/common/optional.h +++ b/src/common/optional.h @@ -32,9 +32,6 @@ * Prefer using this macro where "special" values would be used, e.g. * -1ULL for uint64_t types. * - * LTTNG_OPTIONAL should be combined with the LTTNG_PACKED macro when - * used for IPC / network communication. - * * Declaration example: * struct my_struct { * int a; @@ -57,6 +54,16 @@ type value; \ } +/* + * Alias used for communication structures. If the layout of an LTTNG_OPTIONAL + * is changed, the original layout should still be used for communication + * purposes. + * + * LTTNG_OPTIONAL_COMM should be combined with the LTTNG_PACKED macro when + * used for IPC / network communication. + */ +#define LTTNG_OPTIONAL_COMM LTTNG_OPTIONAL + /* * This macro is available as a 'convenience' to allow sites that assume * an optional value is set to assert() that it is set when accessing it. diff --git a/src/common/sessiond-comm/sessiond-comm.h b/src/common/sessiond-comm/sessiond-comm.h index 3b0093bfb..d9177cf37 100644 --- a/src/common/sessiond-comm/sessiond-comm.h +++ b/src/common/sessiond-comm/sessiond-comm.h @@ -480,7 +480,7 @@ struct lttcomm_consumer_msg { uint64_t channel_key; uint64_t session_id; /* ID of the session's current trace chunk. */ - LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED chunk_id; + LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id; char pathname[PATH_MAX]; uint64_t relayd_id; /* nb_init_streams is the number of streams open initially. */ @@ -542,7 +542,7 @@ struct lttcomm_consumer_msg { uint64_t relayd_id; /* Relayd id if apply. */ uint64_t key; /* Unique channel key. */ /* ID of the session's current trace chunk. */ - LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED chunk_id; + LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED chunk_id; unsigned char uuid[UUID_LEN]; /* uuid for ust tracer. */ uint32_t chan_id; /* Channel ID on the tracer side. */ uint64_t tracefile_size; /* bytes */ @@ -634,7 +634,7 @@ struct lttcomm_consumer_msg { * `override_name` is left NULL (all-zeroes) if the * chunk's name is not overriden. */ - LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED relayd_id; + LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id; char override_name[LTTNG_NAME_MAX]; uint64_t session_id; uint64_t chunk_id; @@ -645,13 +645,13 @@ struct lttcomm_consumer_msg { } LTTNG_PACKED credentials; } LTTNG_PACKED create_trace_chunk; struct { - LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED relayd_id; + LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id; uint64_t session_id; uint64_t chunk_id; uint64_t close_timestamp; } LTTNG_PACKED close_trace_chunk; struct { - LTTNG_OPTIONAL(uint64_t) LTTNG_PACKED relayd_id; + LTTNG_OPTIONAL_COMM(uint64_t) LTTNG_PACKED relayd_id; uint64_t session_id; uint64_t chunk_id; } LTTNG_PACKED trace_chunk_exists;