From: Marcin Siodelski Date: Mon, 24 Jun 2019 15:09:07 +0000 (+0200) Subject: [#689] Do not include subnet-id in failed leases in response to bulk apply. X-Git-Tag: Kea-1.6.0-beta2~220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=59782988ca75bc8794f432f00d4cb90f9c184b25;p=thirdparty%2Fkea.git [#689] Do not include subnet-id in failed leases in response to bulk apply. --- diff --git a/src/hooks/dhcp/lease_cmds/lease_cmds.cc b/src/hooks/dhcp/lease_cmds/lease_cmds.cc index fa7c23d279..5ec7bce1f1 100644 --- a/src/hooks/dhcp/lease_cmds/lease_cmds.cc +++ b/src/hooks/dhcp/lease_cmds/lease_cmds.cc @@ -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(subnet_id))); failed_lease_map->set("type", Element::create(Lease::typeToText(lease_type))); if (!lease_address.isV6Zero()) { diff --git a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc index 3c7a977c10..1d5117eb40 100644 --- a/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc +++ b/src/hooks/dhcp/lease_cmds/tests/lease_cmds_unittest.cc @@ -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; } }