Browse Source

[3977] Do not generate NCRs for prefix delegation.

Marcin Siodelski 9 years ago
parent
commit
52f812a86d

+ 1 - 1
src/lib/dhcpsrv/ncr_generator.cc

@@ -101,7 +101,7 @@ void queueNCR(const NameChangeType& chg_type, const Lease4Ptr& lease) {
 
 
 void queueNCR(const NameChangeType& chg_type, const Lease6Ptr& lease) {
 void queueNCR(const NameChangeType& chg_type, const Lease6Ptr& lease) {
     // DUID is required to generate NCR.
     // DUID is required to generate NCR.
-    if (lease && lease->duid_) {
+    if (lease && (lease->type_ != Lease::TYPE_PD) && lease->duid_) {
         queueNCRCommon(chg_type, lease, *(lease->duid_),
         queueNCRCommon(chg_type, lease, *(lease->duid_),
                        Pkt6::makeLabel(lease->duid_, lease->hwaddr_));
                        Pkt6::makeLabel(lease->duid_, lease->hwaddr_));
     }
     }

+ 3 - 0
src/lib/dhcpsrv/ncr_generator.h

@@ -40,6 +40,9 @@ void queueNCR(const dhcp_ddns::NameChangeType& chg_type, const Lease4Ptr& lease)
 /// in the DHCPv6 lease. The DUID is used to compute the DHCID for the name
 /// in the DHCPv6 lease. The DUID is used to compute the DHCID for the name
 /// change request.
 /// change request.
 ///
 ///
+/// This function will skip sending the NCR if the lease type is a delegated
+/// prefix.
+///
 /// This function is exception safe. On failure, it logs an error.
 /// This function is exception safe. On failure, it logs an error.
 ///
 ///
 /// @param chg_type Type of the name change request
 /// @param chg_type Type of the name change request

+ 16 - 0
src/lib/dhcpsrv/tests/ncr_generator_unittest.cc

@@ -348,6 +348,22 @@ TEST_F(NCRGenerator6Test, wrongHostname) {
     }
     }
 }
 }
 
 
+// Test that NameChangeRequest is not generated if the lease is not an
+// address lease, i.e. is a prefix.
+TEST_F(NCRGenerator6Test, wrongLeaseType) {
+    // Change lease type to delegated prefix.
+    lease_->type_ = Lease::TYPE_PD;
+
+    {
+        SCOPED_TRACE("case CHG_REMOVE");
+        testNoUpdate(CHG_REMOVE, true, true, "myhost.example.org.");
+    }
+    {
+        SCOPED_TRACE("case CHG_ADD");
+        testNoUpdate(CHG_ADD, true, true, "myhost.example.org.");
+    }
+}
+
 /// @brief Test fixture class implementation for DHCPv4.
 /// @brief Test fixture class implementation for DHCPv4.
 class NCRGenerator4Test : public NCRGeneratorTest<Lease4Ptr> {
 class NCRGenerator4Test : public NCRGeneratorTest<Lease4Ptr> {
 public:
 public: