{
IDState(): sentTime(true), tempFailureTTL(boost::none) { origDest.sin4.sin_family = 0;}
IDState(const IDState& orig) = delete;
- IDState(IDState&& rhs): subnet(rhs.subnet), origRemote(rhs.origRemote), origDest(rhs.origDest), hopRemote(rhs.hopRemote), hopLocal(rhs.hopLocal), qname(std::move(rhs.qname)), sentTime(rhs.sentTime), dnsCryptQuery(std::move(rhs.dnsCryptQuery)), packetCache(std::move(rhs.packetCache)), qTag(std::move(rhs.qTag)), tempFailureTTL(rhs.tempFailureTTL), cs(rhs.cs), du(std::move(rhs.du)), cacheKey(rhs.cacheKey), cacheKeyNoECS(rhs.cacheKeyNoECS), origFD(rhs.origFD), delayMsec(rhs.delayMsec), qtype(rhs.qtype), qclass(rhs.qclass), origID(rhs.origID), origFlags(rhs.origFlags), cacheFlags(rhs.cacheFlags), protocol(rhs.protocol), ednsAdded(rhs.ednsAdded), ecsAdded(rhs.ecsAdded), skipCache(rhs.skipCache), destHarvested(rhs.destHarvested), dnssecOK(rhs.dnssecOK), useZeroScope(rhs.useZeroScope)
+ IDState(IDState&& rhs): subnet(rhs.subnet), origRemote(rhs.origRemote), origDest(rhs.origDest), hopRemote(rhs.hopRemote), hopLocal(rhs.hopLocal), qname(std::move(rhs.qname)), sentTime(rhs.sentTime), dnsCryptQuery(std::move(rhs.dnsCryptQuery)), packetCache(std::move(rhs.packetCache)), qTag(std::move(rhs.qTag)), tempFailureTTL(rhs.tempFailureTTL), cs(rhs.cs), du(std::move(rhs.du)), cacheKey(rhs.cacheKey), cacheKeyNoECS(rhs.cacheKeyNoECS), cacheKeyUDP(rhs.cacheKeyUDP), origFD(rhs.origFD), delayMsec(rhs.delayMsec), qtype(rhs.qtype), qclass(rhs.qclass), origID(rhs.origID), origFlags(rhs.origFlags), cacheFlags(rhs.cacheFlags), protocol(rhs.protocol), ednsAdded(rhs.ednsAdded), ecsAdded(rhs.ecsAdded), skipCache(rhs.skipCache), destHarvested(rhs.destHarvested), dnssecOK(rhs.dnssecOK), useZeroScope(rhs.useZeroScope)
{
if (rhs.isInUse()) {
throw std::runtime_error("Trying to move an in-use IDState");
du = std::move(rhs.du);
cacheKey = rhs.cacheKey;
cacheKeyNoECS = rhs.cacheKeyNoECS;
+ cacheKeyUDP = rhs.cacheKeyUDP;
origFD = rhs.origFD;
delayMsec = rhs.delayMsec;
#ifdef __SANITIZE_THREAD__
std::atomic<uint32_t> generation{0}; // increased every time a state is used, to be able to detect an ABA issue // 4
uint32_t cacheKey{0}; // 4
uint32_t cacheKeyNoECS{0}; // 4
+ // DoH-only */
+ uint32_t cacheKeyUDP{0}; // 4
int origFD{-1}; // 4
int delayMsec{0};
#ifdef __SANITIZE_THREAD__
*/
zeroScope = false;
}
- // if zeroScope, pass the pre-ECS hash-key and do not pass the subnet to the cache
- dr.packetCache->insert(zeroScope ? dr.cacheKeyNoECS : dr.cacheKey, zeroScope ? boost::none : dr.subnet, dr.cacheFlags, dr.dnssecOK, *dr.qname, dr.qtype, dr.qclass, response, receivedOverUDP, dr.getHeader()->rcode, dr.tempFailureTTL);
+ uint32_t cacheKey = dr.cacheKey;
+ if (dr.protocol == dnsdist::Protocol::DoH && receivedOverUDP) {
+ cacheKey = dr.cacheKeyUDP;
+ }
+ else if (zeroScope) {
+ // if zeroScope, pass the pre-ECS hash-key and do not pass the subnet to the cache
+ cacheKey = dr.cacheKeyNoECS;
+ }
+
+ dr.packetCache->insert(cacheKey, zeroScope ? boost::none : dr.subnet, dr.cacheFlags, dr.dnssecOK, *dr.qname, dr.qtype, dr.qclass, response, receivedOverUDP, dr.getHeader()->rcode, dr.tempFailureTTL);
}
#ifdef HAVE_DNSCRYPT
}
else if (dq.protocol == dnsdist::Protocol::DoH) {
/* do a second-lookup for UDP responses */
- uint32_t udpCacheKey = 0;
/* we need to do a copy to be able to restore the query on a TC=1 cached answer */
PacketBuffer initialQuery(dq.getData());
- if (dq.packetCache->get(dq, dq.getHeader()->id, &udpCacheKey, dq.subnet, dq.dnssecOK, true, allowExpired)) {
+ if (dq.packetCache->get(dq, dq.getHeader()->id, &dq.cacheKeyUDP, dq.subnet, dq.dnssecOK, true, allowExpired)) {
if (dq.getHeader()->tc == 0) {
if (!prepareOutgoingResponse(holders, cs, dq, true)) {
return ProcessQueryResult::Drop;
boost::optional<uint32_t> tempFailureTTL;
uint32_t cacheKeyNoECS{0};
uint32_t cacheKey{0};
+ /* for DoH */
+ uint32_t cacheKeyUDP{0};
const uint16_t qtype;
const uint16_t qclass;
uint16_t ecsPrefixLength;
dr.skipCache = ids.skipCache;
dr.cacheKey = ids.cacheKey;
dr.cacheKeyNoECS = ids.cacheKeyNoECS;
+ dr.cacheKeyUDP = ids.cacheKeyUDP;
dr.dnssecOK = ids.dnssecOK;
dr.tempFailureTTL = ids.tempFailureTTL;
dr.qTag = std::move(ids.qTag);
ids.cacheFlags = dq.cacheFlags;
ids.cacheKey = dq.cacheKey;
ids.cacheKeyNoECS = dq.cacheKeyNoECS;
+ ids.cacheKeyUDP = dq.cacheKeyUDP;
ids.subnet = dq.subnet;
ids.skipCache = dq.skipCache;
ids.packetCache = dq.packetCache;