From 7bb598a04a0d9f0ce2abe15eb597e59b84f712f5 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 2 Mar 2016 13:00:19 +0100 Subject: [PATCH] if you send us EDNS subnet information we did not ask for, ignore it. Increases cache hitrate for a popular CDN. --- pdns/lwres.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/pdns/lwres.cc b/pdns/lwres.cc index 2d136bfa2..f74e9d70a 100644 --- a/pdns/lwres.cc +++ b/pdns/lwres.cc @@ -67,7 +67,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d pw.getHeader()->id=dns_random(0xffff); string ping; - + bool weWantEDNSSubnet=false; if(EDNS0Level && !doTCP) { DNSPacketWriter::optvect_t opts; if(srcmask) { @@ -76,6 +76,7 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d // cout<<"Adding request mask: "<(); // this is also our return value + weWantEDNSSubnet=true; } pw.addOpt(g_outgoingEDNSBufsize, 0, g_dnssecmode == DNSSECMode::Off ? 0 : EDNSOpts::DNSSECOK, opts); @@ -186,16 +187,17 @@ int asyncresolve(const ComboAddress& ip, const DNSName& domain, int type, bool d if(EDNS0Level > 0 && getEDNSOpts(mdp, &edo)) { lwr->d_haveEDNS = true; - for(const auto& opt : edo.d_options) { - if(opt.first==8) { - EDNSSubnetOpts reso; - if(getEDNSSubnetOptsFromString(opt.second, &reso)) { - // cerr<<"EDNS Subnet response: "<