]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1540] Removed useless getLease4 variant
authorFrancis Dupont <fdupont@isc.org>
Sat, 14 Nov 2020 18:26:22 +0000 (19:26 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 4 Jan 2021 15:53:34 +0000 (16:53 +0100)
15 files changed:
src/lib/dhcpsrv/cql_lease_mgr.cc
src/lib/dhcpsrv/cql_lease_mgr.h
src/lib/dhcpsrv/dhcpsrv_messages.cc
src/lib/dhcpsrv/dhcpsrv_messages.h
src/lib/dhcpsrv/dhcpsrv_messages.mes
src/lib/dhcpsrv/lease_mgr.h
src/lib/dhcpsrv/memfile_lease_mgr.cc
src/lib/dhcpsrv/memfile_lease_mgr.h
src/lib/dhcpsrv/mysql_lease_mgr.cc
src/lib/dhcpsrv/mysql_lease_mgr.h
src/lib/dhcpsrv/pgsql_lease_mgr.cc
src/lib/dhcpsrv/pgsql_lease_mgr.h
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

index e0cf89b223a853acb08ab4632e554cae3aef6253..50d2ec2e17c11725a009183be807213c4ba0ad83 100644 (file)
@@ -2263,22 +2263,6 @@ CqlLeaseMgr::getLease4(const ClientId &clientid) const {
     return (result);
 }
 
-Lease4Ptr
-CqlLeaseMgr::getLease4(const ClientId &clientid, const HWAddr &hwaddr,
-                       SubnetID subnet_id) const {
-    /// @todo: Remove this method in this and all other implementations.
-    /// This method is currently not implemented because allocation engine
-    /// searches for the lease using HW address or client identifier.
-    /// It never uses both parameters in the same time. We need to
-    /// consider if this method is needed at all.
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_CLIENTID_HWADDR_SUBID)
-        .arg(clientid.toText())
-        .arg(hwaddr.toText())
-        .arg(subnet_id);
-
-    isc_throw(NotImplemented, "CqlLeaseMgr::getLease4() is obsolete");
-}
-
 Lease4Ptr
 CqlLeaseMgr::getLease4(const ClientId &clientid, SubnetID subnet_id) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_CQL_GET_SUBID_CLIENTID)
index b0db0b33994feafc081cd27093d2a2c91e481382..79a954248852d505d706c4f67cc08c7dbdb40ec7 100644 (file)
@@ -169,21 +169,6 @@ public:
     ///        failed.
     virtual Lease4Collection getLease4(const ClientId& clientid) const override;
 
-    /// @brief Returns IPv4 lease for the specified client identifier, HW
-    /// address and subnet identifier.
-    ///
-    /// @param client_id A client identifier.
-    /// @param hwaddr hardware address.
-    /// @param subnet_id A subnet identifier.
-    ///
-    /// @return A pointer to the lease or NULL if the lease is not found.
-    ///
-    /// @throw isc::NotImplemented On every call as this method is currently
-    /// not implemented for the CQL backend.
-    virtual Lease4Ptr getLease4(const ClientId& client_id,
-                                const HWAddr& hwaddr,
-                                SubnetID subnet_id) const override;
-
     /// @brief Returns existing IPv4 lease for specified client-id
     ///
     /// There can be at most one lease for a given HW address in a single
index ce09d7dd53c1d8022ae67d2891639951f3885c7e..efa6a439ddb7deca1f435b80cf1865831fcf359e 100644 (file)
@@ -121,7 +121,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET6_DUID = "DHCPSRV_MEMFILE_GE
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR4 = "DHCPSRV_MEMFILE_GET_ADDR4";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR6 = "DHCPSRV_MEMFILE_GET_ADDR6";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID = "DHCPSRV_MEMFILE_GET_CLIENTID";
-extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID = "DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED4 = "DHCPSRV_MEMFILE_GET_EXPIRED4";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED6 = "DHCPSRV_MEMFILE_GET_EXPIRED6";
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME4 = "DHCPSRV_MEMFILE_GET_HOSTNAME4";
@@ -382,7 +381,6 @@ const char* values[] = {
     "DHCPSRV_MEMFILE_GET_ADDR4", "obtaining IPv4 lease for address %1",
     "DHCPSRV_MEMFILE_GET_ADDR6", "obtaining IPv6 lease for address %1 and lease type %2",
     "DHCPSRV_MEMFILE_GET_CLIENTID", "obtaining IPv4 leases for client ID %1",
-    "DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID", "obtaining IPv4 lease for client ID %1, hardware address %2 and subnet ID %3",
     "DHCPSRV_MEMFILE_GET_EXPIRED4", "obtaining maximum %1 of expired IPv4 leases",
     "DHCPSRV_MEMFILE_GET_EXPIRED6", "obtaining maximum %1 of expired IPv6 leases",
     "DHCPSRV_MEMFILE_GET_HOSTNAME4", "obtaining IPv4 leases for hostname %1",
index cf96a96b2ef87c41c75950e125a2df8e1ecc0335..40064ca73a4e5867c3868c692627140fb91ec657 100644 (file)
@@ -122,7 +122,6 @@ extern const isc::log::MessageID DHCPSRV_MEMFILE_GET6_DUID;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR4;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_ADDR6;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID;
-extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED4;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_EXPIRED6;
 extern const isc::log::MessageID DHCPSRV_MEMFILE_GET_HOSTNAME4;
index 0dc40cad8720cac8315a44c8010f648f6f487d03..386c73aa446a3a7c9d8ecffa2584e9b9ac23324d 100644 (file)
@@ -600,11 +600,6 @@ A debug message issued when the server is attempting to obtain a set of
 IPv4 leases from the memory file database for a client with the specified
 client identification.
 
-% DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID obtaining IPv4 lease for client ID %1, hardware address %2 and subnet ID %3
-A debug message issued when the server is attempting to obtain an IPv4
-lease from the memory file database for a client with the specified
-client ID, hardware address and subnet ID.
-
 % DHCPSRV_MEMFILE_GET_EXPIRED4 obtaining maximum %1 of expired IPv4 leases
 A debug message issued when the server is attempting to obtain expired
 IPv4 leases to reclaim them. The maximum number of leases to be retrieved
index 35d218fff4bbc58195e350ab2a20f970e0ce9e71..1c8ca49a811ef532b480c576319569fe2c90d840 100644 (file)
@@ -311,20 +311,6 @@ public:
     /// @return lease collection
     virtual Lease4Collection getLease4(const ClientId& clientid) const = 0;
 
-    /// @brief Returns existing IPv4 lease for a given client identifier,
-    /// HW address and subnet identifier.
-    ///
-    /// @todo Consider whether this function is needed or not. In the basic
-    /// DHCPv4 server implementation it is not used by the allocation engine.
-    ///
-    /// @param client_id A client identifier.
-    /// @param hwaddr Hardware address.
-    /// @param subnet_id A subnet identifier.
-    ///
-    /// @return A pointer to the lease or NULL if the lease is not found.
-    virtual Lease4Ptr getLease4(const ClientId& client_id, const HWAddr& hwaddr,
-                                SubnetID subnet_id) const = 0;
-
     /// @brief Returns existing IPv4 lease for specified client-id
     ///
     /// There can be at most one lease for a given client-id in a single
index 349e3bfcbdc9606c3fbe5b1b0b04efc555246367..67296d71b715238a361662f44101146b3c48c4c2 100644 (file)
@@ -882,44 +882,6 @@ Memfile_LeaseMgr::getLease4(const ClientId& client_id) const {
     return (collection);
 }
 
-Lease4Ptr
-Memfile_LeaseMgr::getLease4Internal(const ClientId& client_id,
-                                    const HWAddr& hwaddr,
-                                    SubnetID subnet_id) const {
-    // Get the index by client id, HW address and subnet id.
-    const Lease4StorageClientIdHWAddressSubnetIdIndex& idx =
-        storage4_.get<ClientIdHWAddressSubnetIdIndexTag>();
-    // Try to get the lease using client id, hardware address and subnet id.
-    Lease4StorageClientIdHWAddressSubnetIdIndex::const_iterator lease =
-        idx.find(boost::make_tuple(client_id.getClientId(), hwaddr.hwaddr_,
-                                   subnet_id));
-
-    if (lease == idx.end()) {
-        // Lease was not found. Return empty pointer to the caller.
-        return (Lease4Ptr());
-    }
-
-    // Lease was found. Return it to the caller.
-    return (*lease);
-}
-
-Lease4Ptr
-Memfile_LeaseMgr::getLease4(const ClientId& client_id,
-                            const HWAddr& hwaddr,
-                            SubnetID subnet_id) const {
-    LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
-              DHCPSRV_MEMFILE_GET_CLIENTID_HWADDR_SUBID).arg(client_id.toText())
-                                                        .arg(hwaddr.toText())
-                                                        .arg(subnet_id);
-
-    if (MultiThreadingMgr::instance().getMode()) {
-        std::lock_guard<std::mutex> lock(*mutex_);
-        return (getLease4Internal(client_id, hwaddr, subnet_id));
-    } else {
-        return (getLease4Internal(client_id, hwaddr, subnet_id));
-    }
-}
-
 Lease4Ptr
 Memfile_LeaseMgr::getLease4Internal(const ClientId& client_id,
                                     SubnetID subnet_id) const {
index 3273ee4839feeb2bf41ed2877099bb752bb4c559..0896114acba5ff92048935709d1678c70e569575 100644 (file)
@@ -200,21 +200,6 @@ public:
     /// @return lease collection
     virtual Lease4Collection getLease4(const ClientId& client_id) const;
 
-    /// @brief Returns IPv4 lease for specified client-id/hwaddr/subnet-id tuple
-    ///
-    /// There can be at most one lease for a given client-id/hwaddr tuple
-    /// in a single pool, so this method with either return a single lease
-    /// or NULL.
-    ///
-    /// @param clientid client identifier
-    /// @param hwaddr hardware address of the client
-    /// @param subnet_id identifier of the subnet that lease must belong to
-    ///
-    /// @return a pointer to the lease (or NULL if a lease is not found)
-    virtual Lease4Ptr getLease4(const ClientId& clientid,
-                                const HWAddr& hwaddr,
-                                SubnetID subnet_id) const;
-
     /// @brief Returns existing IPv4 lease for specified client-id
     ///
     /// This function returns a copy of the lease. The modification in the
index b89d9b29b0aed45583562f984a82f71fbd1200f7..71e45bfb732a888a1398f1a821c6a3e660e691ab 100644 (file)
@@ -2268,16 +2268,6 @@ MySqlLeaseMgr::getLease4(const ClientId& clientid) const {
     return (result);
 }
 
-Lease4Ptr
-MySqlLeaseMgr::getLease4(const ClientId&, const HWAddr&, SubnetID) const {
-    /// This function is currently not implemented because allocation engine
-    /// searches for the lease using HW address or client identifier.
-    /// It never uses both parameters in the same time. We need to
-    /// consider if this function is needed at all.
-    isc_throw(NotImplemented, "The MySqlLeaseMgr::getLease4 function was"
-              " called, but it is not implemented");
-}
-
 Lease4Ptr
 MySqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID_CLIENTID)
index d387883748af60a485e0048712e9f0fbab37c818..f3f8b80aec2ac45b1ffe4b597517c2d0983d0881 100644 (file)
@@ -250,19 +250,6 @@ public:
     ///        failed.
     virtual Lease4Collection getLease4(const ClientId& clientid) const;
 
-    /// @brief Returns IPv4 lease for the specified client identifier, HW
-    /// address and subnet identifier.
-    ///
-    /// @param client_id A client identifier.
-    /// @param hwaddr Hardware address.
-    /// @param subnet_id A subnet identifier.
-    ///
-    /// @return A pointer to the lease or NULL if the lease is not found.
-    /// @throw isc::NotImplemented On every call as this function is currently
-    /// not implemented for the MySQL backend.
-    virtual Lease4Ptr getLease4(const ClientId& client_id, const HWAddr& hwaddr,
-                                SubnetID subnet_id) const;
-
     /// @brief Returns existing IPv4 lease for specified client-id
     ///
     /// There can be at most one lease for a given HW address in a single
index f896d126e5ddeaef19b9e6db5835dddfe64e9c3e..5a9957817fd7210c7b4202d8c770f79e22e30418 100644 (file)
@@ -1597,16 +1597,6 @@ PgSqlLeaseMgr::getLease4(const ClientId& clientid) const {
     return (result);
 }
 
-Lease4Ptr
-PgSqlLeaseMgr::getLease4(const ClientId&, const HWAddr&, SubnetID) const {
-    /// This function is currently not implemented because allocation engine
-    /// searches for the lease using HW address or client identifier.
-    /// It never uses both parameters in the same time. We need to
-    /// consider if this function is needed at all.
-    isc_throw(NotImplemented, "The PgSqlLeaseMgr::getLease4 function was"
-              " called, but it is not implemented");
-}
-
 Lease4Ptr
 PgSqlLeaseMgr::getLease4(const ClientId& clientid, SubnetID subnet_id) const {
     LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_PGSQL_GET_SUBID_CLIENTID)
index bb9d2561009c5afd3676190aa5eba291bf0bc627..f767111128d375ce804fc632c5e1f895a96e6043 100644 (file)
@@ -237,19 +237,6 @@ public:
     ///        failed.
     virtual Lease4Collection getLease4(const ClientId& clientid) const;
 
-    /// @brief Returns IPv4 lease for the specified client identifier, HW
-    /// address and subnet identifier.
-    ///
-    /// @param client_id A client identifier.
-    /// @param hwaddr Hardware address.
-    /// @param subnet_id A subnet identifier.
-    ///
-    /// @return A pointer to the lease or NULL if the lease is not found.
-    /// @throw isc::NotImplemented On every call as this function is currently
-    /// not implemented for the PostgreSQL backend.
-    virtual Lease4Ptr getLease4(const ClientId& client_id, const HWAddr& hwaddr,
-                                SubnetID subnet_id) const;
-
     /// @brief Returns existing IPv4 lease for specified client-id
     ///
     /// There can be at most one lease for a given HW address in a single
index 3a58cb7aba9c4b8af1f3bd7704907c2cc05fe991..ace091e0cc15b3243397171eb7284f45bd41112e 100644 (file)
@@ -595,40 +595,6 @@ GenericLeaseMgrTest::testGetLease4HWAddr2() {
     EXPECT_EQ(0, returned.size());
 }
 
-void
-GenericLeaseMgrTest::testGetLease4ClientIdHWAddrSubnetId() {
-    Lease4Ptr leaseA = initializeLease4(straddress4_[4]);
-    Lease4Ptr leaseB = initializeLease4(straddress4_[5]);
-    Lease4Ptr leaseC = initializeLease4(straddress4_[6]);
-    // Set NULL client id for one of the leases. This is to make sure that such
-    // a lease may coexist with other leases with non NULL client id.
-    leaseC->client_id_.reset();
-
-    HWAddr hwaddrA(*leaseA->hwaddr_);
-    HWAddr hwaddrB(*leaseB->hwaddr_);
-    HWAddr hwaddrC(*leaseC->hwaddr_);
-    EXPECT_TRUE(lmptr_->addLease(leaseA));
-    EXPECT_TRUE(lmptr_->addLease(leaseB));
-    EXPECT_TRUE(lmptr_->addLease(leaseC));
-    // First case we should retrieve our lease
-    Lease4Ptr lease = lmptr_->getLease4(*leaseA->client_id_, hwaddrA, leaseA->subnet_id_);
-    detailCompareLease(lease, leaseA);
-    // Retrieve the other lease.
-    lease = lmptr_->getLease4(*leaseB->client_id_, hwaddrB, leaseB->subnet_id_);
-    detailCompareLease(lease, leaseB);
-    // The last lease has NULL client id so we will use a different getLease4 function
-    // which doesn't require client id (just a hwaddr and subnet id).
-    lease = lmptr_->getLease4(hwaddrC, leaseC->subnet_id_);
-    detailCompareLease(lease, leaseC);
-
-    // An attempt to retrieve the lease with non matching lease parameters should
-    // result in NULL pointer being returned.
-    lease = lmptr_->getLease4(*leaseA->client_id_, hwaddrB, leaseA->subnet_id_);
-    EXPECT_FALSE(lease);
-    lease = lmptr_->getLease4(*leaseA->client_id_, hwaddrA, leaseB->subnet_id_);
-    EXPECT_FALSE(lease);
-}
-
 void
 GenericLeaseMgrTest::testAddGetDelete6() {
     const std::string addr234("2001:db8:1::234");
index 2c57dd8f593bc1f46dbc7b005324678641213e55..b1c739ac01a9d51cb2345f40bc3af81bdba960f5 100644 (file)
@@ -174,9 +174,6 @@ public:
     /// HWAddr information.
     void testGetLease4HWAddr2();
 
-    /// @brief Test lease retrieval using client id, HW address and subnet id.
-    void testGetLease4ClientIdHWAddrSubnetId();
-
     /// @brief Get lease4 by hardware address (2)
     ///
     /// Check that the system can cope with getting a hardware address of
index 937f8a3b4e809aba9072faa210219e9df9999371..0dba30b8312fda402d6895a9373c8410db2802ff 100644 (file)
@@ -910,19 +910,6 @@ TEST_F(MemfileLeaseMgrTest, getLease4HWAddr2MultiThread) {
     testGetLease4HWAddr2();
 }
 
-/// @brief Checks lease4 retrieval with clientId, HWAddr and subnet_id
-TEST_F(MemfileLeaseMgrTest, getLease4ClientIdHWAddrSubnetId) {
-    startBackend(V4);
-    testGetLease4ClientIdHWAddrSubnetId();
-}
-
-/// @brief Checks lease4 retrieval with clientId, HWAddr and subnet_id
-TEST_F(MemfileLeaseMgrTest, getLease4ClientIdHWAddrSubnetIdMultiThread) {
-    startBackend(V4);
-    MultiThreadingMgr::instance().setMode(true);
-    testGetLease4ClientIdHWAddrSubnetId();
-}
-
 /// @brief Basic Lease4 Checks
 ///
 /// Checks that the addLease, getLease4(by address), getLease4(hwaddr,subnet_id),
@@ -2072,16 +2059,6 @@ TEST_F(MemfileLeaseMgrTest, lease4ContainerIndexUpdate) {
             << error_desc;
         detailCompareLease(tested, lease_by_clientid_subnet);
 
-        // Retrieve lease by client id, HW address and subnet.
-        Lease4Ptr lease_by_clientid_hwaddr_subnet = lmptr_->getLease4(*tested->client_id_,
-                                                                      *tested->hwaddr_,
-                                                                      tested->subnet_id_);
-        ASSERT_TRUE(lease_by_clientid_hwaddr_subnet)
-            << "Lease " << tested->addr_.toText()
-            << " not found by getLease4(clientid, hwaddr, subnet_id)"
-            << error_desc;
-        detailCompareLease(tested, lease_by_clientid_hwaddr_subnet);
-
         // Retrieve lease by HW address.
         Lease4Collection leases_by_hwaddr = lmptr_->getLease4(*tested->hwaddr_);
         ASSERT_EQ(1, leases_by_hwaddr.size());