notification: transmit originating trigger as part of evaluation
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Apr 2021 00:41:25 +0000 (20:41 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 7 Apr 2021 02:06:54 +0000 (22:06 -0400)
Transmit the full trigger object instead of its condition when sending a
notification to a client. This allows clients to reliably filter on
triggers as, currently, only the name of a trigger is made available to
clients as part of the "on_event" evaluation object (the owner uid is
needed to perform a correct comparison for filtering).

This will also make the trigger accessible for all condition types.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I61d587436177eb34744487a1d3c486d87fe2e1f1

include/lttng/notification/notification-internal.h
src/bin/lttng-sessiond/action-executor.c
src/bin/lttng-sessiond/notification-thread-events.c
src/bin/lttng-sessiond/notification-thread-internal.h
src/common/notification.c

index a4b0eec2eb9baa50fcbbccbb99bf126502cccc41..dc3a0e1d67569711ef3a13076256c6453b2119eb 100644 (file)
@@ -18,20 +18,20 @@ struct lttng_payload;
 struct lttng_payload_view;
 
 struct lttng_notification {
-       struct lttng_condition *condition;
+       struct lttng_trigger *trigger;
        struct lttng_evaluation *evaluation;
 };
 
 struct lttng_notification_comm {
        /* Size of the payload following this field. */
        uint32_t length;
-       /* Condition and evaluation objects follow. */
+       /* Trigger and evaluation objects follow. */
        char payload[];
 } LTTNG_PACKED;
 
 LTTNG_HIDDEN
 struct lttng_notification *lttng_notification_create(
-               struct lttng_condition *condition,
+               struct lttng_trigger *trigger,
                struct lttng_evaluation *evaluation);
 
 LTTNG_HIDDEN
index 7c2079ae97d40fa8f1bcb8de1b939de577f0a13e..86bada257634b90a8d0ebd7dc225732602b12e48 100644 (file)
@@ -197,9 +197,8 @@ static int action_executor_notify_handler(struct action_executor *executor,
                const struct lttng_action *action)
 {
        return notification_client_list_send_evaluation(work_item->client_list,
-                       lttng_trigger_get_const_condition(work_item->trigger),
+                       work_item->trigger,
                        work_item->evaluation,
-                       lttng_trigger_get_credentials(work_item->trigger),
                        work_item->object_creds.is_set ?
                                        &(work_item->object_creds.value) :
                                        NULL,
index ee20725dd318c3a167053d20b6da2fb03f8fed64..59b10e9db718f82c791abbddd4f8d1e4a8d20ded 100644 (file)
@@ -4212,8 +4212,7 @@ int send_evaluation_to_clients(const struct lttng_trigger *trigger,
        };
 
        return notification_client_list_send_evaluation(client_list,
-                       lttng_trigger_get_const_condition(trigger), evaluation,
-                       lttng_trigger_get_credentials(trigger),
+                       trigger, evaluation,
                        &creds,
                        client_handle_transmission_status_wrapper, state);
 }
@@ -4254,9 +4253,8 @@ int send_evaluation_to_clients(const struct lttng_trigger *trigger,
 LTTNG_HIDDEN
 int notification_client_list_send_evaluation(
                struct notification_client_list *client_list,
-               const struct lttng_condition *condition,
+               const struct lttng_trigger *trigger,
                const struct lttng_evaluation *evaluation,
-               const struct lttng_credentials *trigger_creds,
                const struct lttng_credentials *source_object_creds,
                report_client_transmission_result_cb client_report,
                void *user_data)
@@ -4265,12 +4263,14 @@ int notification_client_list_send_evaluation(
        struct lttng_payload msg_payload;
        struct notification_client_list_element *client_list_element, *tmp;
        const struct lttng_notification notification = {
-               .condition = (struct lttng_condition *) condition,
+               .trigger = (struct lttng_trigger *) trigger,
                .evaluation = (struct lttng_evaluation *) evaluation,
        };
        struct lttng_notification_channel_message msg_header = {
                .type = (int8_t) LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_NOTIFICATION,
        };
+       const struct lttng_credentials *trigger_creds =
+                       lttng_trigger_get_credentials(trigger);
 
        lttng_payload_init(&msg_payload);
 
index 38d968a4dbd685996ff0d1da92c5a383bccf1125..fe53a51613528fe2ba4a2255030a6f583b180635 100644 (file)
@@ -238,9 +238,8 @@ typedef int (*report_client_transmission_result_cb)(
 LTTNG_HIDDEN
 int notification_client_list_send_evaluation(
                struct notification_client_list *list,
-               const struct lttng_condition *condition,
+               const struct lttng_trigger *trigger,
                const struct lttng_evaluation *evaluation,
-               const struct lttng_credentials *trigger_creds,
                const struct lttng_credentials *source_object_creds,
                report_client_transmission_result_cb client_report,
                void *user_data);
index a4e971bd572c159b4a54d90643965dd1479b937d..c640b9e7535fe78643a7602453b927523af33f6d 100644 (file)
 #include <lttng/condition/evaluation-internal.h>
 #include <lttng/condition/condition.h>
 #include <lttng/condition/evaluation.h>
+#include <lttng/trigger/trigger-internal.h>
 #include <common/payload.h>
 #include <common/payload-view.h>
 #include <assert.h>
 
 LTTNG_HIDDEN
 struct lttng_notification *lttng_notification_create(
-               struct lttng_condition *condition,
+               struct lttng_trigger *trigger,
                struct lttng_evaluation *evaluation)
 {
        struct lttng_notification *notification = NULL;
 
-       if (!condition || !evaluation) {
+       if (!trigger || !evaluation) {
                goto end;
        }
 
@@ -30,7 +31,7 @@ struct lttng_notification *lttng_notification_create(
                goto end;
        }
 
-       notification->condition = condition;
+       notification->trigger = trigger;
        notification->evaluation = evaluation;
 end:
        return notification;
@@ -53,7 +54,7 @@ int lttng_notification_serialize(const struct lttng_notification *notification,
        }
 
        size_before_payload = payload->buffer.size;
-       ret = lttng_condition_serialize(notification->condition,
+       ret = lttng_trigger_serialize(notification->trigger,
                        payload);
        if (ret) {
                goto end;
@@ -78,7 +79,7 @@ ssize_t lttng_notification_create_from_payload(
                struct lttng_notification **notification)
 {
        ssize_t ret, notification_size = 0, condition_size, evaluation_size;
-       struct lttng_condition *condition;
+       struct lttng_trigger *trigger;
        struct lttng_evaluation *evaluation;
        const struct lttng_notification_comm *notification_comm;
        const struct lttng_payload_view notification_comm_view =
@@ -104,8 +105,8 @@ ssize_t lttng_notification_create_from_payload(
                                lttng_payload_view_from_view(src_view,
                                                notification_size, -1);
 
-               condition_size = lttng_condition_create_from_payload(
-                               &condition_view, &condition);
+               condition_size = lttng_trigger_create_from_payload(
+                               &condition_view, &trigger);
        }
 
        if (condition_size < 0) {
@@ -122,7 +123,8 @@ ssize_t lttng_notification_create_from_payload(
                                                notification_size, -1);
 
                evaluation_size = lttng_evaluation_create_from_payload(
-                               condition, &evaluation_view, &evaluation);
+                               lttng_trigger_get_const_condition(trigger),
+                               &evaluation_view, &evaluation);
        }
 
        if (evaluation_size < 0) {
@@ -139,7 +141,7 @@ ssize_t lttng_notification_create_from_payload(
                goto error;
        }
 
-       *notification = lttng_notification_create(condition, evaluation);
+       *notification = lttng_notification_create(trigger, evaluation);
        if (!*notification) {
                ret = -1;
                goto error;
@@ -148,7 +150,7 @@ ssize_t lttng_notification_create_from_payload(
 end:
        return ret;
 error:
-       lttng_condition_destroy(condition);
+       lttng_trigger_destroy(trigger);
        lttng_evaluation_destroy(evaluation);
        return ret;
 }
@@ -159,7 +161,7 @@ void lttng_notification_destroy(struct lttng_notification *notification)
                return;
        }
 
-       lttng_condition_destroy(notification->condition);
+       lttng_trigger_destroy(notification->trigger);
        lttng_evaluation_destroy(notification->evaluation);
        free(notification);
 }
@@ -167,7 +169,7 @@ void lttng_notification_destroy(struct lttng_notification *notification)
 const struct lttng_condition *lttng_notification_get_condition(
                struct lttng_notification *notification)
 {
-       return notification ? notification->condition : NULL;
+       return notification ? lttng_trigger_get_const_condition(notification->trigger) : NULL;
 }
 
 const struct lttng_evaluation *lttng_notification_get_evaluation(
This page took 0.033271 seconds and 4 git commands to generate.