2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-31 05:55:28 +00:00

[1775] ensure wildcard expanded RRsets are considered of same kind if they are.

in the previous version, if one is returned from find() and the other is
from getAdditional() they are not recognized as of the same kind, because
the underlying pointers are different.
This commit is contained in:
JINMEI Tatuya
2012-03-22 16:35:40 -07:00
parent 475284be04
commit 868ecf0717
3 changed files with 34 additions and 3 deletions

View File

@@ -93,6 +93,11 @@ const DomainNode::Flags WILD = DomainNode::FLAG_USER1;
// realistic to keep this flag update for all affected nodes, and we may
// have to reconsider the mechanism.
const DomainNode::Flags GLUE = DomainNode::FLAG_USER2;
// This flag indicates the node is generated as a result of wildcard
// expansion. In this implementation, this flag can be set only in
// the separate auxiliary tree of ZoneData (see the structure description).
const DomainNode::Flags WILD_EXPANDED = DomainNode::FLAG_USER3;
};
// Separate storage for NSEC3 RRs (and their RRSIGs). It's an STL map
@@ -711,11 +716,22 @@ private:
if (!glue_ok && additional.node_->getFlag(domain_flag::GLUE)) {
continue;
}
const bool wild_expanded =
additional.node_->getFlag(domain_flag::WILD_EXPANDED);
BOOST_FOREACH(const RRType& rrtype, requested_types) {
Domain::const_iterator found =
additional.node_->getData()->find(rrtype);
if (found != additional.node_->getData()->end()) {
result.push_back(found->second);
// If the additional node was generated as a result of
// wildcard expansion, we return the underlying RRset,
// in case the caller has the same RRset but as a result
// of normal find() and needs to know they are of the same
// kind; otherwise we simply use the stored RBNodeRRset.
if (wild_expanded) {
result.push_back(found->second->getUnderlyingRRset());
} else {
result.push_back(found->second);
}
}
}
}
@@ -1475,6 +1491,9 @@ addAdditional(RBNodeRRset* rrset, ZoneData* zone_data,
&name));
}
wildnode->setData(dst_domain);
// Mark the node as "wildcard expanded" so it can be
// distinguished at lookup time.
wildnode->setFlag(domain_flag::WILD_EXPANDED);
}
match_wild = true;
node = wildnode;

View File

@@ -124,7 +124,8 @@ public:
enum Flags {
FLAG_CALLBACK = 1, ///< Callback enabled. See \ref callback
FLAG_USER1 = 0x80000000U, ///< Application specific flag
FLAG_USER2 = 0x40000000U ///< Application specific flag
FLAG_USER2 = 0x40000000U, ///< Application specific flag
FLAG_USER3 = 0x20000000U ///< Application specific flag
};
private:
// Some flag values are expected to be used for internal purposes
@@ -133,7 +134,7 @@ private:
// explicitly defined in \c Flags. This constant represents all
// such flags.
static const uint32_t SETTABLE_FLAGS = (FLAG_CALLBACK | FLAG_USER1 |
FLAG_USER2);
FLAG_USER2 | FLAG_USER3);
public:

View File

@@ -273,6 +273,17 @@ TEST_P(ZoneFinderContextTest, getAdditionalDelegationWithWild) {
rrsetsCheck("ns.wild.example.org. 3600 IN A 192.0.2.15\n"
"ns2.example.org. 3600 IN A 192.0.2.2\n",
result_sets_.begin(), result_sets_.end());
// ns.wild.example.org/A (expanded from a wildcard) should be considered
// the same kind, whether it's a direct result of find() or a result of
// getAdditional().
ctx = finder_->find(Name("ns.wild.example.org"), RRType::A());
EXPECT_EQ(ZoneFinder::SUCCESS, ctx->code);
for (vector<ConstRRsetPtr>::const_iterator it = result_sets_.begin();
it != result_sets_.end(); ++it) {
const bool same_kind = (*it)->isSameKind(*ctx->rrset);
EXPECT_EQ((*it)->getName() == ctx->rrset->getName(), same_kind);
}
}
TEST_P(ZoneFinderContextTest, getAdditionalDelegationForWild) {