From 1e9d0add3c5dbafadc3892cc707ed39d8c8a8f01 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 11 Nov 2021 14:06:08 -0500 Subject: [PATCH] Protocol bump from 9 to 10 Bump LTTNG_UST_ABI_MAJOR_VERSION from 9 to 10, but keep backward compatibility unchanged (oldest compatible 8) for applications linked against older liblttng-ust. With this protocol bump, we can send a 64-bit "id" in the event registration reply. We keep the 32-bit event id field for now, until we can proceed to bump the oldest compatible major number. The 64-bit id field is useful for events within "counter" channels, but there is no point in keeping a 32-bit value solely for the ring buffer channel. Signed-off-by: Mathieu Desnoyers Change-Id: Ibd3da4c8156886a6d2f6555462526bb717c451dd --- include/lttng/ust-ctl.h | 3 +-- src/common/ustcomm.c | 12 ++++-------- src/common/ustcomm.h | 9 +++++---- src/lib/lttng-ust-ctl/ustctl.c | 7 +++---- src/lib/lttng-ust/lttng-events.c | 12 ++++++++---- 5 files changed, 21 insertions(+), 22 deletions(-) diff --git a/include/lttng/ust-ctl.h b/include/lttng/ust-ctl.h index 07f08ca7..3c197394 100644 --- a/include/lttng/ust-ctl.h +++ b/include/lttng/ust-ctl.h @@ -543,8 +543,7 @@ int lttng_ust_ctl_recv_register_event(int sock, * Returns 0 on success, negative error value on error. */ int lttng_ust_ctl_reply_register_event(int sock, - uint32_t event_id, /* event id (input) */ - uint64_t counter_index, /* counter index (input) */ + uint64_t id, /* id (input) */ int ret_code); /* return code. 0 ok, negative error */ /* diff --git a/src/common/ustcomm.c b/src/common/ustcomm.c index 2435e380..1cf368b8 100644 --- a/src/common/ustcomm.c +++ b/src/common/ustcomm.c @@ -1370,8 +1370,7 @@ int ustcomm_register_event(int sock, const struct lttng_ust_event_field * const *lttng_fields, const char *model_emf_uri, uint64_t user_token, - uint32_t *event_id, /* event id (output) */ - uint64_t *counter_index) /* counter index (output) */ + uint64_t *id) /* event id (output) */ { ssize_t len; struct { @@ -1478,12 +1477,9 @@ int ustcomm_register_event(int sock, return -EINVAL; if (reply.r.ret_code < 0) return reply.r.ret_code; - if (event_id) - *event_id = reply.r.event_id; - if (counter_index) - *counter_index = reply.r.counter_index; - DBG("Sent register event notification for name \"%s\": ret_code %d, event_id %u, counter_index %" PRIu64 "\n", - event_name, reply.r.ret_code, reply.r.event_id, reply.r.counter_index); + *id = reply.r.id; + DBG("Sent register event notification for name \"%s\": ret_code %d, id %" PRIu64 "\n", + event_name, reply.r.ret_code, reply.r.id); return 0; default: if (len < 0) { diff --git a/src/common/ustcomm.h b/src/common/ustcomm.h index ce8a6ce7..6b555391 100644 --- a/src/common/ustcomm.h +++ b/src/common/ustcomm.h @@ -147,8 +147,10 @@ struct ustcomm_notify_event_msg { #define USTCOMM_NOTIFY_EVENT_REPLY_PADDING 24 struct ustcomm_notify_event_reply { int32_t ret_code; /* 0: ok, negative: error code */ - uint32_t event_id; /* for ring buffer channel events */ - uint64_t counter_index; /* for counter channel events */ + + /* 32-bit (lower bits) event id for backward compatibility with ABI major < 10 */ + uint32_t old_event_id; /* TODO: remove field on future protocol compatibility break. */ + uint64_t id; /* 64-bit event id. */ char padding[USTCOMM_NOTIFY_EVENT_REPLY_PADDING]; } __attribute__((packed)); @@ -290,8 +292,7 @@ int ustcomm_register_event(int sock, const struct lttng_ust_event_field * const *fields, const char *model_emf_uri, uint64_t user_token, - uint32_t *id, /* event id (output) */ - uint64_t *counter_index) /* counter index (output) */ + uint64_t *id) /* (output) */ __attribute__((visibility("hidden"))); /* diff --git a/src/lib/lttng-ust-ctl/ustctl.c b/src/lib/lttng-ust-ctl/ustctl.c index ba4edbb4..bf8c1373 100644 --- a/src/lib/lttng-ust-ctl/ustctl.c +++ b/src/lib/lttng-ust-ctl/ustctl.c @@ -2681,8 +2681,7 @@ signature_error: * Returns 0 on success, negative error value on error. */ int lttng_ust_ctl_reply_register_event(int sock, - uint32_t event_id, - uint64_t counter_index, + uint64_t id, int ret_code) { ssize_t len; @@ -2694,8 +2693,8 @@ int lttng_ust_ctl_reply_register_event(int sock, memset(&reply, 0, sizeof(reply)); reply.header.notify_cmd = LTTNG_UST_CTL_NOTIFY_CMD_EVENT; reply.r.ret_code = ret_code; - reply.r.event_id = event_id; - reply.r.counter_index = counter_index; + reply.r.old_event_id = (uint32_t) id; /* For backward compatibility */ + reply.r.id = id; len = ustcomm_send_unix_sock(sock, &reply, sizeof(reply)); if (len > 0 && len != sizeof(reply)) return -EIO; diff --git a/src/lib/lttng-ust/lttng-events.c b/src/lib/lttng-ust/lttng-events.c index 65d02ed5..cbc887d0 100644 --- a/src/lib/lttng-ust/lttng-events.c +++ b/src/lib/lttng-ust/lttng-events.c @@ -965,13 +965,15 @@ int lttng_event_register_to_sessiond(struct lttng_event_enabler_common *event_en struct lttng_ust_event_recorder_private *event_recorder_priv = caa_container_of(event->priv, struct lttng_ust_event_recorder_private, parent.parent); struct lttng_ust_session *session = event_recorder_enabler->chan->parent->session; + uint64_t id; + int ret; notify_socket = lttng_get_notify_socket(session->priv->owner); if (notify_socket < 0) return notify_socket; /* Fetch event ID from sessiond */ - return ustcomm_register_event(notify_socket, + ret = ustcomm_register_event(notify_socket, session, session->priv->objd, event_recorder_enabler->chan->priv->parent.objd, @@ -982,8 +984,11 @@ int lttng_event_register_to_sessiond(struct lttng_event_enabler_common *event_en desc->tp_class->fields, uri, 0, - &event_recorder_priv->id, - NULL); + &id); + if (ret) + return ret; + event_recorder_priv->id = id; + return 0; } case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER: @@ -1013,7 +1018,6 @@ int lttng_event_register_to_sessiond(struct lttng_event_enabler_common *event_en desc->tp_class->fields, uri, event_counter_enabler->parent.parent.user_token, - NULL, &event_counter_priv->counter_index); } default: -- 2.34.1