diff options
Diffstat (limited to 'usr.sbin/unbound/edns-subnet/addrtree.c')
-rw-r--r-- | usr.sbin/unbound/edns-subnet/addrtree.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.sbin/unbound/edns-subnet/addrtree.c b/usr.sbin/unbound/edns-subnet/addrtree.c index 180a0227917..ebe71b9706e 100644 --- a/usr.sbin/unbound/edns-subnet/addrtree.c +++ b/usr.sbin/unbound/edns-subnet/addrtree.c @@ -97,6 +97,7 @@ node_create(struct addrtree *tree, void *elem, addrlen_t scope, tree->node_count++; node->scope = scope; node->ttl = ttl; + node->only_match_scope_zero = 0; node->edge[0] = NULL; node->edge[1] = NULL; node->parent_edge = NULL; @@ -155,6 +156,7 @@ clean_node(struct addrtree *tree, struct addrnode *node) if (!node->elem) return; tree->size_bytes -= tree->sizefunc(node->elem); tree->delfunc(tree->env, node->elem); + node->only_match_scope_zero = 0; node->elem = NULL; } @@ -358,7 +360,7 @@ issub(const addrkey_t *s1, addrlen_t l1, void addrtree_insert(struct addrtree *tree, const addrkey_t *addr, addrlen_t sourcemask, addrlen_t scope, void *elem, time_t ttl, - time_t now) + time_t now, int only_match_scope_zero) { struct addrnode *newnode, *node; struct addredge *edge; @@ -381,6 +383,7 @@ addrtree_insert(struct addrtree *tree, const addrkey_t *addr, /* update this node's scope and data */ clean_node(tree, node); node->ttl = ttl; + node->only_match_scope_zero = only_match_scope_zero; node->elem = elem; node->scope = scope; tree->size_bytes += tree->sizefunc(elem); @@ -447,6 +450,7 @@ addrtree_insert(struct addrtree *tree, const addrkey_t *addr, newnode->elem = elem; newnode->scope = scope; newnode->ttl = ttl; + newnode->only_match_scope_zero = only_match_scope_zero; } tree->size_bytes += node_size(tree, newnode); @@ -483,7 +487,8 @@ addrtree_find(struct addrtree *tree, const addrkey_t *addr, /* Current node more specific then question. */ log_assert(depth <= sourcemask); /* does this node have data? if yes, see if we have a match */ - if (node->elem && node->ttl >= now) { + if (node->elem && node->ttl >= now && + !(sourcemask != 0 && node->only_match_scope_zero)) { /* saved at wrong depth */; log_assert(node->scope >= depth); if (depth == node->scope || |