common: Add index allocator for error counters
[lttng-tools.git] / src / bin / lttng-sessiond / agent.c
1 /*
2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
3 * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 */
8
9 #define _LGPL_SOURCE
10 #include <assert.h>
11 #include <urcu/uatomic.h>
12 #include <urcu/rculist.h>
13
14 #include <lttng/event-rule/event-rule.h>
15 #include <lttng/event-rule/event-rule-internal.h>
16 #include <lttng/event-rule/tracepoint.h>
17 #include <lttng/condition/condition.h>
18 #include <lttng/condition/on-event.h>
19 #include <lttng/domain-internal.h>
20 #include <lttng/log-level-rule-internal.h>
21
22 #include <common/common.h>
23 #include <common/sessiond-comm/agent.h>
24
25 #include <common/compat/endian.h>
26
27 #include "agent.h"
28 #include "ust-app.h"
29 #include "utils.h"
30 #include "common/error.h"
31
32 #define AGENT_RET_CODE_INDEX(code) (code - AGENT_RET_CODE_SUCCESS)
33
34 /*
35 * Agent application context representation.
36 */
37 struct agent_app_ctx {
38 char *provider_name;
39 char *ctx_name;
40
41 /* agent_app_ctx are part of the agent app_ctx_list. */
42 struct cds_list_head list_node;
43
44 /* For call_rcu teardown. */
45 struct rcu_head rcu_node;
46 };
47
48 /*
49 * Human readable agent return code.
50 */
51 static const char *error_string_array[] = {
52 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_SUCCESS) ] = "Success",
53 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_INVALID) ] = "Invalid command",
54 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_UNKNOWN_NAME) ] = "Unknown logger name",
55
56 /* Last element */
57 [ AGENT_RET_CODE_INDEX(AGENT_RET_CODE_NR) ] = "Unknown code",
58 };
59
60 static
61 void log_reply_code(uint32_t in_reply_ret_code)
62 {
63 int level = PRINT_DBG3;
64 /*
65 * reply_ret_code and in_reply_ret_code are kept separate to have a
66 * sanitized value (used to retrieve the human readable string) and the
67 * original value which is logged as-is.
68 */
69 uint32_t reply_ret_code = in_reply_ret_code;
70
71 if (reply_ret_code < AGENT_RET_CODE_SUCCESS ||
72 reply_ret_code >= AGENT_RET_CODE_NR) {
73 reply_ret_code = AGENT_RET_CODE_NR;
74 level = PRINT_ERR;
75 }
76
77 LOG(level, "Agent replied with retcode: %s (%"PRIu32")",
78 error_string_array[AGENT_RET_CODE_INDEX(
79 reply_ret_code)],
80 in_reply_ret_code);
81 }
82
83 /*
84 * Match function for the events hash table lookup by name.
85 */
86 static int ht_match_event_by_name(struct cds_lfht_node *node,
87 const void *_key)
88 {
89 struct agent_event *event;
90 const struct agent_ht_key *key;
91
92 assert(node);
93 assert(_key);
94
95 event = caa_container_of(node, struct agent_event, node.node);
96 key = _key;
97
98 /* Match 1 elements of the key: name. */
99
100 /* Event name */
101 if (strncmp(event->name, key->name, sizeof(event->name)) != 0) {
102 goto no_match;
103 }
104 /* Match. */
105 return 1;
106
107 no_match:
108 return 0;
109 }
110
111 /*
112 * Match function for the events hash table lookup by name, log level and
113 * filter expression.
114 */
115 static int ht_match_event(struct cds_lfht_node *node,
116 const void *_key)
117 {
118 struct agent_event *event;
119 const struct agent_ht_key *key;
120 int ll_match;
121
122 assert(node);
123 assert(_key);
124
125 event = caa_container_of(node, struct agent_event, node.node);
126 key = _key;
127
128 /* Match 2 elements of the key: name and loglevel. */
129
130 /* Event name */
131 if (strncmp(event->name, key->name, sizeof(event->name)) != 0) {
132 goto no_match;
133 }
134
135 /* Event loglevel value and type. */
136 ll_match = loglevels_match(event->loglevel_type,
137 event->loglevel_value, key->loglevel_type,
138 key->loglevel_value, LTTNG_EVENT_LOGLEVEL_ALL);
139
140 if (!ll_match) {
141 goto no_match;
142 }
143
144 /* Filter expression */
145 if (!!event->filter_expression != !!key->filter_expression) {
146 /* One has a filter expression, the other does not */
147 goto no_match;
148 }
149
150 if (event->filter_expression) {
151 if (strncmp(event->filter_expression, key->filter_expression,
152 strlen(event->filter_expression)) != 0) {
153 goto no_match;
154 }
155 }
156
157 return 1;
158
159 no_match:
160 return 0;
161 }
162
163 /*
164 * Add unique agent event based on the event name and loglevel.
165 */
166 static void add_unique_agent_event(struct lttng_ht *ht,
167 struct agent_event *event)
168 {
169 struct cds_lfht_node *node_ptr;
170 struct agent_ht_key key;
171
172 assert(ht);
173 assert(ht->ht);
174 assert(event);
175
176 key.name = event->name;
177 key.loglevel_value = event->loglevel_value;
178 key.loglevel_type = event->loglevel_type;
179 key.filter_expression = event->filter_expression;
180
181 node_ptr = cds_lfht_add_unique(ht->ht,
182 ht->hash_fct(event->node.key, lttng_ht_seed),
183 ht_match_event, &key, &event->node.node);
184 assert(node_ptr == &event->node.node);
185 }
186
187 /*
188 * URCU delayed agent event reclaim.
189 */
190 static void destroy_event_agent_rcu(struct rcu_head *head)
191 {
192 struct lttng_ht_node_str *node =
193 caa_container_of(head, struct lttng_ht_node_str, head);
194 struct agent_event *event =
195 caa_container_of(node, struct agent_event, node);
196
197 agent_destroy_event(event);
198 }
199
200 /*
201 * URCU delayed agent app reclaim.
202 */
203 static void destroy_app_agent_rcu(struct rcu_head *head)
204 {
205 struct lttng_ht_node_ulong *node =
206 caa_container_of(head, struct lttng_ht_node_ulong, head);
207 struct agent_app *app =
208 caa_container_of(node, struct agent_app, node);
209
210 free(app);
211 }
212
213 /*
214 * Communication with the agent. Send the message header to the given socket in
215 * big endian.
216 *
217 * Return 0 on success or else a negative errno message of sendmsg() op.
218 */
219 static int send_header(struct lttcomm_sock *sock, uint64_t data_size,
220 uint32_t cmd, uint32_t cmd_version)
221 {
222 int ret;
223 ssize_t size;
224 struct lttcomm_agent_hdr msg;
225
226 assert(sock);
227
228 memset(&msg, 0, sizeof(msg));
229 msg.data_size = htobe64(data_size);
230 msg.cmd = htobe32(cmd);
231 msg.cmd_version = htobe32(cmd_version);
232
233 size = sock->ops->sendmsg(sock, &msg, sizeof(msg), 0);
234 if (size < sizeof(msg)) {
235 ret = -errno;
236 goto error;
237 }
238 ret = 0;
239
240 error:
241 return ret;
242 }
243
244 /*
245 * Communication call with the agent. Send the payload to the given socket. The
246 * header MUST be sent prior to this call.
247 *
248 * Return 0 on success or else a negative errno value of sendmsg() op.
249 */
250 static int send_payload(struct lttcomm_sock *sock, const void *data,
251 size_t size)
252 {
253 int ret;
254 ssize_t len;
255
256 assert(sock);
257 assert(data);
258
259 len = sock->ops->sendmsg(sock, data, size, 0);
260 if (len < size) {
261 ret = -errno;
262 goto error;
263 }
264 ret = 0;
265
266 error:
267 return ret;
268 }
269
270 /*
271 * Communication call with the agent. Receive reply from the agent using the
272 * given socket.
273 *
274 * Return 0 on success or else a negative errno value from recvmsg() op.
275 */
276 static int recv_reply(struct lttcomm_sock *sock, void *buf, size_t size)
277 {
278 int ret;
279 ssize_t len;
280
281 assert(sock);
282 assert(buf);
283
284 len = sock->ops->recvmsg(sock, buf, size, 0);
285 if (len < size) {
286 ret = -errno;
287 goto error;
288 }
289 ret = 0;
290
291 error:
292 return ret;
293 }
294
295 /*
296 * Internal event listing for a given app. Populate events.
297 *
298 * Return number of element in the list or else a negative LTTNG_ERR* code.
299 * On success, the caller is responsible for freeing the memory
300 * allocated for "events".
301 */
302 static ssize_t list_events(struct agent_app *app, struct lttng_event **events)
303 {
304 int ret, i, len = 0, offset = 0;
305 uint32_t nb_event;
306 size_t data_size;
307 uint32_t reply_ret_code;
308 struct lttng_event *tmp_events = NULL;
309 struct lttcomm_agent_list_reply *reply = NULL;
310 struct lttcomm_agent_list_reply_hdr reply_hdr;
311
312 assert(app);
313 assert(app->sock);
314 assert(events);
315
316 DBG2("Agent listing events for app pid: %d and socket %d", app->pid,
317 app->sock->fd);
318
319 ret = send_header(app->sock, 0, AGENT_CMD_LIST, 0);
320 if (ret < 0) {
321 goto error_io;
322 }
323
324 /* Get list header so we know how much we'll receive. */
325 ret = recv_reply(app->sock, &reply_hdr, sizeof(reply_hdr));
326 if (ret < 0) {
327 goto error_io;
328 }
329
330 reply_ret_code = be32toh(reply_hdr.ret_code);
331 log_reply_code(reply_ret_code);
332 switch (reply_ret_code) {
333 case AGENT_RET_CODE_SUCCESS:
334 data_size = be32toh(reply_hdr.data_size) + sizeof(*reply);
335 break;
336 default:
337 ret = LTTNG_ERR_UNK;
338 goto error;
339 }
340
341 reply = zmalloc(data_size);
342 if (!reply) {
343 ret = LTTNG_ERR_NOMEM;
344 goto error;
345 }
346
347 /* Get the list with the appropriate data size. */
348 ret = recv_reply(app->sock, reply, data_size);
349 if (ret < 0) {
350 goto error_io;
351 }
352
353 nb_event = be32toh(reply->nb_event);
354 tmp_events = zmalloc(sizeof(*tmp_events) * nb_event);
355 if (!tmp_events) {
356 ret = LTTNG_ERR_NOMEM;
357 goto error;
358 }
359
360 for (i = 0; i < nb_event; i++) {
361 offset += len;
362 if (lttng_strncpy(tmp_events[i].name, reply->payload + offset,
363 sizeof(tmp_events[i].name))) {
364 ret = LTTNG_ERR_INVALID;
365 goto error;
366 }
367 tmp_events[i].pid = app->pid;
368 tmp_events[i].enabled = -1;
369 len = strlen(reply->payload + offset) + 1;
370 }
371
372 *events = tmp_events;
373
374 free(reply);
375 return nb_event;
376
377 error_io:
378 ret = LTTNG_ERR_UST_LIST_FAIL;
379 error:
380 free(reply);
381 free(tmp_events);
382 return -ret;
383
384 }
385
386 /*
387 * Internal enable agent event on a agent application. This function
388 * communicates with the agent to enable a given event.
389 *
390 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
391 */
392 static int enable_event(const struct agent_app *app, struct agent_event *event)
393 {
394 int ret;
395 char *bytes_to_send;
396 uint64_t data_size;
397 size_t filter_expression_length;
398 uint32_t reply_ret_code;
399 struct lttcomm_agent_enable_event msg;
400 struct lttcomm_agent_generic_reply reply;
401
402 assert(app);
403 assert(app->sock);
404 assert(event);
405
406 DBG2("Agent enabling event %s for app pid: %d and socket %d", event->name,
407 app->pid, app->sock->fd);
408
409 /*
410 * Calculate the payload's size, which is the fixed-size struct followed
411 * by the variable-length filter expression (+1 for the ending \0).
412 */
413 if (!event->filter_expression) {
414 filter_expression_length = 0;
415 } else {
416 filter_expression_length = strlen(event->filter_expression) + 1;
417 }
418 data_size = sizeof(msg) + filter_expression_length;
419
420 memset(&msg, 0, sizeof(msg));
421 msg.loglevel_value = htobe32(event->loglevel_value);
422 msg.loglevel_type = htobe32(event->loglevel_type);
423 if (lttng_strncpy(msg.name, event->name, sizeof(msg.name))) {
424 ret = LTTNG_ERR_INVALID;
425 goto error;
426 }
427 msg.filter_expression_length = htobe32(filter_expression_length);
428
429 ret = send_header(app->sock, data_size, AGENT_CMD_ENABLE, 0);
430 if (ret < 0) {
431 goto error_io;
432 }
433
434 bytes_to_send = zmalloc(data_size);
435 if (!bytes_to_send) {
436 ret = LTTNG_ERR_NOMEM;
437 goto error;
438 }
439
440 memcpy(bytes_to_send, &msg, sizeof(msg));
441 if (filter_expression_length > 0) {
442 memcpy(bytes_to_send + sizeof(msg), event->filter_expression,
443 filter_expression_length);
444 }
445
446 ret = send_payload(app->sock, bytes_to_send, data_size);
447 free(bytes_to_send);
448 if (ret < 0) {
449 goto error_io;
450 }
451
452 ret = recv_reply(app->sock, &reply, sizeof(reply));
453 if (ret < 0) {
454 goto error_io;
455 }
456
457 reply_ret_code = be32toh(reply.ret_code);
458 log_reply_code(reply_ret_code);
459 switch (reply_ret_code) {
460 case AGENT_RET_CODE_SUCCESS:
461 break;
462 case AGENT_RET_CODE_UNKNOWN_NAME:
463 ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
464 goto error;
465 default:
466 ret = LTTNG_ERR_UNK;
467 goto error;
468 }
469
470 return LTTNG_OK;
471
472 error_io:
473 ret = LTTNG_ERR_UST_ENABLE_FAIL;
474 error:
475 return ret;
476 }
477
478 /*
479 * Send Pascal-style string. Size is sent as a 32-bit big endian integer.
480 */
481 static
482 int send_pstring(struct lttcomm_sock *sock, const char *str, uint32_t len)
483 {
484 int ret;
485 uint32_t len_be;
486
487 len_be = htobe32(len);
488 ret = send_payload(sock, &len_be, sizeof(len_be));
489 if (ret) {
490 goto end;
491 }
492
493 ret = send_payload(sock, str, len);
494 if (ret) {
495 goto end;
496 }
497 end:
498 return ret;
499 }
500
501 /*
502 * Internal enable application context on an agent application. This function
503 * communicates with the agent to enable a given application context.
504 *
505 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
506 */
507 static int app_context_op(const struct agent_app *app,
508 const struct agent_app_ctx *ctx, enum lttcomm_agent_command cmd)
509 {
510 int ret;
511 uint32_t reply_ret_code;
512 struct lttcomm_agent_generic_reply reply;
513 size_t app_ctx_provider_name_len, app_ctx_name_len, data_size;
514
515 assert(app);
516 assert(app->sock);
517 assert(ctx);
518 assert(cmd == AGENT_CMD_APP_CTX_ENABLE ||
519 cmd == AGENT_CMD_APP_CTX_DISABLE);
520
521 DBG2("Agent %s application %s:%s for app pid: %d and socket %d",
522 cmd == AGENT_CMD_APP_CTX_ENABLE ? "enabling" : "disabling",
523 ctx->provider_name, ctx->ctx_name,
524 app->pid, app->sock->fd);
525
526 /*
527 * Calculate the payload's size, which consists of the size (u32, BE)
528 * of the provider name, the NULL-terminated provider name string, the
529 * size (u32, BE) of the context name, followed by the NULL-terminated
530 * context name string.
531 */
532 app_ctx_provider_name_len = strlen(ctx->provider_name) + 1;
533 app_ctx_name_len = strlen(ctx->ctx_name) + 1;
534 data_size = sizeof(uint32_t) + app_ctx_provider_name_len +
535 sizeof(uint32_t) + app_ctx_name_len;
536
537 ret = send_header(app->sock, data_size, cmd, 0);
538 if (ret < 0) {
539 goto error_io;
540 }
541
542 if (app_ctx_provider_name_len > UINT32_MAX ||
543 app_ctx_name_len > UINT32_MAX) {
544 ERR("Application context name > MAX_UINT32");
545 ret = LTTNG_ERR_INVALID;
546 goto error;
547 }
548
549 ret = send_pstring(app->sock, ctx->provider_name,
550 (uint32_t) app_ctx_provider_name_len);
551 if (ret < 0) {
552 goto error_io;
553 }
554
555 ret = send_pstring(app->sock, ctx->ctx_name,
556 (uint32_t) app_ctx_name_len);
557 if (ret < 0) {
558 goto error_io;
559 }
560
561 ret = recv_reply(app->sock, &reply, sizeof(reply));
562 if (ret < 0) {
563 goto error_io;
564 }
565
566 reply_ret_code = be32toh(reply.ret_code);
567 log_reply_code(reply_ret_code);
568 switch (reply_ret_code) {
569 case AGENT_RET_CODE_SUCCESS:
570 break;
571 default:
572 ret = LTTNG_ERR_UNK;
573 goto error;
574 }
575
576 return LTTNG_OK;
577
578 error_io:
579 ret = LTTNG_ERR_UST_ENABLE_FAIL;
580 error:
581 return ret;
582 }
583
584 /*
585 * Internal disable agent event call on a agent application. This function
586 * communicates with the agent to disable a given event.
587 *
588 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
589 */
590 static int disable_event(struct agent_app *app, struct agent_event *event)
591 {
592 int ret;
593 uint64_t data_size;
594 uint32_t reply_ret_code;
595 struct lttcomm_agent_disable_event msg;
596 struct lttcomm_agent_generic_reply reply;
597
598 assert(app);
599 assert(app->sock);
600 assert(event);
601
602 DBG2("Agent disabling event %s for app pid: %d and socket %d", event->name,
603 app->pid, app->sock->fd);
604
605 data_size = sizeof(msg);
606 memset(&msg, 0, sizeof(msg));
607 if (lttng_strncpy(msg.name, event->name, sizeof(msg.name))) {
608 ret = LTTNG_ERR_INVALID;
609 goto error;
610 }
611
612 ret = send_header(app->sock, data_size, AGENT_CMD_DISABLE, 0);
613 if (ret < 0) {
614 goto error_io;
615 }
616
617 ret = send_payload(app->sock, &msg, sizeof(msg));
618 if (ret < 0) {
619 goto error_io;
620 }
621
622 ret = recv_reply(app->sock, &reply, sizeof(reply));
623 if (ret < 0) {
624 goto error_io;
625 }
626
627 reply_ret_code = be32toh(reply.ret_code);
628 log_reply_code(reply_ret_code);
629 switch (reply_ret_code) {
630 case AGENT_RET_CODE_SUCCESS:
631 break;
632 case AGENT_RET_CODE_UNKNOWN_NAME:
633 ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
634 goto error;
635 default:
636 ret = LTTNG_ERR_UNK;
637 goto error;
638 }
639
640 return LTTNG_OK;
641
642 error_io:
643 ret = LTTNG_ERR_UST_DISABLE_FAIL;
644 error:
645 return ret;
646 }
647
648 /*
649 * Send back the registration DONE command to a given agent application.
650 *
651 * Return 0 on success or else a negative value.
652 */
653 int agent_send_registration_done(struct agent_app *app)
654 {
655 assert(app);
656 assert(app->sock);
657
658 DBG("Agent sending registration done to app socket %d", app->sock->fd);
659
660 return send_header(app->sock, 0, AGENT_CMD_REG_DONE, 0);
661 }
662
663 /*
664 * Enable agent event on every agent applications registered with the session
665 * daemon.
666 *
667 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
668 */
669 int agent_enable_event(struct agent_event *event,
670 enum lttng_domain_type domain)
671 {
672 int ret;
673 struct agent_app *app;
674 struct lttng_ht_iter iter;
675
676 assert(event);
677
678 rcu_read_lock();
679
680 cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app,
681 node.node) {
682 if (app->domain != domain) {
683 continue;
684 }
685
686 /* Enable event on agent application through TCP socket. */
687 ret = enable_event(app, event);
688 if (ret != LTTNG_OK) {
689 goto error;
690 }
691 }
692
693 event->enabled_count++;
694 ret = LTTNG_OK;
695
696 error:
697 rcu_read_unlock();
698 return ret;
699 }
700
701 static
702 void destroy_app_ctx(struct agent_app_ctx *ctx)
703 {
704 free(ctx->provider_name);
705 free(ctx->ctx_name);
706 free(ctx);
707 }
708
709 static
710 struct agent_app_ctx *create_app_ctx(const struct lttng_event_context *ctx)
711 {
712 struct agent_app_ctx *agent_ctx = NULL;
713
714 if (!ctx) {
715 goto end;
716 }
717
718 assert(ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT);
719 agent_ctx = zmalloc(sizeof(*ctx));
720 if (!agent_ctx) {
721 goto end;
722 }
723
724 agent_ctx->provider_name = strdup(ctx->u.app_ctx.provider_name);
725 agent_ctx->ctx_name = strdup(ctx->u.app_ctx.ctx_name);
726 if (!agent_ctx->provider_name || !agent_ctx->ctx_name) {
727 destroy_app_ctx(agent_ctx);
728 agent_ctx = NULL;
729 }
730 end:
731 return agent_ctx;
732 }
733
734 /*
735 * Enable agent context on every agent applications registered with the session
736 * daemon.
737 *
738 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
739 */
740 int agent_enable_context(const struct lttng_event_context *ctx,
741 enum lttng_domain_type domain)
742 {
743 int ret;
744 struct agent_app *app;
745 struct lttng_ht_iter iter;
746
747 assert(ctx);
748 if (ctx->ctx != LTTNG_EVENT_CONTEXT_APP_CONTEXT) {
749 ret = LTTNG_ERR_INVALID;
750 goto error;
751 }
752
753 rcu_read_lock();
754
755 cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app,
756 node.node) {
757 struct agent_app_ctx *agent_ctx;
758
759 if (app->domain != domain) {
760 continue;
761 }
762
763 agent_ctx = create_app_ctx(ctx);
764 if (!agent_ctx) {
765 ret = LTTNG_ERR_NOMEM;
766 goto error_unlock;
767 }
768
769 /* Enable event on agent application through TCP socket. */
770 ret = app_context_op(app, agent_ctx, AGENT_CMD_APP_CTX_ENABLE);
771 destroy_app_ctx(agent_ctx);
772 if (ret != LTTNG_OK) {
773 goto error_unlock;
774 }
775 }
776
777 ret = LTTNG_OK;
778
779 error_unlock:
780 rcu_read_unlock();
781 error:
782 return ret;
783 }
784
785 /*
786 * Disable agent event on every agent application registered with the session
787 * daemon.
788 *
789 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
790 */
791 int agent_disable_event(struct agent_event *event,
792 enum lttng_domain_type domain)
793 {
794 int ret = LTTNG_OK;
795 struct agent_app *app;
796 struct lttng_ht_iter iter;
797
798 assert(event);
799 if (!AGENT_EVENT_IS_ENABLED(event)) {
800 goto end;
801 }
802
803 if (--event->enabled_count != 0) {
804 /*
805 * Agent event still enabled. Disable the agent event only when
806 * all "users" have disabled it (event notifiers, event rules,
807 * etc.).
808 */
809 ret = LTTNG_OK;
810 goto end;
811 }
812
813 rcu_read_lock();
814
815 cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app,
816 node.node) {
817 if (app->domain != domain) {
818 continue;
819 }
820
821 /* Enable event on agent application through TCP socket. */
822 ret = disable_event(app, event);
823 if (ret != LTTNG_OK) {
824 goto error;
825 }
826 }
827
828 /* event->enabled_count is now 0. */
829 assert(!AGENT_EVENT_IS_ENABLED(event));
830
831 error:
832 rcu_read_unlock();
833 end:
834 return ret;
835 }
836
837 /*
838 * Disable agent context on every agent application registered with the session
839 * daemon.
840 *
841 * Return LTTNG_OK on success or else a LTTNG_ERR* code.
842 */
843 static int disable_context(struct agent_app_ctx *ctx,
844 enum lttng_domain_type domain)
845 {
846 int ret = LTTNG_OK;
847 struct agent_app *app;
848 struct lttng_ht_iter iter;
849
850 assert(ctx);
851
852 rcu_read_lock();
853 DBG2("Disabling agent application context %s:%s",
854 ctx->provider_name, ctx->ctx_name);
855 cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app,
856 node.node) {
857 if (app->domain != domain) {
858 continue;
859 }
860
861 ret = app_context_op(app, ctx, AGENT_CMD_APP_CTX_DISABLE);
862 if (ret != LTTNG_OK) {
863 goto end;
864 }
865 }
866 end:
867 rcu_read_unlock();
868 return ret;
869 }
870
871 /*
872 * Ask every agent for the list of possible event. Events is allocated with the
873 * events of every agent application.
874 *
875 * Return the number of events or else a negative value.
876 */
877 int agent_list_events(struct lttng_event **events,
878 enum lttng_domain_type domain)
879 {
880 int ret;
881 size_t nbmem, count = 0;
882 struct agent_app *app;
883 struct lttng_event *tmp_events = NULL;
884 struct lttng_ht_iter iter;
885
886 assert(events);
887
888 DBG2("Agent listing events for domain %d", domain);
889
890 nbmem = UST_APP_EVENT_LIST_SIZE;
891 tmp_events = zmalloc(nbmem * sizeof(*tmp_events));
892 if (!tmp_events) {
893 PERROR("zmalloc agent list events");
894 ret = -ENOMEM;
895 goto error;
896 }
897
898 rcu_read_lock();
899 cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, app,
900 node.node) {
901 ssize_t nb_ev;
902 struct lttng_event *agent_events;
903
904 /* Skip domain not asked by the list. */
905 if (app->domain != domain) {
906 continue;
907 }
908
909 nb_ev = list_events(app, &agent_events);
910 if (nb_ev < 0) {
911 ret = nb_ev;
912 goto error_unlock;
913 }
914
915 if (count + nb_ev > nbmem) {
916 /* In case the realloc fails, we free the memory */
917 struct lttng_event *new_tmp_events;
918 size_t new_nbmem;
919
920 new_nbmem = max_t(size_t, count + nb_ev, nbmem << 1);
921 DBG2("Reallocating agent event list from %zu to %zu entries",
922 nbmem, new_nbmem);
923 new_tmp_events = realloc(tmp_events,
924 new_nbmem * sizeof(*new_tmp_events));
925 if (!new_tmp_events) {
926 PERROR("realloc agent events");
927 ret = -ENOMEM;
928 free(agent_events);
929 goto error_unlock;
930 }
931 /* Zero the new memory */
932 memset(new_tmp_events + nbmem, 0,
933 (new_nbmem - nbmem) * sizeof(*new_tmp_events));
934 nbmem = new_nbmem;
935 tmp_events = new_tmp_events;
936 }
937 memcpy(tmp_events + count, agent_events,
938 nb_ev * sizeof(*tmp_events));
939 free(agent_events);
940 count += nb_ev;
941 }
942 rcu_read_unlock();
943
944 ret = count;
945 *events = tmp_events;
946 return ret;
947
948 error_unlock:
949 rcu_read_unlock();
950 error:
951 free(tmp_events);
952 return ret;
953 }
954
955 /*
956 * Create a agent app object using the given PID.
957 *
958 * Return newly allocated object or else NULL on error.
959 */
960 struct agent_app *agent_create_app(pid_t pid, enum lttng_domain_type domain,
961 struct lttcomm_sock *sock)
962 {
963 struct agent_app *app;
964
965 assert(sock);
966
967 app = zmalloc(sizeof(*app));
968 if (!app) {
969 PERROR("Failed to allocate agent application instance");
970 goto error;
971 }
972
973 app->pid = pid;
974 app->domain = domain;
975 app->sock = sock;
976 lttng_ht_node_init_ulong(&app->node, (unsigned long) app->sock->fd);
977
978 error:
979 return app;
980 }
981
982 /*
983 * Lookup agent app by socket in the global hash table.
984 *
985 * RCU read side lock MUST be acquired.
986 *
987 * Return object if found else NULL.
988 */
989 struct agent_app *agent_find_app_by_sock(int sock)
990 {
991 struct lttng_ht_node_ulong *node;
992 struct lttng_ht_iter iter;
993 struct agent_app *app;
994
995 assert(sock >= 0);
996
997 lttng_ht_lookup(agent_apps_ht_by_sock, (void *)((unsigned long) sock), &iter);
998 node = lttng_ht_iter_get_node_ulong(&iter);
999 if (node == NULL) {
1000 goto error;
1001 }
1002 app = caa_container_of(node, struct agent_app, node);
1003
1004 DBG3("Agent app pid %d found by sock %d.", app->pid, sock);
1005 return app;
1006
1007 error:
1008 DBG3("Agent app NOT found by sock %d.", sock);
1009 return NULL;
1010 }
1011
1012 /*
1013 * Add agent application object to the global hash table.
1014 */
1015 void agent_add_app(struct agent_app *app)
1016 {
1017 assert(app);
1018
1019 DBG3("Agent adding app sock: %d and pid: %d to ht", app->sock->fd, app->pid);
1020 lttng_ht_add_unique_ulong(agent_apps_ht_by_sock, &app->node);
1021 }
1022
1023 /*
1024 * Delete agent application from the global hash table.
1025 *
1026 * rcu_read_lock() must be held by the caller.
1027 */
1028 void agent_delete_app(struct agent_app *app)
1029 {
1030 int ret;
1031 struct lttng_ht_iter iter;
1032
1033 assert(app);
1034
1035 DBG3("Agent deleting app pid: %d and sock: %d", app->pid, app->sock->fd);
1036
1037 iter.iter.node = &app->node.node;
1038 ret = lttng_ht_del(agent_apps_ht_by_sock, &iter);
1039 assert(!ret);
1040 }
1041
1042 /*
1043 * Destroy an agent application object by detaching it from its corresponding
1044 * UST app if one is connected by closing the socket. Finally, perform a
1045 * delayed memory reclaim.
1046 */
1047 void agent_destroy_app(struct agent_app *app)
1048 {
1049 assert(app);
1050
1051 if (app->sock) {
1052 app->sock->ops->close(app->sock);
1053 lttcomm_destroy_sock(app->sock);
1054 }
1055
1056 call_rcu(&app->node.head, destroy_app_agent_rcu);
1057 }
1058
1059 /*
1060 * Initialize an already allocated agent object.
1061 *
1062 * Return 0 on success or else a negative errno value.
1063 */
1064 int agent_init(struct agent *agt)
1065 {
1066 int ret;
1067
1068 assert(agt);
1069
1070 agt->events = lttng_ht_new(0, LTTNG_HT_TYPE_STRING);
1071 if (!agt->events) {
1072 ret = -ENOMEM;
1073 goto error;
1074 }
1075 lttng_ht_node_init_u64(&agt->node, agt->domain);
1076
1077 CDS_INIT_LIST_HEAD(&agt->app_ctx_list);
1078 return 0;
1079
1080 error:
1081 return ret;
1082 }
1083
1084 /*
1085 * Add agent object to the given hash table.
1086 */
1087 void agent_add(struct agent *agt, struct lttng_ht *ht)
1088 {
1089 assert(agt);
1090 assert(ht);
1091
1092 DBG3("Agent adding from domain %d", agt->domain);
1093
1094 lttng_ht_add_unique_u64(ht, &agt->node);
1095 }
1096
1097 /*
1098 * Create an agent object for the given domain.
1099 *
1100 * Return the allocated agent or NULL on error.
1101 */
1102 struct agent *agent_create(enum lttng_domain_type domain)
1103 {
1104 int ret;
1105 struct agent *agt;
1106
1107 agt = zmalloc(sizeof(struct agent));
1108 if (!agt) {
1109 goto error;
1110 }
1111 agt->domain = domain;
1112
1113 ret = agent_init(agt);
1114 if (ret < 0) {
1115 free(agt);
1116 agt = NULL;
1117 goto error;
1118 }
1119
1120 error:
1121 return agt;
1122 }
1123
1124 /*
1125 * Create a newly allocated agent event data structure.
1126 * Ownership of filter_expression is taken.
1127 *
1128 * Return a new object else NULL on error.
1129 */
1130 struct agent_event *agent_create_event(const char *name,
1131 enum lttng_loglevel_type loglevel_type, int loglevel_value,
1132 struct lttng_bytecode *filter, char *filter_expression)
1133 {
1134 struct agent_event *event = NULL;
1135
1136 DBG3("Agent create new event with name %s, loglevel type %d, \
1137 loglevel value %d and filter %s",
1138 name, loglevel_type, loglevel_value,
1139 filter_expression ? filter_expression : "NULL");
1140
1141 if (!name) {
1142 ERR("Failed to create agent event; no name provided.");
1143 goto error;
1144 }
1145
1146 event = zmalloc(sizeof(*event));
1147 if (!event) {
1148 goto error;
1149 }
1150
1151 strncpy(event->name, name, sizeof(event->name));
1152 event->name[sizeof(event->name) - 1] = '\0';
1153 lttng_ht_node_init_str(&event->node, event->name);
1154
1155 event->loglevel_value = loglevel_value;
1156 event->loglevel_type = loglevel_type;
1157 event->filter = filter;
1158 event->filter_expression = filter_expression;
1159 error:
1160 return event;
1161 }
1162
1163 /*
1164 * Unique add of a agent event to an agent object.
1165 */
1166 void agent_add_event(struct agent_event *event, struct agent *agt)
1167 {
1168 assert(event);
1169 assert(agt);
1170 assert(agt->events);
1171
1172 DBG3("Agent adding event %s", event->name);
1173 add_unique_agent_event(agt->events, event);
1174 agt->being_used = 1;
1175 }
1176
1177 /*
1178 * Unique add of a agent context to an agent object.
1179 */
1180 int agent_add_context(const struct lttng_event_context *ctx, struct agent *agt)
1181 {
1182 int ret = LTTNG_OK;
1183 struct agent_app_ctx *agent_ctx = NULL;
1184
1185 assert(ctx);
1186 assert(agt);
1187 assert(agt->events);
1188 assert(ctx->ctx == LTTNG_EVENT_CONTEXT_APP_CONTEXT);
1189
1190 agent_ctx = create_app_ctx(ctx);
1191 if (!agent_ctx) {
1192 ret = LTTNG_ERR_NOMEM;
1193 goto end;
1194 }
1195
1196 DBG3("Agent adding context %s:%s", ctx->u.app_ctx.provider_name,
1197 ctx->u.app_ctx.ctx_name);
1198 cds_list_add_tail_rcu(&agent_ctx->list_node, &agt->app_ctx_list);
1199 end:
1200 return ret;
1201 }
1202
1203 /*
1204 * Find multiple agent events sharing the given name.
1205 *
1206 * RCU read side lock MUST be acquired. It must be held for the
1207 * duration of the iteration.
1208 *
1209 * Sets the given iterator.
1210 */
1211 void agent_find_events_by_name(const char *name, struct agent *agt,
1212 struct lttng_ht_iter* iter)
1213 {
1214 struct lttng_ht *ht;
1215 struct agent_ht_key key;
1216
1217 assert(name);
1218 assert(agt);
1219 assert(agt->events);
1220 assert(iter);
1221
1222 ht = agt->events;
1223 key.name = name;
1224
1225 cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
1226 ht_match_event_by_name, &key, &iter->iter);
1227 }
1228
1229 /*
1230 * Find the agent event matching a trigger.
1231 *
1232 * RCU read side lock MUST be acquired. It must be held for as long as
1233 * the returned agent_event is used.
1234 *
1235 * Return object if found else NULL.
1236 */
1237 struct agent_event *agent_find_event_by_trigger(
1238 const struct lttng_trigger *trigger, struct agent *agt)
1239 {
1240 enum lttng_condition_status c_status;
1241 enum lttng_event_rule_status er_status;
1242 enum lttng_domain_type domain;
1243 const struct lttng_condition *condition;
1244 const struct lttng_event_rule *rule;
1245 const char *name;
1246 const char *filter_expression;
1247 const struct lttng_log_level_rule *log_level_rule;
1248 /* Unused when loglevel_type is 'ALL'. */
1249 int loglevel_value = 0;
1250 enum lttng_loglevel_type loglevel_type;
1251
1252 assert(agt);
1253 assert(agt->events);
1254
1255 condition = lttng_trigger_get_const_condition(trigger);
1256
1257 assert(lttng_condition_get_type(condition) ==
1258 LTTNG_CONDITION_TYPE_ON_EVENT);
1259
1260 c_status = lttng_condition_on_event_get_rule(condition, &rule);
1261 assert(c_status == LTTNG_CONDITION_STATUS_OK);
1262
1263 assert(lttng_event_rule_get_type(rule) ==
1264 LTTNG_EVENT_RULE_TYPE_TRACEPOINT);
1265
1266 domain = lttng_event_rule_get_domain_type(rule);
1267 assert(domain == LTTNG_DOMAIN_JUL || domain == LTTNG_DOMAIN_LOG4J ||
1268 domain == LTTNG_DOMAIN_PYTHON);
1269
1270 /* Get the event's pattern ('name' in the legacy terminology). */
1271 er_status = lttng_event_rule_tracepoint_get_pattern(rule, &name);
1272 assert(er_status == LTTNG_EVENT_RULE_STATUS_OK);
1273
1274 /* Get the internal filter expression. */
1275 filter_expression = lttng_event_rule_get_filter(rule);
1276
1277 /* Map log_level_rule to loglevel value. */
1278 er_status = lttng_event_rule_tracepoint_get_log_level_rule(
1279 rule, &log_level_rule);
1280 if (er_status == LTTNG_EVENT_RULE_STATUS_UNSET) {
1281 loglevel_type = LTTNG_EVENT_LOGLEVEL_ALL;
1282 loglevel_value = 0;
1283 } else if (er_status == LTTNG_EVENT_RULE_STATUS_OK) {
1284 lttng_log_level_rule_to_loglevel(log_level_rule, &loglevel_type, &loglevel_value);
1285 } else {
1286 abort();
1287 }
1288
1289 return agent_find_event(name, loglevel_type, loglevel_value,
1290 filter_expression, agt);
1291 }
1292
1293 /*
1294 * Get the next agent event duplicate by name. This should be called
1295 * after a call to agent_find_events_by_name() to iterate on events.
1296 *
1297 * The RCU read lock must be held during the iteration and for as long
1298 * as the object the iterator points to remains in use.
1299 */
1300 void agent_event_next_duplicate(const char *name,
1301 struct agent *agt, struct lttng_ht_iter* iter)
1302 {
1303 struct agent_ht_key key;
1304
1305 key.name = name;
1306
1307 cds_lfht_next_duplicate(agt->events->ht, ht_match_event_by_name,
1308 &key, &iter->iter);
1309 }
1310
1311 /*
1312 * Find a agent event in the given agent using name, loglevel and filter.
1313 *
1314 * RCU read side lock MUST be acquired. It must be kept for as long as
1315 * the returned agent_event is used.
1316 *
1317 * Return object if found else NULL.
1318 */
1319 struct agent_event *agent_find_event(const char *name,
1320 enum lttng_loglevel_type loglevel_type,
1321 int loglevel_value,
1322 const char *filter_expression,
1323 struct agent *agt)
1324 {
1325 struct lttng_ht_node_str *node;
1326 struct lttng_ht_iter iter;
1327 struct lttng_ht *ht;
1328 struct agent_ht_key key;
1329
1330 assert(name);
1331 assert(agt);
1332 assert(agt->events);
1333
1334 ht = agt->events;
1335 key.name = name;
1336 key.loglevel_value = loglevel_value;
1337 key.loglevel_type = loglevel_type;
1338 key.filter_expression = filter_expression;
1339
1340 cds_lfht_lookup(ht->ht, ht->hash_fct((void *) name, lttng_ht_seed),
1341 ht_match_event, &key, &iter.iter);
1342 node = lttng_ht_iter_get_node_str(&iter);
1343 if (node == NULL) {
1344 goto error;
1345 }
1346
1347 DBG3("Agent event found %s.", name);
1348 return caa_container_of(node, struct agent_event, node);
1349
1350 error:
1351 DBG3("Agent event NOT found %s.", name);
1352 return NULL;
1353 }
1354
1355 /*
1356 * Free given agent event. This event must not be globally visible at this
1357 * point (only expected to be used on failure just after event creation). After
1358 * this call, the pointer is not usable anymore.
1359 */
1360 void agent_destroy_event(struct agent_event *event)
1361 {
1362 assert(event);
1363
1364 free(event->filter);
1365 free(event->filter_expression);
1366 free(event->exclusion);
1367 free(event);
1368 }
1369
1370 static
1371 void destroy_app_ctx_rcu(struct rcu_head *head)
1372 {
1373 struct agent_app_ctx *ctx =
1374 caa_container_of(head, struct agent_app_ctx, rcu_node);
1375
1376 destroy_app_ctx(ctx);
1377 }
1378
1379 /*
1380 * Destroy an agent completely.
1381 */
1382 void agent_destroy(struct agent *agt)
1383 {
1384 struct lttng_ht_node_str *node;
1385 struct lttng_ht_iter iter;
1386 struct agent_app_ctx *ctx;
1387
1388 assert(agt);
1389
1390 DBG3("Agent destroy");
1391
1392 rcu_read_lock();
1393 cds_lfht_for_each_entry(agt->events->ht, &iter.iter, node, node) {
1394 int ret;
1395 struct agent_event *event;
1396
1397 /*
1398 * When destroying an event, we have to try to disable it on the
1399 * agent side so the event stops generating data. The return
1400 * value is not important since we have to continue anyway
1401 * destroying the object.
1402 */
1403 event = caa_container_of(node, struct agent_event, node);
1404 (void) agent_disable_event(event, agt->domain);
1405
1406 ret = lttng_ht_del(agt->events, &iter);
1407 assert(!ret);
1408 call_rcu(&node->head, destroy_event_agent_rcu);
1409 }
1410
1411 cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node) {
1412 (void) disable_context(ctx, agt->domain);
1413 cds_list_del(&ctx->list_node);
1414 call_rcu(&ctx->rcu_node, destroy_app_ctx_rcu);
1415 }
1416 rcu_read_unlock();
1417 ht_cleanup_push(agt->events);
1418 free(agt);
1419 }
1420
1421 /*
1422 * Allocate agent_apps_ht_by_sock.
1423 */
1424 int agent_app_ht_alloc(void)
1425 {
1426 agent_apps_ht_by_sock = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG);
1427 return agent_apps_ht_by_sock ? 0 : -1;
1428 }
1429
1430 /*
1431 * Destroy a agent application by socket.
1432 */
1433 void agent_destroy_app_by_sock(int sock)
1434 {
1435 struct agent_app *app;
1436
1437 assert(sock >= 0);
1438
1439 /*
1440 * Not finding an application is a very important error that should NEVER
1441 * happen. The hash table deletion is ONLY done through this call when the
1442 * main sessiond thread is torn down.
1443 */
1444 rcu_read_lock();
1445 app = agent_find_app_by_sock(sock);
1446 assert(app);
1447
1448 /* RCU read side lock is assumed to be held by this function. */
1449 agent_delete_app(app);
1450
1451 /* The application is freed in a RCU call but the socket is closed here. */
1452 agent_destroy_app(app);
1453 rcu_read_unlock();
1454 }
1455
1456 /*
1457 * Clean-up the agent app hash table and destroy it.
1458 */
1459 void agent_app_ht_clean(void)
1460 {
1461 struct lttng_ht_node_ulong *node;
1462 struct lttng_ht_iter iter;
1463
1464 if (!agent_apps_ht_by_sock) {
1465 return;
1466 }
1467 rcu_read_lock();
1468 cds_lfht_for_each_entry(agent_apps_ht_by_sock->ht, &iter.iter, node, node) {
1469 struct agent_app *app;
1470
1471 app = caa_container_of(node, struct agent_app, node);
1472 agent_destroy_app_by_sock(app->sock->fd);
1473 }
1474 rcu_read_unlock();
1475
1476 lttng_ht_destroy(agent_apps_ht_by_sock);
1477 }
1478
1479 /*
1480 * Update a agent application (given socket) using the given agent.
1481 *
1482 * Note that this function is most likely to be used with a tracing session
1483 * thus the caller should make sure to hold the appropriate lock(s).
1484 */
1485 void agent_update(const struct agent *agt, const struct agent_app *app)
1486 {
1487 int ret;
1488 struct agent_event *event;
1489 struct lttng_ht_iter iter;
1490 struct agent_app_ctx *ctx;
1491
1492 assert(agt);
1493 assert(app);
1494
1495 DBG("Agent updating app: pid = %ld", (long) app->pid);
1496
1497 rcu_read_lock();
1498 /*
1499 * We are in the registration path thus if the application is gone,
1500 * there is a serious code flow error.
1501 */
1502
1503 cds_lfht_for_each_entry(agt->events->ht, &iter.iter, event, node.node) {
1504 /* Skip event if disabled. */
1505 if (!AGENT_EVENT_IS_ENABLED(event)) {
1506 continue;
1507 }
1508
1509 ret = enable_event(app, event);
1510 if (ret != LTTNG_OK) {
1511 DBG2("Agent update unable to enable event %s on app pid: %d sock %d",
1512 event->name, app->pid, app->sock->fd);
1513 /* Let's try the others here and don't assume the app is dead. */
1514 continue;
1515 }
1516 }
1517
1518 cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node) {
1519 ret = app_context_op(app, ctx, AGENT_CMD_APP_CTX_ENABLE);
1520 if (ret != LTTNG_OK) {
1521 DBG2("Agent update unable to add application context %s:%s on app pid: %d sock %d",
1522 ctx->provider_name, ctx->ctx_name,
1523 app->pid, app->sock->fd);
1524 continue;
1525 }
1526 }
1527
1528 rcu_read_unlock();
1529 }
1530
1531 /*
1532 * Allocate the per-event notifier domain agent hash table. It is lazily
1533 * populated as domains are used.
1534 */
1535 int agent_by_event_notifier_domain_ht_create(void)
1536 {
1537 trigger_agents_ht_by_domain = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
1538 return trigger_agents_ht_by_domain ? 0 : -1;
1539 }
1540
1541 /*
1542 * Clean-up the per-event notifier domain agent hash table and destroy it.
1543 */
1544 void agent_by_event_notifier_domain_ht_destroy(void)
1545 {
1546 struct lttng_ht_node_u64 *node;
1547 struct lttng_ht_iter iter;
1548
1549 if (!trigger_agents_ht_by_domain) {
1550 return;
1551 }
1552
1553 rcu_read_lock();
1554 cds_lfht_for_each_entry (trigger_agents_ht_by_domain->ht, &iter.iter,
1555 node, node) {
1556 struct agent *agent =
1557 caa_container_of(node, struct agent, node);
1558 const int ret = lttng_ht_del(
1559 trigger_agents_ht_by_domain, &iter);
1560
1561 assert(ret == 0);
1562 agent_destroy(agent);
1563 }
1564
1565 rcu_read_unlock();
1566 lttng_ht_destroy(trigger_agents_ht_by_domain);
1567 }
1568
1569 struct agent *agent_find_by_event_notifier_domain(
1570 enum lttng_domain_type domain_type)
1571 {
1572 struct agent *agt = NULL;
1573 struct lttng_ht_node_u64 *node;
1574 struct lttng_ht_iter iter;
1575 const uint64_t key = (uint64_t) domain_type;
1576
1577 assert(trigger_agents_ht_by_domain);
1578
1579 DBG3("Per-event notifier domain agent lookup for domain '%s'",
1580 lttng_domain_type_str(domain_type));
1581
1582 lttng_ht_lookup(trigger_agents_ht_by_domain, &key, &iter);
1583 node = lttng_ht_iter_get_node_u64(&iter);
1584 if (!node) {
1585 goto end;
1586 }
1587
1588 agt = caa_container_of(node, struct agent, node);
1589
1590 end:
1591 return agt;
1592 }
This page took 0.098802 seconds and 4 git commands to generate.