Browse Source

[master] D2 correctly sets TSIG rdata original ID

    Merge branch 'trac5071'
Thomas Markwalder 8 years ago
parent
commit
cafa3d5c24
2 changed files with 14 additions and 1 deletions
  1. 4 0
      src/bin/d2/nc_trans.cc
  2. 10 1
      src/bin/d2/tests/nc_trans_unittests.cc

+ 4 - 0
src/bin/d2/nc_trans.cc

@@ -9,10 +9,12 @@
 #include <d2/d2_log.h>
 #include <d2/nc_trans.h>
 #include <dns/rdata.h>
+#include <util/random/qid_gen.h>
 
 #include <sstream>
 
 using namespace isc::util;
+using namespace isc::util::random;
 
 namespace isc {
 namespace d2 {
@@ -321,6 +323,8 @@ NameChangeTransaction::prepNewRequest(DdnsDomainPtr domain) {
         // Create a "blank" update request.
         D2UpdateMessagePtr request(new D2UpdateMessage(D2UpdateMessage::
                                                        OUTBOUND));
+        // Set the query id
+        request->setId(QidGenerator::getInstance().generateQid());
         // Construct the Zone Section.
         dns::Name zone_name(domain->getName());
         request->setZone(zone_name, dns::RRClass::IN());

+ 10 - 1
src/bin/d2/tests/nc_trans_unittests.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2017 Internet Systems Consortium, Inc. ("ISC")
 //
 // This Source Code Form is subject to the terms of the Mozilla Public
 // License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -1195,6 +1195,15 @@ TEST_F(NameChangeTransactionTest, prepNewRequest) {
     // valid input.
     ASSERT_NO_THROW(request = name_change->prepNewRequest(forward_domain_));
     checkZone(request, forward_domain_->getName());
+
+    // The query id is random so 0 is not impossible
+    for (unsigned i = 0; i < 10; ++i) {
+        if (request->getId() == 0) {
+            request = name_change->prepNewRequest(forward_domain_);
+        }
+    }
+
+    EXPECT_NE(0, request->getId());
 }
 
 /// @brief Tests the addLeaseAddressRData method