Commit 1f141f14 authored by Francis Dupont's avatar Francis Dupont Committed by Tomek Mrugalski

[5440] Checkpoint before giving up

parent 71c92cab
......@@ -98,6 +98,11 @@ client and transaction identification information. The second argument
specifies the hostname carried in the Hostname option sent by the
client.
% DHCP4_CLIENT_HOSTNAME_EMPTY %1: client sent bogus empty Hostname option
This informational message is issued when the server receives an
empty Hostname option. Such option is bogus (size is required to be
at least one) and is ignored.
% DHCP4_CLIENT_HOSTNAME_PROCESS %1: processing client's Hostname option
This debug message is issued when the server starts processing the Hostname
option sent in the client's query. The argument includes the client and
......
......@@ -1679,6 +1679,13 @@ Dhcpv4Srv::processHostnameOption(Dhcpv4Exchange& ex) {
OptionStringPtr opt_hostname = boost::dynamic_pointer_cast<OptionString>
(ex.getQuery()->getOption(DHO_HOST_NAME));
// Ignore empty/bogus Hostname option.
if (opt_hostname && opt_hostname->getValue().empty()) {
opt_hostname.reset();
LOG_INFO(ddns4_logger, DHCP4_CLIENT_HOSTNAME_EMPTY)
.arg(ex.getQuery()->getLabel());
}
if (opt_hostname) {
LOG_DEBUG(ddns4_logger, DBG_DHCP4_DETAIL_DATA, DHCP4_CLIENT_HOSTNAME_DATA)
.arg(ex.getQuery()->getLabel())
......
......@@ -412,6 +412,29 @@ public:
}
// Create a message holding an empty Hostname option.
Pkt4Ptr generatePktWithEmptyHostname(const uint8_t msg_type) {
Pkt4Ptr pkt = Pkt4Ptr(new Pkt4(msg_type, 1234));
pkt->setRemoteAddr(IOAddress("192.0.2.3"));
// For DISCOVER we don't include server id, because client broadcasts
// the message to all servers.
if (msg_type != DHCPDISCOVER) {
pkt->addOption(srv_->getServerID());
}
pkt->addOption(generateClientId());
// Create Hostname option.
std::string hostname(" ");
OptionPtr opt = createHostname(hostname);
opt->setData(hostname.begin(), hostname.begin());
pkt->addOption(opt);
return (pkt);
}
// Create a message holding of a given type
Pkt4Ptr generatePkt(const uint8_t msg_type) {
Pkt4Ptr pkt = Pkt4Ptr(new Pkt4(msg_type, 1234));
......@@ -813,6 +836,15 @@ TEST_F(NameDhcpv4SrvTest, serverUpdateWrongHostname) {
EXPECT_FALSE(hostname);
}
// Test that the server skips processing of an empty Hostname option.
TEST_F(NameDhcpv4SrvTest, serverUpdateEmptyHostname) {
Pkt4Ptr query;
ASSERT_NO_THROW(query = generatePktWithEmptyHostname(DHCPREQUEST));
OptionStringPtr hostname;
ASSERT_NO_THROW(hostname = processHostname(query));
EXPECT_FALSE(hostname);
}
// Test that server generates the fully qualified domain name for the client
// if client supplies the partial name.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment