Commit e49c834d authored by Brian Wellington's avatar Brian Wellington
Browse files

Replaced dns_keynode_next by the more correct dns_keytable_findnextkeynode

parent e755d598
......@@ -153,6 +153,29 @@ dns_keytable_findkeynode(dns_keytable_t *keytable, dns_name_t *name,
* Any other result indicates an error.
*/
isc_result_t
dns_keytable_findnextkeynode(dns_keytable_t *keytable, dns_keynode_t *keynode,
dns_keynode_t **nextnodep);
/*
* Search for the next key with the same properties as 'keynode' in
* 'keytable'.
*
* Requires:
*
* 'keytable' is a valid keytable.
*
* 'keynode' is a valid keynode.
*
* nextnodep != NULL && *nextnodep == NULL
*
* Returns:
*
* ISC_R_SUCCESS
* ISC_R_NOTFOUND
*
* Any other result indicates an error.
*/
isc_result_t
dns_keytable_finddeepestmatch(dns_keytable_t *keytable, dns_name_t *name,
dns_name_t *foundname);
......@@ -225,12 +248,6 @@ dns_keynode_key(dns_keynode_t *keynode);
* Get the DST key associated with keynode.
*/
dns_keynode_t *
dns_keynode_next(dns_keynode_t *keynode);
/*
* Get the next keynode in the list.
*/
ISC_LANG_ENDDECLS
#endif /* DNS_KEYTABLE_H */
......@@ -281,6 +281,39 @@ dns_keytable_findkeynode(dns_keytable_t *keytable, dns_name_t *name,
return (result);
}
isc_result_t
dns_keytable_findnextkeynode(dns_keytable_t *keytable, dns_keynode_t *keynode,
dns_keynode_t **nextnodep)
{
isc_result_t result;
dns_keynode_t *knode;
/*
* Search for the next key with the same properties as 'keynode' in
* 'keytable'.
*/
REQUIRE(VALID_KEYTABLE(keytable));
REQUIRE(VALID_KEYNODE(keynode));
REQUIRE(nextnodep != NULL && *nextnodep == NULL);
for (knode = keynode->next; knode != NULL; knode = knode->next) {
if (dst_key_alg(keynode->key) == dst_key_alg(knode->key) &&
dst_key_id(keynode->key) == dst_key_id(knode->key))
break;
}
if (knode != NULL) {
LOCK(&keytable->lock);
keytable->active_nodes++;
UNLOCK(&keytable->lock);
result = ISC_R_SUCCESS;
*nextnodep = knode;
} else
result = ISC_R_NOTFOUND;
return (result);
}
isc_result_t
dns_keytable_finddeepestmatch(dns_keytable_t *keytable, dns_name_t *name,
dns_name_t *foundname)
......@@ -372,15 +405,3 @@ dns_keynode_key(dns_keynode_t *keynode) {
return (keynode->key);
}
dns_keynode_t *
dns_keynode_next(dns_keynode_t *keynode) {
/*
* Get the next keynode in the list.
*/
REQUIRE(VALID_KEYNODE(keynode));
return (keynode->next);
}
......@@ -888,9 +888,18 @@ validate(dns_validator_t *val, isc_boolean_t resume) {
if (result == ISC_R_SUCCESS)
break;
if (val->keynode != NULL) {
val->keynode = dns_keynode_next(val->keynode);
if (val->keynode == NULL)
dns_keynode_t *nextnode = NULL;
result = dns_keytable_findnextkeynode(
val->keytable,
val->keynode,
&nextnode);
dns_keytable_detachkeynode(val->keytable,
&val->keynode);
val->keynode = nextnode;
if (result != ISC_R_SUCCESS) {
val->key = NULL;
break;
}
val->key = dns_keynode_key(val->keynode);
}
else
......@@ -918,7 +927,7 @@ validate(dns_validator_t *val, isc_boolean_t resume) {
else
validator_log(val, ISC_LOG_DEBUG(3),
"verify failure: %s",
dns_result_totext(result));
isc_result_totext(result));
}
INSIST(result == ISC_R_NOMORE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment