summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/cfg_hosts.cc
diff options
context:
space:
mode:
authorTomek Mrugalski <tomasz@isc.org>2017-04-10 19:45:05 +0200
committerTomek Mrugalski <tomasz@isc.org>2017-04-10 19:45:05 +0200
commitf1866ab8c76297bacacf743ee3244f5bcb4ccea7 (patch)
treec06bd1a30b78dfa3a889227b625597b47f49bd24 /src/lib/dhcpsrv/cfg_hosts.cc
parent[5207] Improved duplication checks when adding reservations (diff)
downloadkea-f1866ab8c76297bacacf743ee3244f5bcb4ccea7.tar.xz
kea-f1866ab8c76297bacacf743ee3244f5bcb4ccea7.zip
[5207] extra checks added in add4(), add6()
Diffstat (limited to 'src/lib/dhcpsrv/cfg_hosts.cc')
-rw-r--r--src/lib/dhcpsrv/cfg_hosts.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc
index a1f99e0f5c..7b5efd900f 100644
--- a/src/lib/dhcpsrv/cfg_hosts.cc
+++ b/src/lib/dhcpsrv/cfg_hosts.cc
@@ -573,14 +573,13 @@ CfgHosts::add(const HostPtr& host) {
void
CfgHosts::add4(const HostPtr& host) {
- /// @todo: Should we add this host at all if IPv4 subnet-id is 0?
- /// Why, if it's IPv6-only host?
HWAddrPtr hwaddr = host->getHWAddress();
DuidPtr duid = host->getDuid();
// There should be at least one resource reserved: hostname, IPv4
// address, siaddr, sname, file or IPv6 address or prefix.
+ /// @todo: this check should be done in add(), not in add4()
if (host->getHostname().empty() &&
(host->getIPv4Reservation().isV4Zero()) &&
!host->hasIPv6Reservation() &&
@@ -603,6 +602,11 @@ CfgHosts::add4(const HostPtr& host) {
"options");
}
+ if (host->getIPv4SubnetID() == 0) {
+ // This is IPv6-only host. No need to add it to v4 tables.
+ return;
+ }
+
// Check for duplicates for the specified IPv4 subnet.
if ((host->getIPv4SubnetID() > 0) &&
get4(host->getIPv4SubnetID(), hwaddr, duid)) {
@@ -640,7 +644,7 @@ CfgHosts::add4(const HostPtr& host) {
if ((host->getIPv4SubnetID() > 0) && !id.empty()) {
if (get4(host->getIPv4SubnetID(), host->getIdentifierType(), &id[0],
id.size())) {
- isc_throw(DuplicateHost, "failed to add duplicate host using identifier: "
+ isc_throw(DuplicateHost, "failed to add duplicate IPv4 host using identifier: "
<< Host::getIdentifierAsText(host->getIdentifierType(),
&id[0], id.size()));
}
@@ -653,8 +657,11 @@ CfgHosts::add4(const HostPtr& host) {
void
CfgHosts::add6(const HostPtr& host) {
- /// @todo: Should we add this host at all if IPv6 subnet-id is 0?
- /// Why, if it's IPv4-only host?
+ if (host->getIPv6SubnetID() == 0) {
+ // This is IPv4-only host. No need to add it to v6 tables.
+ return;
+ }
+
HWAddrPtr hwaddr = host->getHWAddress();
DuidPtr duid = host->getDuid();
@@ -664,9 +671,9 @@ CfgHosts::add6(const HostPtr& host) {
// Check if the (identifier type, identifier) tuple is already used.
const std::vector<uint8_t>& id = host->getIdentifier();
if ((host->getIPv6SubnetID() > 0) && !id.empty()) {
- if (get6(host->getIPv4SubnetID(), host->getIdentifierType(), &id[0],
+ if (get6(host->getIPv6SubnetID(), host->getIdentifierType(), &id[0],
id.size())) {
- isc_throw(DuplicateHost, "failed to add duplicate host using identifier: "
+ isc_throw(DuplicateHost, "failed to add duplicate IPv6 host using identifier: "
<< Host::getIdentifierAsText(host->getIdentifierType(),
&id[0], id.size()));
}