Skip to content

Resolve "ping-check-hook-task-6 add core support to Dhcpv4Srv for declining leases"

Contributes to #3084 (closed)

  1. Add a function to Dhcp4Srv::serverDecline() to decline a lease to be used specifically for server initiated declines. It needs to create or update the lease in lease store, in declined state, increment appropriate stats. It does not need to worry about DNS entries or the ilk. It needs to include a new hook point, "lease4-ping-check-decline" (or some such name). This hook point will be implemented by HA in a future release for propagating declines to peers.

  2. Modify unpark lambda in Dhcpv4Srv::processDhcp4Query() to handle unparking when a lease fails ping check (i.e. is already in use). Something like this:

                 HooksManager::park(
                     hook_label, query,
-                    [this, callout_handle, query, rsp, callout_handle_state]() mutable {
+                    [this, callout_handle, query, rsp, callout_handle_state, hook_idx]() mutable {
+                        if (hook_idx == Hooks.hook_index_lease4_offer_) {
+                            auto status = callout_handle->getStatus();
+                            if (status == CalloutHandle::NEXT_STEP_DROP) {
+                                if (MultiThreadingMgr::instance().getMode()) {
+                                    typedef function<void()> CallBack;
+                                    boost::shared_ptr<CallBack> call_back = boost::make_shared<CallBack>(
+                                        std::bind(&Dhcpv4Srv::serverDeclineNoThrow, this, callout_handle, query, rsp));
+                                    callout_handle_state->on_completion_ = [call_back]() {
+                                        MultiThreadingMgr::instance().getThreadPool().add(call_back);
+                                    };
+                                } else {
+                                    serverDecline(callout_handle, query, rsp);
+                                }
+
+                                rsp.reset();
+                                return;
+                            }
+                        }
+
                         if (MultiThreadingMgr::instance().getMode()) {
                             typedef function<void()> CallBack;
                             boost::shared_ptr<CallBack> call_back = boost::make_shared<CallBack>(

Merge request reports