static bool g_gettagNeedsEDNSOptions{false};
static time_t g_statisticsInterval;
static bool g_useIncomingECS;
+static bool g_useKernelTimestamp;
std::atomic<uint32_t> g_maxCacheEntries, g_maxPacketCacheEntries;
#ifdef NOD_ENABLED
static bool g_nodEnabled;
boost::uuids::uuid d_uuid;
string d_requestorId;
string d_deviceId;
+ struct timeval d_kernelTimestamp{0,0};
#endif
std::string d_query;
std::vector<std::string> d_policyTags;
pbMessage->setAppliedPolicyType(appliedPolicy.d_type);
}
pbMessage->setPolicyTags(dc->d_policyTags);
- pbMessage->setQueryTime(dc->d_now.tv_sec, dc->d_now.tv_usec);
+ if (g_useKernelTimestamp && dc->d_kernelTimestamp.tv_sec) {
+ pbMessage->setQueryTime(dc->d_kernelTimestamp.tv_sec, dc->d_kernelTimestamp.tv_usec);
+ }
+ else {
+ pbMessage->setQueryTime(dc->d_now.tv_sec, dc->d_now.tv_usec);
+ }
pbMessage->setRequestorId(dq.requestorId);
pbMessage->setDeviceId(dq.deviceId);
#ifdef NOD_ENABLED
static string* doProcessUDPQuestion(const std::string& question, const ComboAddress& fromaddr, const ComboAddress& destaddr, struct timeval tv, int fd)
{
gettimeofday(&g_now, 0);
- struct timeval diff = g_now - tv;
- double delta=(diff.tv_sec*1000 + diff.tv_usec/1000.0);
+ if (tv.tv_sec) {
+ struct timeval diff = g_now - tv;
+ double delta=(diff.tv_sec*1000 + diff.tv_usec/1000.0);
- if(tv.tv_sec && delta > 1000.0) {
- g_stats.tooOldDrops++;
- return 0;
+ if(delta > 1000.0) {
+ g_stats.tooOldDrops++;
+ return nullptr;
+ }
}
++g_stats.qcounter;
const ComboAddress& requestor = requestorNM.getMaskedNetwork();
pbMessage->update(uniqueId, &requestor, &destination, false, dh->id);
pbMessage->setEDNSSubnet(ednssubnet.source, ednssubnet.source.isIpv4() ? luaconfsLocal->protobufMaskV4 : luaconfsLocal->protobufMaskV6);
- pbMessage->setQueryTime(g_now.tv_sec, g_now.tv_usec);
+ if (g_useKernelTimestamp && tv.tv_sec) {
+ pbMessage->setQueryTime(tv.tv_sec, tv.tv_usec);
+ }
+ else {
+ pbMessage->setQueryTime(g_now.tv_sec, g_now.tv_usec);
+ }
pbMessage->setRequestorId(requestorId);
pbMessage->setDeviceId(deviceId);
protobufLogResponse(*pbMessage);
}
dc->d_requestorId = requestorId;
dc->d_deviceId = deviceId;
+ dc->d_kernelTimestamp = tv;
#endif
MT->makeThread(startDoResolve, (void*) dc.release()); // deletes dc
g_tcpMaxQueriesPerConn=::arg().asNum("max-tcp-queries-per-connection");
s_maxUDPQueriesPerRound=::arg().asNum("max-udp-queries-per-round");
+ g_useKernelTimestamp = ::arg().mustDo("protobuf-use-kernel-timestamp");
+
blacklistStats(StatComponent::API, ::arg()["stats-api-blacklist"]);
blacklistStats(StatComponent::Carbon, ::arg()["stats-carbon-blacklist"]);
blacklistStats(StatComponent::RecControl, ::arg()["stats-rec-control-blacklist"]);
::arg().set("max-total-msec", "Maximum total wall-clock time per query in milliseconds, 0 for unlimited")="7000";
::arg().set("max-recursion-depth", "Maximum number of internal recursion calls per query, 0 for unlimited")="40";
::arg().set("max-udp-queries-per-round", "Maximum number of UDP queries processed per recvmsg() round, before returning back to normal processing")="10000";
+ ::arg().set("protobuf-use-kernel-timestamp", "Compute the latency of queries in protobuf messages by using the timestamp set by the kernel when the query was received (when available)")="";
::arg().set("include-dir","Include *.conf files from this directory")="";
::arg().set("security-poll-suffix","Domain name from which to query security update notifications")="secpoll.powerdns.com.";