isc_result_t
named_zone_loadplugins(dns_zone_t *zone, const cfg_obj_t *config,
- const cfg_obj_t *zoptions);
+ const cfg_obj_t *toptions, const cfg_obj_t *zoptions);
/*%<
* Load plugins that should run for this specific zone. Take care of cleaning
* up any pre-existing plugins first, if the zone is re-used.
* \li 'zone' to be a valid zone
* \li 'config' to be a valid named.conf configuration tree
* \li 'zoptions' to be a valid zone configuration tree
+ * \li 'toptions' to be NULL or valid template configuration tree
+ * \li 'zoptions' to be NULL or a valid zone configuration tree
*/
isc_result_t
named_zone_loadplugins(dns_zone_t *zone, const cfg_obj_t *config,
- const cfg_obj_t *zoptions) {
+ const cfg_obj_t *toptions, const cfg_obj_t *zoptions) {
isc_result_t result = ISC_R_SUCCESS;
- const cfg_obj_t *pluginlist = NULL;
+ const cfg_obj_t *zpluginlist = NULL;
+ const cfg_obj_t *tpluginlist = NULL;
/*
* If the zone previously had any loaded plugins, unload them:
/*
* Load zone-specific plugin instances.
*/
+ if (toptions != NULL) {
+ (void)cfg_map_get(toptions, "plugin", &tpluginlist);
+ }
+
if (zoptions != NULL) {
- (void)cfg_map_get(zoptions, "plugin", &pluginlist);
+ (void)cfg_map_get(zoptions, "plugin", &zpluginlist);
}
- if (pluginlist != NULL) {
+ if (tpluginlist != NULL || zpluginlist != NULL) {
ns_hook_data_t hookdata = {};
isc_mem_t *zmctx = dns_zone_getmctx(zone);
ns_plugins_create(zmctx, &hookdata.plugins);
dns_zone_setplugins(zone, hookdata.plugins, ns_plugins_free);
- result = cfg_pluginlist_foreach(config, pluginlist,
+ result = cfg_pluginlist_foreach(config, tpluginlist,
+ named_register_one_plugin,
+ &hookdata);
+ if (result != ISC_R_SUCCESS) {
+ return result;
+ }
+
+ result = cfg_pluginlist_foreach(config, zpluginlist,
named_register_one_plugin,
&hookdata);
}