From cbc033201863c9f67bde66ca22e4e0d9d1d1a414 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Sat, 16 Jan 2016 12:48:53 +0100 Subject: [PATCH] found with the help of @mischapeters - turns out our recent 'supply local address to lua' improvements triggered us to set the source address on all our replies explicitly, something FreeBSD did not like and was wasteful on Linux. Plus added some logging that would have helped debug this faster. --- pdns/pdns_recursor.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 5fdb7be88..4fff3ef50 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -141,6 +141,7 @@ unsigned int g_maxMThreads; __thread struct timeval g_now; // timestamp, updated (too) frequently typedef map listenSocketsAddresses_t; // is shared across all threads right now listenSocketsAddresses_t g_listenSocketsAddresses; // is shared across all threads right now +set g_fromtosockets; // listen sockets that use 'sendfromto()' mechanism __thread MT_t* MT; // the big MTasker @@ -860,11 +861,13 @@ void startDoResolve(void *p) struct iovec iov; char cbuf[256]; fillMSGHdr(&msgh, &iov, cbuf, 0, (char*)&*packet.begin(), packet.size(), &dc->d_remote); - if(dc->d_local.sin4.sin_family) + if(g_fromtosockets.count(dc->d_socket)) { addCMsgSrcAddr(&msgh, cbuf, &dc->d_local, 0); - else + } else msgh.msg_control=NULL; - sendmsg(dc->d_socket, &msgh, 0); + if(sendmsg(dc->d_socket, &msgh, 0) < 0 && g_logCommonErrors) + L<d_remote.toStringWithPort()<<" failed with: "<insertResponsePacket(string((const char*)&*packet.begin(), packet.size()), (edo.d_Z & EDNSOpts::DNSSECOK), // ponder filtering on dnssecmode here @@ -1168,13 +1171,14 @@ string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fr struct iovec iov; char cbuf[256]; fillMSGHdr(&msgh, &iov, cbuf, 0, (char*)response.c_str(), response.length(), const_cast(&fromaddr)); - if(destaddr.sin4.sin_family) { + if(g_fromtosockets.count(fd)) { addCMsgSrcAddr(&msgh, cbuf, &destaddr, 0); } else { msgh.msg_control=NULL; } - sendmsg(fd, &msgh, 0); + if(sendmsg(fd, &msgh, 0) < 0 && g_logCommonErrors) + L<= sizeof(struct dnsheader)) { struct dnsheader dh; @@ -1413,9 +1417,13 @@ void makeUDPServerSockets() L<