On 12/13/06, Augie Schwer <[EMAIL PROTECTED]> wrote:
Is there a reason why TCP queries are always getting sent to the recursor (if available) for answers instead of checking for an authoritative answer first and then recursing if no authoritative answer was found?
I submitted a ticket for this: http://wiki.powerdns.com/cgi-bin/trac.fcgi/ticket/118 The patch should look something like this; doing a packet cache and backend check before passing along for recursion, but this is pretty rudimentary and probably not totally correct: [EMAIL PROTECTED] pdns]$ svn diff tcpreceiver.cc Index: tcpreceiver.cc =================================================================== --- tcpreceiver.cc (revision 935) +++ tcpreceiver.cc (working copy) @@ -169,32 +169,6 @@ continue; } - - if(packet->d.rd && arg().mustDo("recursor")) { - // now what - // this is a pretty rare event all in all, so we can afford to be slow - - // this code SHOULD attempt to answer from the local cache first! - S.inc("recursing-questions"); - Resolver res; - unsigned int len; - DLOG(L<<"About to hand query to recursor"<<endl); - ServiceTuple st; - st.port=53; - parseService(arg()["recursor"],st); - - char *buffer=res.sendReceive(st.host,st.port,packet->getRaw(),packet->len,&len); - DLOG(L<<"got an answer from recursor: "<<len<<" bytes, "<<(int)buffer<<endl); - if(buffer) { - sendData(buffer,len,fd); - DLOG(L<<"sent out to customer: "<<len<<" bytes"<<endl); - delete buffer; - S.inc("recursing-answers"); - S.inc("tcp-answers"); - } - continue; - } - DNSPacket* cached=new DNSPacket; if(!packet->d.rd && (PC.get(packet, cached))) { // short circuit - does the PacketCache recognize this question? cached->setRemote(&packet->remote); @@ -217,15 +191,41 @@ } reply=s_P->question(packet); // we really need to ask the backend :-) } - - delete packet; - packet = NULL; - if(!reply) // unable to write an answer? + if(!reply){ // unable to write an answer? + delete packet; + packet = NULL; break; + } S.inc("tcp-answers"); sendDelPacket(reply, fd); + + if(packet->d.rd && arg().mustDo("recursor")) { + // now what + // this is a pretty rare event all in all, so we can afford to be slow + + // this code SHOULD attempt to answer from the local cache first! + S.inc("recursing-questions"); + Resolver res; + unsigned int len; + DLOG(L<<"About to hand query to recursor"<<endl); + ServiceTuple st; + st.port=53; + parseService(arg()["recursor"],st); + + char *buffer=res.sendReceive(st.host,st.port,packet->getRaw(),packet->len,&len); + DLOG(L<<"got an answer from recursor: "<<len<<" bytes, "<<(int)buffer<<endl); + delete packet; + if(buffer) { + sendData(buffer,len,fd); + DLOG(L<<"sent out to customer: "<<len<<" bytes"<<endl); + delete buffer; + S.inc("recursing-answers"); + S.inc("tcp-answers"); + } + continue; + } } out: -- Augie Schwer - [EMAIL PROTECTED] - http://schwer.us Key fingerprint = 9815 AE19 AFD1 1FE7 5DEE 2AC3 CB99 2784 27B0 C072 _______________________________________________ Pdns-users mailing list [email protected] http://mailman.powerdns.com/mailman/listinfo/pdns-users
