]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add fr_rb_node_t fields to structures that are inserted into rbtrees
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 2 Feb 2021 18:49:04 +0000 (18:49 +0000)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 2 Feb 2021 19:49:02 +0000 (19:49 +0000)
This is being done ahead of removing malloc calls in the rbtree.

52 files changed:
src/bin/radclient.c
src/bin/radclient.h
src/bin/radsniff.c
src/bin/radsniff.h
src/lib/io/listen.h
src/lib/io/master.c
src/lib/io/master.h
src/lib/io/network.c
src/lib/io/worker.c
src/lib/redis/cluster.c
src/lib/server/cf_file.c
src/lib/server/cf_priv.h
src/lib/server/cf_util.c
src/lib/server/client.c
src/lib/server/client.h
src/lib/server/dl_module.c
src/lib/server/dl_module.h
src/lib/server/map_proc.c
src/lib/server/map_proc_priv.h
src/lib/server/module.c
src/lib/server/module.h
src/lib/server/request.h
src/lib/server/state.c
src/lib/server/trigger.c
src/lib/server/users_file.h
src/lib/server/virtual_servers.c
src/lib/server/virtual_servers.h
src/lib/unlang/xlat.h
src/lib/unlang/xlat_builtin.c
src/lib/unlang/xlat_inst.c
src/lib/unlang/xlat_priv.h
src/lib/util/dl.c
src/lib/util/dl.h
src/lib/util/event.c
src/lib/util/packet.h
src/lib/util/rbtree.c
src/lib/util/rbtree.h
src/modules/proto_bfd/proto_bfd.c
src/modules/proto_ldap_sync/sync.c
src/modules/rlm_cache/drivers/rlm_cache_rbtree/rlm_cache_rbtree.c
src/modules/rlm_csv/rlm_csv.c
src/modules/rlm_files/rlm_files.c
src/modules/rlm_icmp/rlm_icmp.c
src/modules/rlm_radius/track.c
src/modules/rlm_radius/track.h
src/modules/rlm_securid/rlm_securid.c
src/modules/rlm_securid/rlm_securid.h
src/modules/rlm_sigtran/sccp.c
src/modules/rlm_sigtran/sigtran.h
src/modules/rlm_stats/rlm_stats.c
src/protocols/radius/list.c
src/tests/rbmonkey.c

index 93b80ca1266e1873770fa28f728760414578bbda..21f37e108ec266ff7b4a7512f7a35135c1b428a9 100644 (file)
@@ -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");
index 6331d412fdea036ef39c3b33ebd9d6c714d0632e..44ccc57fd24cc25b57f2acd5322ef78c00dfbee4 100644 (file)
@@ -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.
index c8fee2bf7ec0b809c91751c6a4e2e41228200ad7..5c38da58967465ce1108f4255e3649a41a3f561e 100644 (file)
@@ -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;
index 7cf7a2c8fea6da0997ad7117b752abcf64165157..b53db01e5283afa1739d2782ef10a3bcd8871a1e 100644 (file)
@@ -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;
index c05b14664a09750680e60e7401f3055865581d1d..db9540fef24d6503004b9ad737a00624e5790422 100644 (file)
@@ -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;
index d3769bfa0b716f2c3f8103a1797a867c75d09eda..f718ad0198a146db30d637071d0310c680c8788f 100644 (file)
@@ -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));
                }
 
index 3413b996c46e67e97456f8a16676097a994d3884..662c3f3ac68dae2abb860bc0f0a8a7c0b6e7cfc7 100644 (file)
@@ -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
index 4a415a344a6250d7471dcfd33139e7d491df60eb..81baf2fe5ae1f2a10c65aa4555aff241320c1a11 100644 (file)
@@ -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;
index e04c207410e8ced334bc4bf9a730537755e16792..fe12852b8e7f19f6880ad4ab104db23f2d8da8cc 100644 (file)
@@ -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;
index 2a4877934b8bbe15ef5db5ff5b505147f22c3e78..932044e83d5d9e2abd129b05422f31ea82d0a168 100644 (file)
@@ -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);
index ba0a3f95e0a48677ee68924cff549e2ab1f969c2..1ee4ecfe2aa99af5917e8702cdfb777070e912cb 100644 (file)
@@ -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);
 
index 8bed0e1511558abae81f0d975992c16cc8b8f0dd..4397f0fa930239845911d7b1200d9e83081041da 100644 (file)
@@ -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
index aa0bd5e2564a9828d27d2df779e8c0567f0416f0..ddadd494023d9fc203d5ddca1f411b904a78fb68 100644 (file)
@@ -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);
 
index 99ec209f9a26046cad1efe3996f5996d41aef9a4..0119c44eb76e88b2a5f83f46b7c26b0369f9af03 100644 (file)
@@ -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;
                }
index 40b3e6a380230cc85bb4f435b02bf83335f6460c..fc1c1941fa815c20c3bc38e45245c6427853437d 100644 (file)
@@ -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).
index c1ea0d1bca39561826cc15af1f8c980f62fd8c44..69339b3c10a38c9c7cdf1749b1f7e057838ab437 100644 (file)
@@ -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;
index ceb93322f167725a01b96ea048aa0ef789acf0df..526e6fdaa12590b6eb30f2cc4150d8d39f31f560 100644 (file)
@@ -31,9 +31,10 @@ RCSIDH(dl_module_h, "$Id$")
 #  include <dlfcn.h>
 #endif
 
-#include <freeradius-devel/util/version.h>
-#include <freeradius-devel/util/dl.h>
 #include <freeradius-devel/server/cf_parse.h>
+#include <freeradius-devel/util/dl.h>
+#include <freeradius-devel/util/rbtree.h>
+#include <freeradius-devel/util/version.h>
 
 #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.
index b99a25a042a96f5258b4736489aba0ace36191ae..fffa353dd3cd7ae32683f0c6ba71547a89bd26e4 100644 (file)
@@ -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;
index 2049e3035a20c875200eeb1c331a3e495e2e6018..ad0de8807a32bc676e54928add61d115f92775ed 100644 (file)
@@ -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.
index 877cd21817d5534d4a9aba1b0780530bc00b6b53..b35ccdbbf5b1d7f5531fa270f6a692eb26738c2c 100644 (file)
@@ -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;
index c0e683ec93c4a502542ce195ecc3c2b5fcca259a..bc85f16f66984eb7ce3cf3f78987e3cf76262122 100644 (file)
@@ -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,
index 00e26f9cc3a3826abe882d61f8cdae1bb0d1bfeb..d143220475661660c91b015ffcb361629bbe015a 100644 (file)
@@ -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
 
index d06b994d781949775d7ecfdb95c84572588dcce6..c58604a751b43496ff92cd00951c54037bd91cd0 100644 (file)
@@ -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;
index f5d6f1b6d36890adfa63695be90ba6b04ba1f8e6..edd7746b37dd698e9bb3b261b5b1b6adf4a5e4a4 100644 (file)
@@ -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);
index 604222e92ed0d44840e7a708b91d8d34987a0974..ab06f80e880d3e838f68cf66335e8fc1eeb8556e 100644 (file)
@@ -36,6 +36,8 @@ extern "C" {
 #include <talloc.h>
 
 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;
index 4ca8bbfa5db54d4586376dad509aa0cd18c49dd8..b1e8fadf61f39cabf7a16fe9599e65148637bea0 100644 (file)
@@ -42,6 +42,7 @@ RCSID("$Id$")
 #include <freeradius-devel/unlang/base.h>
 
 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;
 }
index bbd929c566de43adb2a98f3e00923944be798ed8..bdd54ca1b27719ffc941fb8f8c6eb856bb5f930d 100644 (file)
@@ -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
index 9872c9863f5e498132bca1a847991588a925d244..a4d8ab81b3fd750441d593362a44214845123b5b 100644 (file)
@@ -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.
 
index 3e8e756e7aa909d767dba55c3dc9b0b701ff4870..9a6e3cd08a38d3d0cb1e1d8d2842b023e63e5466 100644 (file)
@@ -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;
index 48e4ba20ddc3f28522b02094839f54ced9016c84..742fe1b5404f85143c3ba967be2c5631df5028ef 100644 (file)
@@ -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;
index 5cfafa01ebcdc655dec58f0ba7b02bae3c96c467..7c174bfae530906484a6eac8dd0a349571106493 100644 (file)
@@ -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 {
index adb8d827b585ff8a93656124dcd803290775e62c..3027b7443e48951e1cb4ef84a6217592b22a5468 100644 (file)
@@ -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:
index b17a5ca2ace71cc284342eaa79eb5e01cd59428e..5b1693423f75efc3ce601c70622ccebc340dc4da 100644 (file)
@@ -31,6 +31,7 @@ RCSIDH(dl_h, "$Id$")
 #  include <dlfcn.h>
 #endif
 #include <freeradius-devel/util/version.h>
+#include <freeradius-devel/util/rbtree.h>
 
 #include <talloc.h>
 #include <stdbool.h>
@@ -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.
index deb41bd7f704b9805b5a88272827ab6ab5b8e195..94bce66bad53b27d04933b00fe8e5a48ce889d85 100644 (file)
@@ -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;
        }
 
index ea2fac8d7fbcb0c661abcf689b3688ec23322772..3937cdc927867002593e47c2be0b662029a2ffbb 100644 (file)
@@ -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).
index da0b4be251aae4056ec7700f87bd493421ef7e47..214528fc7f2e7610a6abddcba44dbc66f99f3245 100644 (file)
@@ -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;
 }
index 8e4bda37c073ce3105b66cbd3482167187efe8aa..6b27d209a4fb4829327b9499d091c930ba0ef7e8 100644 (file)
@@ -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);
 
index 049fd74de58c13c0603848b07017a3e9a1c0097a..67b9a0f26351343b57d0d9411928ed3b52c25f6d 100644 (file)
@@ -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;
index d11359b012cb93eb461d81497f9e880f557cbf42..c5c88258153fe74f385795fc029ce1e02126b62f 100644 (file)
@@ -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);
index b62cd2bbf1e2348cb658fc2deb1f6bed3835f5a5..dcf19480aa9832e70e63968c076c2a2d97486936 100644 (file)
@@ -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;
index 719db50c607dc916371e15299f177da02a56ff70..f48e36d770b1814d386b9fce9836eb0ed6005dd4 100644 (file)
@@ -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)) {
index f3147a3b5a0b035f4c997341effd8c9b2eed3685..b4815c3b526bf99bcc178fa161c75c0cc46726da 100644 (file)
@@ -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;
index 324f5e2627bc9184a4063213d4dca20d60ce5ec3..227964086b87a3ead1a30e40e1bcb252a41127d2 100644 (file)
@@ -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;
 
index b1a390c0bd0f3e0f0fbf40f2e5bf436ef78d8eb0..4537cefbb8d904d4907607cb60a9ef8a9a73adb8 100644 (file)
@@ -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));
        }
 
        /*
index aecd2577f3b00811c8e184e0a1a5fec6f756dd72..1845776cbb0d2ed3375e54a7d5a02469d1ac7ee8 100644 (file)
@@ -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
index ed94e442202e91d7c92126e90706a1156d525134..09bfa6438b4c95ff6206dc889f6d4e8aa6664a02 100644 (file)
@@ -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;
index 027c60a695f3c310da1689b5a048bb9b20110b8f..e5d30d2bd668bf1a31e5fcc1e9da2fae28438405 100644 (file)
@@ -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;
 
index f9ea9c14a500d00b6a1a81ece4d29cf51d806fd9..be98cac497825e7010889d2a2bba1c8e899434b6 100644 (file)
@@ -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++;
index 457100e58c922bdcb7ba51e98a6815ae87c3de71..1d75a639587f19c21c1d16e54ced07778583adad 100644 (file)
@@ -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.
index fa23b127a9ad123fb8ee10ccde02db8575547085..9c40d41b952b6d412a6b085a5c6d6397613f2fab 100644 (file)
@@ -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);
index acd50b34f07afb32ccb8ec33c05f7245a1147b53..a0f78426544feac0c1d83707382d82edbb52d8e4 100644 (file)
@@ -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;
index 3dbc41100724d5dccda25bdcb76fa79ce288ff8c..b97da319da34ada82b38c70da4235332f4a8af4a 100644 (file)
@@ -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;