[kea-dev] Hooks called in incorrect order

Adrian Moreno amoreno at tecteco.com
Thu Nov 26 16:01:49 UTC 2015


Hi,

I'm trying to make use of Kea's hooks system and I'm encountering a what 
I think is a contradiction between the documentation and the actual 
behaviour

In the docs 
(http://git.kea.isc.org/~tester/kea/doxygen/de/df3/dhcpv4Hooks.html) I 
can read:

"...The following list is ordered by appearance of specific hook points 
during packet processing. Hook points that are not specific to packet 
processing (e.g. lease expiration) will be added to the end of this list..."

The list that follows start with:
buffer4_receive
pkt4_receive
subnet4_select
lease4_select
lease4_renew
...

Based on this, I'd expect "subnet4_select" hook to be called *after* 
"pkt4_receive". However, this is not the case.
Following the code flow, the culprit seems to be the following code 
which is run *before* going through the "pkt4_receive" callouts.
src/bin/dhcp4/dhcp4_srv.cc:
  515         // Check whether the message should be further processed 
or discarded.
  516         // There is no need to log anything here. This function 
logs by itself.
  517         if (!accept(query)) {
  518             // Increase the statistic of dropped packets.
  519 isc::stats::StatsMgr::instance().addValue("pkt4-receive-drop",
  520 static_cast<int64_t>(1));
  521 continue;
  522         }
With the stack being:
isc::dhcp::Subnet4Ptr Dhcpv4Srv::selectSubnet(const Pkt4Ptr& query) const
bool Dhcpv4Srv::acceptDirectRequest(const Pkt4Ptr& pkt) const
bool Dhcpv4Srv::accept(const Pkt4Ptr& query) const
bool Dhcpv4Srv::run()


I can see the point of dropping messages for which there is no valid 
subnet but, isn't that the reason why selectSubnet is called in 
"Dhcpv4Srv::processDiscover(Pkt4Ptr& discover)"?
Why call it twice?
and
Shouldn't this counter-intuitive behaviour be reflected in the 
Documentation?

Many thanks!
Adrian

PS: By the way, I'm running Kea 0.9.2.


More information about the kea-dev mailing list