From: Remi Gacogne Date: Tue, 23 Jan 2024 10:03:50 +0000 (+0100) Subject: dnsdist: Relax file descriptor check for XSK-enabled backends X-Git-Tag: dnsdist-1.9.0-rc1^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cd807ad2f610453cabac0fb9528435e10202547a;p=thirdparty%2Fpdns.git dnsdist: Relax file descriptor check for XSK-enabled backends We cannot guarantee that the response will be coming via XSK, so we need to accept that a response that does not come from the expected socket descriptor. --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index cf3f6129e9..67382a04bb 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -868,7 +868,7 @@ void responderThread(std::shared_ptr dss) continue; } - if (fd != ids->backendFD) { + if (!ids->isXSK() && fd != ids->backendFD) { dss->restoreState(queryId, std::move(*ids)); continue; } @@ -1992,8 +1992,6 @@ bool XskProcessQuery(ClientState& cs, LocalHolders& holders, XskPacket& packet) return false; } else { - const auto& xskInfo = ss->pickWorkerForSending(); - ids.backendFD = xskInfo->workerWaker; assignOutgoingUDPQueryToBackend(ss, dh->id, dq, query, false); auto sourceAddr = ss->pickSourceAddressForSending(); packet.setAddr(sourceAddr, ss->d_config.sourceMACAddr, ss->d_config.remote, ss->d_config.destMACAddr); diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 52019d56e2..4dba2db925 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -995,7 +995,6 @@ public: #ifdef HAVE_XSK void registerXsk(std::vector>& xsks); [[nodiscard]] ComboAddress pickSourceAddressForSending(); - [[nodiscard]] const std::shared_ptr& pickWorkerForSending(); #endif /* HAVE_XSK */ dnsdist::Protocol getProtocol() const diff --git a/pdns/dnsdistdist/dnsdist-backend.cc b/pdns/dnsdistdist/dnsdist-backend.cc index 966b3ff9c2..9c5da43e56 100644 --- a/pdns/dnsdistdist/dnsdist-backend.cc +++ b/pdns/dnsdistdist/dnsdist-backend.cc @@ -885,16 +885,6 @@ void DownstreamState::submitHealthCheckResult(bool initial, bool newResult) return (*addresses)[idx % numberOfAddresses]; } -[[nodiscard]] const std::shared_ptr& DownstreamState::pickWorkerForSending() -{ - auto numberOfWorkers = d_xskInfos.size(); - if (numberOfWorkers == 0) { - throw std::runtime_error("No XSK worker available for sending XSK data to backend " + getNameWithAddr()); - } - size_t idx = dnsdist::getRandomValue(numberOfWorkers); - return d_xskInfos[idx % numberOfWorkers]; -} - void DownstreamState::registerXsk(std::vector>& xsks) { d_xskSockets = xsks; diff --git a/pdns/dnsdistdist/dnsdist-xsk.cc b/pdns/dnsdistdist/dnsdist-xsk.cc index fc77706aa0..058e381908 100644 --- a/pdns/dnsdistdist/dnsdist-xsk.cc +++ b/pdns/dnsdistdist/dnsdist-xsk.cc @@ -42,7 +42,6 @@ void XskResponderThread(std::shared_ptr dss, std::shared_ptrworkerWaker.getHandle(); while (!dss->isStopped()) { poll(pollfds.data(), pollfds.size(), -1); bool needNotify = false; @@ -63,7 +62,6 @@ void XskResponderThread(std::shared_ptr dss, std::shared_ptrgetState(queryId); if (ids) { if (!ids->isXSK()) { - // if (xskFd != ids->backendFD || !ids->isXSK()) { dss->restoreState(queryId, std::move(*ids)); ids = std::nullopt; }