Lines Matching defs:p

260 load_function(plugin_t *p, char *name, auditd_rc_t (**func)())
262 *func = (auditd_rc_t (*)())dlsym(p->plg_dlptr, name);
281 load_plugin(plugin_t *p)
290 if ((fd = open(p->plg_path, O_NONBLOCK | O_RDONLY)) != -1) {
300 p->plg_path, strerror(errno));
314 p->plg_path);
327 p->plg_path);
337 p->plg_path);
345 p->plg_dlptr = dlopen(p->plg_path, RTLD_LAZY);
347 if (p->plg_dlptr == NULL) {
353 p->plg_path, errmsg != NULL ? errmsg :
359 if (load_function(p, "auditd_plugin", &(p->plg_fplugin)))
362 if (load_function(p, "auditd_plugin_open", &(p->plg_fplugin_open)))
365 if (load_function(p, "auditd_plugin_close", &(p->plg_fplugin_close)))
379 unload_plugin(plugin_t *p)
385 DPRINT((dbfp, "unload_plugin: removing %s\n", p->plg_path));
387 _kva_free(p->plg_kvlist); /* _kva_free accepts NULL */
388 qpool_close(p); /* qpool_close accepts NULL pool, queue */
389 DPRINT((dbfp, "unload_plugin: %s structure removed\n", p->plg_path));
391 (void) dlclose(p->plg_dlptr);
393 DPRINT((dbfp, "unload_plugin: %s dlclosed\n", p->plg_path));
394 free(p->plg_path);
396 (void) pthread_mutex_destroy(&(p->plg_mutex));
397 (void) pthread_cond_destroy(&(p->plg_cv));
402 if (q == p) {
403 *r = p->plg_next;
404 free(p);
420 open_return(plugin_t *p, char *attrval)
437 plugin_t *p;
464 p = plugin_head;
465 while (p != NULL) {
466 if (p->plg_removed) {
467 DPRINT((dbfp, "start removing %s\n", p->plg_path));
468 /* tell process(p) to exit and dlclose */
469 (void) pthread_cond_signal(&(p->plg_cv));
470 } else if (!p->plg_initialized) {
472 p->plg_path));
473 if (load_plugin(p)) {
476 p->plg_path);
477 p = unload_plugin(p);
482 if ((rc = p->plg_fplugin_open(
483 p->plg_kvlist,
485 report_error(rc, error_string, p->plg_path);
487 p = unload_plugin(p);
490 open_return(p, open_params);
491 p->plg_reopen = 0;
493 threshold = ((p->plg_qmax * THRESHOLD_PCT) + 99) / 100;
494 p->plg_qmin = INPUT_MIN;
498 p->plg_path, p->plg_qmax));
500 qpool_init(p, threshold);
501 audit_queue_init(&(p->plg_queue));
502 p->plg_initialized = 1;
504 (void) pthread_mutex_init(&(p->plg_mutex), NULL);
505 (void) pthread_cond_init(&(p->plg_cv), NULL);
506 p->plg_waiting = 0;
508 if (pthread_create(&(p->plg_tid), NULL,
509 (void *(*)(void *))process, p)) {
512 p->plg_path);
513 p = unload_plugin(p);
516 } else if (p->plg_reopen) {
517 DPRINT((dbfp, "reopen %s\n", p->plg_path));
519 if ((rc = p->plg_fplugin_open(p->plg_kvlist,
521 report_error(rc, error_string, p->plg_path);
523 p = unload_plugin(p);
526 open_return(p, open_params);
527 p->plg_reopen = 0;
530 p->plg_path, p->plg_qmax));
533 p->plg_q_threshold = ((p->plg_qmax * THRESHOLD_PCT) + 99) / 100;
535 p = p->plg_next;
576 qpool_init(plugin_t *p, int threshold)
581 audit_queue_init(&(p->plg_pool));
584 p->plg_tid, p->plg_qmax, p->plg_qmin, threshold));
586 if (p->plg_qmax > largest_queue)
587 largest_queue = p->plg_qmax;
589 p->plg_q_threshold = threshold;
591 for (i = 0; i < p->plg_qmin; i++) {
597 audit_enqueue(&p->plg_pool, node);
638 qpool_close(plugin_t *p) {
642 if (!p->plg_initialized)
645 while (audit_dequeue(&(p->plg_pool), (void *)&q_node) == 0) {
648 audit_queue_destroy(&(p->plg_pool));
650 while (audit_dequeue(&(p->plg_queue), (void *)&q_node) == 0) {
656 audit_queue_destroy(&(p->plg_queue));
663 qpool_withdraw(plugin_t *p)
669 rc = audit_dequeue(&(p->plg_pool), (void *)&node);
707 DPRINT((dbfp, "bpool_withdraw node=%p (pool=%d)\n",
738 DPRINT((dbfp, "bpool_withdraw node=%p (alloc=%d, pool=%d)\n",
757 qpool_return(plugin_t *p, audit_q_t *node)
765 qpool_size = audit_queue_size(&(p->plg_pool));
766 q_size = audit_queue_size(&(p->plg_queue));
768 if (qpool_size + q_size > p->plg_qmax)
771 audit_enqueue(&(p->plg_pool), node);
776 p->plg_tid, sequence, q_size, qpool_size,
777 q_size + qpool_size, p->plg_q_threshold));
794 "bpool_return: requeue %p (allocated=%d,"
801 "bpool_return: decrement count for %p (allocated=%d,"
810 dump_state(char *src, plugin_t *p, uint64_t count, char *msg)
817 (void) pthread_getschedparam(p->plg_tid, &policy, &param);
828 src, p->plg_tid, count, msg,
830 audit_queue_size(&(p->plg_queue)),
831 audit_queue_size(&(p->plg_pool)),
832 p->plg_waiting, p->plg_tossed,
833 p->plg_queued, p->plg_output);
846 plugin_t *p;
849 p = plugin_head;
851 while (p != NULL) {
852 if (p->plg_cnt == 0) {
858 p = p->plg_next;
872 plugin_t *p;
876 p = plugin_head;
877 while (p != NULL) {
878 p->plg_cnt = (newpolicy & AUDIT_CNT) ? 1 : 0;
879 (void) pthread_cond_signal(&(p->plg_cv));
881 DPRINT((dbfp, "policy changed for thread %d\n", p->plg_tid));
882 p = p->plg_next;
902 plugin_t *p;
1000 p = plugin_head;
1001 while (p != NULL) {
1002 if (!p->plg_removed) {
1011 q_copy = qpool_withdraw(p);
1012 q_copy->aqq_sequence = p->plg_sequence++;
1015 p->plg_save_q_copy = q_copy; /* enqueue below */
1018 p->plg_save_q_copy = NULL;
1019 p = p->plg_next;
1025 p = plugin_head;
1026 while ((p != NULL) && (p->plg_save_q_copy != NULL)) {
1027 audit_enqueue(&(p->plg_queue), p->plg_save_q_copy);
1028 (void) pthread_cond_signal(&(p->plg_cv));
1029 p->plg_queued++;
1030 p = p->plg_next;
1066 plugin_t *p;
1072 p = plugin_head;
1073 while (p != NULL) {
1074 queue_size = audit_queue_size(&(p->plg_queue));
1075 if (queue_size > p->plg_q_threshold) {
1076 if (p->plg_priority != HIGH_PRIORITY) {
1077 p->plg_priority =
1080 (void) pthread_setschedparam(p->plg_tid,
1083 if (queue_size > p->plg_qmax - p->plg_qmin) {
1088 p = p->plg_next;
1120 plugin_t *p;
1169 p = plugin_head;
1170 while (p != NULL) {
1171 (void) pthread_cond_signal(&(p->plg_cv));
1172 p = p->plg_next;
1182 process(plugin_t *p)
1195 DPRINT((dbfp, "%s is thread %d\n", p->plg_path, p->plg_tid));
1196 p->plg_priority = param.sched_priority = BASE_PRIORITY;
1197 (void) pthread_setschedparam(p->plg_tid, SCHED_OTHER, &param);
1202 while (audit_dequeue(&(p->plg_queue), (void *)&q_node) != 0) {
1203 DUMP("process", p, p->plg_last_seq_out, "blocked");
1206 (void) pthread_mutex_lock(&(p->plg_mutex));
1207 p->plg_waiting++;
1208 (void) pthread_cond_wait(&(p->plg_cv),
1209 &(p->plg_mutex));
1210 p->plg_waiting--;
1211 (void) pthread_mutex_unlock(&(p->plg_mutex));
1213 if (p->plg_removed)
1216 DUMP("process", p, p->plg_last_seq_out, "unblocked");
1219 if (q_node->aqq_sequence != p->plg_last_seq_out + 1)
1222 p->plg_tid, q_node->aqq_sequence,
1223 p->plg_last_seq_out);
1229 plugrc = p->plg_fplugin(b_node->abq_buffer,
1232 if (p->plg_removed)
1235 p->plg_last_seq_out = q_node->aqq_sequence;
1240 report_error(plugrc, error_string, p->plg_path);
1248 p->plg_tid, p->plg_cnt));
1250 if (p->plg_cnt) /* if cnt is on, lose the buffer */
1253 delay.tv_sec = p->plg_retry_time;
1254 (void) pthread_mutex_lock(&(p->plg_mutex));
1255 p->plg_waiting++;
1256 (void) pthread_cond_reltimedwait_np(&(p->plg_cv),
1257 &(p->plg_mutex), &delay);
1258 p->plg_waiting--;
1259 (void) pthread_mutex_unlock(&(p->plg_mutex));
1261 DPRINT((dbfp, "left retry mode for %d\n", p->plg_tid));
1265 p->plg_output++;
1269 report_error(plugrc, error_string, p->plg_path);
1275 qpool_return(p, q_node);
1278 queue_len = audit_queue_size(&(p->plg_queue));
1281 if (in_thr.thd_waiting && (queue_len > p->plg_qmin) &&
1282 (queue_len < p->plg_q_threshold))
1296 } else if ((p->plg_priority < BASE_PRIORITY) &&
1297 (queue_len < p->plg_q_threshold)) {
1298 p->plg_priority = param.sched_priority =
1300 (void) pthread_setschedparam(p->plg_tid, SCHED_OTHER,
1305 DUMP("process", p, p->plg_last_seq_out, "exit");
1307 if ((rc = p->plg_fplugin_close(&error_string)) !=
1309 report_error(rc, error_string, p->plg_path);
1314 (void) unload_plugin(p);