bool cacheHit{false};
bool staleCacheHit{false};
bool tracingEnabled{false}; // Whether or not Open Telemetry tracing is enabled for this query
- bool tracingPastProcessRules{false}; // Whether processRules has been called for the query, used to determine if we can trace
+ bool rulesAppliedToQuery{false}; // Whether applyRulesToQuery has been called for the query, used to determine if we need to trace
+ struct rulesAppliedToQuerySetter
+ {
+ rulesAppliedToQuerySetter(bool& pastProcessRules) :
+ d_rulesAppliedToQuery(pastProcessRules)
+ {
+ d_rulesAppliedToQuery = false;
+ }
+ ~rulesAppliedToQuerySetter()
+ {
+ d_rulesAppliedToQuery = true;
+ }
+
+ private:
+ bool& d_rulesAppliedToQuery;
+ };
};
struct IDState
static bool applyRulesToQuery(DNSQuestion& dnsQuestion, const timespec& now)
{
+ InternalQueryState::rulesAppliedToQuerySetter tpprs(dnsQuestion.ids.rulesAppliedToQuery); // Ensure IDS knows we are past the rules processing when we exit this function
auto closer = dnsQuestion.ids.getCloser("applyRulesToQuery");
if (g_rings.shouldRecordQueries()) {
g_rings.insertQuery(now, dnsQuestion.ids.origRemote, dnsQuestion.ids.qname, dnsQuestion.ids.qtype, dnsQuestion.getData().size(), *dnsQuestion.getHeader(), dnsQuestion.getProtocol());
updateBlockStats();
setRCode(RCode::NXDomain);
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
case DNSAction::Action::Refused:
updateBlockStats();
setRCode(RCode::Refused);
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
case DNSAction::Action::Truncate:
header.ad = false;
return true;
});
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
}
else {
header.rd = false;
return true;
});
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
case DNSAction::Action::SetTag: {
if (!got->second.tagSettings) {
default:
updateBlockStats();
vinfolog("Query from %s dropped because of dynamic block", dnsQuestion.ids.origRemote.toStringWithPort());
- dnsQuestion.ids.tracingPastProcessRules = true;
return false;
}
}
updateBlockStats();
setRCode(RCode::NXDomain);
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
case DNSAction::Action::Refused:
vinfolog("Query from %s for %s refused because of dynamic block", dnsQuestion.ids.origRemote.toStringWithPort(), dnsQuestion.ids.qname.toLogString());
updateBlockStats();
setRCode(RCode::Refused);
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
case DNSAction::Action::Truncate:
if (!dnsQuestion.overTCP()) {
header.ad = false;
return true;
});
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
}
else {
header.rd = false;
return true;
});
- dnsQuestion.ids.tracingPastProcessRules = true;
return true;
case DNSAction::Action::SetTag: {
if (!got->tagSettings) {
default:
updateBlockStats();
vinfolog("Query from %s for %s dropped because of dynamic block", dnsQuestion.ids.origRemote.toStringWithPort(), dnsQuestion.ids.qname.toLogString());
- dnsQuestion.ids.tracingPastProcessRules = true;
return false;
}
}
const auto& chains = dnsdist::configuration::getCurrentRuntimeConfiguration().d_ruleChains;
const auto& queryRules = dnsdist::rules::getRuleChain(chains, dnsdist::rules::RuleChain::Rules);
- auto ret = applyRulesChainToQuery(queryRules, dnsQuestion);
- dnsQuestion.ids.tracingPastProcessRules = true;
- return ret;
+ return applyRulesChainToQuery(queryRules, dnsQuestion);
}
ssize_t udpClientSendRequestToBackend(const std::shared_ptr<DownstreamState>& backend, const int socketDesc, const PacketBuffer& request, bool healthCheck)