Commit ad274a49 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2310] set zone's minimum TTL when loader adds the SOA RR.

parent 6ff25a39
......@@ -336,6 +336,17 @@ ZoneDataUpdater::addRdataSet(const Name& name, const RRType& rrtype,
// "NSEC signed")
zone_data_.setSigned(true);
}
// If we are adding a new SOA at the origin, update zone's min TTL.
// Note: if the input is broken and contains multiple SOAs, the load
// or update will be rejected higher level. We just always (though
// this should be only once in normal cases) update the TTL.
if (rrset && rrtype == RRType::SOA() && is_origin) {
// Our own validation ensures the RRset is not empty.
zone_data_.setMinTTL(
dynamic_cast<const generic::SOA&>(
rrset->getRdataIterator()->getCurrent()).getMinimum());
}
}
}
......
......@@ -12,13 +12,15 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <dns/name.h>
#include <dns/rrclass.h>
#include <datasrc/memory/zone_data_loader.h>
#include <datasrc/memory/rdataset.h>
#include <datasrc/memory/zone_data.h>
#include <datasrc/memory/zone_data_updater.h>
#include <datasrc/memory/zone_data_loader.h>
#include <util/buffer.h>
#include <dns/name.h>
#include <dns/rrclass.h>
#include "memory_segment_test.h"
......@@ -62,4 +64,13 @@ TEST_F(ZoneDataLoaderTest, loadRRSIGFollowsNothing) {
// Teardown checks for memory segment leaks
}
TEST_F(ZoneDataLoaderTest, zoneMinTTL) {
// This should hold outside of the loader class, but we do double check.
zone_data_ = loadZoneData(mem_sgmt_, zclass_, Name("example.org"),
TEST_DATA_DIR
"/example.org-nsec3-signed.zone");
isc::util::InputBuffer b(zone_data_->getMinTTLData(), sizeof(uint32_t));
EXPECT_EQ(RRTTL(1200), RRTTL(b));
}
}
......@@ -12,6 +12,10 @@
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <datasrc/memory/zone_data_updater.h>
#include <datasrc/memory/rdataset.h>
#include <datasrc/memory/zone_data.h>
#include <testutils/dnsmessage_test.h>
#include <exceptions/exceptions.h>
......@@ -19,10 +23,7 @@
#include <dns/name.h>
#include <dns/rrclass.h>
#include <dns/rrset.h>
#include <datasrc/memory/rdataset.h>
#include <datasrc/memory/zone_data.h>
#include <datasrc/memory/zone_data_updater.h>
#include <dns/rrttl.h>
#include "memory_segment_test.h"
......@@ -86,6 +87,16 @@ getNode(isc::util::MemorySegment& mem_sgmt, const Name& name,
return (node);
}
TEST_F(ZoneDataUpdaterTest, zoneMinTTL) {
// If we add SOA, zone's min TTL will be updated.
updater_->add(textToRRset(
"example.org. 3600 IN SOA . . 0 0 0 0 1200",
zclass_, zname_),
ConstRRsetPtr());
isc::util::InputBuffer b(zone_data_->getMinTTLData(), sizeof(uint32_t));
EXPECT_EQ(RRTTL(1200), RRTTL(b));
}
TEST_F(ZoneDataUpdaterTest, rrsigOnly) {
// RRSIG that doesn't have covered RRset can be added. The resulting
// rdataset won't have "normal" RDATA but sig RDATA.
......
Supports Markdown
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