Bug 1407

Summary: Add ECS options check to unbound-checkconf
Product: unbound Reporter: Uladzimir Trehubenka <utrehubenka>
Component: serverAssignee: unbound team <unbound-team>
Status: RESOLVED FIXED    
Severity: minor CC: cathya, wouter
Priority: P5    
Version: 1.6.4   
Hardware: x86_64   
OS: Linux   

Description Uladzimir Trehubenka 2017-08-15 13:08:11 CEST
Add to smallapp/unbound-checkconf.c

include "edns-subnet/subnet-whitelist.h"

/** check ECS configuration */
static void
ecs_conf_checks(struct config_file* cfg)
{
	struct ednssubnet_upstream* upstream = NULL;
	if(!(upstream = upstream_create()))
		fatal_exit("Could not create ednssubnet upstream: out of memory");
        if(!upstream_apply_cfg(upstream, cfg))
		fatal_exit("Could not setup ednssubnet upstream");
	upstream_delete(upstream);
}

/** check configuration for errors */
static void
morechecks(struct config_file* cfg, const char* fname)
{
	...
	localzonechecks(cfg);
	view_and_respipchecks(cfg);
	ecs_conf_checks(cfg); // <------ new added function
}
Comment 1 Wouter Wijngaards 2017-08-22 09:43:44 CEST
Hi Uladzimir,

Thanks for the code, I have adjust it like below and committed it!

Best regards, Wouter


#ifdef CLIENT_SUBNET
/** check ECS configuration */
static void
ecs_conf_checks(struct config_file* cfg)
{
        struct ecs_whitelist* whitelist = NULL;
        if(!(whitelist = ecs_whitelist_create()))
                fatal_exit("Could not create ednssubnet whitelist: out of memory");
        if(!ecs_whitelist_apply_cfg(whitelist, cfg))
                fatal_exit("Could not setup ednssubnet whitelist");
        ecs_whitelist_delete(whitelist);
}
#endif /* CLIENT_SUBNET */