]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#2764] Addressed review comments
authorMarcin Siodelski <msiodelski@gmail.com>
Mon, 13 Mar 2023 21:13:18 +0000 (22:13 +0100)
committerMarcin Siodelski <msiodelski@gmail.com>
Tue, 14 Mar 2023 18:23:31 +0000 (19:23 +0100)
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/generic_lease_mgr_unittest.h
src/lib/dhcpsrv/tests/memfile_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/tracking_lease_mgr_unittest.cc
src/lib/dhcpsrv/tracking_lease_mgr.cc
src/lib/dhcpsrv/tracking_lease_mgr.h

index 244fe355e2f25c1355fb35e96492873a5e0497a2..da23ec3a04dadc1d02aab8a93a6109c1200a1010 100644 (file)
@@ -2230,6 +2230,9 @@ TEST(CfgSubnets4Test, initAllocatorsAfterConfigure) {
     cfg.add(subnet2);
     cfg.add(subnet3);
 
+    EXPECT_EQ(0, allocator0->callcount_);
+    EXPECT_EQ(0, allocator2->callcount_);
+
     cfg.initAllocatorsAfterConfigure();
 
     EXPECT_EQ(1, allocator0->callcount_);
index c6c821af60d540060d10d5420dceb2c9748a980d..c86e190091a54f1af378467ea55157d2c0b239e9 100644 (file)
@@ -2152,6 +2152,9 @@ TEST(CfgSubnets6Test, initAllocatorsAfterConfigure) {
     cfg.add(subnet2);
     cfg.add(subnet3);
 
+    EXPECT_EQ(0, allocator0->callcount_);
+    EXPECT_EQ(0, allocator2->callcount_);
+
     cfg.initAllocatorsAfterConfigure();
 
     EXPECT_EQ(1, allocator0->callcount_);
index 58a98d09032ebefae4dbebffc6dd1fa6740d209b..c656f34a229d5a17bb986ed49297f57f128a5e87 100644 (file)
@@ -4163,12 +4163,12 @@ GenericLeaseMgrTest::testClassLeaseCount6(Lease::Type ltype) {
 void
 GenericLeaseMgrTest::testTrackAddLease4(bool expect_locked, bool expect_mt_safe) {
     // Register a callback for all subnets.
-    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                             Lease::TYPE_V4,
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                       0,
+                                       SUBNET_ID_GLOBAL,
                                        ph::_1,
                                        ph::_2));
     // Add a lease. It should trigger the callback.
@@ -4200,14 +4200,14 @@ GenericLeaseMgrTest::testTrackAddLease4(bool expect_locked, bool expect_mt_safe)
 }
 
 void
-GenericLeaseMgrTest::testTrackAddLease6(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackAddLeaseNA(bool expect_locked, bool expect_mt_safe) {
     // Register a callback for all subnets.
-    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                             Lease::TYPE_NA,
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                       0,
+                                       SUBNET_ID_GLOBAL,
                                        ph::_1,
                                        ph::_2));
     // Add a lease. It should trigger the callback.
@@ -4238,15 +4238,55 @@ GenericLeaseMgrTest::testTrackAddLease6(bool expect_locked, bool expect_mt_safe)
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
+void
+GenericLeaseMgrTest::testTrackAddLeasePD(bool expect_locked, bool expect_mt_safe) {
+    // Register a callback for all subnets.
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_PD,
+                             std::bind(&GenericLeaseMgrTest::logCallback,
+                                       this,
+                                       TrackingLeaseMgr::TRACK_ADD_LEASE,
+                                       SUBNET_ID_GLOBAL,
+                                       ph::_1,
+                                       ph::_2));
+    // Add a lease. It should trigger the callback.
+    Lease6Ptr lease = initializeLease6(straddress6_[2]);
+    EXPECT_TRUE(lmptr_->addLease(lease));
+
+    // Make sure that the callback has been invoked.
+    ASSERT_EQ(1, logs_.size());
+
+    // This flag should be false for the Memfile backend and true
+    // for the SQL backends.
+    if (expect_locked) {
+        EXPECT_TRUE(logs_[0].locked);
+    } else {
+        EXPECT_FALSE(logs_[0].locked);
+    }
+    // This flag should be set to true for the Memfile backends.
+    // It should be false for other backends. If the backends do
+    // not provide the MT-safe context, the callbacks must protect
+    // against the concurrent access on their own.
+    if (expect_mt_safe) {
+        EXPECT_TRUE(logs_[0].mt_safe);
+    } else {
+        EXPECT_FALSE(logs_[0].mt_safe);
+    }
+
+    // The lease locks should have been released.
+    EXPECT_FALSE(lmptr_->isLocked(lease));
+}
+
 void
 GenericLeaseMgrTest::testTrackUpdateLease4(bool expect_locked, bool expect_mt_safe) {
     // Register a callback for all subnets.
-    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 0,
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
+                             SUBNET_ID_GLOBAL,
                              Lease::TYPE_V4,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                       0,
+                                       SUBNET_ID_GLOBAL,
                                        ph::_1,
                                        ph::_2));
     // Add a lease.
@@ -4281,14 +4321,14 @@ GenericLeaseMgrTest::testTrackUpdateLease4(bool expect_locked, bool expect_mt_sa
 }
 
 void
-GenericLeaseMgrTest::testTrackUpdateLease6(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackUpdateLeaseNA(bool expect_locked, bool expect_mt_safe) {
     // Register a callback for all subnets.
-    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 0,
-                             Lease::TYPE_NA,
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                       0,
+                                       SUBNET_ID_GLOBAL,
                                        ph::_1,
                                        ph::_2));
     // Add a lease.
@@ -4322,15 +4362,57 @@ GenericLeaseMgrTest::testTrackUpdateLease6(bool expect_locked, bool expect_mt_sa
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
+void
+GenericLeaseMgrTest::testTrackUpdateLeasePD(bool expect_locked, bool expect_mt_safe) {
+    // Register a callback for all subnets.
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_PD,
+                             std::bind(&GenericLeaseMgrTest::logCallback,
+                                       this,
+                                       TrackingLeaseMgr::TRACK_UPDATE_LEASE,
+                                       SUBNET_ID_GLOBAL,
+                                       ph::_1,
+                                       ph::_2));
+    // Add a lease.
+    Lease6Ptr lease = initializeLease6(straddress6_[2]);
+    EXPECT_TRUE(lmptr_->addLease(lease));
+    EXPECT_TRUE(logs_.empty());
+
+    lmptr_->updateLease6(lease);
+
+    // Make sure that the callback has been invoked.
+    ASSERT_EQ(1, logs_.size());
+
+    // This flag should be false for the Memfile backend and true
+    // for the SQL backends.
+    if (expect_locked) {
+        EXPECT_TRUE(logs_[0].locked);
+    } else {
+        EXPECT_FALSE(logs_[0].locked);
+    }
+    // This flag should be set to true for the Memfile backends.
+    // It should be false for other backends. If the backends do
+    // not provide the MT-safe context, the callbacks must protect
+    // against the concurrent access on their own.
+    if (expect_mt_safe) {
+        EXPECT_TRUE(logs_[0].mt_safe);
+    } else {
+        EXPECT_FALSE(logs_[0].mt_safe);
+    }
+
+    // The lease locks should have been released.
+    EXPECT_FALSE(lmptr_->isLocked(lease));
+}
+
 void
 GenericLeaseMgrTest::testTrackDeleteLease4(bool expect_locked, bool expect_mt_safe) {
     // Register a callback for all subnets.
-    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq", 0,
-                             Lease::TYPE_V4,
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                       0,
+                                       SUBNET_ID_GLOBAL,
                                        ph::_1,
                                        ph::_2));
     // Add a lease.
@@ -4365,14 +4447,14 @@ GenericLeaseMgrTest::testTrackDeleteLease4(bool expect_locked, bool expect_mt_sa
 }
 
 void
-GenericLeaseMgrTest::testTrackDeleteLease6(bool expect_locked, bool expect_mt_safe) {
+GenericLeaseMgrTest::testTrackDeleteLeaseNA(bool expect_locked, bool expect_mt_safe) {
     // Register a callback for all subnets.
-    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq", 0,
-                             Lease::TYPE_NA,
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                              std::bind(&GenericLeaseMgrTest::logCallback,
                                        this,
                                        TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                       0,
+                                       SUBNET_ID_GLOBAL,
                                        ph::_1,
                                        ph::_2));
     // Add a lease.
@@ -4406,6 +4488,48 @@ GenericLeaseMgrTest::testTrackDeleteLease6(bool expect_locked, bool expect_mt_sa
     EXPECT_FALSE(lmptr_->isLocked(lease));
 }
 
+void
+GenericLeaseMgrTest::testTrackDeleteLeasePD(bool expect_locked, bool expect_mt_safe) {
+    // Register a callback for all subnets.
+    lmptr_->registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
+                             SUBNET_ID_GLOBAL, Lease::TYPE_PD,
+                             std::bind(&GenericLeaseMgrTest::logCallback,
+                                       this,
+                                       TrackingLeaseMgr::TRACK_DELETE_LEASE,
+                                       SUBNET_ID_GLOBAL,
+                                       ph::_1,
+                                       ph::_2));
+    // Add a lease.
+    Lease6Ptr lease = initializeLease6(straddress6_[2]);
+    EXPECT_TRUE(lmptr_->addLease(lease));
+    EXPECT_TRUE(logs_.empty());
+
+    lmptr_->deleteLease(lease);
+
+    // Make sure that the callback has been invoked.
+    ASSERT_EQ(1, logs_.size());
+
+    // This flag should be false for the Memfile backend and true
+    // for the SQL backends.
+    if (expect_locked) {
+        EXPECT_TRUE(logs_[0].locked);
+    } else {
+        EXPECT_FALSE(logs_[0].locked);
+    }
+    // This flag should be set to true for the Memfile backends.
+    // It should be false for other backends. If the backends do
+    // not provide the MT-safe context, the callbacks must protect
+    // against the concurrent access on their own.
+    if (expect_mt_safe) {
+        EXPECT_TRUE(logs_[0].mt_safe);
+    } else {
+        EXPECT_FALSE(logs_[0].mt_safe);
+    }
+
+    // The lease locks should have been released.
+    EXPECT_FALSE(lmptr_->isLocked(lease));
+}
+
 void
 GenericLeaseMgrTest::testRecreateWithCallbacks(const std::string& access) {
     // Register a callback.
index 68545f9af54e70583587d5571c4e0c276893be4b..3f47baf2ff8c7f14b727242ce735bea7fcb2e30d 100644 (file)
@@ -584,13 +584,22 @@ public:
     void testTrackAddLease4(bool expect_locked, bool expect_mt_safe);
 
     /// @brief Checks if the backends call the callbacks when an
-    /// IPv6 lease is added.
+    /// IPv6 address lease is added.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
     /// @param expect_mt_safe a boolean flag indicating if the test should
     /// expect that the callbacks are called in the MT-safe context.
-    void testTrackAddLease6(bool expect_locked, bool expect_mt_safe);
+    void testTrackAddLeaseNA(bool expect_locked, bool expect_mt_safe);
+
+    /// @brief Checks if the backends call the callbacks when an
+    /// IPv6 prefix lease is added.
+    ///
+    /// @param expect_locked a boolean flag indicating if the test should
+    /// expect that the lease is locked before the callback.
+    /// @param expect_mt_safe a boolean flag indicating if the test should
+    /// expect that the callbacks are called in the MT-safe context.
+    void testTrackAddLeasePD(bool expect_locked, bool expect_mt_safe);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv4 lease is updated.
@@ -602,13 +611,22 @@ public:
     void testTrackUpdateLease4(bool expect_locked, bool expect_mt_safe);
 
     /// @brief Checks if the backends call the callbacks when an
-    /// IPv6 lease is updated.
+    /// IPv6 address lease is updated.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
     /// @param expect_mt_safe a boolean flag indicating if the test should
     /// expect that the callbacks are called in the MT-safe context.
-    void testTrackUpdateLease6(bool expect_locked, bool expect_mt_safe);
+    void testTrackUpdateLeaseNA(bool expect_locked, bool expect_mt_safe);
+
+    /// @brief Checks if the backends call the callbacks when an
+    /// IPv6 prefix lease is updated.
+    ///
+    /// @param expect_locked a boolean flag indicating if the test should
+    /// expect that the lease is locked before the callback.
+    /// @param expect_mt_safe a boolean flag indicating if the test should
+    /// expect that the callbacks are called in the MT-safe context.
+    void testTrackUpdateLeasePD(bool expect_locked, bool expect_mt_safe);
 
     /// @brief Checks if the backends call the callbacks when an
     /// IPv4 lease is deleted.
@@ -620,13 +638,22 @@ public:
     void testTrackDeleteLease4(bool expect_locked, bool expect_mt_safe);
 
     /// @brief Checks if the backends call the callbacks when an
-    /// IPv6 lease is deleted.
+    /// IPv6 address lease is deleted.
+    ///
+    /// @param expect_locked a boolean flag indicating if the test should
+    /// expect that the lease is locked before the callback.
+    /// @param expect_mt_safe a boolean flag indicating if the test should
+    /// expect that the callbacks are called in the MT-safe context.
+    void testTrackDeleteLeaseNA(bool expect_locked, bool expect_mt_safe);
+
+    /// @brief Checks if the backends call the callbacks when an
+    /// IPv6 prefix lease is deleted.
     ///
     /// @param expect_locked a boolean flag indicating if the test should
     /// expect that the lease is locked before the callback.
     /// @param expect_mt_safe a boolean flag indicating if the test should
     /// expect that the callbacks are called in the MT-safe context.
-    void testTrackDeleteLease6(bool expect_locked, bool expect_mt_safe);
+    void testTrackDeleteLeasePD(bool expect_locked, bool expect_mt_safe);
 
     /// @brief Checks that the lease manager can be recreated and its
     /// registered callbacks preserved, if desired.
index 403aacced9a1246fc40283894567af519d61ab2a..443e7f4df59fcecc55a03059b3c0ecafb76515a9 100644 (file)
@@ -4255,20 +4255,37 @@ TEST_F(MemfileLeaseMgrTest, trackAddLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MemfileLeaseMgrTest, trackAddLease6) {
+/// IPv6 address lease is added.
+TEST_F(MemfileLeaseMgrTest, trackAddLeaseNA) {
     startBackend(V6);
     // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLease6(false, true);
+    testTrackAddLeaseNA(false, true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MemfileLeaseMgrTest, trackAddLease6MultiThreading) {
+/// IPv6 address lease is added.
+TEST_F(MemfileLeaseMgrTest, trackAddLeaseNAMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
     // Expect that lease is not locked and the MT-safe context.
-    testTrackAddLease6(false, true);
+    testTrackAddLeaseNA(false, true);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is added.
+TEST_F(MemfileLeaseMgrTest, trackAddLeasePD) {
+    startBackend(V6);
+    // Expect that lease is not locked and the MT-safe context.
+    testTrackAddLeasePD(false, true);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is added.
+TEST_F(MemfileLeaseMgrTest, trackAddLeasePDMultiThreading) {
+    startBackend(V6);
+    MultiThreadingMgr::instance().setMode(true);
+    // Expect that lease is not locked and the MT-safe context.
+    testTrackAddLeasePD(false, true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4289,20 +4306,37 @@ TEST_F(MemfileLeaseMgrTest, trackUpdateLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MemfileLeaseMgrTest, trackUpdateLease6) {
+/// IPv6 address lease is updated.
+TEST_F(MemfileLeaseMgrTest, trackUpdateLeaseNA) {
     startBackend(V6);
     // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLease6(false, true);
+    testTrackUpdateLeaseNA(false, true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MemfileLeaseMgrTest, trackUpdateLease6MultiThreading) {
+/// IPv6 address lease is updated.
+TEST_F(MemfileLeaseMgrTest, trackUpdateLeaseNAMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
     // Expect that lease is not locked and the MT-safe context.
-    testTrackUpdateLease6(false, true);
+    testTrackUpdateLeaseNA(false, true);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is updated.
+TEST_F(MemfileLeaseMgrTest, trackUpdateLeasePD) {
+    startBackend(V6);
+    // Expect that lease is not locked and the MT-safe context.
+    testTrackUpdateLeasePD(false, true);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is updated.
+TEST_F(MemfileLeaseMgrTest, trackUpdateLeasePDMultiThreading) {
+    startBackend(V6);
+    MultiThreadingMgr::instance().setMode(true);
+    // Expect that lease is not locked and the MT-safe context.
+    testTrackUpdateLeasePD(false, true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -4323,20 +4357,37 @@ TEST_F(MemfileLeaseMgrTest, trackDeleteLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MemfileLeaseMgrTest, trackDeleteLease6) {
+/// IPv6 address lease is deleted.
+TEST_F(MemfileLeaseMgrTest, trackDeleteLeaseNA) {
+    startBackend(V6);
+    // Expect that lease is not locked and the MT-safe context.
+    testTrackDeleteLeaseNA(false, true);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 addres lease is deleted.
+TEST_F(MemfileLeaseMgrTest, trackDeleteLeaseNAMultiThreading) {
+    startBackend(V6);
+    MultiThreadingMgr::instance().setMode(true);
+    // Expect that lease is not locked and the MT-safe context.
+    testTrackDeleteLeaseNA(false, true);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is deleted.
+TEST_F(MemfileLeaseMgrTest, trackDeleteLeasePD) {
     startBackend(V6);
     // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLease6(false, true);
+    testTrackDeleteLeasePD(false, true);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MemfileLeaseMgrTest, trackDeleteLease6MultiThreading) {
+/// IPv6 prefix lease is deleted.
+TEST_F(MemfileLeaseMgrTest, trackDeleteLeasePDMultiThreading) {
     startBackend(V6);
     MultiThreadingMgr::instance().setMode(true);
     // Expect that lease is not locked and the MT-safe context.
-    testTrackDeleteLease6(false, true);
+    testTrackDeleteLeasePD(false, true);
 }
 
 /// @brief Checks that the lease manager can be recreated and its
index da14ff2baf44247070ba448991ed9e021826c860..87b6b82500a863731b7592fb8cc2cf5ae03271d8 100644 (file)
@@ -1192,20 +1192,37 @@ TEST_F(MySqlLeaseMgrTest, trackAddLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MySqlLeaseMgrTest, trackAddLease6) {
+/// IPv6 address lease is added.
+TEST_F(MySqlLeaseMgrTest, trackAddLeaseNA) {
     // It is unnecessary to lock the lease in ST. The backend does not
     // provide the MT-safe context for the callbacks.
-    testTrackAddLease6(false, false);
+    testTrackAddLeaseNA(false, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(MySqlLeaseMgrTest, trackAddLease6MultiThreading) {
+/// IPv6 address lease is added.
+TEST_F(MySqlLeaseMgrTest, trackAddLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
     // The lease should be locked in the MT mode. The backend does not
     // provide an MT-safe context.
-    testTrackAddLease6(true, false);
+    testTrackAddLeaseNA(true, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is added.
+TEST_F(MySqlLeaseMgrTest, trackAddLeasePD) {
+    // It is unnecessary to lock the lease in ST. The backend does not
+    // provide the MT-safe context for the callbacks.
+    testTrackAddLeasePD(false, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is added.
+TEST_F(MySqlLeaseMgrTest, trackAddLeasePDMultiThreading) {
+    MultiThreadingMgr::instance().setMode(true);
+    // The lease should be locked in the MT mode. The backend does not
+    // provide an MT-safe context.
+    testTrackAddLeasePD(true, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -1226,20 +1243,37 @@ TEST_F(MySqlLeaseMgrTest, trackUpdateLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is updated.
-TEST_F(MySqlLeaseMgrTest, trackUpdateLease6) {
+/// IPv6 address lease is updated.
+TEST_F(MySqlLeaseMgrTest, trackUpdateLeaseNA) {
     // It is unnecessary to lock the lease in ST. The backend does not
     // provide the MT-safe context for the callbacks.
-    testTrackUpdateLease6(false, false);
+    testTrackUpdateLeaseNA(false, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is updated.
-TEST_F(MySqlLeaseMgrTest, trackUpdateLease6MultiThreading) {
+/// IPv6 address lease is updated.
+TEST_F(MySqlLeaseMgrTest, trackUpdateLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
     // The lease should be locked in the MT mode. The backend does not
     // provide an MT-safe context.
-    testTrackUpdateLease6(true, false);
+    testTrackUpdateLeaseNA(true, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is updated.
+TEST_F(MySqlLeaseMgrTest, trackUpdateLeasePD) {
+    // It is unnecessary to lock the lease in ST. The backend does not
+    // provide the MT-safe context for the callbacks.
+    testTrackUpdateLeasePD(false, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is updated.
+TEST_F(MySqlLeaseMgrTest, trackUpdateLeasePDMultiThreading) {
+    MultiThreadingMgr::instance().setMode(true);
+    // The lease should be locked in the MT mode. The backend does not
+    // provide an MT-safe context.
+    testTrackUpdateLeasePD(true, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -1260,20 +1294,37 @@ TEST_F(MySqlLeaseMgrTest, trackDeleteLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is deleted.
-TEST_F(MySqlLeaseMgrTest, trackDeleteLease6) {
+/// IPv6 address lease is deleted.
+TEST_F(MySqlLeaseMgrTest, trackDeleteLeaseNA) {
+    // It is unnecessary to lock the lease in ST. The backend does not
+    // provide the MT-safe context for the callbacks.
+    testTrackDeleteLeaseNA(false, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 address lease is deleted.
+TEST_F(MySqlLeaseMgrTest, trackDeleteLeaseNAMultiThreading) {
+    MultiThreadingMgr::instance().setMode(true);
+    // The lease should be locked in the MT mode. The backend does not
+    // provide an MT-safe context.
+    testTrackDeleteLeaseNA(true, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is deleted.
+TEST_F(MySqlLeaseMgrTest, trackDeleteLeasePD) {
     // It is unnecessary to lock the lease in ST. The backend does not
     // provide the MT-safe context for the callbacks.
-    testTrackDeleteLease6(false, false);
+    testTrackDeleteLeasePD(false, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is deleted.
-TEST_F(MySqlLeaseMgrTest, trackDeleteLease6MultiThreading) {
+/// IPv6 prefix lease is deleted.
+TEST_F(MySqlLeaseMgrTest, trackDeleteLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
     // The lease should be locked in the MT mode. The backend does not
     // provide an MT-safe context.
-    testTrackDeleteLease6(true, false);
+    testTrackDeleteLeasePD(true, false);
 }
 
 /// @brief Checks that the lease manager can be recreated and its
index b18cb9171548fd727e2d32a3b80d4a8bed63b826..c5f84643722875241aeea9d0a18be3e40f8b4281 100644 (file)
@@ -1181,20 +1181,37 @@ TEST_F(PgSqlLeaseMgrTest, trackAddLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(PgSqlLeaseMgrTest, trackAddLease6) {
+/// IPv6 address lease is added.
+TEST_F(PgSqlLeaseMgrTest, trackAddLeaseNA) {
     // It is unnecessary to lock the lease in ST. The backend does not
     // provide the MT-safe context for the callbacks.
-    testTrackAddLease6(false, false);
+    testTrackAddLeaseNA(false, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is added.
-TEST_F(PgSqlLeaseMgrTest, trackAddLease6MultiThreading) {
+/// IPv6 address lease is added.
+TEST_F(PgSqlLeaseMgrTest, trackAddLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
     // The lease should be locked in the MT mode. The backend does not
     // provide an MT-safe context.
-    testTrackAddLease6(true, false);
+    testTrackAddLeaseNA(true, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is added.
+TEST_F(PgSqlLeaseMgrTest, trackAddLeasePD) {
+    // It is unnecessary to lock the lease in ST. The backend does not
+    // provide the MT-safe context for the callbacks.
+    testTrackAddLeasePD(false, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is added.
+TEST_F(PgSqlLeaseMgrTest, trackAddLeasePDMultiThreading) {
+    MultiThreadingMgr::instance().setMode(true);
+    // The lease should be locked in the MT mode. The backend does not
+    // provide an MT-safe context.
+    testTrackAddLeasePD(true, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -1215,20 +1232,37 @@ TEST_F(PgSqlLeaseMgrTest, trackUpdateLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is updated.
-TEST_F(PgSqlLeaseMgrTest, trackUpdateLease6) {
+/// IPv6 address lease is updated.
+TEST_F(PgSqlLeaseMgrTest, trackUpdateLeaseNA) {
     // It is unnecessary to lock the lease in ST. The backend does not
     // provide the MT-safe context for the callbacks.
-    testTrackUpdateLease6(false, false);
+    testTrackUpdateLeaseNA(false, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is updated.
-TEST_F(PgSqlLeaseMgrTest, trackUpdateLease6MultiThreading) {
+/// IPv6 address lease is updated.
+TEST_F(PgSqlLeaseMgrTest, trackUpdateLeaseNAMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
     // The lease should be locked in the MT mode. The backend does not
     // provide an MT-safe context.
-    testTrackUpdateLease6(true, false);
+    testTrackUpdateLeaseNA(true, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is updated.
+TEST_F(PgSqlLeaseMgrTest, trackUpdateLeasePD) {
+    // It is unnecessary to lock the lease in ST. The backend does not
+    // provide the MT-safe context for the callbacks.
+    testTrackUpdateLeasePD(false, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is updated.
+TEST_F(PgSqlLeaseMgrTest, trackUpdateLeasePDMultiThreading) {
+    MultiThreadingMgr::instance().setMode(true);
+    // The lease should be locked in the MT mode. The backend does not
+    // provide an MT-safe context.
+    testTrackUpdateLeasePD(true, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
@@ -1249,20 +1283,37 @@ TEST_F(PgSqlLeaseMgrTest, trackDeleteLease4MultiThreading) {
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is deleted.
-TEST_F(PgSqlLeaseMgrTest, trackDeleteLease6) {
+/// IPv6 address lease is deleted.
+TEST_F(PgSqlLeaseMgrTest, trackDeleteLeaseNA) {
+    // It is unnecessary to lock the lease in ST. The backend does not
+    // provide the MT-safe context for the callbacks.
+    testTrackDeleteLeaseNA(false, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 address lease is deleted.
+TEST_F(PgSqlLeaseMgrTest, trackDeleteLeaseNAMultiThreading) {
+    MultiThreadingMgr::instance().setMode(true);
+    // The lease should be locked in the MT mode. The backend does not
+    // provide an MT-safe context.
+    testTrackDeleteLeaseNA(true, false);
+}
+
+/// @brief Checks if the backends call the callbacks when an
+/// IPv6 prefix lease is deleted.
+TEST_F(PgSqlLeaseMgrTest, trackDeleteLeasePD) {
     // It is unnecessary to lock the lease in ST. The backend does not
     // provide the MT-safe context for the callbacks.
-    testTrackDeleteLease6(false, false);
+    testTrackDeleteLeasePD(false, false);
 }
 
 /// @brief Checks if the backends call the callbacks when an
-/// IPv6 lease is deleted.
-TEST_F(PgSqlLeaseMgrTest, trackDeleteLease6MultiThreading) {
+/// IPv6 prefix lease is deleted.
+TEST_F(PgSqlLeaseMgrTest, trackDeleteLeasePDMultiThreading) {
     MultiThreadingMgr::instance().setMode(true);
     // The lease should be locked in the MT mode. The backend does not
     // provide an MT-safe context.
-    testTrackDeleteLease6(true, false);
+    testTrackDeleteLeasePD(true, false);
 }
 
 /// @brief Checks that the lease manager can be recreated and its
index 7c42606e5eea0fee773dbdd3a1ee0b8d91ae20b0..c12140a460a0aa657849345d3f43c7e99f8d2383 100644 (file)
@@ -99,13 +99,13 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacks) {
     DatabaseConnection::ParameterMap pmap;
     ConcreteLeaseMgr mgr(pmap);
 
-    // Callback for lease add and subnet id 0.
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    // Callback for lease add and global subnet id.
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
     // Callback for lease add and subnet id 1.
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 1,
@@ -123,34 +123,34 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacks) {
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
                                                    1,
                                                    ph::_1, ph::_2)));
-    // Callback for lease update and subnet id 0.
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    // Callback for lease update and global subnet id.
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
-    // Callback for lease delete and subnet id 0.
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    // Callback for lease delete and global subnet id.
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   1,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
 
     // This call should trigger the lease add callbacks for subnet id 0 and 1.
     EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1"), false));
     EXPECT_EQ(2, logs_.size());
-    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 0, Lease::TYPE_V4));
+    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
     EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 1, Lease::TYPE_V4));
 
     // This call should trigger the lease add callback for subnet id 0 only. That's
     // because we have no callback for the subnet id 3.
     EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(3, "192.0.2.1"), false));
     EXPECT_EQ(3, logs_.size());
-    EXPECT_EQ(2, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 0, Lease::TYPE_V4));
+    EXPECT_EQ(2, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 }
 
 /// Test that registering the callbacks of the same type, for the same subnet id by the
@@ -160,31 +160,32 @@ TEST_F(TrackingLeaseMgrTest, registerCallbacksConflicts) {
     ConcreteLeaseMgr mgr(pmap);
 
     // Add the callback for lease add and subnet id 0.
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_NA,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
 
     // Another attempt should fail.
-    EXPECT_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                      Lease::TYPE_NA,
+    EXPECT_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                      SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                                       std::bind(&TrackingLeaseMgrTest::logCallback,
                                                 this,
                                                 TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                0,
+                                                SUBNET_ID_GLOBAL,
                                                 ph::_1, ph::_2)),
                  InvalidOperation);
 
     // It should succeed for a different owner.
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "qlf", 0,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "qlf",
+                                         SUBNET_ID_GLOBAL,
                                          Lease::TYPE_NA,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
 
     // It should also succeed for a different subnet id.
@@ -221,41 +222,41 @@ TEST_F(TrackingLeaseMgrTest, trackAddLeaseDifferentLeaseTypes) {
     DatabaseConnection::ParameterMap pmap;
     ConcreteLeaseMgr mgr(pmap);
 
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
 
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_NA,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_NA,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
 
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_PD,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_PD,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
 
     EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1"), false));
     EXPECT_EQ(1, logs_.size());
-    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 0, Lease::TYPE_V4));
+    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 
     EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, Lease::TYPE_NA, "2001:db8:1::1"), false));
     EXPECT_EQ(2, logs_.size());
-    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 0, Lease::TYPE_NA));
+    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_NA));
 
     EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, Lease::TYPE_PD, "3000::"), false));
     EXPECT_EQ(3, logs_.size());
-    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 0, Lease::TYPE_PD));
+    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_PD));
 }
 
 /// Test invoking the registered lease update callbacks.
@@ -263,26 +264,27 @@ TEST_F(TrackingLeaseMgrTest, trackUpdateLease) {
     DatabaseConnection::ParameterMap pmap;
     ConcreteLeaseMgr mgr(pmap);
 
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 0,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL,
                                          Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
     EXPECT_NO_THROW(mgr.trackUpdateLease(initializeLease(1, "192.0.2.1"), false));
     EXPECT_EQ(1, logs_.size());
@@ -294,30 +296,30 @@ TEST_F(TrackingLeaseMgrTest, trackDeleteLease) {
     DatabaseConnection::ParameterMap pmap;
     ConcreteLeaseMgr mgr(pmap);
 
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_DELETE_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_DELETE_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
     EXPECT_NO_THROW(mgr.trackDeleteLease(initializeLease(1, "192.0.2.1"), false));
     EXPECT_EQ(1, logs_.size());
-    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_DELETE_LEASE, 0, Lease::TYPE_V4));
+    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_DELETE_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 }
 
 // Test unregistering the callbacks by subnet id.
@@ -326,12 +328,12 @@ TEST_F(TrackingLeaseMgrTest, unregisterCallbacksBySubnetID) {
     ConcreteLeaseMgr mgr(pmap);
 
     // Register different callback types for different subnet identifiers.
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
     EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 1,
                                          Lease::TYPE_V4,
@@ -384,20 +386,20 @@ TEST_F(TrackingLeaseMgrTest, unregisterCallbacksBySubnetID) {
     EXPECT_NO_THROW(mgr.trackUpdateLease(initializeLease(1, "192.0.2.1"), false));
     EXPECT_NO_THROW(mgr.trackDeleteLease(initializeLease(1, "192.0.2.1"), false));
 
-    // It should only run the callback for the subnet id 0 that is still
+    // It should only run the callback for the global subnet id that is still
     // registered.
     EXPECT_EQ(1, logs_.size());
-    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, 0, Lease::TYPE_V4));
+    EXPECT_EQ(1, countLogs(TrackingLeaseMgr::TRACK_ADD_LEASE, SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 
     // Unregister this callback.
-    EXPECT_NO_THROW(mgr.unregisterCallbacks(SubnetID(0), Lease::TYPE_V4));
+    EXPECT_NO_THROW(mgr.unregisterCallbacks(SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 
     // Make sure it is no longer invoked.
     EXPECT_NO_THROW(mgr.trackAddLease(initializeLease(1, "192.0.2.1"), false));
     EXPECT_EQ(1, logs_.size());
 
     // Unregistering it again should be no-op.
-    EXPECT_NO_THROW(mgr.unregisterCallbacks(SubnetID(0), Lease::TYPE_V4));
+    EXPECT_NO_THROW(mgr.unregisterCallbacks(SUBNET_ID_GLOBAL, Lease::TYPE_V4));
 }
 
 /// Test unregistering all callbacks.
@@ -406,19 +408,19 @@ TEST_F(TrackingLeaseMgrTest, unregisterAllCallbacks) {
     ConcreteLeaseMgr mgr(pmap);
 
     // Register some callbacks.
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_UPDATE_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_UPDATE_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
     // Make sure they have been registered.
     EXPECT_TRUE(mgr.hasCallbacks());
@@ -434,12 +436,12 @@ TEST_F(TrackingLeaseMgrTest, hasCallbacks) {
     ConcreteLeaseMgr mgr(pmap);
     EXPECT_FALSE(mgr.hasCallbacks());
 
-    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq", 0,
-                                         Lease::TYPE_V4,
+    EXPECT_NO_THROW(mgr.registerCallback(TrackingLeaseMgr::TRACK_ADD_LEASE, "flq",
+                                         SUBNET_ID_GLOBAL, Lease::TYPE_V4,
                                          std::bind(&TrackingLeaseMgrTest::logCallback,
                                                    this,
                                                    TrackingLeaseMgr::TRACK_ADD_LEASE,
-                                                   0,
+                                                   SUBNET_ID_GLOBAL,
                                                    ph::_1, ph::_2)));
     EXPECT_TRUE(mgr.hasCallbacks());
 }
index c723d48ddb1b73e0a27dea24deff27ef7f5c3cd4..a245c138f3a067fddf91d32fc66f77ee99141d86 100644 (file)
@@ -85,7 +85,7 @@ TrackingLeaseMgr::registerCallback(TrackingLeaseMgr::CallbackType type,
                                    std::string owner,
                                    Lease::Type lease_type,
                                    TrackingLeaseMgr::CallbackFn callback_fn) {
-    registerCallback(type, owner, 0, lease_type, callback_fn);
+    registerCallback(type, owner, SUBNET_ID_GLOBAL, lease_type, callback_fn);
 }
 
 void
@@ -126,7 +126,7 @@ TrackingLeaseMgr::callbackTypeToString(CallbackType type) {
 void
 TrackingLeaseMgr::runCallbacks(TrackingLeaseMgr::CallbackType type, const LeasePtr& lease,
                                bool mt_safe) {
-    runCallbacksForSubnetID(type, 0, lease, mt_safe);
+    runCallbacksForSubnetID(type, SUBNET_ID_GLOBAL, lease, mt_safe);
     runCallbacksForSubnetID(type, lease->subnet_id_, lease, mt_safe);
 }
 
index 88b2740d03a80d5f3e8c61ae4f44d6d4289b09ef..b6f673ccac735a07332658de2d0e741ec5e45616 100644 (file)
@@ -232,7 +232,7 @@ public:
     /// @param type callback type.
     /// @param owner callback owner identifier.
     /// @param subnet_id subnet identifier; it can be set to 0 if the callback should be
-    /// called for subnets.
+    /// called for all subnets.
     /// @param lease_type a lease type.
     /// @param callback_fn callback function instance.
     /// @throw InvalidOperation when the callback has been already registered for the given owner and