From f821ff19dcd4ad1bb4e88d40913e40201d81c118 Mon Sep 17 00:00:00 2001 From: =?utf8?q?H=C3=A5kan=20Lindqvist?= Date: Mon, 24 Oct 2022 17:26:54 +0000 Subject: [PATCH] Fix generation of multiple-version updates See https://github.com/PowerDNS/pdns/issues/6880#issuecomment-420980817 --- pdns/ixfrdist.cc | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index aea08ee066..24ac0e6a3a 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -717,24 +717,34 @@ static bool handleIXFR(int fd, const ComboAddress& destination, const MOADNSPars return handleAXFR(fd, mdp); } - std::vector> packets; - for (const auto& diff : toSend) { - /* An IXFR packet's ANSWER section looks as follows: - * SOA new_serial - * SOA old_serial - * ... removed records ... - * SOA new_serial - * ... added records ... - * SOA new_serial - */ + /* An IXFR packet's ANSWER section looks as follows: + * SOA latest_serial C + + First set of changes: + * SOA requested_serial A + * ... removed records ... + * SOA intermediate_serial B + * ... added records ... + + Next set of changes: + * SOA intermediate_serial B + * ... removed records ... + * SOA latest_serial C + * ... added records ... + + * SOA latest_serial C + */ + + const auto latestSOAPacket = getSOAPacket(mdp, zoneInfo->soa, zoneInfo->soaTTL); + if (!sendPacketOverTCP(fd, latestSOAPacket)) { + return false; + } + + for (const auto& diff : toSend) { const auto newSOAPacket = getSOAPacket(mdp, diff->newSOA, diff->newSOATTL); const auto oldSOAPacket = getSOAPacket(mdp, diff->oldSOA, diff->oldSOATTL); - if (!sendPacketOverTCP(fd, newSOAPacket)) { - return false; - } - if (!sendPacketOverTCP(fd, oldSOAPacket)) { return false; } @@ -750,10 +760,10 @@ static bool handleIXFR(int fd, const ComboAddress& destination, const MOADNSPars if (!sendRecordsOverTCP(fd, mdp, diff->additions)) { return false; } + } - if (!sendPacketOverTCP(fd, newSOAPacket)) { - return false; - } + if (!sendPacketOverTCP(fd, latestSOAPacket)) { + return false; } return true; -- 2.47.2