Skip to content

Commit

Permalink
with this, EDNS Client Subnet becomes compatible with the packet cach…
Browse files Browse the repository at this point in the history
…e, using the existing variable answer facility.

(cherry picked from commit 8bec43b)
  • Loading branch information
ahupowerdns authored and rgacogne committed Jul 3, 2017
1 parent 66f894b commit 2325010
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion pdns/recursor_cache.cc
Expand Up @@ -31,7 +31,7 @@ unsigned int MemRecursorCache::bytes()
} }


// returns -1 for no hits // returns -1 for no hits
int MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vector<DNSRecord>* res, const ComboAddress& who, vector<std::shared_ptr<RRSIGRecordContent>>* signatures) int MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vector<DNSRecord>* res, const ComboAddress& who, vector<std::shared_ptr<RRSIGRecordContent>>* signatures, bool* variable)
{ {
unsigned int ttd=0; unsigned int ttd=0;
// cerr<<"looking up "<< qname<<"|"+qt.getName()<<"\n"; // cerr<<"looking up "<< qname<<"|"+qt.getName()<<"\n";
Expand All @@ -54,6 +54,9 @@ int MemRecursorCache::get(time_t now, const DNSName &qname, const QType& qt, vec
(qt.getCode()==QType::ADDR && (i->d_qtype == QType::A || i->d_qtype == QType::AAAA) )) (qt.getCode()==QType::ADDR && (i->d_qtype == QType::A || i->d_qtype == QType::AAAA) ))
&& (i->d_netmask.empty() || i->d_netmask.match(who)) && (i->d_netmask.empty() || i->d_netmask.match(who))
) { ) {
if(variable && !i->d_netmask.empty()) {
*variable=true;
}


ttd = i->d_ttd; ttd = i->d_ttd;


Expand Down
2 changes: 1 addition & 1 deletion pdns/recursor_cache.hh
Expand Up @@ -53,7 +53,7 @@ public:
} }
unsigned int size(); unsigned int size();
unsigned int bytes(); unsigned int bytes();
int get(time_t, const DNSName &qname, const QType& qt, vector<DNSRecord>* res, const ComboAddress& who, vector<std::shared_ptr<RRSIGRecordContent>>* signatures=0); int get(time_t, const DNSName &qname, const QType& qt, vector<DNSRecord>* res, const ComboAddress& who, vector<std::shared_ptr<RRSIGRecordContent>>* signatures=0, bool* variable=0);


void replace(time_t, const DNSName &qname, const QType& qt, const vector<DNSRecord>& content, const vector<shared_ptr<RRSIGRecordContent>>& signatures, bool auth, boost::optional<Netmask> ednsmask=boost::optional<Netmask>()); void replace(time_t, const DNSName &qname, const QType& qt, const vector<DNSRecord>& content, const vector<shared_ptr<RRSIGRecordContent>>& signatures, bool auth, boost::optional<Netmask> ednsmask=boost::optional<Netmask>());
void doPrune(void); void doPrune(void);
Expand Down
4 changes: 2 additions & 2 deletions pdns/syncres.cc
Expand Up @@ -713,7 +713,7 @@ bool SyncRes::doCNAMECacheCheck(const DNSName &qname, const QType &qtype, vector
LOG(prefix<<qname<<": Looking for CNAME cache hit of '"<<qname<<"|CNAME"<<"'"<<endl); LOG(prefix<<qname<<": Looking for CNAME cache hit of '"<<qname<<"|CNAME"<<"'"<<endl);
vector<DNSRecord> cset; vector<DNSRecord> cset;
vector<std::shared_ptr<RRSIGRecordContent>> signatures; vector<std::shared_ptr<RRSIGRecordContent>> signatures;
if(t_RC->get(d_now.tv_sec, qname,QType(QType::CNAME), &cset, d_requestor, &signatures) > 0) { if(t_RC->get(d_now.tv_sec, qname,QType(QType::CNAME), &cset, d_requestor, &signatures, &d_wasVariable) > 0) {


for(auto j=cset.cbegin() ; j != cset.cend() ; ++j) { for(auto j=cset.cbegin() ; j != cset.cend() ; ++j) {
if(j->d_ttl>(unsigned int) d_now.tv_sec) { if(j->d_ttl>(unsigned int) d_now.tv_sec) {
Expand Down Expand Up @@ -842,7 +842,7 @@ bool SyncRes::doCacheCheck(const DNSName &qname, const QType &qtype, vector<DNSR
bool found=false, expired=false; bool found=false, expired=false;
vector<std::shared_ptr<RRSIGRecordContent>> signatures; vector<std::shared_ptr<RRSIGRecordContent>> signatures;
uint32_t ttl=0; uint32_t ttl=0;
if(t_RC->get(d_now.tv_sec, sqname, sqt, &cset, d_requestor, d_doDNSSEC ? &signatures : 0) > 0) { if(t_RC->get(d_now.tv_sec, sqname, sqt, &cset, d_requestor, d_doDNSSEC ? &signatures : 0, &d_wasVariable) > 0) {
LOG(prefix<<sqname<<": Found cache hit for "<<sqt.getName()<<": "); LOG(prefix<<sqname<<": Found cache hit for "<<sqt.getName()<<": ");
for(auto j=cset.cbegin() ; j != cset.cend() ; ++j) { for(auto j=cset.cbegin() ; j != cset.cend() ; ++j) {
LOG(j->d_content->getZoneRepresentation()); LOG(j->d_content->getZoneRepresentation());
Expand Down

0 comments on commit 2325010

Please sign in to comment.