diff --git a/src/bin/dhcp4/dhcp4_messages.cc b/src/bin/dhcp4/dhcp4_messages.cc index 1a52f027f0..1a389396c7 100644 --- a/src/bin/dhcp4/dhcp4_messages.cc +++ b/src/bin/dhcp4/dhcp4_messages.cc @@ -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_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_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_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"; @@ -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_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_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_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", diff --git a/src/bin/dhcp4/dhcp4_messages.h b/src/bin/dhcp4/dhcp4_messages.h index ec00771297..4dd3797350 100644 --- a/src/bin/dhcp4/dhcp4_messages.h +++ b/src/bin/dhcp4/dhcp4_messages.h @@ -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_DDNS_UPDATE; 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_PARK; extern const isc::log::MessageID DHCP4_HOOK_LEASE4_OFFER_PARKING_LOT_FULL; diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index ecf3f5c408..1bea7561dd 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -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 the underlying problem of a misconfigured or rogue device is not solved, this 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. diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 64d96d1ed9..7e209e722d 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -1502,6 +1502,7 @@ Dhcpv4Srv::processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp, static_cast(1)); rsp.reset(); return; + } } @@ -1513,8 +1514,17 @@ Dhcpv4Srv::processDhcp4Query(Pkt4Ptr& query, Pkt4Ptr& rsp, hook_label, query, [this, callout_handle, query, rsp, callout_handle_state, hook_idx, ctx]() mutable { if (hook_idx == Hooks.hook_index_lease4_offer_) { - auto status = callout_handle->getStatus(); - if (status == CalloutHandle::NEXT_STEP_DROP) { + bool offer_address_in_use = false; + 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_; bool lease_exists = (ctx->offer_lft_ > 0); if (MultiThreadingMgr::instance().getMode()) {