IOAddress requester_ip = query->getGiaddr();
if (requester_ip.isV4Zero()) {
invalid = true;
+ StatsMgr::instance().addValue("pkt4-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "giaddr cannot be 0.0.0.0");
}
OptionPtr client_server_id;
if (!acceptServerId(query, client_server_id)) {
invalid = true;
+ // Drop statistic updated by acceptServerId.
isc_throw(BadValue, "rejecting query from: "
<< requester_ip.toText() << ", unknown server-id: "
<< (client_server_id ? client_server_id->toText() : "malformed"));
default:
// We have some combination of the three which is invalid.
invalid = true;
+ StatsMgr::instance().addValue("pkt4-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "malformed lease query: "
<< "ciaddr: [" << ciaddr
<< "] HWAddr: [" << hwaddr->toText()
// Unable to convert the option to the option type which encapsulates it.
// We treat this as non-matching server id.
if (!option_custom) {
+ StatsMgr::instance().addValue("pkt4-rfc-violation",
+ static_cast<int64_t>(1));
return (false);
}
// The server identifier option should carry exactly one IPv4 address.
if (option_custom->getDataFieldsNum() != 1) {
+ StatsMgr::instance().addValue("pkt4-rfc-violation",
+ static_cast<int64_t>(1));
return (false);
}
IOAddress client_server_id = option_custom->readAddress();
if (!client_server_id.isV4() ||
(client_server_id == IOAddress::IPV4_ZERO_ADDRESS())) {
+ StatsMgr::instance().addValue("pkt4-rfc-violation",
+ static_cast<int64_t>(1));
return (false);
}
OptionCustomPtr cfg_server_id = boost::dynamic_pointer_cast<OptionCustom>
(cfg->getCfgOption()->get(DHCP4_OPTION_SPACE, DHO_DHCP_SERVER_IDENTIFIER).option_);
- return (cfg_server_id && (cfg_server_id->readAddress() == client_server_id));
+ if (cfg_server_id && (cfg_server_id->readAddress() == client_server_id)) {
+ return (true);
+ }
+
+ // Everything failed so the query is not for us.
+ StatsMgr::instance().addValue("pkt4-not-for-us",
+ static_cast<int64_t>(1));
+ return (false);
}
void
DuidPtr req_clientid = query->getClientId();
if (!req_clientid) {
invalid = true;
+ StatsMgr::instance().addValue("pkt6-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "DHCPV6_LEASEQUERY must supply a D6O_CLIENTID");
}
testServerId(query);
} catch (const BadValue&) {
invalid = true;
+ // Drop statistic updated by testServerId.
throw;
}
if (requester_ip.isV6Zero()) {
/// Not sure this really possible.
invalid = true;
+ StatsMgr::instance().addValue("pkt6-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "DHCPV6_LEASEQUERY source address cannot be ::");
}
(query->getOption(D6O_LQ_QUERY));
if (!lq_option) {
invalid = true;
+ StatsMgr::instance().addValue("pkt6-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "DHCPV6_LEASEQUERY must supply a D6O_LQ_QUERY option");
}
} catch (const std::exception& ex) {
// unpack() should catch this?
invalid = true;
+ StatsMgr::instance().addValue("pkt6-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "error reading query field(s):" << ex.what());
}
try {
client_duid.reset(new DUID(client_server_id->getData()));
} catch (const std::exception& ex) {
+ StatsMgr::instance().addValue("pkt6-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "DHCPV6_LEASEQUERY D6O_SERVERID malformed: "
<< ex.what());
}
DuidPtr server_id = CfgMgr::instance().getCurrentCfg()->getCfgDUID()->getCurrentDuid();
if (!server_id) {
+ StatsMgr::instance().addValue("pkt6-rfc-violation",
+ static_cast<int64_t>(1));
isc_throw(Unexpected, "Server has no current server id?");
} else if (*client_duid != *server_id) {
+ StatsMgr::instance().addValue("pkt6-not-for-us",
+ static_cast<int64_t>(1));
isc_throw(BadValue, "rejecting DHCPV6_LEASEQUERY from: "
<< query->getRemoteAddr() << ", unknown server-id: "
<< (client_server_id ? client_server_id->toText() : "malformed"));