Skip to content

Commit 6901b0f

Browse files
committed
[#3094] Checkpoint: added UTs, doc to do
1 parent 8f1742a commit 6901b0f

File tree

6 files changed

+1058
-19
lines changed

6 files changed

+1058
-19
lines changed

src/bin/dhcp4/dhcp4_messages.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ extern const isc::log::MessageID DHCP4_SUBNET_SELECTED = "DHCP4_SUBNET_SELECTED"
174174
extern const isc::log::MessageID DHCP4_SUBNET_SELECTION_FAILED = "DHCP4_SUBNET_SELECTION_FAILED";
175175
extern const isc::log::MessageID DHCP4_TESTING_MODE_SEND_TO_SOURCE_ENABLED = "DHCP4_TESTING_MODE_SEND_TO_SOURCE_ENABLED";
176176
extern const isc::log::MessageID DHCP4_UNKNOWN_ADDRESS_REQUESTED = "DHCP4_UNKNOWN_ADDRESS_REQUESTED";
177+
extern const isc::log::MessageID DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK = "DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK";
178+
extern const isc::log::MessageID DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER = "DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER";
177179

178180
} // namespace dhcp
179181
} // namespace isc
@@ -348,6 +350,8 @@ const char* values[] = {
348350
"DHCP4_SUBNET_SELECTION_FAILED", "%1: failed to select subnet for the client",
349351
"DHCP4_TESTING_MODE_SEND_TO_SOURCE_ENABLED", "All packets will be send to source address of an incoming packet - use only for testing",
350352
"DHCP4_UNKNOWN_ADDRESS_REQUESTED", "%1: client requested an unknown address, client sent ciaddr %2, requested-ip-address %3",
353+
"DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK", "v6-only-preferred option missing in 0.0.0.0 offer to query: %1",
354+
"DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER", "v6-only-preferred option missing in 0.0.0.0 offer to query: %1",
351355
NULL
352356
};
353357

src/bin/dhcp4/dhcp4_messages.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ extern const isc::log::MessageID DHCP4_SUBNET_SELECTED;
175175
extern const isc::log::MessageID DHCP4_SUBNET_SELECTION_FAILED;
176176
extern const isc::log::MessageID DHCP4_TESTING_MODE_SEND_TO_SOURCE_ENABLED;
177177
extern const isc::log::MessageID DHCP4_UNKNOWN_ADDRESS_REQUESTED;
178+
extern const isc::log::MessageID DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK;
179+
extern const isc::log::MessageID DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER;
178180

179181
} // namespace dhcp
180182
} // namespace isc

src/bin/dhcp4/dhcp4_messages.mes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,3 +1154,13 @@ contains the client and the transaction identification information.
11541154
The second argument contains the IPv4 address in the ciaddr field. The
11551155
third argument contains the IPv4 address in the requested-ip-address
11561156
option (if present).
1157+
1158+
% DHCP4_V6_ONLY_PREFERRED_MISSING_IN_ACK v6-only-preferred option missing in 0.0.0.0 offer to query: %1
1159+
An DHCPACK for the 0.0.0.0 address was generated for a client requesting
1160+
the v6-only-preferred (108) option but the option is not in the response as
1161+
expected: the erroneous response is dropped, the request query is displayed.
1162+
1163+
% DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER v6-only-preferred option missing in 0.0.0.0 offer to query: %1
1164+
An DHCPOFFER for the 0.0.0.0 address was generated for a client requesting
1165+
the v6-only-preferred (108) option but the option is not in the response as
1166+
expected: the erroneous response is dropped, the discover query is displayed.

src/bin/dhcp4/dhcp4_srv.cc

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,24 +2843,9 @@ Dhcpv4Srv::createNameChangeRequests(const Lease4Ptr& lease,
28432843
bool
28442844
Dhcpv4Srv::assignZero(Subnet4Ptr& subnet, const ClientClasses& client_classes) {
28452845
Subnet4Ptr current_subnet = subnet;
2846+
// Try subnets.
28462847
while (current_subnet) {
2847-
// Try pools.
2848-
for (auto const& pool : current_subnet->getPools(Lease::TYPE_V4)) {
2849-
if (!pool->clientSupported(client_classes)) {
2850-
continue;
2851-
}
2852-
auto const& co = pool->getCfgOption();
2853-
if (!co->empty()) {
2854-
OptionDescriptor desc = co->get(DHCP4_OPTION_SPACE,
2855-
DHO_V6_ONLY_PREFERRED);
2856-
if (desc.option_) {
2857-
subnet = current_subnet;
2858-
return (true);
2859-
}
2860-
}
2861-
}
2862-
// Try the subnet.
2863-
auto const& co = current_subnet->getCfgOption();
2848+
const ConstCfgOptionPtr& co = current_subnet->getCfgOption();
28642849
if (!co->empty()) {
28652850
OptionDescriptor desc = co->get(DHCP4_OPTION_SPACE,
28662851
DHO_V6_ONLY_PREFERRED);
@@ -2875,7 +2860,7 @@ Dhcpv4Srv::assignZero(Subnet4Ptr& subnet, const ClientClasses& client_classes) {
28752860
SharedNetwork4Ptr network;
28762861
subnet->getSharedNetwork(network);
28772862
if (network) {
2878-
auto const& co = network->getCfgOption();
2863+
const ConstCfgOptionPtr& co = network->getCfgOption();
28792864
if (!co->empty()) {
28802865
OptionDescriptor desc = co->get(DHCP4_OPTION_SPACE,
28812866
DHO_V6_ONLY_PREFERRED);
@@ -3802,6 +3787,8 @@ Dhcpv4Srv::processDiscover(Pkt4Ptr& discover, AllocEngine::ClientContext4Ptr& co
38023787
if (ex.getIPv6OnlyPreferred()) {
38033788
if (!ex.getResponse()->getOption(DHO_V6_ONLY_PREFERRED)) {
38043789
// Better to drop the packet than to send an insane response.
3790+
LOG_ERROR(packet4_logger, DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER)
3791+
.arg(discover->getLabel());
38053792
return (Pkt4Ptr());
38063793
}
38073794
}
@@ -3886,6 +3873,8 @@ Dhcpv4Srv::processRequest(Pkt4Ptr& request, AllocEngine::ClientContext4Ptr& cont
38863873
if (ex.getIPv6OnlyPreferred()) {
38873874
if (!response->getOption(DHO_V6_ONLY_PREFERRED)) {
38883875
// Better to drop the packet than to send an insane response.
3876+
LOG_ERROR(packet4_logger, DHCP4_V6_ONLY_PREFERRED_MISSING_IN_OFFER)
3877+
.arg(request->getLabel());
38893878
return (Pkt4Ptr());
38903879
}
38913880
}

src/bin/dhcp4/dhcp4_srv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ class Dhcpv4Srv : public process::Daemon {
737737
/// or assigning the zero address as the assigned address if the
738738
/// Yiaddr field of the DHCPv4 message header...
739739
///
740-
/// Check if there is a pool, subnet or shared network defining an
740+
/// Check if there is asubnet or shared network defining an
741741
/// IPv6-Only Preferred option which will be included by the response.
742742
///
743743
/// @param subnet Reference to the selected subnet, can be modified if

0 commit comments

Comments
 (0)