mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 06:25:34 +00:00
[#2719] kea-dhcp4 offer-lft is now functional
kea-dhcp4 supports offer-lft for global, shared-network, and subnets. Not yet supported in classes. src/bin/dhcp4/dhcp4_srv.cc Dhcpv4Srv::assignLease() - adjust outbound lease time option Dhcpv4Srv::postAllocateNameUpdate() - allow reuse check on allocated discover src/lib/dhcpsrv/alloc_engine.* AllocEngine::ClientContext4 - add offer_lft_ member AllocEngine::discoverLease4() -set contexts offer_lft_ AllocEngine::getOfferLft() - new, get context appropriate value for offer_lft AllocEngine::createLease4() - use offer_lft on DISCOVER, pass offer_lft into hook, set lease fqdn flags to false AllocEngine::reuseExpiredLease4() - reclaim on discover allocation AllocEngine::updateLease4Information() - use offer_lft if appropriate src/lib/dhcpsrv/tests/alloc_engine4_unittest.cc TEST_F(AllocEngine4Test, discoverOfferLft) - enabled TEST_F(AllocEngine4Test, discoverOfferLftReuseExpiredLease4) - new test
This commit is contained in:
@@ -2855,8 +2855,12 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
|
||||
}
|
||||
|
||||
// IP Address Lease time (type 51)
|
||||
OptionPtr opt(new OptionUint32(Option::V4, DHO_DHCP_LEASE_TIME,
|
||||
lease->valid_lft_));
|
||||
// If we're not allocating on discover then we just sent the lifetime on the lease.
|
||||
// Otherwise (i.e. offer_lft > 0), the lease's lifetime has been set to offer_lft but
|
||||
// we want to send the client the proper valid lifetime so we have to fetch it.
|
||||
auto send_lft = (ctx->offer_lft_ ? AllocEngine::getValidLft(*ctx) : lease->valid_lft_);
|
||||
OptionPtr opt(new OptionUint32(Option::V4, DHO_DHCP_LEASE_TIME, send_lft));
|
||||
|
||||
resp->addOption(opt);
|
||||
|
||||
// Subnet mask (type 1)
|
||||
@@ -2964,7 +2968,8 @@ Dhcpv4Srv::postAllocateNameUpdate(const AllocEngine::ClientContext4Ptr& ctx, con
|
||||
// any potential exceptions (e.g. invalid lease database backend
|
||||
// implementation) and log an error.
|
||||
try {
|
||||
if (!ctx->fake_allocation_) {
|
||||
/// TKM - do this on committed-discover
|
||||
if (!ctx->fake_allocation_ || (ctx->offer_lft_ > 0)) {
|
||||
// The lease can't be reused.
|
||||
lease->reuseable_valid_lft_ = 0;
|
||||
|
||||
|
Reference in New Issue
Block a user