[Kea-users] Kea hook lease6_select callback not getting called at times

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[Kea-users] Kea hook lease6_select callback not getting called at times

Mayank Tiwari
Hi,

  In our software component I have the requirement to get the IP address allocated to the host using kea dhcp server. In my original implementation I was using lease6_select callback to get that information. However, while testing figured out that lease6_select callback is not called at all times.

Working scenario log:
2019-09-26 02:58:32.003 INFO  [kea-dhcp6.event-handler/1] pkt6_receive callback function called
2019-09-26 02:58:32.004 INFO  [kea-dhcp6.event-handler/1] subnet6_select callback function called
2019-09-26 02:58:32.005 INFO  [kea-dhcp6.event-handler/1] lease6_select callback function called
2019-09-26 02:58:32.009 INFO  [kea-dhcp6.leases/1] DHCP6_LEASE_ALLOC duid=[00:03:00:01:00:20:a3:27:c4:7b], tid=0xd81ddb: lease for address 2001:xxx:yyyy:c1::2 and iaid=2737292411 has been allocated
2019-09-26 02:58:32.009 INFO  [kea-dhcp6.event-handler/1] pkt6_send callback function called

Non working scenario:
2019-09-26 09:53:13.941 INFO  [kea-dhcp6.event-handler/1] pkt6_receive callback function called
2019-09-26 09:53:13.946 INFO  [kea-dhcp6.event-handler/1] subnet6_select callback function called
2019-09-26 09:53:13.946 INFO  [kea-dhcp6.leases/1] DHCP6_LEASE_ALLOC duid=[00:03:00:01:f4:db:e6:b4:d3:ec], tid=0xca17c5: lease for address 2001:xxx:yyyy:c3::2 and iaid=1 has been allocated
2019-09-26 09:53:13.946 INFO  [kea-dhcp6.event-handler/1] pkt6_send callback function called

  In either scenarios, pkt6_send is getting called. So I was planning to move the implementation to pkt6_send. I have observed that the client IP is available in the response structure under option 5. So was planning to extract client IP information from there.

  However, in order to understand the issue in completeness. I wanted to know under what scenarios lease6_select function does not get called. I have referred https://jenkins.isc.org/job/Kea_doc/doxygen/d1/d02/dhcpv6Hooks.html . It has other useful details but not the detail on the scenario when lease6_select does not get called.

  Can you please give your inputs on it.

Thanks and Regards,
Mayank

_______________________________________________
Kea-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users
Reply | Threaded
Open this post in threaded view
|

Re: [Kea-users] Kea hook lease6_select callback not getting called at times

Francis Dupont
Explaination: the DHCP6_LEASE_ALLOC log message is from the server code,
lease6_select callout point is in the allocation engine library.
The server calls allocateLeases6 in the library, this method has at least
4 main cases so I am not very surprised that not all branches call
the callout (it is called only by 2 internal methods).
We'll revisit the definition of the callout point to see if it is a bug
and if it is we'll fix it.

Thanks

Francis Dupont <[hidden email]>
_______________________________________________
Kea-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users
Reply | Threaded
Open this post in threaded view
|

Re: [Kea-users] Kea hook lease6_select callback not getting called at times

Mayank Tiwari
Thanks Francis for your response. I have also checked the code and found the following code logic:
File: alloc_engine.cc
Function:
void
AllocEngine::allocateReservedLeases6(ClientContext6& ctx,
                                     Lease6Collection& existing_leases)

If there is existing lease for the client then the client lease time is extended
Else we create a new entry of the lease for the client. It is during new entry creation lease6_select callback gets called.

Usually in our testing we were doing reboot of the host causing the lease release and then lease select. But it seems that there could be few scenarios where the lease allocation can happen without the previous release. Few scenarios which I can think of is hard reboot of the host or plug out the cable of the host causing no lease release. Hence, I have decided to move my logic from lease6_select callback to ptk6_send callback as I have seen pkt6_send callback getting called consistently. Then I am planning to extract the host IP address allocated to client from Option 3 suboption 5 from the response.

Thanks for your inputs.

Regards,
Mayank

On Fri, Sep 27, 2019 at 12:03 PM Francis Dupont <[hidden email]> wrote:
Explaination: the DHCP6_LEASE_ALLOC log message is from the server code,
lease6_select callout point is in the allocation engine library.
The server calls allocateLeases6 in the library, this method has at least
4 main cases so I am not very surprised that not all branches call
the callout (it is called only by 2 internal methods).
We'll revisit the definition of the callout point to see if it is a bug
and if it is we'll fix it.

Thanks

Francis Dupont <[hidden email]>

_______________________________________________
Kea-users mailing list
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users