From 79816288afe7169c1f1bb28463f22512ca11c3b9 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 20 Jan 2020 12:05:03 +0100 Subject: [PATCH] Make ComboAddress::setPort() update the current object Instead of creating a new one. --- pdns/iputils.hh | 6 ++---- pdns/packethandler.cc | 5 +++-- pdns/pdns_recursor.cc | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pdns/iputils.hh b/pdns/iputils.hh index 7b171efec9..77b5667ee2 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -306,11 +306,9 @@ union ComboAddress { return ntohs(sin4.sin_port); } - ComboAddress setPort(uint16_t port) const + void setPort(uint16_t port) { - ComboAddress ret(*this); - ret.sin4.sin_port=htons(port); - return ret; + sin4.sin_port = htons(port); } void reset() diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index e0e78992fb..6d59cff076 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -784,10 +784,11 @@ int PacketHandler::trySuperMaster(const DNSPacket& p, const DNSName& tsigkeyname int PacketHandler::trySuperMasterSynchronous(const DNSPacket& p, const DNSName& tsigkeyname) { - ComboAddress remote = p.getRemote().setPort(53); + ComboAddress remote = p.getRemote(); if(p.hasEDNSSubnet() && ::arg().contains("trusted-notification-proxy", remote.toString())) { - remote = p.getRealRemote().getNetwork().setPort(53); + remote = p.getRealRemote().getNetwork(); } + remote.setPort(53); Resolver::res_t nsset; try { diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index a4f3196d4d..76b325497a 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -814,7 +814,7 @@ static void protobufLogQuery(uint8_t maskV4, uint8_t maskV6, const boost::uuids: } Netmask requestorNM(remote, remote.sin4.sin_family == AF_INET ? maskV4 : maskV6); - const ComboAddress requestor = requestorNM.getMaskedNetwork(); + ComboAddress requestor = requestorNM.getMaskedNetwork(); requestor.setPort(remote.getPort()); RecProtoBufMessage message(DNSProtoBufMessage::Query, uniqueId, &requestor, &local, qname, qtype, qclass, id, tcp, len); message.setServerIdentity(SyncRes::s_serverID); -- 2.47.2