mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-11 06:19:59 -04:00
rename ns_pluginregister_ctx_t into ns_pluginctx_t
The type `ns_pluginregister_ctx_t` was initially added to pass plugin contextual data when the plugin is registered, but this is also now passed into `plugin_check`. Furthermore, those various data are not specific to the registration in particular. Rename the type into `ns_pluginctx_t` for clarity.
This commit is contained in:
parent
fe717ed910
commit
62002cfa9c
10 changed files with 35 additions and 37 deletions
|
|
@ -5422,7 +5422,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
|
||||
if (plugin_list != NULL) {
|
||||
ns_hook_data_t hookdata = {
|
||||
.pluginregister_ctx = { .source = NS_HOOKSOURCE_VIEW }
|
||||
.pluginctx = { .source = NS_HOOKSOURCE_VIEW }
|
||||
};
|
||||
|
||||
INSIST(view->hooktable == NULL);
|
||||
|
|
|
|||
|
|
@ -2130,9 +2130,8 @@ named_zone_loadplugins(dns_zone_t *zone, const cfg_obj_t *config,
|
|||
|
||||
if (tpluginlist != NULL || zpluginlist != NULL) {
|
||||
ns_hook_data_t hookdata = {
|
||||
.pluginregister_ctx = { .source = NS_HOOKSOURCE_ZONE,
|
||||
.origin = dns_zone_getorigin(
|
||||
zone) }
|
||||
.pluginctx = { .source = NS_HOOKSOURCE_ZONE,
|
||||
.origin = dns_zone_getorigin(zone) }
|
||||
};
|
||||
isc_mem_t *zmctx = dns_zone_getmctx(zone);
|
||||
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ cleanup:
|
|||
isc_result_t
|
||||
plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginregister_ctx_t *ctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
|
||||
void **instp) {
|
||||
filter_instance_t *inst = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
|
@ -366,7 +366,7 @@ cleanup:
|
|||
isc_result_t
|
||||
plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
|
||||
const ns_pluginregister_ctx_t *ctx ISC_ATTR_UNUSED) {
|
||||
const ns_pluginctx_t *ctx ISC_ATTR_UNUSED) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *param_obj = NULL;
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ cleanup:
|
|||
isc_result_t
|
||||
plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginregister_ctx_t *ctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
|
||||
void **instp) {
|
||||
filter_instance_t *inst = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
|
@ -370,7 +370,7 @@ cleanup:
|
|||
isc_result_t
|
||||
plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
|
||||
const ns_pluginregister_ctx_t *ctx ISC_ATTR_UNUSED) {
|
||||
const ns_pluginctx_t *ctx ISC_ATTR_UNUSED) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *param_obj = NULL;
|
||||
|
|
|
|||
|
|
@ -601,8 +601,8 @@ cleanup:
|
|||
|
||||
isc_result_t
|
||||
plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
|
||||
unsigned long cfgline, isc_mem_t *mctx, void *actx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginregister_ctx_t *ctx,
|
||||
unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
|
||||
void **instp) {
|
||||
synthrecord_t *inst = NULL;
|
||||
ns_hook_t hook;
|
||||
|
|
@ -610,7 +610,7 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
|
|||
|
||||
REQUIRE(cfg);
|
||||
REQUIRE(mctx);
|
||||
REQUIRE(actx);
|
||||
REQUIRE(aclctx);
|
||||
REQUIRE(hooktable);
|
||||
REQUIRE(instp && *instp == NULL);
|
||||
|
||||
|
|
@ -625,7 +625,7 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
|
|||
isc_mem_attach(mctx, &inst->mctx);
|
||||
result = ISC_R_SUCCESS;
|
||||
result = synthrecord_parseconfig(inst, parameters, cfg, cfgfile,
|
||||
cfgline, actx, ctx->origin);
|
||||
cfgline, aclctx, ctx->origin);
|
||||
|
||||
hook = (ns_hook_t){ .action = synthrecord_entry, .action_data = inst };
|
||||
ns_hook_add(hooktable, mctx, NS_QUERY_NXDOMAIN_BEGIN, &hook);
|
||||
|
|
@ -641,8 +641,8 @@ plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
|
|||
|
||||
isc_result_t
|
||||
plugin_check(const char *parameters, const void *cfg, const char *cfgfile,
|
||||
unsigned long cfgline, isc_mem_t *mctx, void *actx,
|
||||
const ns_pluginregister_ctx_t *ctx) {
|
||||
unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
|
||||
const ns_pluginctx_t *ctx) {
|
||||
isc_result_t result;
|
||||
synthrecord_t *inst = NULL;
|
||||
const dns_name_t *zname = (ctx == NULL) ? NULL : ctx->origin;
|
||||
|
|
@ -660,7 +660,7 @@ plugin_check(const char *parameters, const void *cfg, const char *cfgfile,
|
|||
|
||||
isc_mem_attach(mctx, &inst->mctx);
|
||||
result = synthrecord_parseconfig(inst, parameters, cfg, cfgfile,
|
||||
cfgline, actx, zname);
|
||||
cfgline, aclctx, zname);
|
||||
plugin_destroy((void **)&inst);
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ logmsg(const char *fmt, ...) {
|
|||
isc_result_t
|
||||
plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginregister_ctx_t *ctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
|
||||
void **instp) {
|
||||
async_instance_t *inst = NULL;
|
||||
|
||||
|
|
@ -158,7 +158,7 @@ plugin_register(const char *parameters, const void *cfg, const char *cfg_file,
|
|||
isc_result_t
|
||||
plugin_check(const char *parameters, const void *cfg, const char *cfg_file,
|
||||
unsigned long cfg_line, isc_mem_t *mctx, void *aclctx,
|
||||
const ns_pluginregister_ctx_t *ctx) {
|
||||
const ns_pluginctx_t *ctx) {
|
||||
UNUSED(parameters);
|
||||
UNUSED(cfg);
|
||||
UNUSED(cfg_file);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ syncplugin__parse_rcode(const cfg_obj_t *syncplugincfg, uint8_t *rcode) {
|
|||
isc_result_t
|
||||
plugin_register(const char *parameters, const void *cfg, const char *cfgfile,
|
||||
unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginregister_ctx_t *ctx,
|
||||
ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
|
||||
void **instp) {
|
||||
isc_result_t result;
|
||||
cfg_parser_t *parser = NULL;
|
||||
|
|
@ -230,7 +230,7 @@ cleanup:
|
|||
isc_result_t
|
||||
plugin_check(const char *parameters, const void *cfg, const char *cfgfile,
|
||||
unsigned long cfgline, isc_mem_t *mctx, void *aclctx,
|
||||
const ns_pluginregister_ctx_t *ctx) {
|
||||
const ns_pluginctx_t *ctx) {
|
||||
UNUSED(parameters);
|
||||
UNUSED(cfg);
|
||||
UNUSED(cfgfile);
|
||||
|
|
|
|||
|
|
@ -3063,7 +3063,7 @@ struct check_one_plugin_data {
|
|||
cfg_aclconfctx_t *aclctx;
|
||||
ns_hooksource_t source;
|
||||
isc_result_t *check_result;
|
||||
const ns_pluginregister_ctx_t *ctx;
|
||||
const ns_pluginctx_t *ctx;
|
||||
};
|
||||
|
||||
/*%
|
||||
|
|
@ -3110,7 +3110,7 @@ check_plugins(const cfg_obj_t *plugins, const cfg_obj_t *config,
|
|||
cfg_aclconfctx_t *aclctx, const dns_name_t *zname,
|
||||
isc_mem_t *mctx) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
ns_pluginregister_ctx_t ctx = {
|
||||
ns_pluginctx_t ctx = {
|
||||
.source = (zname == NULL) ? NS_HOOKSOURCE_VIEW
|
||||
: NS_HOOKSOURCE_ZONE,
|
||||
.origin = zname,
|
||||
|
|
|
|||
|
|
@ -239,14 +239,13 @@ ns_plugin_register(const char *modpath, const char *parameters, const void *cfg,
|
|||
isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS, ISC_LOG_INFO,
|
||||
"registering plugin '%s'", modpath);
|
||||
|
||||
INSIST(hookdata->pluginregister_ctx.source != NS_HOOKSOURCE_UNDEFINED);
|
||||
INSIST(hookdata->pluginctx.source != NS_HOOKSOURCE_UNDEFINED);
|
||||
|
||||
CHECK(plugin->check_func(parameters, cfg, cfg_file, cfg_line, mctx,
|
||||
aclctx, &hookdata->pluginregister_ctx));
|
||||
aclctx, &hookdata->pluginctx));
|
||||
CHECK(plugin->register_func(parameters, cfg, cfg_file, cfg_line, mctx,
|
||||
aclctx, hookdata->hooktable,
|
||||
&hookdata->pluginregister_ctx,
|
||||
&plugin->inst));
|
||||
&hookdata->pluginctx, &plugin->inst));
|
||||
|
||||
ISC_LIST_APPEND(*hookdata->plugins, plugin, link);
|
||||
|
||||
|
|
@ -261,7 +260,7 @@ cleanup:
|
|||
isc_result_t
|
||||
ns_plugin_check(const char *modpath, const char *parameters, const void *cfg,
|
||||
const char *cfg_file, unsigned long cfg_line, isc_mem_t *mctx,
|
||||
void *aclctx, const ns_pluginregister_ctx_t *ctx) {
|
||||
void *aclctx, const ns_pluginctx_t *ctx) {
|
||||
isc_result_t result;
|
||||
ns_plugin_t *plugin = NULL;
|
||||
|
||||
|
|
|
|||
|
|
@ -369,7 +369,7 @@
|
|||
* instance, bad cookie handling), it would be skipped.
|
||||
*
|
||||
* The `plugin_register` function (defined by each plugin and called
|
||||
* when the plugin is loaded) has a `ns_pluginregister_ctx_t ctx` parameter.
|
||||
* when the plugin is loaded) has a `ns_pluginctx_t ctx` parameter.
|
||||
* This provides to the plugin registering function various contextual
|
||||
* informations about the plugin. For instance, the `ns_hooksource_t source`
|
||||
* property indicates whether the plugin has been loaded at the zone level
|
||||
|
|
@ -378,7 +378,7 @@
|
|||
* loaded, it can also be checked to enforce that the plugin is loaded
|
||||
* only at the zone or view level. Another property is `dns_name_t *origin`
|
||||
* which indicates the zone name to the plugin if it is loaded at the zone level
|
||||
* (this property is NULL otherwise). Note that `ns_pluginregister_ctx_t`
|
||||
* (this property is NULL otherwise). Note that `ns_pluginctx_t`
|
||||
* parameter is defined in a parent stack frame, thus, it is valid only during
|
||||
* `plugin_register` execution.
|
||||
*/
|
||||
|
|
@ -496,18 +496,18 @@ typedef enum {
|
|||
NS_HOOKSOURCE_ZONE
|
||||
} ns_hooksource_t;
|
||||
|
||||
typedef struct ns_pluginregister_ctx {
|
||||
typedef struct ns_pluginctx {
|
||||
/* is this a zone or a view plugin */
|
||||
ns_hooksource_t source;
|
||||
|
||||
/* origin of the zone if this is a zone plugin, NULL otherwise */
|
||||
const dns_name_t *origin;
|
||||
} ns_pluginregister_ctx_t;
|
||||
} ns_pluginctx_t;
|
||||
|
||||
typedef struct ns_hook_data {
|
||||
ns_hooktable_t *hooktable;
|
||||
ns_plugins_t *plugins;
|
||||
ns_pluginregister_ctx_t pluginregister_ctx;
|
||||
ns_hooktable_t *hooktable;
|
||||
ns_plugins_t *plugins;
|
||||
ns_pluginctx_t pluginctx;
|
||||
} ns_hook_data_t;
|
||||
|
||||
/*
|
||||
|
|
@ -526,8 +526,8 @@ typedef struct ns_hook_data {
|
|||
typedef isc_result_t
|
||||
ns_plugin_register_t(const char *parameters, const void *cfg, const char *file,
|
||||
unsigned long line, isc_mem_t *mctx, void *aclctx,
|
||||
ns_hooktable_t *hooktable,
|
||||
const ns_pluginregister_ctx_t *ctx, void **instp);
|
||||
ns_hooktable_t *hooktable, const ns_pluginctx_t *ctx,
|
||||
void **instp);
|
||||
/*%<
|
||||
* Called when registering a new plugin.
|
||||
*
|
||||
|
|
@ -552,7 +552,7 @@ ns_plugin_destroy_t(void **instp);
|
|||
typedef isc_result_t
|
||||
ns_plugin_check_t(const char *parameters, const void *cfg, const char *file,
|
||||
unsigned long line, isc_mem_t *mctx, void *aclctx,
|
||||
const ns_pluginregister_ctx_t *ctx);
|
||||
const ns_pluginctx_t *ctx);
|
||||
/*%<
|
||||
* Check the validity of 'parameters'.
|
||||
*/
|
||||
|
|
@ -619,7 +619,7 @@ ns_plugin_register(const char *modpath, const char *parameters, const void *cfg,
|
|||
isc_result_t
|
||||
ns_plugin_check(const char *modpath, const char *parameters, const void *cfg,
|
||||
const char *cfg_file, unsigned long cfg_line, isc_mem_t *mctx,
|
||||
void *aclctx, const ns_pluginregister_ctx_t *ctx);
|
||||
void *aclctx, const ns_pluginctx_t *ctx);
|
||||
/*%<
|
||||
* Open the plugin module at 'modpath' and check the validity of
|
||||
* 'parameters', logging any errors or warnings found, then
|
||||
|
|
|
|||
Loading…
Reference in a new issue