From: Marcin Siodelski Date: Tue, 3 Oct 2017 18:00:52 +0000 (+0200) Subject: [5364] Added log messages to the DHCP servers about dynamic subnet change. X-Git-Tag: trac5297_base~6^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e03503ebc01112170fe71f9ba69e2a39f97275f;p=thirdparty%2Fkea.git [5364] Added log messages to the DHCP servers about dynamic subnet change. --- diff --git a/src/bin/dhcp4/dhcp4_messages.mes b/src/bin/dhcp4/dhcp4_messages.mes index bf09086c7b..15b9e82723 100644 --- a/src/bin/dhcp4/dhcp4_messages.mes +++ b/src/bin/dhcp4/dhcp4_messages.mes @@ -663,6 +663,14 @@ the client. The first argument includes the client and the transaction identification information. The second arguments includes the subnet details. +% DHCP4_SUBNET_DYNAMICALLY_CHANGED %1: changed selected subnet %2 to subnet %3 from shared network %4 for client assignments +This debug message indicates that the server is using another subnet +than initially selected for client assignments. This newly selected +subnet belongs to the same shared network as the original subnet. +Some reasons why the new subnet was selected include: address pool +exhaustion in the original subnet or the fact that the new subnet +includes some static reservations for this client. + % DHCP4_SUBNET_SELECTED %1: the subnet with ID %2 was selected for client assignments This is a debug message noting the selection of a subnet to be used for address and option assignment. Subnet selection is one of the early diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 602bf5efc8..012ceffd36 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -1835,7 +1835,18 @@ Dhcpv4Srv::assignLease(Dhcpv4Exchange& ex) { // Subnet may be modified by the allocation engine, if the initial subnet // belongs to a shared network. - subnet = ctx->subnet_; + if (subnet->getID() != ctx->subnet_->getID()) { + SharedNetwork4Ptr network; + subnet->getSharedNetwork(network); + if (network) { + LOG_DEBUG(packet4_logger, DBG_DHCP4_BASIC_DATA, DHCP4_SUBNET_DYNAMICALLY_CHANGED) + .arg(query->getLabel()) + .arg(subnet->toText()) + .arg(ctx->subnet_->toText()) + .arg(network->getName()); + } + subnet = ctx->subnet_; + } if (lease) { // We have a lease! Let's set it in the packet and send it back to diff --git a/src/bin/dhcp6/dhcp6_messages.mes b/src/bin/dhcp6/dhcp6_messages.mes index f6ece11570..4fde8c77ed 100644 --- a/src/bin/dhcp6/dhcp6_messages.mes +++ b/src/bin/dhcp6/dhcp6_messages.mes @@ -711,6 +711,14 @@ the client. The first argument includes the client and the transaction identification information. The second argument includes the subnet details. +% DHCP6_SUBNET_DYNAMICALLY_CHANGED %1: changed selected subnet %2 to subnet %3 from shared network %4 for client assignments +This debug message indicates that the server is using another subnet +than initially selected for client assignments. This newly selected +subnet belongs to the same shared network as the original subnet. +Some reasons why the new subnet was selected include: address pool +exhaustion in the original subnet or the fact that the new subnet +includes some static reservations for this client. + % DHCP6_SUBNET_SELECTED %1: the subnet with ID %2 was selected for client assignments This is a debug message noting the selection of a subnet to be used for address and option assignment. Subnet selection is one of the early diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 9c90bc92d3..d016b0f032 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -1195,6 +1195,8 @@ void Dhcpv6Srv::assignLeases(const Pkt6Ptr& question, Pkt6Ptr& answer, AllocEngine::ClientContext6& ctx) { + Subnet6Ptr subnet = ctx.subnet_; + // We need to allocate addresses for all IA_NA options in the client's // question (i.e. SOLICIT or REQUEST) message. // @todo add support for IA_TA @@ -1232,6 +1234,20 @@ Dhcpv6Srv::assignLeases(const Pkt6Ptr& question, Pkt6Ptr& answer, break; } } + + // Subnet may be modified by the allocation engine, if the initial subnet + // belongs to a shared network. + if (subnet->getID() != ctx.subnet_->getID()) { + SharedNetwork6Ptr network; + subnet->getSharedNetwork(network); + if (network) { + LOG_DEBUG(packet6_logger, DBG_DHCP6_BASIC_DATA, DHCP6_SUBNET_DYNAMICALLY_CHANGED) + .arg(question->getLabel()) + .arg(subnet->toText()) + .arg(ctx.subnet_->toText()) + .arg(network->getName()); + } + } }