[Kea-users] isc_kea: Reuse same IP for a host

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

[Kea-users] isc_kea: Reuse same IP for a host

Mayank Tiwari
Hi,

  We have requirement to use same IPv6 for the host after the reboot of the host. What we have observed is that every SOLICIT message results in allocation of new IP to the host.

First solicit:
2020-06-02 14:29:41.499 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available - trying to dynamically allocate leases for client duid=[00:03:00:01:**:45:34], tid=0x8be064

Second immediate solicit:
2020-06-02 14:29:43.103 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_LEASES_NO_HR no reservations found but leases exist for client duid=[00:03:00:01:**:45:34], tid=0xcae8c5

  Both solicit allocate different IP. (First one ::2, Second one ::3)

 Similarly after reboot of host:

First solicit:
2020-06-02 14:35:38.020 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available - trying to dynamically allocate leases for client duid=[00:03:00:01:***:45:34], tid=0xac71b9
Second immediate solicit:
2020-06-02 14:35:38.023 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available - trying to dynamically allocate leases for client duid=[00:03:00:01:***:45:34], tid=0xac71b9
Both solicit allocates different IP (First one ::4, Second one: ::5)

  How can I override this behaviour in kea so that for the given DUID it keeps using same IP address which is allocated for the first time when it SOLICITS(::2 in this example).

Thanks,
Mayank



_______________________________________________
ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.

To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.

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] isc_kea: Reuse same IP for a host

Mayank Tiwari
Hi,

  It may not be possible to use ::2 as both SOLICIT came at around same time. In first attempt it allocated ::3.  In the second attempt after reboot there was release of ::3. So how can I force it to reuse ::3 instead of looking for new IP ::4 or ::5. kea code has following logic to reuse expire lease:

} else {

// If the lease is expired, we may likely reuse it, but...
if (lease->expired()) {

ConstHostPtr host;
if (hr_mode != Network::HR_DISABLED) {
host = HostMgr::instance().get6(subnet->getID(), hint);
}

// Let's check if there is a reservation for this address.
if (!host) {

// Copy an existing, expired lease so as it can be returned
// to the caller.
Lease6Ptr old_lease(new Lease6(*lease));
ctx.currentIA().old_leases_.push_back(old_lease);

/// We found a lease and it is expired, so we can reuse it
lease = reuseExpiredLease(lease, ctx, pool->getLength(),
callout_status);

/// @todo: We support only one lease per ia for now
leases.push_back(lease);
return (leases);

} else {
LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE,
ALLOC_ENGINE_V6_EXPIRED_HINT_RESERVED)
.arg(ctx.query_->getLabel())
.arg(hint.toText());
}
}
}


 Not sure why this logic is not getting triggered.

Thanks,
Mayank

On Tue, Jun 2, 2020 at 11:39 AM Mayank Tiwari <[hidden email]> wrote:
Hi,

  We have requirement to use same IPv6 for the host after the reboot of the host. What we have observed is that every SOLICIT message results in allocation of new IP to the host.

First solicit:
2020-06-02 14:29:41.499 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available - trying to dynamically allocate leases for client duid=[00:03:00:01:**:45:34], tid=0x8be064

Second immediate solicit:
2020-06-02 14:29:43.103 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_LEASES_NO_HR no reservations found but leases exist for client duid=[00:03:00:01:**:45:34], tid=0xcae8c5

  Both solicit allocate different IP. (First one ::2, Second one ::3)

 Similarly after reboot of host:

First solicit:
2020-06-02 14:35:38.020 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available - trying to dynamically allocate leases for client duid=[00:03:00:01:***:45:34], tid=0xac71b9
Second immediate solicit:
2020-06-02 14:35:38.023 DEBUG [kea-dhcp6.alloc-engine/1] ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available - trying to dynamically allocate leases for client duid=[00:03:00:01:***:45:34], tid=0xac71b9
Both solicit allocates different IP (First one ::4, Second one: ::5)

  How can I override this behaviour in kea so that for the given DUID it keeps using same IP address which is allocated for the first time when it SOLICITS(::2 in this example).

Thanks,
Mayank



_______________________________________________
ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.

To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.

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] isc_kea: Reuse same IP for a host

Tomek Mrugalski-2
Hi,
Kea does not allocate anything when processing SOLICIT. It only picks an
address, does all the checks (checks if there's a reservation for this
specific client, that the address is not used by anyone else, not
reserved, etc) and sends it back in ADVERTISE.

The client is supposed to send the address it got in ADVERTISE in its
REQUEST and under normal circumstances Kea should then assign it. It was
implemented that way for two reasons. First, the RFC8415 says the
address should be allocated when REQUEST is received (there's good
explanation for that in the RFC). Second, there's a performance gain. If
there are multiple servers, all of them will send back ADVERTISES and
client will pick only one.

If you really want to enforce that client always gets the same address,
you have several options:

1. use rapid-commit. If you can turn rapid-commit on your clients,
they'll send solicit and kea will allocate the address and send back
REPLY (skipping the ADVERTISE/REQUEST phase).

2. you could define reservation for your host. Kea then would always try
to use it before using an address from dynamic pool.

3. technically, solicit processing and request processing is very
similar. Internally, they differ with fake_allocation flag, which is
true for solicit and false for request. You could patch the code or
write a hook that would always set the fake_allocation to false,
effectively doing lease allocation on solicit. Not really RFC compliant,
but it would work.

There's probably couple other things you could do, but those are the
most obvious ones.

Hope that helps,
Tomek

On 02.06.2020 18:13, Mayank Tiwari wrote:

> Hi,
>
>    It may not be possible to use ::2 as both SOLICIT came at around
> same time. In first attempt it allocated ::3.  In the second attempt
> after reboot there was release of ::3. So how can I force it to reuse
> ::3 instead of looking for new IP ::4 or ::5. kea code has following
> logic to reuse expire lease:
>
> }else {
>
>      // If the lease is expired, we may likely reuse it, but...
> if (lease->expired()) {
>
>          ConstHostPtr host;
> if (hr_mode != Network::HR_DISABLED) {
>              host = HostMgr::instance().get6(subnet->getID(), hint);
> }
>
>          // Let's check if there is a reservation for this address.
> if (!host) {
>
>              // Copy an existing, expired lease so as it can be returned
> // to the caller.
> Lease6Ptr old_lease(new Lease6(*lease));
> ctx.currentIA().old_leases_.push_back(old_lease);
>
> /// We found a lease and it is expired, so we can reuse it
> lease = reuseExpiredLease(lease, ctx, pool->getLength(),
> callout_status);
>
> /// @todo: We support only one lease per ia for now
> leases.push_back(lease);
> return (leases);
>
> }else {
>              LOG_DEBUG(alloc_engine_logger, ALLOC_ENGINE_DBG_TRACE,
> ALLOC_ENGINE_V6_EXPIRED_HINT_RESERVED)
>                  .arg(ctx.query_->getLabel())
>                  .arg(hint.toText());
> }
>      }
> }
>
>
>
>   Not sure why this logic is not getting triggered.
>
> Thanks,
> Mayank
>
> On Tue, Jun 2, 2020 at 11:39 AM Mayank Tiwari <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Hi,
>
>        We have requirement to use same IPv6 for the host after the
>     reboot of the host. What we have observed is that every SOLICIT
>     message results in allocation of new IP to the host.
>
>     First solicit:
>     2020-06-02 14:29:41.499 DEBUG [kea-dhcp6.alloc-engine/1]
>     ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available -
>     trying to dynamically allocate leases for client
>     duid=[00:03:00:01:**:45:34], tid=0x8be064
>
>     Second immediate solicit:
>     2020-06-02 14:29:43.103 DEBUG [kea-dhcp6.alloc-engine/1]
>     ALLOC_ENGINE_V6_ALLOC_LEASES_NO_HR no reservations found but leases
>     exist for client duid=[00:03:00:01:**:45:34], tid=0xcae8c5
>
>        Both solicit allocate different IP. (First one ::2, Second one ::3)
>
>       Similarly after reboot of host:
>
>     First solicit:
>     2020-06-02 14:35:38.020 DEBUG [kea-dhcp6.alloc-engine/1]
>     ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available -
>     trying to dynamically allocate leases for client
>     duid=[00:03:00:01:***:45:34], tid=0xac71b9
>     Second immediate solicit:
>     2020-06-02 14:35:38.023 DEBUG [kea-dhcp6.alloc-engine/1]
>     ALLOC_ENGINE_V6_ALLOC_UNRESERVED no static reservations available -
>     trying to dynamically allocate leases for client
>     duid=[00:03:00:01:***:45:34], tid=0xac71b9
>     Both solicit allocates different IP (First one ::4, Second one: ::5)
>
>        How can I override this behaviour in kea so that for the given
>     DUID it keeps using same IP address which is allocated for the first
>     time when it SOLICITS(::2 in this example).
>
>     Thanks,
>     Mayank
>
>
>
> _______________________________________________
> ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.
>
> To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.
>
> Kea-users mailing list
> [hidden email]
> https://lists.isc.org/mailman/listinfo/kea-users
>
_______________________________________________
ISC funds the development of this software with paid support subscriptions. Contact us at https://www.isc.org/contact/ for more information.

To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.

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