2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-05 00:15:17 +00:00

[5306] Use match-client-id defined on shared network level.

This commit is contained in:
Marcin Siodelski
2017-09-18 12:11:51 +02:00
parent 65281a78c4
commit 521afdb269
4 changed files with 141 additions and 27 deletions

View File

@@ -132,20 +132,13 @@ Dhcpv4Exchange::Dhcpv4Exchange(const AllocEnginePtr& alloc_engine,
// Pointer to client's query.
context_->query_ = query;
// Set client identifier if the match-client-id flag is enabled (default).
// If the subnet wasn't found it doesn't matter because we will not be
// able to allocate a lease anyway so this context will not be used.
// If subnet found, retrieve client identifier which will be needed
// for allocations and search for reservations associated with a
// subnet/shared network.
if (subnet) {
if (subnet->getMatchClientId()) {
OptionPtr opt_clientid = query->getOption(DHO_DHCP_CLIENT_IDENTIFIER);
if (opt_clientid) {
context_->clientid_.reset(new ClientId(opt_clientid->getData()));
}
} else {
/// @todo When merging with #3806 use different logger.
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_CLIENTID_IGNORED_FOR_LEASES)
.arg(query->getLabel())
.arg(subnet->getID());
OptionPtr opt_clientid = query->getOption(DHO_DHCP_CLIENT_IDENTIFIER);
if (opt_clientid) {
context_->clientid_.reset(new ClientId(opt_clientid->getData()));
}
// Find static reservations if not disabled for our subnet.
@@ -1847,6 +1840,16 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) {
.arg(query->getLabel())
.arg(lease->addr_.toText());
// We're logging this here, because this is the place where we know
// which subnet has been actually used for allocation. If the
// client identifier matching is disabled, we want to make sure that
// the user is notified.
if (!ctx->subnet_->getMatchClientId()) {
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_DETAIL, DHCP4_CLIENTID_IGNORED_FOR_LEASES)
.arg(ctx->query_->getLabel())
.arg(ctx->subnet_->getID());
}
resp->setYiaddr(lease->addr_);
/// @todo The server should check what ciaddr the client has supplied