From: Arran Cudbard-Bell Date: Tue, 2 Feb 2021 18:49:04 +0000 (+0000) Subject: Add fr_rb_node_t fields to structures that are inserted into rbtrees X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=538751ea1937899f6fc087f3d476ac1d64337cfe;p=thirdparty%2Ffreeradius-server.git Add fr_rb_node_t fields to structures that are inserted into rbtrees This is being done ahead of removing malloc calls in the rbtree. --- diff --git a/src/bin/radclient.c b/src/bin/radclient.c index 93b80ca126..21f37e108e 100644 --- a/src/bin/radclient.c +++ b/src/bin/radclient.c @@ -1162,7 +1162,7 @@ int main(int argc, char **argv) talloc_set_log_stderr(); - filename_tree = rbtree_talloc_alloc(NULL, filename_cmp, rc_file_pair_t, NULL, 0); + filename_tree = rbtree_talloc_alloc(NULL, rc_file_pair_t, node, filename_cmp, NULL, 0); if (!filename_tree) { oom: ERROR("Out of memory"); diff --git a/src/bin/radclient.h b/src/bin/radclient.h index 6331d412fd..44ccc57fd2 100644 --- a/src/bin/radclient.h +++ b/src/bin/radclient.h @@ -59,6 +59,7 @@ typedef struct { } rc_stats_t; typedef struct { + fr_rb_node_t node; //!< rbtree node data. char const *packets; //!< The file containing the request packet char const *filters; //!< The file containing the definition of the //!< packet we want to match. diff --git a/src/bin/radsniff.c b/src/bin/radsniff.c index c8fee2bf7e..5c38da5896 100644 --- a/src/bin/radsniff.c +++ b/src/bin/radsniff.c @@ -2666,7 +2666,7 @@ int main(int argc, char *argv[]) usage(64); } - link_tree = rbtree_talloc_alloc(conf, (rbcmp) rs_rtx_cmp, rs_request_t, _unmark_link, 0); + link_tree = rbtree_talloc_alloc(conf, rs_request_t, link_node, (rbcmp) rs_rtx_cmp, _unmark_link, 0); if (!link_tree) { ERROR("Failed creating RTX tree"); goto finish; @@ -2724,7 +2724,7 @@ int main(int argc, char *argv[]) /* * Setup the request tree */ - request_tree = rbtree_talloc_alloc(conf, (rbcmp) rs_packet_cmp, rs_request_t, _unmark_request, 0); + request_tree = rbtree_talloc_alloc(conf, rs_request_t, request_node, (rbcmp) rs_packet_cmp, _unmark_request, 0); if (!request_tree) { ERROR("Failed creating request tree"); goto finish; diff --git a/src/bin/radsniff.h b/src/bin/radsniff.h index 7cf7a2c8fe..b53db01e52 100644 --- a/src/bin/radsniff.h +++ b/src/bin/radsniff.h @@ -213,7 +213,8 @@ typedef struct { //!< ignore stats about packet loss. - + fr_rb_node_t request_node; + fr_rb_node_t link_node; bool in_request_tree; //!< Whether the request is currently in the request tree. bool in_link_tree; //!< Whether the request is currently in the linked tree. } rs_request_t; diff --git a/src/lib/io/listen.h b/src/lib/io/listen.h index c05b14664a..db9540fef2 100644 --- a/src/lib/io/listen.h +++ b/src/lib/io/listen.h @@ -23,6 +23,8 @@ */ typedef struct fr_listen fr_listen_t; struct fr_listen { + fr_rb_node_t virtual_server_node; //!< Entry into the virtual server's tree of listeners. + int fd; //!< file descriptor for this socket - set by open char const *name; //!< printable name for this socket - set by open @@ -30,7 +32,7 @@ struct fr_listen { void const *app_io_instance; //!< I/O path configuration context. void *thread_instance; //!< thread / socket context - fr_socket_t *app_io_addr; //!< for tracking duplicate sockets + fr_socket_t *app_io_addr; //!< for tracking duplicate sockets fr_app_t const *app; void const *app_instance; diff --git a/src/lib/io/master.c b/src/lib/io/master.c index d3769bfa0b..f718ad0198 100644 --- a/src/lib/io/master.c +++ b/src/lib/io/master.c @@ -528,8 +528,8 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t const *inst, * #todo - unify the code with static clients? */ if (inst->app_io->track_duplicates) { - MEM(connection->client->table = rbtree_talloc_alloc(client, track_connected_cmp, fr_io_track_t, - NULL, RBTREE_FLAG_NONE)); + MEM(connection->client->table = rbtree_talloc_alloc(client, fr_io_track_t, node, + track_connected_cmp, NULL, RBTREE_FLAG_NONE)); } /* @@ -1453,7 +1453,7 @@ do_read: */ if (inst->app_io->track_duplicates) { fr_assert(inst->app_io->compare != NULL); - MEM(client->table = rbtree_talloc_alloc(client, track_cmp, fr_io_track_t, + MEM(client->table = rbtree_talloc_alloc(client, fr_io_track_t, node, track_cmp, NULL, RBTREE_FLAG_NONE)); } diff --git a/src/lib/io/master.h b/src/lib/io/master.h index 3413b996c4..662c3f3ac6 100644 --- a/src/lib/io/master.h +++ b/src/lib/io/master.h @@ -39,6 +39,7 @@ extern "C" { typedef struct fr_io_client_s fr_io_client_t; typedef struct { + fr_rb_node_t node; //!< rbtree node in the tracking tree. fr_event_timer_t const *ev; //!< when we clean up this tracking entry fr_time_t timestamp; //!< when this packet was received fr_time_t expires; //!< when this packet expires diff --git a/src/lib/io/network.c b/src/lib/io/network.c index 4a415a344a..81baf2fe5a 100644 --- a/src/lib/io/network.c +++ b/src/lib/io/network.c @@ -73,6 +73,9 @@ typedef struct { } fr_network_worker_t; typedef struct { + fr_rb_node_t listen_node; //!< rbtree node for looking up by listener. + fr_rb_node_t num_node; //!< rbtree node for looking up by number. + fr_network_t *nr; //!< O(N) issues in talloc int number; //!< unique ID int heap_id; //!< for the sockets_by_num heap @@ -1654,13 +1657,13 @@ fr_network_t *fr_network_create(TALLOC_CTX *ctx, fr_event_list_t *el, char const /* * Create the various heaps. */ - nr->sockets = rbtree_talloc_alloc(nr, socket_listen_cmp, fr_network_socket_t, NULL, RBTREE_FLAG_NONE); + nr->sockets = rbtree_talloc_alloc(nr, fr_network_socket_t, listen_node, socket_listen_cmp, NULL, RBTREE_FLAG_NONE); if (!nr->sockets) { fr_strerror_const_push("Failed creating listen tree for sockets"); goto fail2; } - nr->sockets_by_num = rbtree_talloc_alloc(nr, socket_num_cmp, fr_network_socket_t, NULL, RBTREE_FLAG_NONE); + nr->sockets_by_num = rbtree_talloc_alloc(nr, fr_network_socket_t, num_node, socket_num_cmp, NULL, RBTREE_FLAG_NONE); if (!nr->sockets_by_num) { fr_strerror_const_push("Failed creating number tree for sockets"); goto fail2; diff --git a/src/lib/io/worker.c b/src/lib/io/worker.c index e04c207410..fe12852b8e 100644 --- a/src/lib/io/worker.c +++ b/src/lib/io/worker.c @@ -1164,7 +1164,7 @@ nomem: goto fail; } - worker->dedup = rbtree_talloc_alloc(worker, worker_dedup_cmp, request_t, NULL, RBTREE_FLAG_NONE); + worker->dedup = rbtree_talloc_alloc(worker, request_t, dedup_node, worker_dedup_cmp, NULL, RBTREE_FLAG_NONE); if (!worker->dedup) { fr_strerror_const("Failed creating de_dup tree"); goto fail; diff --git a/src/lib/redis/cluster.c b/src/lib/redis/cluster.c index 2a4877934b..932044e83d 100644 --- a/src/lib/redis/cluster.c +++ b/src/lib/redis/cluster.c @@ -200,6 +200,8 @@ typedef struct { * Passed as opaque data to pools which open connection to nodes. */ struct fr_redis_cluster_node_s { + fr_rb_node_t rbnode; //!< Entry into the tree of redis nodes. + char name[INET6_ADDRSTRLEN]; //!< Buffer to hold IP string. //!< text for debug messages. uint8_t id; //!< Node ID (index in node array). @@ -2355,7 +2357,7 @@ fr_redis_cluster_t *fr_redis_cluster_alloc(TALLOC_CTX *ctx, cluster->node = talloc_zero_array(cluster, fr_redis_cluster_node_t, conf->max_nodes + 1); if (!cluster->node) goto oom; - cluster->used_nodes = rbtree_alloc(cluster, _cluster_node_cmp, NULL, 0); + cluster->used_nodes = rbtree_alloc(cluster, fr_redis_cluster_node_t, rbnode, _cluster_node_cmp, NULL, 0); if (!cluster->used_nodes) goto oom; cluster->free_nodes = fr_fifo_create(cluster, conf->max_nodes, NULL); diff --git a/src/lib/server/cf_file.c b/src/lib/server/cf_file.c index ba0a3f95e0..1ee4ecfe2a 100644 --- a/src/lib/server/cf_file.c +++ b/src/lib/server/cf_file.c @@ -2329,7 +2329,7 @@ int cf_file_read(CONF_SECTION *cs, char const *filename) cf_item_add(cs, &(cp->item)); - MEM(tree = rbtree_talloc_alloc(cs, _inode_cmp, cf_file_t, NULL, 0)); + MEM(tree = rbtree_talloc_alloc(cs, cf_file_t, node, _inode_cmp, NULL, 0)); cf_data_add(cs, tree, "filename", false); diff --git a/src/lib/server/cf_priv.h b/src/lib/server/cf_priv.h index 8bed0e1511..4397f0fa93 100644 --- a/src/lib/server/cf_priv.h +++ b/src/lib/server/cf_priv.h @@ -43,6 +43,9 @@ typedef enum conf_type { * */ struct cf_item { + fr_rb_node_t ident1_node; //!< Entry in the ident1 tree. + fr_rb_node_t ident2_node; //!< Entry in the ident2 tree. + CONF_ITEM_TYPE type; //!< Whether the config item is a config_pair, conf_section or cf_data. CONF_ITEM *next; //!< Sibling. @@ -115,6 +118,7 @@ struct cf_data { }; typedef struct { + fr_rb_node_t node; char const *filename; //!< name of the file CONF_SECTION *cs; //!< CONF_SECTION associated with the file struct stat buf; //!< stat about the file diff --git a/src/lib/server/cf_util.c b/src/lib/server/cf_util.c index aa0bd5e256..ddadd49402 100644 --- a/src/lib/server/cf_util.c +++ b/src/lib/server/cf_util.c @@ -382,8 +382,10 @@ void _cf_item_add(CONF_ITEM *parent, CONF_ITEM *child) /* * New child, add child trees. */ - if (!parent->ident1) parent->ident1 = rbtree_alloc(parent, _cf_ident1_cmp, NULL, RBTREE_FLAG_NONE); - if (!parent->ident2) parent->ident2 = rbtree_alloc(parent, _cf_ident2_cmp, NULL, RBTREE_FLAG_NONE); + if (!parent->ident1) parent->ident1 = rbtree_alloc(parent, CONF_ITEM, ident1_node, + _cf_ident1_cmp, NULL, RBTREE_FLAG_NONE); + if (!parent->ident2) parent->ident2 = rbtree_alloc(parent, CONF_ITEM, ident2_node, + _cf_ident2_cmp, NULL, RBTREE_FLAG_NONE); fr_cursor_init(&to_merge, &child); diff --git a/src/lib/server/client.c b/src/lib/server/client.c index 99ec209f9a..0119c44eb7 100644 --- a/src/lib/server/client.c +++ b/src/lib/server/client.c @@ -286,8 +286,8 @@ bool client_add(RADCLIENT_LIST *clients, RADCLIENT *client) #else /* WITH_TRIE */ if (!clients->tree[client->ipaddr.prefix]) { - clients->tree[client->ipaddr.prefix] = rbtree_talloc_alloc(clients, client_cmp, RADCLIENT, - NULL, RBTREE_FLAG_NONE); + clients->tree[client->ipaddr.prefix] = rbtree_talloc_alloc(clients, RADCLIENT, node, client_cmp, + NULL, RBTREE_FLAG_NONE); if (!clients->tree[client->ipaddr.prefix]) { return false; } diff --git a/src/lib/server/client.h b/src/lib/server/client.h index 40b3e6a380..fc1c1941fa 100644 --- a/src/lib/server/client.h +++ b/src/lib/server/client.h @@ -75,6 +75,8 @@ typedef int (*client_value_cb_t)(char **out, CONF_PAIR const *cp, void *data); * */ struct rad_client { + fr_rb_node_t node; //!< Entry in the client tree. + fr_ipaddr_t ipaddr; //!< IPv4/IPv6 address of the host. fr_ipaddr_t src_ipaddr; //!< IPv4/IPv6 address to send responses //!< from (family must match ipaddr). diff --git a/src/lib/server/dl_module.c b/src/lib/server/dl_module.c index c1ea0d1bca..69339b3c10 100644 --- a/src/lib/server/dl_module.c +++ b/src/lib/server/dl_module.c @@ -655,14 +655,16 @@ dl_module_loader_t *dl_module_loader_init(char const *lib_dir) dl_search_path_prepend(dl_module_loader->dl_loader, lib_dir); dl_module_loader->inst_data_tree = rbtree_talloc_alloc(dl_module_loader, - dl_module_inst_data_cmp, dl_module_inst_t, NULL, 0); + dl_module_inst_t, node, + dl_module_inst_data_cmp, NULL, 0); if (!dl_module_loader->inst_data_tree) { ERROR("Failed initialising dl->inst_data_tree"); goto error; } dl_module_loader->module_tree = rbtree_talloc_alloc(dl_module_loader, - dl_module_cmp, dl_module_t, NULL, 0); + dl_module_t, node, + dl_module_cmp, NULL, 0); if (!dl_module_loader->inst_data_tree) { ERROR("Failed initialising dl->module_tree"); goto error; diff --git a/src/lib/server/dl_module.h b/src/lib/server/dl_module.h index ceb93322f1..526e6fdaa1 100644 --- a/src/lib/server/dl_module.h +++ b/src/lib/server/dl_module.h @@ -31,9 +31,10 @@ RCSIDH(dl_module_h, "$Id$") # include #endif -#include -#include #include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -121,6 +122,8 @@ typedef struct { */ typedef struct dl_module_s dl_module_t; struct dl_module_s { + fr_rb_node_t node; //!< Entry in the module tree. + dl_t *dl; //!< Dynamic loader handle. dl_module_t const *parent; //!< of this module. @@ -142,6 +145,7 @@ struct dl_module_s { */ typedef struct dl_module_instance_s dl_module_inst_t; struct dl_module_instance_s { + fr_rb_node_t node; //!< Entry in the module instance tree. char const *name; //!< Instance name. dl_module_t const *module; //!< Module void *data; //!< Module instance's parsed configuration. diff --git a/src/lib/server/map_proc.c b/src/lib/server/map_proc.c index b99a25a042..fffa353dd3 100644 --- a/src/lib/server/map_proc.c +++ b/src/lib/server/map_proc.c @@ -115,8 +115,8 @@ int map_proc_register(void *mod_inst, char const *name, fr_assert(name && name[0]); if (!map_proc_root) { - map_proc_root = rbtree_talloc_alloc(NULL, map_proc_cmp, map_proc_t, - _map_proc_tree_free, RBTREE_FLAG_REPLACE); + map_proc_root = rbtree_talloc_alloc(NULL, map_proc_t, node, + map_proc_cmp, _map_proc_tree_free, RBTREE_FLAG_REPLACE); if (!map_proc_root) { DEBUG("map_proc: Failed to create tree"); return -1; diff --git a/src/lib/server/map_proc_priv.h b/src/lib/server/map_proc_priv.h index 2049e3035a..ad0de8807a 100644 --- a/src/lib/server/map_proc_priv.h +++ b/src/lib/server/map_proc_priv.h @@ -36,6 +36,7 @@ extern "C" { /** Map processor registration */ struct map_proc { + fr_rb_node_t node; //!< Entry in the map processor tree. void *mod_inst; //!< Module instance. char name[FR_MAX_STRING_LEN]; //!< Name of the map function. int length; //!< Length of name. diff --git a/src/lib/server/module.c b/src/lib/server/module.c index 877cd21817..b35ccdbbf5 100644 --- a/src/lib/server/module.c +++ b/src/lib/server/module.c @@ -1168,8 +1168,10 @@ void modules_free(void) int modules_init(void) { - MEM(module_instance_name_tree = rbtree_alloc(NULL, module_instance_name_cmp, NULL, RBTREE_FLAG_NONE)); - MEM(module_instance_data_tree = rbtree_alloc(NULL, module_instance_data_cmp, NULL, RBTREE_FLAG_NONE)); + MEM(module_instance_name_tree = rbtree_alloc(NULL, module_instance_t, name_node, + module_instance_name_cmp, NULL, RBTREE_FLAG_NONE)); + MEM(module_instance_data_tree = rbtree_alloc(NULL, module_instance_t, data_node, + module_instance_data_cmp, NULL, RBTREE_FLAG_NONE)); instance_ctx = talloc_init("module instance context"); return 0; diff --git a/src/lib/server/module.h b/src/lib/server/module.h index c0e683ec93..bc85f16f66 100644 --- a/src/lib/server/module.h +++ b/src/lib/server/module.h @@ -187,6 +187,9 @@ struct module_s { * data structures. */ struct module_instance_s { + fr_rb_node_t name_node; //!< Entry in the name tree. + fr_rb_node_t data_node; //!< Entry in the data tree. + char const *name; //!< Instance name e.g. user_database. dl_module_inst_t *dl_inst; //!< Structure containing the module's instance data, diff --git a/src/lib/server/request.h b/src/lib/server/request.h index 00e26f9cc3..d143220475 100644 --- a/src/lib/server/request.h +++ b/src/lib/server/request.h @@ -206,6 +206,7 @@ struct request_s { fr_event_timer_t const *ev; //!< Event in event loop tied to this request. + fr_rb_node_t dedup_node; //!< entry in the deduplication tree. int32_t runnable_id; //!< entry in the queue / heap of runnable packets int32_t time_order_id; //!< entry in the queue / heap of time ordered packets diff --git a/src/lib/server/state.c b/src/lib/server/state.c index d06b994d78..c58604a751 100644 --- a/src/lib/server/state.c +++ b/src/lib/server/state.c @@ -60,7 +60,8 @@ RCSID("$Id$") * */ typedef struct { - uint64_t id; //!< State number within state tree. + uint64_t id; //!< State number within state heap. + fr_rb_node_t node; //!< Entry in the state rbtree. union { /** Server ID components * @@ -233,7 +234,7 @@ fr_state_tree_t *fr_state_tree_init(TALLOC_CTX *ctx, fr_dict_attr_t const *da, b * are freed before it's destroyed. Hence * it being parented from the NULL ctx. */ - state->tree = rbtree_talloc_alloc(NULL, state_entry_cmp, fr_state_entry_t, NULL, 0); + state->tree = rbtree_talloc_alloc(NULL, fr_state_entry_t, node, state_entry_cmp, NULL, 0); if (!state->tree) { talloc_free(state); return NULL; diff --git a/src/lib/server/trigger.c b/src/lib/server/trigger.c index f5d6f1b6d3..edd7746b37 100644 --- a/src/lib/server/trigger.c +++ b/src/lib/server/trigger.c @@ -52,6 +52,7 @@ static pthread_mutex_t *trigger_mutex; * */ typedef struct { + fr_rb_node_t node; //!< Entry in the trigger last fired tree. CONF_ITEM *ci; //!< Config item this rate limit counter is associated with. time_t last_fired; //!< When this trigger last fired. } trigger_last_fired_t; @@ -157,8 +158,8 @@ int trigger_exec_init(CONF_SECTION const *cs) } MEM(trigger_last_fired_tree = rbtree_talloc_alloc(talloc_null_ctx(), - _trigger_last_fired_cmp, trigger_last_fired_t, - _trigger_last_fired_free, 0)); + trigger_last_fired_t, node, + _trigger_last_fired_cmp, _trigger_last_fired_free, 0)); trigger_mutex = talloc(talloc_null_ctx(), pthread_mutex_t); pthread_mutex_init(trigger_mutex, 0); diff --git a/src/lib/server/users_file.h b/src/lib/server/users_file.h index 604222e92e..ab06f80e88 100644 --- a/src/lib/server/users_file.h +++ b/src/lib/server/users_file.h @@ -36,6 +36,8 @@ extern "C" { #include typedef struct pair_list { + fr_rb_node_t node; //!< Entry into the tree of pair lists. + char const *name; map_t *check; map_t *reply; diff --git a/src/lib/server/virtual_servers.c b/src/lib/server/virtual_servers.c index 4ca8bbfa5d..b1e8fadf61 100644 --- a/src/lib/server/virtual_servers.c +++ b/src/lib/server/virtual_servers.c @@ -42,6 +42,7 @@ RCSID("$Id$") #include typedef struct { + fr_rb_node_t node; //!< Entry in the namespace tree. char const *namespace; //!< Namespace function is registered to. fr_dict_t const *dict; //!< dictionary to use fr_virtual_server_compile_t func; //!< Function to call to compile sections. @@ -881,8 +882,9 @@ int virtual_namespace_register(char const *namespace, fr_dict_t const *dict, * virtual_server_root. */ MEM(vns_tree = rbtree_talloc_alloc(NULL, - _virtual_namespace_cmp, fr_virtual_namespace_t, - _virtual_namespace_free, RBTREE_FLAG_REPLACE)); + fr_virtual_namespace_t, node, + _virtual_namespace_cmp, + _virtual_namespace_free, RBTREE_FLAG_REPLACE)); if (!cf_data_add(virtual_server_root, vns_tree, "vns_tree", true)) { ERROR("Failed adding namespace tree data to config"); @@ -1007,8 +1009,10 @@ int virtual_servers_init(CONF_SECTION *config) return -1; } - MEM(listen_addr_root = rbtree_alloc(NULL, listen_addr_cmp, NULL, RBTREE_FLAG_NONE)); - MEM(server_section_name_tree = rbtree_alloc(NULL, server_section_name_cmp, NULL, RBTREE_FLAG_NONE)); + MEM(listen_addr_root = rbtree_alloc(NULL, fr_listen_t, virtual_server_node, + listen_addr_cmp, NULL, RBTREE_FLAG_NONE)); + MEM(server_section_name_tree = rbtree_alloc(NULL, virtual_server_compile_t, node, + server_section_name_cmp, NULL, RBTREE_FLAG_NONE)); return 0; } diff --git a/src/lib/server/virtual_servers.h b/src/lib/server/virtual_servers.h index bbd929c566..bdd54ca1b2 100644 --- a/src/lib/server/virtual_servers.h +++ b/src/lib/server/virtual_servers.h @@ -100,7 +100,7 @@ fr_listen_t * listen_find_any(fr_listen_t *li) CC_HINT(nonnull); bool listen_record(fr_listen_t *li) CC_HINT(nonnull); int fr_app_process_type_parse(TALLOC_CTX *ctx, dl_module_inst_t **module_inst, - CONF_ITEM *ci, fr_dict_attr_t const *packet_type, + CONF_ITEM *ci, fr_dict_attr_t const *packet_type, char const *proto_name, char const **type_table, size_t type_table_len, dl_module_inst_t **type_submodule_by_code, uint32_t code_max); @@ -117,6 +117,7 @@ typedef struct { * */ typedef struct { + fr_rb_node_t node; //!< Entry into the tree of sections. char const *name; //!< Name of the processing section, such as "recv" or "send" char const *name2; //!< Second name, such as "Access-Request" rlm_components_t component; //!< Sets the default list of actions for this section diff --git a/src/lib/unlang/xlat.h b/src/lib/unlang/xlat.h index 9872c9863f..a4d8ab81b3 100644 --- a/src/lib/unlang/xlat.h +++ b/src/lib/unlang/xlat.h @@ -57,6 +57,8 @@ typedef struct xlat_exp xlat_exp_t; * */ struct xlat_inst { + fr_rb_node_t inst_node; //!< Entry in rbtree of thread instances. + xlat_exp_t const *node; //!< Node this data relates to. void *data; //!< xlat node specific instance data. }; @@ -65,6 +67,8 @@ struct xlat_inst { * */ struct xlat_thread_inst { + fr_rb_node_t inst_node; //!< Entry in rbtree of thread instances. + xlat_exp_t const *node; //!< Node this data relates to. void *data; //!< Thread specific instance data. diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index 3e8e756e7a..9a6e3cd08a 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -3262,8 +3262,6 @@ static xlat_action_t xlat_func_urlunquote(TALLOC_CTX *ctx, fr_cursor_t *out, return XLAT_ACTION_DONE; } - - /** Global initialisation for xlat * * @note Free memory with #xlat_free @@ -3289,7 +3287,7 @@ int xlat_init(void) /* * Create the function tree */ - xlat_root = rbtree_talloc_alloc(NULL, xlat_cmp, xlat_t, _xlat_func_tree_free, RBTREE_FLAG_REPLACE); + xlat_root = rbtree_talloc_alloc(NULL, xlat_t, node, xlat_cmp, _xlat_func_tree_free, RBTREE_FLAG_REPLACE); if (!xlat_root) { ERROR("%s: Failed to create tree", __FUNCTION__); return -1; diff --git a/src/lib/unlang/xlat_inst.c b/src/lib/unlang/xlat_inst.c index 48e4ba20dd..742fe1b540 100644 --- a/src/lib/unlang/xlat_inst.c +++ b/src/lib/unlang/xlat_inst.c @@ -354,8 +354,8 @@ int xlat_thread_instantiate(TALLOC_CTX *ctx) if (!xlat_inst_tree) return 0; if (!xlat_thread_inst_tree) { - MEM(xlat_thread_inst_tree = rbtree_talloc_alloc(ctx, _xlat_thread_inst_cmp, - xlat_thread_inst_t, _xlat_thread_inst_free, 0)); + MEM(xlat_thread_inst_tree = rbtree_talloc_alloc(ctx, xlat_thread_inst_t, inst_node, + _xlat_thread_inst_cmp, _xlat_thread_inst_free, 0)); } /* @@ -402,8 +402,8 @@ static int xlat_instantiate_init(void) { if (xlat_inst_tree) return 0; - xlat_inst_tree = rbtree_talloc_alloc(NULL, _xlat_inst_cmp, - xlat_inst_t, _xlat_inst_free, RBTREE_FLAG_NONE); + xlat_inst_tree = rbtree_talloc_alloc(NULL, xlat_inst_t, inst_node, + _xlat_inst_cmp, _xlat_inst_free, RBTREE_FLAG_NONE); if (!xlat_inst_tree) return -1; return 0; diff --git a/src/lib/unlang/xlat_priv.h b/src/lib/unlang/xlat_priv.h index 5cfafa01eb..7c174bfae5 100644 --- a/src/lib/unlang/xlat_priv.h +++ b/src/lib/unlang/xlat_priv.h @@ -45,6 +45,7 @@ typedef enum { } xlat_func_legacy_type_t; typedef struct xlat_s { + fr_rb_node_t node; //!< Entry in the xlat function tree. char const *name; //!< Name of xlat function. union { diff --git a/src/lib/util/dl.c b/src/lib/util/dl.c index adb8d827b5..3027b7443e 100644 --- a/src/lib/util/dl.c +++ b/src/lib/util/dl.c @@ -792,7 +792,7 @@ dl_loader_t *dl_loader_init(TALLOC_CTX *ctx, void *uctx, bool uctx_free, bool de return NULL; } - dl_loader->tree = rbtree_talloc_alloc(dl_loader, dl_handle_cmp, dl_t, NULL, 0); + dl_loader->tree = rbtree_talloc_alloc(dl_loader, dl_t, node, dl_handle_cmp, NULL, 0); if (!dl_loader->tree) { fr_strerror_const("Failed initialising dl->tree"); error: diff --git a/src/lib/util/dl.h b/src/lib/util/dl.h index b17a5ca2ac..5b1693423f 100644 --- a/src/lib/util/dl.h +++ b/src/lib/util/dl.h @@ -31,6 +31,7 @@ RCSIDH(dl_h, "$Id$") # include #endif #include +#include #include #include @@ -54,6 +55,8 @@ typedef struct dl_loader_s dl_loader_t; * Contains module's dlhandle, and the functions it exports. */ typedef struct dl_s { + fr_rb_node_t node; //!< Entry in the rbtree module handles. + char const *name; //!< Name of the module e.g. sql. void *handle; //!< Handle returned by dlopen. dl_loader_t *loader; //!< Loader that owns this dl. diff --git a/src/lib/util/event.c b/src/lib/util/event.c index deb41bd7f7..94bce66bad 100644 --- a/src/lib/util/event.c +++ b/src/lib/util/event.c @@ -242,7 +242,7 @@ static fr_event_func_map_t vnode_func_map[] = { }; static fr_table_num_sorted_t const fr_event_fd_type_table[] = { - { L("directory"), FR_EVENT_FD_DIRECTORY }, + { L("directory"), FR_EVENT_FD_DIRECTORY }, { L("file"), FR_EVENT_FD_FILE }, { L("pcap"), FR_EVENT_FD_PCAP }, { L("socket"), FR_EVENT_FD_SOCKET } @@ -253,6 +253,10 @@ static size_t fr_event_fd_type_table_len = NUM_ELEMENTS(fr_event_fd_type_table); * */ struct fr_event_fd { + fr_rb_node_t node; //!< Entry in the tree of file descriptor handles. + ///< this should really go away and we should pass around + ///< handles directly. + fr_event_list_t *el; //!< because talloc_parent() is O(N) in number of objects fr_event_filter_t filter; int fd; //!< File descriptor we're listening for events on. @@ -2281,7 +2285,7 @@ fr_event_list_t *fr_event_list_alloc(TALLOC_CTX *ctx, fr_event_status_cb_t statu return NULL; } - el->fds = rbtree_talloc_alloc(el, fr_event_fd_cmp, fr_event_fd_t, NULL, 0); + el->fds = rbtree_talloc_alloc(el, fr_event_fd_t, node, fr_event_fd_cmp, NULL, 0); if (!el->fds) { fr_strerror_const("Failed allocating FD tree"); goto error; @@ -2361,6 +2365,7 @@ static const char *decade_names[18] = { }; typedef struct { + fr_rb_node_t node; char const *file; int line; uint32_t count; @@ -2409,7 +2414,7 @@ void fr_event_report(fr_event_list_t *el, fr_time_t now, void *uctx) } for (i = 0; i < NUM_ELEMENTS(decades); i++) { - locations[i] = rbtree_alloc(tmp_ctx, event_timer_location_cmp, NULL, 0); + locations[i] = rbtree_alloc(tmp_ctx, fr_event_counter_t, node, event_timer_location_cmp, NULL, 0); if (!locations[i]) goto oom; } diff --git a/src/lib/util/packet.h b/src/lib/util/packet.h index ea2fac8d7f..3937cdc927 100644 --- a/src/lib/util/packet.h +++ b/src/lib/util/packet.h @@ -54,6 +54,9 @@ extern "C" { * data,data_len: Used between fr_radius_recv and fr_radius_decode. */ typedef struct { + fr_rb_node_t node; //!< Allows insertion into the list.c + ///< rbtree, may be removed in future. + fr_socket_t socket; //!< This packet was received on. int id; //!< Packet ID (used to link requests/responses). diff --git a/src/lib/util/rbtree.c b/src/lib/util/rbtree.c index da0b4be251..214528fc7f 100644 --- a/src/lib/util/rbtree.c +++ b/src/lib/util/rbtree.c @@ -138,9 +138,27 @@ static int _tree_free(rbtree_t *tree) /** Create a new RED-BLACK tree * * @note Due to the node memory being allocated from a different pool to the main + * + * @param[in] ctx to allocate the tree in. + * Only the tree is allocated in this context, the memory + * for the #fr_rb_node_t is allocated as part of the data + * being inserted into the tree. + * @param[in] offset offsetof the #fr_rb_node_t field in the data being inserted. + * @param[in] type Talloc type of structures being inserted, may be NULL. + * @param[in] compare Comparator function for ordering data in the tree. + * @param[in] node_free Free function to call whenever data is deleted or replaced. + * @param[in] flags A bitfield of flags. + * - RBTREE_FLAG_REPLACE - replace nodes if a duplicate is found. + * - RBTREE_FLAG_LOCK - use a mutex to prevent concurrent access + * to the tree. + * @return + * - A new tree on success. + * - NULL on failure. */ -rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, fr_rb_cmp_t compare, - char const *type, fr_rb_free_t node_free, int flags) +rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, + size_t offset, char const *type, + fr_rb_cmp_t compare, fr_rb_free_t node_free, + int flags) { rbtree_t *tree; @@ -152,7 +170,7 @@ rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, fr_rb_cmp_t compare, .magic = RBTREE_MAGIC, #endif .root = NIL, -// .offset = offset, + .offset = offset, .type = type, .compare = compare, .replace = ((flags & RBTREE_FLAG_REPLACE) != 0), @@ -162,8 +180,6 @@ rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, fr_rb_cmp_t compare, if (tree->lock) pthread_mutex_init(&tree->mutex, NULL); talloc_set_destructor(tree, _tree_free); - tree->free = node_free; - tree->type = type; return tree; } diff --git a/src/lib/util/rbtree.h b/src/lib/util/rbtree.h index 8e4bda37c0..6b27d209a4 100644 --- a/src/lib/util/rbtree.h +++ b/src/lib/util/rbtree.h @@ -88,8 +88,9 @@ typedef void (*fr_rb_free_t)(void *data); * @param[in] _ctx to tie tree lifetime to. * If ctx is freed, tree will free any nodes, calling the * free function if set. + * @param[in] _type of item being stored in the tree, e.g. fr_value_box_t. + * @param[in] _field Containing the #fr_rb_node_t within item being stored. * @param[in] _cmp Comparator used to compare nodes. - * @param[in] _talloc_type of elements. * @param[in] _node_free Optional function used to free data if tree nodes are * deleted or replaced. * @param[in] _flags To modify tree behaviour. @@ -97,14 +98,18 @@ typedef void (*fr_rb_free_t)(void *data); * - A new rbtree on success. * - NULL on failure. */ -#define rbtree_talloc_alloc(_ctx, _cmp, _talloc_type, _node_free, _flags) \ - _rbtree_alloc(_ctx, _cmp, #_talloc_type, _node_free, _flags) +#define rbtree_talloc_alloc(_ctx, _type, _field, _cmp, _node_free, _flags) \ + _Generic((((_type *)0)->_field), \ + fr_rb_node_t: _rbtree_alloc(_ctx, offsetof(_type, _field), #_type, _cmp, _node_free, _flags) \ + ) /** Creates a red black tree * * @param[in] _ctx to tie tree lifetime to. * If ctx is freed, tree will free any nodes, calling the * free function if set. + * @param[in] _type of item being stored in the tree, e.g. fr_value_box_t. + * @param[in] _field Containing the #fr_rb_node_t within item being stored. * @param[in] _cmp Comparator used to compare nodes. * @param[in] _node_free Optional function used to free data if tree nodes are * deleted or replaced. @@ -113,11 +118,13 @@ typedef void (*fr_rb_free_t)(void *data); * - A new rbtree on success. * - NULL on failure. */ -#define rbtree_alloc(_ctx, _cmp, _node_free, _flags) \ - _rbtree_alloc(_ctx, _cmp, NULL, _node_free, _flags) +#define rbtree_alloc(_ctx, _type, _field, _cmp, _node_free, _flags) \ + _Generic((((_type *)0)->_field), \ + fr_rb_node_t: _rbtree_alloc(_ctx, offsetof(_type, _field), NULL, _cmp, _node_free, _flags) \ + ) -rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, fr_rb_cmp_t compare, - char const *type, fr_rb_free_t node_free, int flags); +rbtree_t *_rbtree_alloc(TALLOC_CTX *ctx, size_t offset, char const *type, + fr_rb_cmp_t compare, fr_rb_free_t node_free, int flags); void rbtree_node_talloc_free(void *data); diff --git a/src/modules/proto_bfd/proto_bfd.c b/src/modules/proto_bfd/proto_bfd.c index 049fd74de5..67b9a0f263 100644 --- a/src/modules/proto_bfd/proto_bfd.c +++ b/src/modules/proto_bfd/proto_bfd.c @@ -68,6 +68,8 @@ typedef enum bfd_auth_type_t { #define BFD_AUTH_INVALID (BFD_AUTH_MET_KEYED_SHA1 + 1) typedef struct { + fr_rb_node_t node; //!< Entry in the tree of sessions. + int number; fr_socket_t socket; @@ -1710,7 +1712,7 @@ static int bfd_socket_parse(CONF_SECTION *cs, rad_listen_t *this) } } - sock->session_tree = rbtree_talloc_alloc(sock, bfd_session_cmp, bfd_state_t, bfd_session_free, 0); + sock->session_tree = rbtree_talloc_alloc(sock, bfd_state_t, node, bfd_session_cmp, bfd_session_free, 0); if (!sock->session_tree) { ERROR("Failed creating session tree!"); return -1; diff --git a/src/modules/proto_ldap_sync/sync.c b/src/modules/proto_ldap_sync/sync.c index d11359b012..c5c8825815 100644 --- a/src/modules/proto_ldap_sync/sync.c +++ b/src/modules/proto_ldap_sync/sync.c @@ -37,7 +37,9 @@ USES_APPLE_DEPRECATED_API #include "sync.h" struct sync_state_s { - fr_ldap_connection_t *conn; + fr_rb_node_t node; //!< Entry in the tree of nodes. + + fr_ldap_connection_t *conn; sync_config_t const *config; @@ -992,7 +994,7 @@ int sync_state_init(fr_ldap_connection_t *conn, sync_config_t const *config, * these are specific to the connection. */ if (!conn->uctx) { - MEM(tree = rbtree_talloc_alloc(conn, _sync_cmp, sync_state_t, NULL, RBTREE_FLAG_NONE)); + MEM(tree = rbtree_talloc_alloc(conn, sync_state_t, node, _sync_cmp, NULL, RBTREE_FLAG_NONE)); conn->uctx = tree; } else { tree = talloc_get_type_abort(conn->uctx, rbtree_t); diff --git a/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c b/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c index b62cd2bbf1..dcf19480aa 100644 --- a/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c +++ b/src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c @@ -35,7 +35,9 @@ typedef struct { typedef struct { rlm_cache_entry_t fields; //!< Entry data. - int32_t heap_id; //!< Offset used for heap. + + fr_rb_node_t node; //!< Entry used for lookups. + int32_t heap_id; //!< Offset used for expiry heap. } rlm_cache_rbtree_entry_t; /** Compare two entries by key @@ -113,7 +115,7 @@ static int mod_instantiate(void *instance, UNUSED CONF_SECTION *conf) /* * The cache. */ - driver->cache = rbtree_talloc_alloc(NULL, cache_entry_cmp, rlm_cache_rbtree_entry_t, NULL, 0); + driver->cache = rbtree_talloc_alloc(NULL, rlm_cache_rbtree_entry_t, node, cache_entry_cmp, NULL, 0); if (!driver->cache) { ERROR("Failed to create cache"); return -1; diff --git a/src/modules/rlm_csv/rlm_csv.c b/src/modules/rlm_csv/rlm_csv.c index 719db50c60..f48e36d770 100644 --- a/src/modules/rlm_csv/rlm_csv.c +++ b/src/modules/rlm_csv/rlm_csv.c @@ -69,6 +69,7 @@ typedef struct { typedef struct rlm_csv_entry_s rlm_csv_entry_t; struct rlm_csv_entry_s { + fr_rb_node_t node; rlm_csv_entry_t *next; fr_value_box_t *key; char *data[]; @@ -570,7 +571,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *conf) (inst->key_data_type == FR_TYPE_IPV6_ADDR) || (inst->key_data_type == FR_TYPE_IPV6_PREFIX)) { MEM(inst->trie = fr_trie_alloc(inst)); } else { - MEM(inst->tree = rbtree_talloc_alloc(inst, csv_entry_cmp, rlm_csv_entry_t, NULL, 0)); + MEM(inst->tree = rbtree_talloc_alloc(inst, rlm_csv_entry_t, node, csv_entry_cmp, NULL, 0)); } if ((*inst->index_field_name == ',') || (*inst->index_field_name == *inst->delimiter)) { diff --git a/src/modules/rlm_files/rlm_files.c b/src/modules/rlm_files/rlm_files.c index f3147a3b5a..b4815c3b52 100644 --- a/src/modules/rlm_files/rlm_files.c +++ b/src/modules/rlm_files/rlm_files.c @@ -206,7 +206,7 @@ static int getusersfile(TALLOC_CTX *ctx, char const *filename, rbtree_t **ptree) entry = entry->next; } - tree = rbtree_alloc(ctx, pairlist_cmp, NULL, RBTREE_FLAG_NONE); + tree = rbtree_alloc(ctx, PAIR_LIST, node, pairlist_cmp, NULL, RBTREE_FLAG_NONE); if (!tree) { pairlist_free(&users); return -1; diff --git a/src/modules/rlm_icmp/rlm_icmp.c b/src/modules/rlm_icmp/rlm_icmp.c index 324f5e2627..227964086b 100644 --- a/src/modules/rlm_icmp/rlm_icmp.c +++ b/src/modules/rlm_icmp/rlm_icmp.c @@ -62,6 +62,7 @@ typedef struct { } rlm_icmp_thread_t; typedef struct { + fr_rb_node_t node; //!< Entry in the outstanding list of echo requests. bool replied; //!< do we have a reply? fr_value_box_t *ip; //!< the IP we're pinging uint32_t counter; //!< for pinging the same IP multiple times @@ -429,7 +430,7 @@ static int mod_thread_instantiate(UNUSED CONF_SECTION const *cs, void *instance, rlm_icmp_thread_t *t = talloc_get_type_abort(thread, rlm_icmp_thread_t); fr_ipaddr_t ipaddr, *src; - MEM(t->tree = rbtree_alloc(t, echo_cmp, NULL, RBTREE_FLAG_NONE)); + MEM(t->tree = rbtree_alloc(t, rlm_icmp_echo_t, node, echo_cmp, NULL, RBTREE_FLAG_NONE)); t->inst = inst; t->el = el; diff --git a/src/modules/rlm_radius/track.c b/src/modules/rlm_radius/track.c index b1a390c0bd..4537cefbb8 100644 --- a/src/modules/rlm_radius/track.c +++ b/src/modules/rlm_radius/track.c @@ -158,8 +158,8 @@ retry: * If needed, allocate a subtree. */ if (!tt->subtree[tt->next_id]) { - MEM(tt->subtree[tt->next_id] = rbtree_talloc_alloc(tt, te_cmp, radius_track_entry_t, - NULL, RBTREE_FLAG_NONE)); + MEM(tt->subtree[tt->next_id] = rbtree_talloc_alloc(tt, radius_track_entry_t, node, + te_cmp, NULL, RBTREE_FLAG_NONE)); } /* diff --git a/src/modules/rlm_radius/track.h b/src/modules/rlm_radius/track.h index aecd2577f3..1845776cbb 100644 --- a/src/modules/rlm_radius/track.h +++ b/src/modules/rlm_radius/track.h @@ -34,6 +34,8 @@ typedef struct radius_track_s radius_track_t; * */ struct radius_track_entry_s { + fr_rb_node_t node; //!< Entry in the tracking tree. + radius_track_t *tt; radius_track_entry_t ***binding; //!< Binding chunk we use to release the entry diff --git a/src/modules/rlm_securid/rlm_securid.c b/src/modules/rlm_securid/rlm_securid.c index ed94e44220..09bfa6438b 100644 --- a/src/modules/rlm_securid/rlm_securid.c +++ b/src/modules/rlm_securid/rlm_securid.c @@ -451,7 +451,7 @@ static int mod_instantiate(void *instance, UNUSED CONF_SECTION *conf) * Lookup sessions in the tree. We don't free them in * the tree, as that's taken care of elsewhere... */ - inst->session_tree = rbtree_talloc_alloc(NULL, securid_session_cmp, SECURID_SESSION NULL, 0); + inst->session_tree = rbtree_talloc_alloc(NULL, SECURID_SESSION, node, securid_session_cmp, NULL, 0); if (!inst->session_tree) { ERROR("Cannot initialize session tree"); return -1; diff --git a/src/modules/rlm_securid/rlm_securid.h b/src/modules/rlm_securid/rlm_securid.h index 027c60a695..e5d30d2bd6 100644 --- a/src/modules/rlm_securid/rlm_securid.h +++ b/src/modules/rlm_securid/rlm_securid.h @@ -35,19 +35,20 @@ typedef enum { #define SECURID_STATE_LEN 32 typedef struct { - struct _securid_session_t *prev, *next; - SDI_HANDLE sdiHandle; - SECURID_SESSION_STATE securidSessionState; + struct _securid_session_t *prev, *next; + fr_rb_node_t node; + SDI_HANDLE sdiHandle; + SECURID_SESSION_STATE securidSessionState; - char state[SECURID_STATE_LEN]; + char state[SECURID_STATE_LEN]; - fr_ipaddr_t src_ipaddr; - time_t timestamp; - unsigned int session_id; - uint32_t trips; + fr_ipaddr_t src_ipaddr; + time_t timestamp; + unsigned int session_id; + uint32_t trips; - char *pin; /* previous pin if user entered it during NEW-PIN mode process */ - char *identity; /* save user's identity name for future use */ + char *pin; /* previous pin if user entered it during NEW-PIN mode process */ + char *identity; /* save user's identity name for future use */ } SECURID_SESSION; diff --git a/src/modules/rlm_sigtran/sccp.c b/src/modules/rlm_sigtran/sccp.c index f9ea9c14a5..be98cac497 100644 --- a/src/modules/rlm_sigtran/sccp.c +++ b/src/modules/rlm_sigtran/sccp.c @@ -379,7 +379,7 @@ int sigtran_sccp_global_init(void) return 0; } - txn_tree = rbtree_talloc_alloc(NULL, sigtran_txn_cmp, sigtran_transaction_t, false, 0); + txn_tree = rbtree_talloc_alloc(NULL, sigtran_transaction_t, node, sigtran_txn_cmp, false, 0); if (!txn_tree) return -1; txn_tree_inst++; diff --git a/src/modules/rlm_sigtran/sigtran.h b/src/modules/rlm_sigtran/sigtran.h index 457100e58c..1d75a63958 100644 --- a/src/modules/rlm_sigtran/sigtran.h +++ b/src/modules/rlm_sigtran/sigtran.h @@ -73,6 +73,8 @@ typedef enum { * and won't mind extra memory being allocated from this ctx. */ typedef struct sigtran_transaction { + fr_rb_node_t node; //!< Entry in the tree of transactions. + struct { sigtran_request_type_t type; //!< Type of request void *data; //!< Data for the request. diff --git a/src/modules/rlm_stats/rlm_stats.c b/src/modules/rlm_stats/rlm_stats.c index fa23b127a9..9c40d41b95 100644 --- a/src/modules/rlm_stats/rlm_stats.c +++ b/src/modules/rlm_stats/rlm_stats.c @@ -57,6 +57,8 @@ typedef struct { } rlm_stats_t; typedef struct { + fr_rb_node_t src_node; + fr_rb_node_t dst_node; fr_ipaddr_t ipaddr; //!< IP address of this thing fr_time_t created; //!< when it was created fr_time_t last_packet; //!< when we last saw a packet @@ -346,8 +348,8 @@ static int mod_thread_instantiate(UNUSED CONF_SECTION const *cs, void *instance, t->inst = inst; - t->src = rbtree_talloc_alloc(t, data_cmp, rlm_stats_data_t, NULL, RBTREE_FLAG_LOCK); - t->dst = rbtree_talloc_alloc(t, data_cmp, rlm_stats_data_t, NULL, RBTREE_FLAG_LOCK); + t->src = rbtree_talloc_alloc(t, rlm_stats_data_t, src_node, data_cmp, NULL, RBTREE_FLAG_LOCK); + t->dst = rbtree_talloc_alloc(t, rlm_stats_data_t, dst_node, data_cmp, NULL, RBTREE_FLAG_LOCK); pthread_mutex_lock(&inst->mutex); fr_dlist_insert_head(&inst->list, t); diff --git a/src/protocols/radius/list.c b/src/protocols/radius/list.c index acd50b34f0..a0f7842654 100644 --- a/src/protocols/radius/list.c +++ b/src/protocols/radius/list.c @@ -299,7 +299,7 @@ fr_packet_list_t *fr_packet_list_create(int alloc_id) pl = talloc_zero(NULL, fr_packet_list_t); if (!pl) return NULL; - pl->tree = rbtree_alloc(pl, fr_packet_cmp, NULL, 0); /* elements not talloc safe */ + pl->tree = rbtree_alloc(pl, fr_radius_packet_t, node, fr_packet_cmp, NULL, 0); /* elements not talloc safe */ if (!pl->tree) { fr_packet_list_free(pl); return NULL; diff --git a/src/tests/rbmonkey.c b/src/tests/rbmonkey.c index 3dbc411007..b97da319da 100644 --- a/src/tests/rbmonkey.c +++ b/src/tests/rbmonkey.c @@ -152,7 +152,7 @@ again: fprintf(stderr, "filter = %x mask = %x n = %i\n", thresh.num, mask, n); - t = rbtree_alloc(NULL, comp, freenode, RBTREE_FLAG_LOCK); + t = rbtree_alloc(NULL, fr_rb_test_node_t, node, comp, freenode, RBTREE_FLAG_LOCK); for (i = 0; i < n; i++) { fr_rb_test_node_t *p;