Skip to content

Commit 3a36a1c

Browse files
committed
import bindbackend rectify code from master
1 parent 1ee7e22 commit 3a36a1c

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

pdns/backends/bind/bindbackend2.cc

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static string canonic(string ret)
411411
/** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedence matching
412412
This function adds a record to a domain with a certain id.
413413
Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */
414-
void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed)
414+
void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu, const QType &qtype, const string &content, int ttl, int prio, const std::string& hashed, bool *auth)
415415
{
416416
BB2DomainInfo bb2 = stage->id_zone_map[id];
417417
Bind2DNSRecord bdr;
@@ -443,7 +443,9 @@ void Bind2Backend::insert(shared_ptr<State> stage, int id, const string &qnameu,
443443
bdr.nsec3hash = hashed;
444444
// cerr<<"qname '"<<bdr.qname<<"' nsec3hash '"<<hashed<<"' qtype '"<<qtype.getName()<<"'"<<endl;
445445

446-
if (!qtype.getCode()) // Set auth on empty non-terminals
446+
if (auth) // Set auth on empty non-terminals
447+
bdr.auth=*auth;
448+
else
447449
bdr.auth=true;
448450

449451
if(bdr.qtype == QType::MX || bdr.qtype == QType::SRV) {
@@ -597,32 +599,41 @@ void Bind2Backend::doEmptyNonTerminals(shared_ptr<State> stage, int id, bool nse
597599
{
598600
BB2DomainInfo bb2 = stage->id_zone_map[id];
599601

600-
bool doent=true;
601-
set<string> qnames, nonterm;
602-
string qname, shorter, hashed;
602+
bool auth, doent=true;
603+
set<string> qnames;
604+
map<string, bool> nonterm;
605+
string shorter, hashed;
603606

604607
uint32_t maxent = ::arg().asNum("max-ent-entries");
605608

606609
BOOST_FOREACH(const Bind2DNSRecord& bdr, *bb2.d_records)
607-
if (bdr.auth && (bdr.qtype != QType::RRSIG))
608-
qnames.insert(labelReverse(bdr.qname));
610+
qnames.insert(labelReverse(bdr.qname));
609611

610-
BOOST_FOREACH(const string& qname, qnames)
611-
{
612-
shorter=qname;
612+
BOOST_FOREACH(const Bind2DNSRecord& bdr, *bb2.d_records) {
613+
shorter=labelReverse(bdr.qname);
614+
615+
if (!bdr.auth && bdr.qtype == QType::NS)
616+
auth=(!nsec3zone || !ns3pr.d_flags);
617+
else
618+
auth=bdr.auth;
613619

614620
while(chopOff(shorter))
615621
{
616622
if(!qnames.count(shorter))
617623
{
618624
if(!(maxent))
619625
{
620-
L<<Logger::Error<<"Zone '"<<bb2.d_name<<"' has too many empty non terminals."<<endl;
626+
if(!::arg().asNum("max-ent-entries"))
627+
L<<Logger::Error<<"Zone '"<<bb2.d_name<<"' has too many empty non terminals."<<endl;
621628
doent=false;
622629
break;
623630
}
624-
nonterm.insert(shorter);
625-
--maxent;
631+
632+
if (!nonterm.count(shorter)) {
633+
nonterm.insert(pair<string, bool>(shorter, auth));
634+
--maxent;
635+
} else if (auth)
636+
nonterm[shorter]=true;
626637
}
627638
}
628639
if(!doent)
@@ -634,12 +645,13 @@ void Bind2Backend::doEmptyNonTerminals(shared_ptr<State> stage, int id, bool nse
634645
rr.content="";
635646
rr.ttl=0;
636647
rr.priority=0;
637-
BOOST_FOREACH(const string& qname, nonterm)
648+
pair<string, bool> nt;
649+
BOOST_FOREACH(nt, nonterm)
638650
{
639-
rr.qname=qname+"."+bb2.d_name+".";
651+
rr.qname=nt.first+"."+bb2.d_name+".";
640652
if(nsec3zone)
641653
hashed=toLower(toBase32Hex(hashQNameWithSalt(ns3pr.d_iterations, ns3pr.d_salt, rr.qname)));
642-
insert(stage, id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed);
654+
insert(stage, id, rr.qname, rr.qtype, rr.content, rr.ttl, rr.priority, hashed, &nt.second);
643655
}
644656
}
645657

pdns/backends/bind/bindbackend2.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public:
170170
id_zone_map_t id_zone_map;
171171
};
172172

173-
static void insert(shared_ptr<State> stage, int id, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string());
173+
static void insert(shared_ptr<State> stage, int id, const string &qname, const QType &qtype, const string &content, int ttl=300, int prio=25, const std::string& hashed=string(), bool *auth=0);
174174
void rediscover(string *status=0);
175175

176176
bool isMaster(const string &name, const string &ip);

0 commit comments

Comments
 (0)