container->addOption(status);
}
- void
+ bool
Dhcpv6Srv::declineLease(const Pkt6Ptr& decline, const Lease6Ptr lease,
boost::shared_ptr<Option6IA> ia_rsp) {
+ // We do not want to decrease the assigned-nas at this time. While
+ // technically a declined address is no longer allocated, the primary usage
+ // of the assigned-addresses statistic is to monitor pool utilization. Most
+ // people would forget to include declined-addresses in the calculation,
+ // and simply do assigned-addresses/total-addresses. This would have a bias
+ // towards under-representing pool utilization, if we decreased allocated
+ // immediately after receiving DHCPDECLINE, rather than later when we recover
+ // the address.
+ // Let's call lease6_decline hooks if necessary.
+ if (HooksManager::calloutsPresent(Hooks.hook_index_lease6_decline_)) {
+ CalloutHandlePtr callout_handle = getCalloutHandle(decline);
+
+ // Delete previously set arguments
+ callout_handle->deleteAllArguments();
+
+ // Pass incoming packet as argument
+ callout_handle->setArgument("query6", decline);
+ callout_handle->setArgument("lease6", lease);
+
+ // Call callouts
+ HooksManager::callCallouts(Hooks.hook_index_lease6_decline_,
+ *callout_handle);
+
+ // Callouts decided to SKIP the next processing step. The next
+ // processing step would to actually decline the lease, so we'll
+ // keep the lease as is.
+ if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) {
+ LOG_DEBUG(hooks_logger, DBG_DHCP6_DETAIL, DHCP6_HOOK_DECLINE_SKIP)
+ .arg(decline->getLabel())
+ .arg(decline->getIface())
+ .arg(lease->addr_.toText());
+ return (true);
+ }
+
+ // Callouts decided to DROP the packet. Let's simply log it and
+ // return false, so callers will act accordingly.
+ if (callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP) {
+ LOG_DEBUG(hooks_logger, DBG_DHCP6_DETAIL, DHCP6_HOOK_DECLINE_DROP)
+ .arg(decline->getLabel())
+ .arg(decline->getIface())
+ .arg(lease->addr_.toText());
+ return (false);
+ }
+ }
+
// Check if a lease has flags indicating that the FQDN update has
// been performed. If so, create NameChangeRequest which removes
// the entries. This method does all necessary checks.