This lets us get the instance data in all the appropriate trees before running CONF_PARSER callbacks
DEBUG("Failed to find proto_%s_%s", inst->app->name, inst->transport);
return NULL;
}
+
+ if (dl_module_conf_parse(dl_inst) < 0) {
+ TALLOC_FREE(dl_inst);
+ return NULL;
+ }
+
fr_assert(dl_inst != NULL);
} else {
dl_inst = talloc_init_const("nak");
return -1;
}
+ if (dl_module_conf_parse(inst->dynamic_submodule) < 0) {
+ TALLOC_FREE(inst->dynamic_submodule);
+ return -1;
+ }
+
fr_assert(inst->dynamic_submodule != NULL);
/*
*/
cf_data_add(conf, dl_inst, dl_inst->module->dl->name, false);
- if (dl_inst->module->common->config && conf) {
- if ((cf_section_rules_push(conf, dl_inst->module->common->config)) < 0 ||
- (cf_section_parse(dl_inst->data, dl_inst->data, conf) < 0)) {
- cf_log_err(conf, "Failed evaluating configuration for module \"%s\"",
- dl_inst->module->dl->name);
- talloc_free(dl_inst);
- return -1;
- }
- }
-
name2 = cf_section_name2(conf);
if (name2) {
dl_inst->name = talloc_typed_strdup(dl_inst, name2);
return 0;
}
+int dl_module_conf_parse(dl_module_inst_t *dl_inst)
+{
+ if (dl_inst->module->common->config && dl_inst->conf) {
+ if ((cf_section_rules_push(dl_inst->conf, dl_inst->module->common->config)) < 0 ||
+ (cf_section_parse(dl_inst->data, dl_inst->data, dl_inst->conf) < 0)) {
+ cf_log_err(dl_inst->conf, "Failed evaluating configuration for module \"%s\"",
+ dl_inst->module->dl->name);
+ return -1;
+ }
+ }
+ return 0;
+}
+
static int _dl_module_loader_free(dl_module_loader_t *dl_module_l)
{
int ret = 0;
CONF_SECTION *conf, dl_module_inst_t const *parent,
char const *name, dl_module_type_t type);
+int dl_module_conf_parse(dl_module_inst_t *dl_inst);
+
char const *dl_module_search_path(void);
dl_loader_t *dl_loader_from_module_loader(dl_module_loader_t *dl_module_loader);
module_instance_t *mi;
mi = fr_rb_find(module_instance_data_tree,
- &(module_instance_t){
+ &(module_instance_t){
.dl_inst = &(dl_module_inst_t){ .data = UNCONST(void *, data) },
- });
+ });
if (!mi) return NULL;
return talloc_get_type_abort(mi, module_instance_t);
mi->in_data_tree = true;
}
+ /*
+ * Do this after inserting the module instance into the tree
+ */
+ if (dl_module_conf_parse(mi->dl_inst) < 0) {
+ TALLOC_FREE(mi->dl_inst);
+ return -1;
+ }
+
/*
* Bootstrap the module.
* This must be done last so that the
return -1;
}
+ if (dl_module_conf_parse(server->process_module) < 0) {
+ TALLOC_FREE(server->process_module);
+ return -1;
+ }
+
return 0;
}
return -1;
}
+ if (dl_module_conf_parse(listen->proto_module) < 0) {
+ TALLOC_FREE(listen->proto_module);
+ return -1;
+ }
+
return 0;
}
return -1;
}
+ if (dl_module_conf_parse(server->dynamic_client_module) < 0) {
+ TALLOC_FREE(server->dynamic_client_module);
+ return -1;
+ }
+
return 0;
}
return -1;
}
+ if (dl_module_conf_parse(inst->io_submodule) < 0) {
+ TALLOC_FREE(inst->io_submodule);
+ return -1;
+ }
+
/*
* Bootstrap the I/O module
*/
*/
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- proto_control_t *inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ proto_control_t *inst;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
inst = talloc_get_type_abort(parent_inst->data, proto_control_t);
inst->io.transport = name;
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_cron"));
fr_assert(parent_inst);
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet, and set the request->process function
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_detail"));
fr_assert(parent_inst);
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet, and set the request->process function
return -1;
}
+ if (dl_module_conf_parse(inst->work_submodule) < 0) {
+ TALLOC_FREE(inst->work_submodule);
+ return -1;
+ }
+
/*
* Boot strap the work module.
*/
if (inst->work_io->bootstrap && (inst->work_io->bootstrap(inst->work_io_instance,
inst->work_io_conf) < 0)) {
cf_log_err(inst->work_io_conf, "Bootstrap failed for \"%s\"", inst->work_io->name);
+ TALLOC_FREE(inst->work_submodule);
return -1;
}
}
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- proto_dhcpv4_t *inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ proto_dhcpv4_t *inst;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
inst = talloc_get_type_abort(parent_inst->data, proto_dhcpv4_t);
inst->io.transport = name;
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- proto_dhcpv6_t *inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ proto_dhcpv6_t *inst;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
inst = talloc_get_type_abort(parent_inst->data, proto_dhcpv6_t);
inst->io.transport = name;
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- proto_dns_t *inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ proto_dns_t *inst;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
inst = talloc_get_type_abort(parent_inst->data, proto_dns_t);
inst->io.transport = name;
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
parent_inst = cf_data_value(cf_data_find(listen_cs, dl_module_inst_t, "proto_load"));
fr_assert(parent_inst);
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet, and set the request->process function
*/
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- proto_radius_t *inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ proto_radius_t *inst;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
inst->io.app_io_conf = transport_cs;
}
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet
*/
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent, CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- proto_tacacs_t *inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ proto_tacacs_t *inst;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
inst->io.app_io_conf = transport_cs;
}
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet
static int transport_parse(TALLOC_CTX *ctx, void *out, UNUSED void *parent,
CONF_ITEM *ci, UNUSED CONF_PARSER const *rule)
{
- char const *name = cf_pair_value(cf_item_to_pair(ci));
+ char const *name = cf_pair_value(cf_item_to_pair(ci));
dl_module_inst_t *parent_inst;
- proto_vmps_t *inst;
- CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
- CONF_SECTION *transport_cs;
+ proto_vmps_t *inst;
+ CONF_SECTION *listen_cs = cf_item_to_section(cf_parent(ci));
+ CONF_SECTION *transport_cs;
+ dl_module_inst_t *dl_mod_inst;
transport_cs = cf_section_find(listen_cs, name, NULL);
inst = talloc_get_type_abort(parent_inst->data, proto_vmps_t);
inst->io.transport = name;
- return dl_module_instance(ctx, out, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE);
+ if (dl_module_instance(ctx, &dl_mod_inst, transport_cs, parent_inst, name, DL_MODULE_TYPE_SUBMODULE) < 0) return -1;
+ if (dl_module_conf_parse(dl_mod_inst) < 0) {
+ talloc_free(dl_mod_inst);
+ return -1;
+ }
+ *((dl_module_inst_t **)out) = dl_mod_inst;
+
+ return 0;
}
/** Decode the packet