2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 06:25:34 +00:00

[#3084] Use callout argument instead of status

src/bin/dhcp4/dhcp4_messages.mes
    DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING - new message

src/bin/dhcp4/dhcp4_srv.cc
    Dhcpv4Srv::processDhcp4Query() - look for offer-address-in-use
    argument in lease4_offer unpark lambda
This commit is contained in:
Thomas Markwalder
2023-11-09 14:58:33 -05:00
parent 2d998a28be
commit e662234173
4 changed files with 21 additions and 2 deletions

View File

@@ -83,6 +83,7 @@ extern const isc::log::MessageID DHCP4_HOOK_BUFFER_RCVD_SKIP = "DHCP4_HOOK_BUFFE
extern const isc::log::MessageID DHCP4_HOOK_BUFFER_SEND_SKIP = "DHCP4_HOOK_BUFFER_SEND_SKIP"; extern const isc::log::MessageID DHCP4_HOOK_BUFFER_SEND_SKIP = "DHCP4_HOOK_BUFFER_SEND_SKIP";
extern const isc::log::MessageID DHCP4_HOOK_DDNS_UPDATE = "DHCP4_HOOK_DDNS_UPDATE"; extern const isc::log::MessageID DHCP4_HOOK_DDNS_UPDATE = "DHCP4_HOOK_DDNS_UPDATE";
extern const isc::log::MessageID DHCP4_HOOK_DECLINE_SKIP = "DHCP4_HOOK_DECLINE_SKIP"; extern const isc::log::MessageID DHCP4_HOOK_DECLINE_SKIP = "DHCP4_HOOK_DECLINE_SKIP";
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING = "DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING";
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_DROP = "DHCP4_HOOK_LEASE4_OFFER_DROP"; extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_DROP = "DHCP4_HOOK_LEASE4_OFFER_DROP";
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARK = "DHCP4_HOOK_LEASE4_OFFER_PARK"; extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARK = "DHCP4_HOOK_LEASE4_OFFER_PARK";
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL = "DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL"; extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL = "DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL";
@@ -263,6 +264,7 @@ const char* values[] = {
"DHCP4_HOOK_BUFFER_SEND_SKIP", "%1: prepared response is dropped because a callout set the next step to SKIP.", "DHCP4_HOOK_BUFFER_SEND_SKIP", "%1: prepared response is dropped because a callout set the next step to SKIP.",
"DHCP4_HOOK_DDNS_UPDATE", "A hook has updated the DDNS parameters: hostname %1=>%2, forward update %3=>%4, reverse update %5=>%6", "DHCP4_HOOK_DDNS_UPDATE", "A hook has updated the DDNS parameters: hostname %1=>%2, forward update %3=>%4, reverse update %5=>%6",
"DHCP4_HOOK_DECLINE_SKIP", "Decline4 hook callouts set status to DROP, ignoring packet.", "DHCP4_HOOK_DECLINE_SKIP", "Decline4 hook callouts set status to DROP, ignoring packet.",
"DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING", "hook callouts did not set an argument as expected %1 for %2",
"DHCP4_HOOK_LEASE4_OFFER_DROP", "%1: packet is dropped, because a callout set the next step to DROP", "DHCP4_HOOK_LEASE4_OFFER_DROP", "%1: packet is dropped, because a callout set the next step to DROP",
"DHCP4_HOOK_LEASE4_OFFER_PARK", "%1: packet is parked, because a callout set the next step to PARK", "DHCP4_HOOK_LEASE4_OFFER_PARK", "%1: packet is parked, because a callout set the next step to PARK",
"DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL", "The parked-packet-limit %1, has been reached, dropping query: %2", "DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL", "The parked-packet-limit %1, has been reached, dropping query: %2",

View File

@@ -84,6 +84,7 @@ extern const isc::log::MessageID DHCP4_HOOK_BUFFER_RCVD_SKIP;
extern const isc::log::MessageID DHCP4_HOOK_BUFFER_SEND_SKIP; extern const isc::log::MessageID DHCP4_HOOK_BUFFER_SEND_SKIP;
extern const isc::log::MessageID DHCP4_HOOK_DDNS_UPDATE; extern const isc::log::MessageID DHCP4_HOOK_DDNS_UPDATE;
extern const isc::log::MessageID DHCP4_HOOK_DECLINE_SKIP; extern const isc::log::MessageID DHCP4_HOOK_DECLINE_SKIP;
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING;
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_DROP; extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_DROP;
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARK; extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARK;
extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL; extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL;

View File

@@ -1073,3 +1073,9 @@ in a network or more likely a device that is using an address that it is not
supposed to use. The server will fully recover from this situation, but if supposed to use. The server will fully recover from this situation, but if
the underlying problem of a misconfigured or rogue device is not solved, this the underlying problem of a misconfigured or rogue device is not solved, this
address may be declined again in the future. address may be declined again in the future.
% DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING hook callouts did not set an argument as expected %1 for %2
This debug message is printed when none of the callouts installed on the
lease4_offer hook point set an expected argument in the callout status.
This is a programming error in the installed hook libraries. Details of
the argument and the query in process at the time are provided log arguments.

View File

@@ -1502,6 +1502,7 @@ Dhcpv4Srv::processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp,
static_cast<int64_t>(1)); static_cast<int64_t>(1));
rsp.reset(); rsp.reset();
return; return;
} }
} }
@@ -1513,8 +1514,17 @@ Dhcpv4Srv::processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp,
hook_label, query, hook_label, query,
[this, callout_handle, query, rsp, callout_handle_state, hook_idx, ctx]() mutable { [this, callout_handle, query, rsp, callout_handle_state, hook_idx, ctx]() mutable {
if (hook_idx == Hooks.hook_index_lease4_offer_) { if (hook_idx == Hooks.hook_index_lease4_offer_) {
auto status = callout_handle->getStatus(); bool offer_address_in_use = false;
if (status == CalloutHandle::NEXT_STEP_DROP) { try {
callout_handle->getArgument("offer-address-in-use", offer_address_in_use);
} catch (const NoSuchArgument& ex) {
/// @todo consider logging this
LOG_DEBUG(hooks_logger, DBG_DHCP4_HOOKS,
DHCP4_HOOK_LEASE4_OFFER_ARGUMENT_MISSING)
.arg(query->getLabel());
}
if (offer_address_in_use) {
Lease4Ptr lease = ctx->new_lease_; Lease4Ptr lease = ctx->new_lease_;
bool lease_exists = (ctx->offer_lft_ > 0); bool lease_exists = (ctx->offer_lft_ > 0);
if (MultiThreadingMgr::instance().getMode()) { if (MultiThreadingMgr::instance().getMode()) {