ust-ctl: allow runtime version checks
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 29 Jul 2022 21:40:45 +0000 (17:40 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 13 Jan 2023 14:46:52 +0000 (09:46 -0500)
Officially, building (and dynamically linking) mismatching LTTng-UST
and LTTng-tools versions is unsupported.

At build time, LTTng-tools ensures that both versions match. However, it
remains possible for a user to mistakenly deploy LTTng-tools built
againt liblttng-ust-ctl v2.x and liblttng-ust-ctl.so from a different
LTTng-UST release. Since the soname major version of liblttng-ust-ctl is
not bumped at every release, this would allow LTTng-tools binary to
load.

In practice, this is unlikely to work since new symbols are introduced
at almost every release cycle. However, it isn't guaranteed.

In the case of a recent change -- removing the underscore prefix of
enumeration mappings used by a variant -- we don't change the ABI, but
we rely on the LTTNG_UST_ABI_MAJOR_VERSION to indicate whether or not
the fix is present to change the interpretation of existing fields.

Adding lttng_ust_ctl_get_version() provides an additional safety net
to check, at runtime, that the version of liblttng-ust-ctl.so that
is loaded matches that of LTTng-tools.

Technically, only major and minor versions are necessary. I propose
including the patchlevel version for future-proofing should we want to
work around known bugs in the future.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I14bee30bb5d2109be0c8c015ed845d70df16630b

include/lttng/ust-ctl.h
src/lib/lttng-ust-ctl/ustctl.c

index 25e588b39a32f409da0f83de037b2205e2350624..42b30ea9f06ae5565801d26b87ad7785ec4b6203 100644 (file)
@@ -660,6 +660,8 @@ int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
 
 void lttng_ust_ctl_sigbus_handle(void *addr);
 
+int lttng_ust_ctl_get_version(uint32_t *major, uint32_t *minor, uint32_t *patchlevel);
+
 #ifdef __cplusplus
 }
 #endif
index 6faaef5ed44ff4fcc88a31b181ddd511c3f87cce..7b6798802e0b04f6058103afa73ae8df4abf3860 100644 (file)
@@ -3294,6 +3294,14 @@ int lttng_ust_ctl_counter_clear(struct lttng_ust_ctl_daemon_counter *counter,
        return counter->ops->counter_clear(counter->counter, dimension_indexes);
 }
 
+int lttng_ust_ctl_get_version(uint32_t *major, uint32_t *minor,
+               uint32_t *patchlevel) {
+       *major = LTTNG_UST_MAJOR_VERSION;
+       *minor = LTTNG_UST_MINOR_VERSION;
+       *patchlevel = LTTNG_UST_PATCHLEVEL_VERSION;
+       return 0;
+}
+
 static
 void lttng_ust_ctl_ctor(void)
        __attribute__((constructor));
This page took 0.026977 seconds and 4 git commands to generate.