From: Otto Moerbeek Date: Thu, 15 Jan 2026 13:04:06 +0000 (+0100) Subject: rec: cleanup in lwres related code X-Git-Tag: rec-5.5.0-alpha0~4^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=558ee9b4672e9534b48b1154986442cac6b5bdef;p=thirdparty%2Fpdns.git rec: cleanup in lwres related code Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/lwres.cc b/pdns/recursordist/lwres.cc index f0d1da1438..f077446055 100644 --- a/pdns/recursordist/lwres.cc +++ b/pdns/recursordist/lwres.cc @@ -704,7 +704,7 @@ static LWResult::Result asyncresolve(const OptLog& log, const ComboAddress& addr if (!doTCP) { int queryfd; try { - ret = asendto(vpacket.data(), vpacket.size(), 0, address, addressToBindTo, qid, domain, type, subnetOpts, &queryfd, *now); + ret = asendto(vpacket.data(), vpacket.size(), address, addressToBindTo, qid, domain, type, subnetOpts, &queryfd, *now); } catch (const PDNSException& e) { if (addressToBindTo) { @@ -737,7 +737,7 @@ static LWResult::Result asyncresolve(const OptLog& log, const ComboAddress& addr } // sleep until we see an answer to this, interface to mtasker - ret = arecvfrom(buf, 0, address, len, qid, domain, type, queryfd, subnetOpts, *now); + ret = arecvfrom(buf, address, len, qid, domain, type, queryfd, subnetOpts, *now); } else { bool isNew{}; @@ -837,7 +837,10 @@ static LWResult::Result asyncresolve(const OptLog& log, const ComboAddress& addr "onwire", Logging::Loggable(mdp.d_qname)); } // unexpected count has already been done @ pdns_recursor.cc - goto out; + if (!lwr->d_rcode) { + lwr->d_rcode = RCode::ServFail; + } + return LWResult::Result::PermanentError; } lwr->d_records.reserve(mdp.d_answers.size()); @@ -947,7 +950,6 @@ static LWResult::Result asyncresolve(const OptLog& log, const ComboAddress& addr t_Counters.at(rec::Counter::serverParseError)++; -out: if (!lwr->d_rcode) { lwr->d_rcode = RCode::ServFail; } diff --git a/pdns/recursordist/lwres.hh b/pdns/recursordist/lwres.hh index 465b9735af..8467514458 100644 --- a/pdns/recursordist/lwres.hh +++ b/pdns/recursordist/lwres.hh @@ -93,10 +93,10 @@ public: class EDNSSubnetOpts; -LWResult::Result asendto(const void* data, size_t len, int flags, const ComboAddress& toAddress, +LWResult::Result asendto(const void* data, size_t len, const ComboAddress& toAddress, std::optional& localAddress, uint16_t qid, const DNSName& domain, uint16_t qtype, const std::optional& ecs, int* fileDesc, timeval& now); -LWResult::Result arecvfrom(PacketBuffer& packet, int flags, const ComboAddress& fromAddr, size_t& len, uint16_t qid, +LWResult::Result arecvfrom(PacketBuffer& packet, const ComboAddress& fromAddr, size_t& len, uint16_t qid, const DNSName& domain, uint16_t qtype, int fileDesc, const std::optional& ecs, const struct timeval& now); LWResult::Result asyncresolve(const OptLog& log, const ComboAddress& address, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, std::optional& srcmask, const ResolveContext& context, const std::shared_ptr>>& outgoingLoggers, const std::shared_ptr>>& fstrmLoggers, const std::set& exportTypes, LWResult* lwr, bool* chained); diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index 712e42be06..9c526c6f4f 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -283,7 +283,7 @@ unsigned int authWaitTimeMSec(const std::unique_ptr& mtasker) } /* these two functions are used by LWRes */ -LWResult::Result asendto(const void* data, size_t len, int /* flags */, +LWResult::Result asendto(const void* data, size_t len, const ComboAddress& toAddress, std::optional& localAddress, uint16_t qid, const DNSName& domain, uint16_t qtype, const std::optional& ecs, int* fileDesc, timeval& now) { @@ -334,10 +334,8 @@ LWResult::Result asendto(const void* data, size_t len, int /* flags */, t_fdm->addReadFD(*fileDesc, handleUDPServerResponse, pident); ssize_t sent = send(*fileDesc, data, len, 0); - - int tmp = errno; - if (sent < 0) { + int tmp = errno; t_udpclientsocks->returnSocket(*fileDesc); errno = tmp; // this is for logging purposes only return LWResult::Result::PermanentError; @@ -348,7 +346,7 @@ LWResult::Result asendto(const void* data, size_t len, int /* flags */, static bool checkIncomingECSSource(const PacketBuffer& packet, const Netmask& subnet); -LWResult::Result arecvfrom(PacketBuffer& packet, int /* flags */, const ComboAddress& fromAddr, size_t& len, +LWResult::Result arecvfrom(PacketBuffer& packet, const ComboAddress& fromAddr, size_t& len, uint16_t qid, const DNSName& domain, uint16_t qtype, int fileDesc, const std::optional& ecs, const struct timeval& now) { static const unsigned int nearMissLimit = ::arg().asNum("spoof-nearmiss-max");