From: Jérémie Galarneau Date: Wed, 7 Apr 2021 00:41:25 +0000 (-0400) Subject: notification: transmit originating trigger as part of evaluation X-Git-Tag: v2.13.0-rc1~164 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=52d55cf94968516273d6c67f2db428908def55ac;p=lttng-tools.git notification: transmit originating trigger as part of evaluation 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 Change-Id: I61d587436177eb34744487a1d3c486d87fe2e1f1 --- diff --git a/include/lttng/notification/notification-internal.h b/include/lttng/notification/notification-internal.h index a4b0eec2e..dc3a0e1d6 100644 --- a/include/lttng/notification/notification-internal.h +++ b/include/lttng/notification/notification-internal.h @@ -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 diff --git a/src/bin/lttng-sessiond/action-executor.c b/src/bin/lttng-sessiond/action-executor.c index 7c2079ae9..86bada257 100644 --- a/src/bin/lttng-sessiond/action-executor.c +++ b/src/bin/lttng-sessiond/action-executor.c @@ -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, diff --git a/src/bin/lttng-sessiond/notification-thread-events.c b/src/bin/lttng-sessiond/notification-thread-events.c index ee20725dd..59b10e9db 100644 --- a/src/bin/lttng-sessiond/notification-thread-events.c +++ b/src/bin/lttng-sessiond/notification-thread-events.c @@ -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); diff --git a/src/bin/lttng-sessiond/notification-thread-internal.h b/src/bin/lttng-sessiond/notification-thread-internal.h index 38d968a4d..fe53a5161 100644 --- a/src/bin/lttng-sessiond/notification-thread-internal.h +++ b/src/bin/lttng-sessiond/notification-thread-internal.h @@ -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); diff --git a/src/common/notification.c b/src/common/notification.c index a4e971bd5..c640b9e75 100644 --- a/src/common/notification.c +++ b/src/common/notification.c @@ -10,18 +10,19 @@ #include #include #include +#include #include #include #include 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(