]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#689] Do not include subnet-id in failed leases in response to bulk apply.
authorMarcin Siodelski <marcin@isc.org>
Mon, 24 Jun 2019 15:09:07 +0000 (17:09 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 24 Jun 2019 17:10:14 +0000 (13:10 -0400)
src/hooks/dhcp/lease_cmds/lease_cmds.cc
src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc

index fa7c23d279acff4755f1cca645161a4033d4297d..5ec7bce1f18b7b7ab309d535960b3fa2e32c60a5 100644 (file)
@@ -269,15 +269,13 @@ public:
     /// The DUID is only included if it is non-null. The address is only
     /// included if it is non-zero.
     ///
-    /// @param subnet_id identifier of the subnet where the lease belongs.
     /// @param lease_type lease type.
     /// @param lease_address lease address.
     /// @param duid DUID of the client.
     /// @param control_result Control result: "empty" of the lease was
     /// not found, "error" otherwise.
     /// @param error_message Error message.
-    ElementPtr createFailedLeaseMap(const SubnetID& subnet_id,
-                                    const Lease::Type& lease_type,
+    ElementPtr createFailedLeaseMap(const Lease::Type& lease_type,
                                     const IOAddress& lease_address,
                                     const DuidPtr& duid,
                                     const int control_result,
@@ -921,7 +919,7 @@ LeaseCmdsImpl::lease6BulkApplyHandler(CalloutHandle& handle) {
                             // on the list of leases which failed to delete. That
                             // corresponds to the lease6-del command which returns
                             // an error when the lease doesn't exist.
-                            failed_deleted_list->add(createFailedLeaseMap(p.subnet_id, p.lease_type,
+                            failed_deleted_list->add(createFailedLeaseMap(p.lease_type,
                                                                           p.addr, p.duid,
                                                                           CONTROL_RESULT_EMPTY,
                                                                           "lease not found"));
@@ -933,7 +931,7 @@ LeaseCmdsImpl::lease6BulkApplyHandler(CalloutHandle& handle) {
                     if (!failed_deleted_list) {
                          failed_deleted_list = Element::createList();
                     }
-                    failed_deleted_list->add(createFailedLeaseMap(p.subnet_id, p.lease_type,
+                    failed_deleted_list->add(createFailedLeaseMap(p.lease_type,
                                                                   p.addr, p.duid,
                                                                   CONTROL_RESULT_ERROR,
                                                                   ex.what()));
@@ -968,8 +966,7 @@ LeaseCmdsImpl::lease6BulkApplyHandler(CalloutHandle& handle) {
                     if (!failed_leases_list) {
                          failed_leases_list = Element::createList();
                     }
-                    failed_leases_list->add(createFailedLeaseMap(lease->subnet_id_,
-                                                                 lease->type_,
+                    failed_leases_list->add(createFailedLeaseMap(lease->type_,
                                                                  lease->addr_,
                                                                  lease->duid_,
                                                                  CONTROL_RESULT_ERROR,
@@ -1279,15 +1276,12 @@ LeaseCmdsImpl::getIPv6AddressForDelete(const Parameters& parameters) const {
 }
 
 ElementPtr
-LeaseCmdsImpl::createFailedLeaseMap(const SubnetID& subnet_id,
-                                    const Lease::Type& lease_type,
+LeaseCmdsImpl::createFailedLeaseMap(const Lease::Type& lease_type,
                                     const IOAddress& lease_address,
                                     const DuidPtr& duid,
                                     const int control_result,
                                     const std::string& error_message) const {
     auto failed_lease_map = Element::createMap();
-    failed_lease_map->set("subnet-id",
-                          Element::create(static_cast<long int>(subnet_id)));
     failed_lease_map->set("type", Element::create(Lease::typeToText(lease_type)));
 
     if (!lease_address.isV6Zero()) {
index 3c7a977c10eac50bbbf1f11f3c68dccc99972cb2..1d5117eb40ccbd30403cff45270851032b2b3eff 100644 (file)
@@ -504,14 +504,11 @@ public:
     /// @oaram expected_control_result Expected control result for the lease.
     /// @param expected_error_msg Expected error message. Default is an empty
     /// string which indicates that the error message should not be checked.
-    /// @param expected_subnet_id Expected subnet id. Default is -1 which means
-    /// that the subnet_id is not required and should not be checked.
     void checkFailedLease(const ConstElementPtr& failed_leases_list,
                           const std::string& expected_type,
                           const std::string& expected_ip_address,
                           const int expected_control_result,
-                          const std::string& expected_error_msg = "",
-                          const SubnetID& expected_subnet_id = -1) {
+                          const std::string& expected_error_msg = "") {
         ASSERT_TRUE(failed_leases_list);
 
         for (auto i = 0; i < failed_leases_list->size(); ++i) {
@@ -540,12 +537,6 @@ public:
                     ASSERT_EQ(Element::string, error_msg->getType());
                 }
 
-                if (expected_subnet_id > 0) {
-                    auto subnet_id = failed_lease->get("subnet-id");
-                    ASSERT_TRUE(subnet_id);
-                    ASSERT_EQ(Element::integer, subnet_id->getType());
-                }
-
                 return;
             }
         }