]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
migrate/combine proto module bootstrance and instantiate functions
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Sun, 12 May 2024 19:58:42 +0000 (13:58 -0600)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Mon, 13 May 2024 13:42:00 +0000 (07:42 -0600)
29 files changed:
src/listen/arp/proto_arp.c
src/listen/arp/proto_arp_ethernet.c
src/listen/bfd/proto_bfd.c
src/listen/bfd/proto_bfd_udp.c
src/listen/control/proto_control.c
src/listen/control/proto_control_unix.c
src/listen/cron/cron.c
src/listen/cron/proto_cron.c
src/listen/cron/proto_cron_crontab.c
src/listen/detail/proto_detail.c
src/listen/detail/proto_detail_file.c
src/listen/detail/proto_detail_work.c
src/listen/dhcpv4/proto_dhcpv4.c
src/listen/dhcpv4/proto_dhcpv4_udp.c
src/listen/dhcpv6/proto_dhcpv6.c
src/listen/dhcpv6/proto_dhcpv6_udp.c
src/listen/dns/proto_dns.c
src/listen/dns/proto_dns_udp.c
src/listen/ldap_sync/proto_ldap_sync.c
src/listen/ldap_sync/proto_ldap_sync_ldap.c
src/listen/load/proto_load.c
src/listen/load/proto_load_step.c
src/listen/radius/proto_radius.c
src/listen/radius/proto_radius_tcp.c
src/listen/radius/proto_radius_udp.c
src/listen/tacacs/proto_tacacs.c
src/listen/tacacs/proto_tacacs_tcp.c
src/listen/vmps/proto_vmps.c
src/listen/vmps/proto_vmps_udp.c

index 68de97f4b7c80cf4900e816df35bb701b3811fac..324a6b621fd489d2fab9bceebbcaf204560e8ccd 100644 (file)
@@ -222,27 +222,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
  *     - -1 on failure.
  */
 static int mod_instantiate(module_inst_ctx_t const *mctx)
-{
-       proto_arp_t             *inst = talloc_get_type_abort(mctx->mi->data, proto_arp_t);
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       return 0;
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
 {
        proto_arp_t             *inst = talloc_get_type_abort(mctx->mi->data, proto_arp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -253,6 +232,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->server_cs = cf_item_to_section(cf_parent(conf));
        inst->cs = conf;
 
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
        return 0;
 }
 
@@ -278,7 +262,6 @@ fr_app_t proto_arp = {
                .inst_size              = sizeof(proto_arp_t),
                .onload                 = mod_load,
                .unload                 = mod_unload,
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_arp,
index 61df2da05729fb9c399a790e9d09aa4355e8da59..63b09eddaf43fa36efcf0f75215eaffdc43a7312 100644 (file)
@@ -216,7 +216,7 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_arp_ethernet_t    *inst = talloc_get_type_abort(mctx->mi->data, proto_arp_ethernet_t);
 
@@ -225,7 +225,6 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        return 0;
 }
 
-
 fr_app_io_t proto_arp_ethernet = {
        .common = {
                .magic                  = MODULE_MAGIC_INIT,
@@ -233,7 +232,7 @@ fr_app_io_t proto_arp_ethernet = {
                .config                 = arp_listen_config,
                .inst_size              = sizeof(proto_arp_ethernet_t),
                .thread_inst_size       = sizeof(proto_arp_ethernet_thread_t),
-               .bootstrap              = mod_bootstrap,
+               .bootstrap              = mod_instantiate
        },
        .default_message_size   = FR_ARP_PACKET_SIZE,
 
index f8a2f428cfe28b8cab41462bb4ede69bb5b96922..e4e609d171897ffa4ec064551f8b8bdd7500eab4 100644 (file)
@@ -307,44 +307,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
                                   inst->max_packet_size, inst->num_messages);
 }
 
-/** Instantiate the application
- *
- * Instantiate I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_instantiate(module_inst_ctx_t const *mctx)
-{
-       proto_bfd_t             *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_t);
-
-       /*
-        *      No IO module, it's an empty listener.
-        */
-       if (!inst->io.submodule) return 0;
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
 /** Bootstrap the application
  *
  * Bootstrap I/O and type submodules.
@@ -353,7 +315,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
  *     - 0 on success.
  *     - -1 on failure.
  */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_bfd_t             *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_t);
        CONF_SECTION            *server;
@@ -481,9 +443,23 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        }
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
+        */
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 static int mod_load(void)
@@ -508,7 +484,6 @@ fr_app_t proto_bfd = {
                .inst_size              = sizeof(proto_bfd_t),
                .onload                 = mod_load,
                .unload                 = mod_unload,
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_bfd,
index ca5d9db8dc8e01a82d5fc2d0aca8d0752c3401c6..14d7211c31364909faaced2fa5f4a5e520559890 100644 (file)
@@ -353,7 +353,7 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_bfd_udp_t         *inst = talloc_get_type_abort(mctx->mi->data, proto_bfd_udp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -520,7 +520,7 @@ fr_app_io_t proto_bfd_udp = {
                .config                 = udp_listen_config,
                .inst_size              = sizeof(proto_bfd_udp_t),
                .thread_inst_size       = sizeof(proto_bfd_udp_thread_t),
-               .bootstrap              = mod_bootstrap
+               .instantiate            = mod_instantiate
        },
        .default_message_size   = FR_BFD_HEADER_LENGTH + 64, /* enough for some auth packets */
        .track_duplicates       = false,
index 16fc75749c5841be7aeee3949d5c01527bdf8e70..25816f62839f6a6d8417b0e73d0a284243353a07 100644 (file)
@@ -95,41 +95,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_control_t         *inst = talloc_get_type_abort(mctx->mi->data, proto_control_t);
-
-       fr_assert(inst->io.submodule != NULL);
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_control_t                 *inst = talloc_get_type_abort(mctx->mi->data, proto_control_t);
        CONF_SECTION                    *conf = mctx->mi->conf;
 
        /*
@@ -166,9 +131,23 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
+        */
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 fr_app_t proto_control = {
@@ -177,7 +156,6 @@ fr_app_t proto_control = {
                .name                   = "control",
                .config                 = proto_control_config,
                .inst_size              = sizeof(proto_control_t),
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .open                   = mod_open,
index 17d06e1d835cc8c1dc506d6ef680af7a9171b338..d6b9bbf91db8dd9cc31869a23cf83434785092ad 100644 (file)
@@ -578,7 +578,7 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_control_unix_t    *inst = talloc_get_type_abort(mctx->mi->data, proto_control_unix_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -681,7 +681,7 @@ fr_app_io_t proto_control_unix = {
                .config                 = unix_listen_config,
                .inst_size              = sizeof(proto_control_unix_t),
                .thread_inst_size       = sizeof(proto_control_unix_thread_t),
-               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate
        },
        .default_message_size   = 4096,
 
index 84f673ce2f4c34530e4be50d2d34c9210b497c20..786073cf8c8fdc98667a68ed1c356acd9afaf890 100644 (file)
@@ -398,6 +398,15 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        FILE                    *fp;
        bool                    done;
 
+       /*
+        *      The listener is inside of a virtual server.
+        */
+       inst->server_cs = cf_item_to_section(cf_parent(conf));
+       inst->cs = conf;
+       inst->self = &proto_cron;
+
+       virtual_server_dict_set(inst->server_cs, inst->dict, false);
+
        FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
        FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
 
@@ -424,40 +433,12 @@ static int mod_instantiate(void *instance, CONF_SECTION *conf)
        return 0;
 }
 
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @param[in] instance Ctx data for this application.
- * @param[in] conf     Listen section parsed to give us instance.
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(void *instance, CONF_SECTION *conf)
-{
-       proto_cron_t            *inst = talloc_get_type_abort(instance, proto_cron_t);
-
-       /*
-        *      The listener is inside of a virtual server.
-        */
-       inst->server_cs = cf_item_to_section(cf_parent(conf));
-       inst->cs = conf;
-       inst->self = &proto_cron;
-
-       virtual_server_dict_set(inst->server_cs, inst->dict, false);
-
-       return 0;
-}
-
 fr_app_t proto_cron = {
        .magic                  = RLM_MODULE_INIT,
        .name                   = "cron",
        .config                 = proto_cron_config,
        .inst_size              = sizeof(proto_cron_t),
 
-       .bootstrap              = mod_bootstrap,
        .instantiate            = mod_instantiate,
        .open                   = mod_open,
 };
index 62fa54a7311f548ddff1855819ce0a784a6c54b0..05f5c7c9490c830f6ae2c19a77b6980b2d6cc991 100644 (file)
@@ -177,40 +177,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_cron_t            *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_t);
-
-       fr_assert(inst->io.submodule);
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_cron_t            *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_t);
        CONF_SECTION            *conf = mctx->mi->conf;
 
        /*
@@ -245,11 +211,24 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
-}
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
 
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
+        */
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
+}
 
 fr_app_t proto_cron = {
        .common = {
@@ -257,8 +236,6 @@ fr_app_t proto_cron = {
                .name                   = "cron",
                .config                 = proto_cron_config,
                .inst_size              = sizeof(proto_cron_t),
-
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .open                   = mod_open,
index 3c1278c6f0abf53429498664572b7c7fe52255b9..44dafff1e8583fce33a11794d152bd054f68f236 100644 (file)
@@ -677,17 +677,6 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_cron_crontab_t    *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_crontab_t);
-
-       inst->parent = talloc_get_type_abort(mctx->mi->parent->data, proto_cron_t);
-       inst->cs = mctx->mi->conf;
-
-       return 0;
-}
-
 static fr_client_t *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
 {
        proto_cron_crontab_t const       *inst = talloc_get_type_abort_const(li->app_io_instance, proto_cron_crontab_t);
@@ -695,7 +684,6 @@ static fr_client_t *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *i
        return inst->client;
 }
 
-
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_cron_crontab_t    *inst = talloc_get_type_abort(mctx->mi->data, proto_cron_crontab_t);
@@ -705,6 +693,9 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        FILE                    *fp;
        bool                    done = false;
 
+       inst->parent = talloc_get_type_abort(mctx->mi->parent->data, proto_cron_t);
+       inst->cs = mctx->mi->conf;
+
        fr_pair_list_init(&inst->pair_list);
        inst->client = client = talloc_zero(inst, fr_client_t);
        if (!inst->client) return 0;
@@ -745,7 +736,6 @@ fr_app_io_t proto_cron_crontab = {
                .config                 = crontab_listen_config,
                .inst_size              = sizeof(proto_cron_crontab_t),
                .thread_inst_size       = sizeof(proto_cron_crontab_thread_t),
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .default_message_size   = 4096,
index c5ed83013a8fd1e8f509f980214486dc85516b87..7fe5890b8888b541cba61bcb99a3054d19872f3c 100644 (file)
@@ -33,7 +33,9 @@
 #include "lib/server/module.h"
 
 extern fr_app_t proto_detail;
+
 static int type_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
+static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule);
 
 #if 0
 /*
@@ -52,7 +54,7 @@ static conf_parser_t const proto_detail_config[] = {
        { FR_CONF_OFFSET_TYPE_FLAGS("type", FR_TYPE_VOID, CONF_FLAG_NOT_EMPTY | CONF_FLAG_REQUIRED, proto_detail_t,
                          type), .func = type_parse },
        { FR_CONF_OFFSET_TYPE_FLAGS("transport", FR_TYPE_VOID, 0, proto_detail_t, io_submodule),
-         .func = virtual_sever_listen_transport_parse, .dflt = "file" },
+         .func = transport_parse, .dflt = "file" },
 
        /*
         *      Add this as a synonym so normal humans can understand it.
@@ -147,6 +149,63 @@ static int type_parse(UNUSED TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM
        return 0;
 }
 
+static int transport_parse(TALLOC_CTX *ctx, void *out, void *parent, CONF_ITEM *ci, conf_parser_t const *rule)
+{
+       proto_detail_t *inst = talloc_get_type_abort(parent, proto_detail_t);
+
+       if (unlikely(virtual_sever_listen_transport_parse(ctx, out, parent, ci, rule) < 0)) {
+               return -1;
+       }
+
+       /*
+        *      If we're not loading the work submodule directly, then try to load it here.
+        */
+       if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
+               CONF_SECTION *transport_cs;
+               module_instance_t *parent_inst;
+
+               inst->work_submodule = NULL;
+
+               transport_cs = cf_section_find(inst->cs, "work", NULL);
+               parent_inst = cf_data_value(cf_data_find(inst->cs, module_instance_t, "proto_detail"));
+               fr_assert(parent_inst);
+
+               if (!transport_cs) {
+                       transport_cs = cf_section_dup(inst->cs, inst->cs, inst->app_io_conf,
+                                                     "work", NULL, false);
+                       if (!transport_cs) {
+                               cf_log_err(inst->cs, "Failed to create configuration for worker");
+                               return -1;
+                       }
+               }
+
+               /*
+                *      This *should* get bootstrapped at some point after this module
+                *      as it's inserted into the three the caller is iterating over.
+                *
+                *      We might want to revisit this, and use a linked list of modules
+                *      to iterate over instead of a tree, so we can add this to the end
+                *      of that list.
+                */
+               inst->work_submodule = module_instance_alloc(parent_inst->ml, parent_inst, DL_MODULE_TYPE_SUBMODULE,
+                                                            "work", module_instance_name_from_conf(transport_cs), 0);
+               if (inst->work_submodule == NULL) {
+               error:
+                       cf_log_perr(inst->cs, "Failed to load proto_detail_work");
+                       TALLOC_FREE(inst->work_submodule);
+                       return -1;
+               }
+
+               if (module_instance_conf_parse(inst->work_submodule, transport_cs) < 0) goto error;
+
+               inst->work_io = (fr_app_io_t const *) inst->work_submodule->exported;
+               inst->work_io_instance = inst->work_submodule->data;
+               inst->work_io_conf = inst->work_submodule->conf;
+       }
+
+       return 0;
+}
+
 /** Decode the packet, and set the request->process function
  *
  */
@@ -460,59 +519,6 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        proto_detail_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_t);
        CONF_SECTION            *conf = mctx->mi->conf;
 
-       /*
-        *      Instantiate the I/O module. But DON'T instantiate the
-        *      work submodule.  We leave that until later.
-        */
-       if (inst->app_io->common.instantiate &&
-           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
-               cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->common.name);
-               return -1;
-       }
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size) inst->max_packet_size = inst->app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 2;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 2);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
-
-       if (!inst->priority) inst->priority = PRIORITY_NORMAL;
-
-       /*
-        *      If the IO is "file" and not the worker, instantiate the worker now.
-        */
-       if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
-               if (inst->work_io->common.instantiate &&
-                   (inst->work_io->common.instantiate(MODULE_INST_CTX(inst->work_submodule)) < 0)) {
-                       cf_log_err(inst->work_io_conf, "Instantiation failed for \"%s\"", inst->work_io->common.name);
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_detail_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_t);
-       CONF_SECTION            *conf = mctx->mi->conf;
-
        /*
         *      The listener is inside of a virtual server.
         */
@@ -537,55 +543,24 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->app_io_conf = inst->io_submodule->conf;
 
        /*
-        *      If we're not loading the work submodule directly, then try to load it here.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       if (strcmp(inst->io_submodule->module->dl->name, "proto_detail_work") != 0) {
-               CONF_SECTION *transport_cs;
-               module_instance_t *parent_inst;
-
-               inst->work_submodule = NULL;
-
-               transport_cs = cf_section_find(inst->cs, "work", NULL);
-               parent_inst = cf_data_value(cf_data_find(inst->cs, module_instance_t, "proto_detail"));
-               fr_assert(parent_inst);
+       if (!inst->max_packet_size) inst->max_packet_size = inst->app_io->default_message_size;
 
-               if (!transport_cs) {
-                       transport_cs = cf_section_dup(inst->cs, inst->cs, inst->app_io_conf,
-                                                     "work", NULL, false);
-                       if (!transport_cs) {
-                               cf_log_err(inst->cs, "Failed to create configuration for worker");
-                               return -1;
-                       }
-               }
+       if (!inst->num_messages) inst->num_messages = 2;
 
-               /*
-                *      This *should* get bootstrapped at some point after this module
-                *      as it's inserted into the three the caller is iterating over.
-                *
-                *      We might want to revisit this, and use a linked list of modules
-                *      to iterate over instead of a tree, so we can add this to the end
-                *      of that list.
-                */
-               inst->work_submodule = module_instance_alloc(parent_inst->ml, parent_inst, DL_MODULE_TYPE_SUBMODULE,
-                                                            "work", module_instance_name_from_conf(transport_cs), 0);
-               if (inst->work_submodule == NULL) {
-               error:
-                       cf_log_perr(inst->cs, "Failed to load proto_detail_work");
-                       TALLOC_FREE(inst->work_submodule);
-                       return -1;
-               }
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 2);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
 
-               if (module_instance_conf_parse(inst->work_submodule, transport_cs) < 0) goto error;
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65536);
 
-               inst->work_io = (fr_app_io_t const *) inst->work_submodule->exported;
-               inst->work_io_instance = inst->work_submodule->data;
-               inst->work_io_conf = inst->work_submodule->conf;
-       }
+       if (!inst->priority) inst->priority = PRIORITY_NORMAL;
 
        return 0;
 }
 
-
 fr_app_t proto_detail = {
        .common = {
                .magic                  = MODULE_MAGIC_INIT,
@@ -593,7 +568,6 @@ fr_app_t proto_detail = {
                .config                 = proto_detail_config,
                .inst_size              = sizeof(proto_detail_t),
 
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate,
        },
        .open                   = mod_open,
index 2f46154f2e59dec3e9f5c6d6882d77af47a8707e..663ba8cb66b7a74d2df732c017d59da4a2575d7e 100644 (file)
@@ -622,10 +622,30 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static fr_rb_tree_t *detail_file_tree = NULL;
+static pthread_mutex_t detail_file_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+/** Compare two thread instances based on node pointer
+ *
+ * @param[in] one      First thread specific xlat expansion instance.
+ * @param[in] two      Second thread specific xlat expansion instance.
+ * @return CMP(one, two)
+ */
+static int8_t _detail_file_cmp(void const *one, void const *two)
+{
+       proto_detail_file_t const *a = one, *b = two;
+
+       return CMP(strcmp(a->filename, b->filename), 0);
+}
+
+/*
+ *     Check for multiple readers on the same set of files.
+ */
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_detail_file_t     *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_file_t);
        CONF_SECTION            *conf = mctx->mi->conf;
+
        module_instance_t const *mi;
        char                    *p;
 
@@ -693,33 +713,6 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
                inst->parent->exit_when_done = false;
        }
 
-       return 0;
-}
-
-static fr_rb_tree_t *detail_file_tree = NULL;
-static pthread_mutex_t detail_file_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/** Compare two thread instances based on node pointer
- *
- * @param[in] one      First thread specific xlat expansion instance.
- * @param[in] two      Second thread specific xlat expansion instance.
- * @return CMP(one, two)
- */
-static int8_t _detail_file_cmp(void const *one, void const *two)
-{
-       proto_detail_file_t const *a = one, *b = two;
-
-       return CMP(strcmp(a->filename, b->filename), 0);
-}
-
-/*
- *     Check for multiple readers on the same set of files.
- */
-static int mod_instantiate(module_inst_ctx_t const *mctx)
-{
-       proto_detail_file_t     *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_file_t);
-       CONF_SECTION            *conf = mctx->mi->conf;
-
        pthread_mutex_lock(&detail_file_mutex);
        if (!detail_file_tree) {
                detail_file_tree = fr_rb_inline_talloc_alloc(conf, proto_detail_file_t, filename_node, _detail_file_cmp, NULL);
@@ -790,7 +783,6 @@ fr_app_io_t proto_detail_file = {
                .config                 = file_listen_config,
                .inst_size              = sizeof(proto_detail_file_t),
                .thread_inst_size       = sizeof(proto_detail_file_thread_t),
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate,
        },
        .default_message_size   = 65536,
index f5af01f76528da2d8a263fb86633847c1e93e532..f2a5a39a9f5dccc34d100609e3897a337af12b40 100644 (file)
@@ -846,23 +846,6 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_detail_work_t *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_work_t);
        fr_client_t *client;
-
-       client = inst->client = talloc_zero(inst, fr_client_t);
-       if (!inst->client) return 0;
-
-       client->ipaddr.af = AF_INET;
-       client->ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
-       client->src_ipaddr = client->ipaddr;
-
-       client->longname = client->shortname = client->secret = inst->filename;
-       client->nas_type = talloc_strdup(client, "other");
-
-       return 0;
-}
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_detail_work_t     *inst = talloc_get_type_abort(mctx->mi->data, proto_detail_work_t);
        CONF_SECTION            *cs = mctx->mi->conf;
        module_instance_t const *mi = mctx->mi;
 
@@ -894,10 +877,19 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
 
        FR_INTEGER_BOUND_CHECK("limit.max_outstanding", inst->max_outstanding, >=, 1);
 
+       client = inst->client = talloc_zero(inst, fr_client_t);
+       if (!inst->client) return 0;
+
+       client->ipaddr.af = AF_INET;
+       client->ipaddr.addr.v4.s_addr = htonl(INADDR_NONE);
+       client->src_ipaddr = client->ipaddr;
+
+       client->longname = client->shortname = client->secret = inst->filename;
+       client->nas_type = talloc_strdup(client, "other");
+
        return 0;
 }
 
-
 /** Private interface for use by proto_detail_file
  *
  */
@@ -909,7 +901,6 @@ fr_app_io_t proto_detail_work = {
                .config                 = file_listen_config,
                .inst_size              = sizeof(proto_detail_work_t),
                .thread_inst_size       = sizeof(proto_detail_work_thread_t),
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .default_message_size   = 65536,
index 7b70406f96d2e819c62e9d7afc0105a77278f4fc..10e9900af76f1fc81780984e60d4e16281662904 100644 (file)
@@ -366,55 +366,36 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        proto_dhcpv4_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv4_t);
 
        /*
-        *      No IO module, it's an empty listener.
+        *      Ensure that the server CONF_SECTION is always set.
         */
-       if (!inst->io.submodule) return 0;
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
+
+       fr_assert(dict_dhcpv4 != NULL);
+       fr_assert(attr_message_type != NULL);
 
        /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
+        *      No IO module, it's an empty listener.
         */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+       if (!inst->io.submodule) return 0;
 
        /*
-        *      Instantiate the master io submodule
+        *      Tell the master handler about the main protocol instance.
         */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_dhcpv4_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv4_t);
+       inst->io.app = &proto_dhcpv4;
+       inst->io.app_instance = inst;
 
        /*
-        *      Ensure that the server CONF_SECTION is always set.
+        *      We will need this for dynamic clients and connected sockets.
         */
-       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
-
-       fr_assert(dict_dhcpv4 != NULL);
-       fr_assert(attr_message_type != NULL);
+       inst->io.mi = mctx->mi;
 
        /*
-        *      No IO module, it's an empty listener.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       if (!inst->io.submodule) return 0;
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
 
        /*
         *      These timers are usually protocol specific.
@@ -428,21 +409,16 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, <=, fr_time_delta_from_sec(30));
        FR_TIME_DELTA_BOUND_CHECK("cleanup_delay", inst->io.cleanup_delay, >, fr_time_delta_from_sec(0));
 
-       /*
-        *      Tell the master handler about the main protocol instance.
-        */
-       inst->io.app = &proto_dhcpv4;
-       inst->io.app_instance = inst;
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
 
-       /*
-        *      We will need this for dynamic clients and connected sockets.
-        */
-       inst->io.mi = mctx->mi;
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
 
        /*
-        *      Bootstrap the master IO handler.
+        *      Instantiate the master io submodule
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 static int mod_load(void)
@@ -470,7 +446,6 @@ fr_app_t proto_dhcpv4 = {
                .onload                 = mod_load,
                .unload                 = mod_unload,
 
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_dhcpv4,
index 5bcbb91a32d1f5ce4c2e0e13c6d5a822519ceb7f..ba1598399df38d5b5497762404dae6f8c87574dd 100644 (file)
@@ -669,7 +669,7 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_dhcpv4_udp_t      *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv4_udp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -824,7 +824,7 @@ fr_app_io_t proto_dhcpv4_udp = {
                .config                 = udp_listen_config,
                .inst_size              = sizeof(proto_dhcpv4_udp_t),
                .thread_inst_size       = sizeof(proto_dhcpv4_udp_thread_t),
-               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate,
        },
        .default_message_size   = 4096,
        .track_duplicates       = true,
index bcc6c7a6fa4034260899a009337e7054f3010aa2..e000980eb9b7301771c1d9f74ca15d181a50d35d 100644 (file)
@@ -346,43 +346,6 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_dhcpv6_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv6_t);
 
-       /*
-        *      No IO module, it's an empty listener.
-        */
-       if (!inst->io.submodule) return 0;
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_dhcpv6_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv6_t);
-
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
@@ -420,9 +383,23 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
+        */
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 static int mod_load(void)
@@ -449,7 +426,6 @@ fr_app_t proto_dhcpv6 = {
                .onload                 = mod_load,
                .unload                 = mod_unload,
 
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_dhcpv6,
index dba46e651f5d53d38d73d746d8aaf12e20751677..8703c3b60c71b4c069627eb57efdf18dbbea68a6 100644 (file)
@@ -467,7 +467,7 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_dhcpv6_udp_t      *inst = talloc_get_type_abort(mctx->mi->data, proto_dhcpv6_udp_t);
        size_t                  num;
@@ -670,7 +670,7 @@ fr_app_io_t proto_dhcpv6_udp = {
                .config                 = udp_listen_config,
                .inst_size              = sizeof(proto_dhcpv6_udp_t),
                .thread_inst_size       = sizeof(proto_dhcpv6_udp_thread_t),
-               .bootstrap              = mod_bootstrap
+               .instantiate            = mod_instantiate
        },
        .default_message_size   = 4096,
        .track_duplicates       = true,
index c1f1fb016e3e0408a8be350a4a071d33f5745397..00885468edb5169d9490d06e82aaad0194158b3f 100644 (file)
@@ -295,43 +295,6 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_dns_t             *inst = talloc_get_type_abort(mctx->mi->data, proto_dns_t);
 
-       /*
-        *      No IO module, it's an empty listener.
-        */
-       if (!inst->io.submodule) return 0;
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 64);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_dns_t             *inst = talloc_get_type_abort(mctx->mi->data, proto_dns_t);
-
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
@@ -363,9 +326,23 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 64);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
+        */
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 static int mod_load(void)
@@ -392,8 +369,6 @@ fr_app_t proto_dns = {
 
                .onload                 = mod_load,
                .unload                 = mod_unload,
-
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_dns,
index 307863c3445b99f9ab63892e8428a814bbb2436a..46e6b856aecad863c319b17226dc4d2542b21863 100644 (file)
@@ -338,7 +338,7 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_dns_udp_t         *inst = talloc_get_type_abort(mctx->mi->data, proto_dns_udp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -450,7 +450,7 @@ fr_app_io_t proto_dns_udp = {
                .config                 = udp_listen_config,
                .inst_size              = sizeof(proto_dns_udp_t),
                .thread_inst_size       = sizeof(proto_dns_udp_thread_t),
-               .bootstrap              = mod_bootstrap
+               .instantiate            = mod_instantiate
        },
        .default_message_size   = 576,
        .track_duplicates       = false,
index a80076998980c4a3b982c6206ee133914c4706eb..7cd5157c35386d3f05b51899af033293a22b0668 100644 (file)
@@ -253,15 +253,22 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
                }
        };
 
-       /*
-        *      Instantiate the I/O module.
-        */
-       if (inst->app_io->common.instantiate &&
-           (inst->app_io->common.instantiate(MODULE_INST_CTX(inst->io_submodule)) < 0)) {
-               cf_log_err(conf, "Instantiation failed for \"%s\"", inst->app_io->common.name);
+       inst->server_cs = cf_item_to_section(cf_parent(conf));
+       inst->cs = conf;
+       inst->self = &proto_ldap_sync;
+
+       if (!inst->io_submodule) {
+               cf_log_err(conf, "Virtual server for LDAP sync requires a 'transport' configuration");
                return -1;
        }
 
+       /*
+        *      Bootstrap the I/O module
+        */
+       inst->app_io = (fr_app_io_t const *) inst->io_submodule->exported;
+       inst->app_io_instance = inst->io_submodule->data;
+       inst->app_io_conf = inst->io_submodule->conf;
+
        /*
         *      These configuration items are not printed by default,
         *      because normal people shouldn't be touching them.
@@ -365,38 +372,12 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        return 0;
 }
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_ldap_sync_t       *inst = talloc_get_type_abort(mctx->mi->data, proto_ldap_sync_t);
-       CONF_SECTION            *conf = mctx->mi->conf;
-
-       inst->server_cs = cf_item_to_section(cf_parent(conf));
-       inst->cs = conf;
-       inst->self = &proto_ldap_sync;
-
-       if (!inst->io_submodule) {
-               cf_log_err(conf, "Virtual server for LDAP sync requires a 'transport' configuration");
-               return -1;
-       }
-
-       /*
-        *      Bootstrap the I/O module
-        */
-       inst->app_io = (fr_app_io_t const *) inst->io_submodule->exported;
-       inst->app_io_instance = inst->io_submodule->data;
-       inst->app_io_conf = inst->io_submodule->conf;
-
-       return 0;
-}
-
 fr_app_t proto_ldap_sync = {
        .common = {
                .magic          = MODULE_MAGIC_INIT,
                .name           = "ldap_sync",
                .config         = proto_ldap_sync_config,
                .inst_size      = sizeof(proto_ldap_sync_t),
-
-               .bootstrap      = mod_bootstrap,
                .instantiate    = mod_instantiate
        },
 
index 99c5443c93ddeac33f1abd943f82f7656f8ecfa6..34e0e4df14a640702ee27f339e127f1eb75b5717 100644 (file)
@@ -1288,6 +1288,14 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
         */
        fr_assert(inst->server);
 
+       inst->parent = talloc_get_type_abort(mctx->mi->parent->data, proto_ldap_sync_t);
+       inst->cs = conf;
+
+       if (inst->recv_buff_is_set) {
+               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
+               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
+       }
+
        server = inst->server;
        inst->handle_config.server = talloc_strdup(inst, "");
 
@@ -1305,23 +1313,6 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        return 0;
 }
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_ldap_sync_ldap_t  *inst = talloc_get_type_abort(mctx->mi->data, proto_ldap_sync_ldap_t);
-       CONF_SECTION            *conf = mctx->mi->conf;
-       module_instance_t const *mi = mctx->mi;
-
-       inst->parent = talloc_get_type_abort(mi->parent->data, proto_ldap_sync_t);
-       inst->cs = conf;
-
-       if (inst->recv_buff_is_set) {
-               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
-               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
-       }
-
-       return 0;
-}
-
 fr_app_io_t proto_ldap_sync_child = {
        .common = {
                .magic                  = MODULE_MAGIC_INIT,
@@ -1342,8 +1333,6 @@ fr_app_io_t proto_ldap_sync_ldap = {
                .config                 = proto_ldap_sync_ldap_config,
                .inst_size              = sizeof(proto_ldap_sync_ldap_t),
                .thread_inst_size       = sizeof(proto_ldap_sync_ldap_thread_t),
-
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
 
index 15403244a919cfc4c5e793ec3568dbe2523d8281..fc43f3bf1e102f12c2914a140f59d448ab3c9f6e 100644 (file)
@@ -187,40 +187,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_load_t            *inst = talloc_get_type_abort(mctx->mi->data, proto_load_t);
-
-       fr_assert(inst->io.submodule);
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_load_t            *inst = talloc_get_type_abort(mctx->mi->data, proto_load_t);
        CONF_SECTION            *conf = mctx->mi->conf;
 
        /*
@@ -256,11 +222,24 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
-}
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
 
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
+        */
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
+}
 
 fr_app_t proto_load = {
        .common = {
@@ -269,7 +248,6 @@ fr_app_t proto_load = {
                .config                 = proto_load_config,
                .inst_size              = sizeof(proto_load_t),
 
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .open                   = mod_open,
index f9253823754c1ed5e57c6ce93ecaa8ec8b0b1496..f5363df40f725ed616f59f72f2c9d33d604fb5e1 100644 (file)
@@ -336,52 +336,13 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_load_step_t       *inst = talloc_get_type_abort(mctx->mi->data, proto_load_step_t);
-       CONF_SECTION            *conf = mctx->mi->conf;
-       module_instance_t const *mi = mctx->mi;
-
-       inst->parent = talloc_get_type_abort(mi->parent->data, proto_load_t);
-       inst->cs = conf;
-
-       FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, >=, 10);
-       FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, <, 400000);
-
-       FR_INTEGER_BOUND_CHECK("step", inst->load.step, >=, 1);
-       FR_INTEGER_BOUND_CHECK("step", inst->load.step, <, 100000);
-
-       if (inst->load.max_pps > 0) FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, >, inst->load.start_pps);
-       FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, <, 100000);
-
-       FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, >=, fr_time_delta_from_sec(1));
-       FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, <, fr_time_delta_from_sec(10000));
-
-
-       FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, >=, 1);
-       FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, <, 1000);
-
-       FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, >=, 1);
-       FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, <, 100000);
-
-       return 0;
-}
-
-static fr_client_t *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
-{
-       proto_load_step_t const       *inst = talloc_get_type_abort_const(li->app_io_instance, proto_load_step_t);
-
-       return inst->client;
-}
-
-
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_load_step_t       *inst = talloc_get_type_abort(mctx->mi->data, proto_load_step_t);
        CONF_SECTION            *conf = mctx->mi->conf;
        fr_client_t             *client;
        fr_pair_t               *vp;
+       module_instance_t const *mi = mctx->mi;
 
        fr_pair_list_init(&inst->pair_list);
        inst->client = client = talloc_zero(inst, fr_client_t);
@@ -418,9 +379,38 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        vp = fr_pair_find_by_da(&inst->pair_list, NULL, inst->parent->attr_packet_type);
        if (vp) inst->code = vp->vp_uint32;
 
+       inst->parent = talloc_get_type_abort(mi->parent->data, proto_load_t);
+       inst->cs = conf;
+
+       FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, >=, 10);
+       FR_INTEGER_BOUND_CHECK("start_pps", inst->load.start_pps, <, 400000);
+
+       FR_INTEGER_BOUND_CHECK("step", inst->load.step, >=, 1);
+       FR_INTEGER_BOUND_CHECK("step", inst->load.step, <, 100000);
+
+       if (inst->load.max_pps > 0) FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, >, inst->load.start_pps);
+       FR_INTEGER_BOUND_CHECK("max_pps", inst->load.max_pps, <, 100000);
+
+       FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, >=, fr_time_delta_from_sec(1));
+       FR_TIME_DELTA_BOUND_CHECK("duration", inst->load.duration, <, fr_time_delta_from_sec(10000));
+
+
+       FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, >=, 1);
+       FR_INTEGER_BOUND_CHECK("parallel", inst->load.parallel, <, 1000);
+
+       FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, >=, 1);
+       FR_INTEGER_BOUND_CHECK("max_backlog", inst->load.milliseconds, <, 100000);
+
        return 0;
 }
 
+static fr_client_t *mod_client_find(fr_listen_t *li, UNUSED fr_ipaddr_t const *ipaddr, UNUSED int ipproto)
+{
+       proto_load_step_t const       *inst = talloc_get_type_abort_const(li->app_io_instance, proto_load_step_t);
+
+       return inst->client;
+}
+
 fr_app_io_t proto_load_step = {
        .common = {
                .magic                  = MODULE_MAGIC_INIT,
@@ -428,7 +418,6 @@ fr_app_io_t proto_load_step = {
                .config                 = load_listen_config,
                .inst_size              = sizeof(proto_load_step_t),
                .thread_inst_size       = sizeof(proto_load_step_thread_t),
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .default_message_size   = 4096,
index dfbddfd7bad07f9f7054eefac767a10aa698aeb6..488f1f362cff348c3c9c8b9aae3086e773a952a3 100644 (file)
@@ -415,9 +415,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
 {
        proto_radius_t  *inst = talloc_get_type_abort(instance, proto_radius_t);
 
-       inst->io.app = &proto_radius;
-       inst->io.app_instance = instance;
-
        /*
         *      io.app_io should already be set
         */
@@ -442,49 +439,6 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
         */
        if (!inst->io.submodule) return 0;
 
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_radius_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_t);
-
-       /*
-        *      Ensure that the server CONF_SECTION is always set.
-        */
-       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
-
-       /*
-        *      No IO module, it's an empty listener.
-        */
-       if (!inst->io.submodule) return 0;
-
        /*
         *      These timers are usually protocol specific.
         */
@@ -506,6 +460,25 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        }
 #endif
 
+       /*
+        *      Ensure that the server CONF_SECTION is always set.
+        */
+       inst->io.server_cs = cf_item_to_section(cf_parent(mctx->mi->conf));
+
+       /*
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
+        */
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
        /*
         *      Tell the master handler about the main protocol instance.
         */
@@ -518,9 +491,9 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      Instantiate the master io submodule
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 /** Get the authentication vector.
@@ -577,7 +550,6 @@ fr_app_t proto_radius = {
                .inst_size              = sizeof(proto_radius_t),
                .onload                 = mod_load,
                .unload                 = mod_unload,
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_radius,
index 70713aefc1e7cbcb05d7aeeb231daf284d8bf876..fe357e11335dc8061d7e17599ba75d80510656e2 100644 (file)
@@ -430,8 +430,7 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
-
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_radius_tcp_t      *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_tcp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -667,7 +666,7 @@ fr_app_io_t proto_radius_tcp = {
                .config                 = tcp_listen_config,
                .inst_size              = sizeof(proto_radius_tcp_t),
                .thread_inst_size       = sizeof(proto_radius_tcp_thread_t),
-               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate,
        },
        .default_message_size   = 4096,
 
index 4f70102d6b78cd9118e6e58b1268028a781db936..a7f948ba9a93856895fbb694b26e45e912e3caf6 100644 (file)
@@ -70,7 +70,7 @@ typedef struct {
        bool                            dynamic_clients;        //!< whether we have dynamic clients
        bool                            dedup_authenticator;    //!< dedup using the request authenticator
 
-       fr_client_list_t                        *clients;               //!< local clients
+       fr_client_list_t                *clients;               //!< local clients
 
        fr_trie_t                       *trie;                  //!< for parsed networks
        fr_ipaddr_t                     *allow;                 //!< allowed networks for dynamic clients
@@ -434,7 +434,7 @@ static char const *mod_name(fr_listen_t *li)
 }
 
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_radius_udp_t      *inst = talloc_get_type_abort(mctx->mi->data, proto_radius_udp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -547,7 +547,7 @@ fr_app_io_t proto_radius_udp = {
                .config                 = udp_listen_config,
                .inst_size              = sizeof(proto_radius_udp_t),
                .thread_inst_size       = sizeof(proto_radius_udp_thread_t),
-               .bootstrap              = mod_bootstrap
+               .instantiate            = mod_instantiate
        },
        .default_message_size   = 4096,
        .track_duplicates       = true,
index 8acae229e6a14e9e31e4313483868ccbe3c76a46..bec40e3e91707e47927f73ce934ee6cfad04d656 100644 (file)
@@ -452,44 +452,6 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_tacacs_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_tacacs_t);
 
-       /*
-        *      No IO module, it's an empty listener.
-        */
-       if (!inst->io.submodule) return 0;
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_tacacs_t          *inst = talloc_get_type_abort(mctx->mi->data, proto_tacacs_t);
-
        /*
         *      Ensure that the server CONF_SECTION is always set.
         */
@@ -523,9 +485,23 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
+        */
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 static int mod_load(void)
@@ -552,7 +528,6 @@ fr_app_t proto_tacacs = {
 
                .onload                 = mod_load,
                .unload                 = mod_unload,
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_tacacs,
index f02442e3f5e710c4611524593e89d5d7bbbe42ca..c0d4caf9d655b0cf0896a2620dd6f50ff6fed0ab 100644 (file)
@@ -398,7 +398,7 @@ static char const *mod_name(fr_listen_t *li)
        return thread->name;
 }
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_tacacs_tcp_t      *inst = talloc_get_type_abort(mctx->mi->data, proto_tacacs_tcp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -507,7 +507,7 @@ fr_app_io_t proto_tacacs_tcp = {
                .config                 = tcp_listen_config,
                .inst_size              = sizeof(proto_tacacs_tcp_t),
                .thread_inst_size       = sizeof(proto_tacacs_tcp_thread_t),
-               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate,
        },
        .default_message_size   = 4096,
        .track_duplicates       = false,
index 6a775dff662378b03921f555d4afe34bca8f2867..086e16264fa82099dec9701a8649187a95f75fc1 100644 (file)
@@ -313,44 +313,6 @@ static int mod_open(void *instance, fr_schedule_t *sc, UNUSED CONF_SECTION *conf
 static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_vmps_t            *inst = talloc_get_type_abort(mctx->mi->data, proto_vmps_t);
-
-       /*
-        *      No IO module, it's an empty listener.
-        */
-       if (!inst->io.submodule) return 0;
-
-       /*
-        *      These configuration items are not printed by default,
-        *      because normal people shouldn't be touching them.
-        */
-       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
-
-       if (!inst->num_messages) inst->num_messages = 256;
-
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
-       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
-
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
-       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
-
-       /*
-        *      Instantiate the master io submodule
-        */
-       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
-}
-
-
-/** Bootstrap the application
- *
- * Bootstrap I/O and type submodules.
- *
- * @return
- *     - 0 on success.
- *     - -1 on failure.
- */
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
-{
-       proto_vmps_t            *inst = talloc_get_type_abort(mctx->mi->data, proto_vmps_t);
        CONF_SECTION            *conf = mctx->mi->conf;
 
        /*
@@ -387,9 +349,23 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->io.mi = mctx->mi;
 
        /*
-        *      Bootstrap the master IO handler.
+        *      These configuration items are not printed by default,
+        *      because normal people shouldn't be touching them.
         */
-       return fr_master_app_io.common.bootstrap(MODULE_INST_CTX(inst->io.mi));
+       if (!inst->max_packet_size && inst->io.app_io) inst->max_packet_size = inst->io.app_io->default_message_size;
+
+       if (!inst->num_messages) inst->num_messages = 256;
+
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, >=, 32);
+       FR_INTEGER_BOUND_CHECK("num_messages", inst->num_messages, <=, 65535);
+
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, >=, 1024);
+       FR_INTEGER_BOUND_CHECK("max_packet_size", inst->max_packet_size, <=, 65535);
+
+       /*
+        *      Instantiate the master io submodule
+        */
+       return fr_master_app_io.common.instantiate(MODULE_INST_CTX(inst->io.mi));
 }
 
 static int mod_load(void)
@@ -416,7 +392,6 @@ fr_app_t proto_vmps = {
 
                .onload                 = mod_load,
                .unload                 = mod_unload,
-               .bootstrap              = mod_bootstrap,
                .instantiate            = mod_instantiate
        },
        .dict                   = &dict_vmps,
index 40986a5e1eabb02d8fa638551500024ab4d4b965..e31a9e7d63ad75b2d70749ea471adcc88ddac238 100644 (file)
@@ -388,7 +388,7 @@ static int mod_track_compare(UNUSED void const *instance, UNUSED void *thread_in
        return (a->opcode < b->opcode) - (a->opcode > b->opcode);
 }
 
-static int mod_bootstrap(module_inst_ctx_t const *mctx)
+static int mod_instantiate(module_inst_ctx_t const *mctx)
 {
        proto_vmps_udp_t        *inst = talloc_get_type_abort(mctx->mi->data, proto_vmps_udp_t);
        CONF_SECTION            *conf = mctx->mi->conf;
@@ -510,7 +510,7 @@ fr_app_io_t proto_vmps_udp = {
                .config                 = udp_listen_config,
                .inst_size              = sizeof(proto_vmps_udp_t),
                .thread_inst_size       = sizeof(proto_vmps_udp_thread_t),
-               .bootstrap              = mod_bootstrap,
+               .instantiate            = mod_instantiate,
        },
        .default_message_size   = 4096,
        .track_duplicates       = true,