summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/cfg_hosts.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2020-09-25 14:12:14 +0200
committerMarcin Siodelski <marcin@isc.org>2020-10-05 15:14:57 +0200
commit99c44ffd314947a20aca781e1a5cc7b58ade0ff4 (patch)
treed53aad88d4f284222a2ba6437da2552d8a1acd40 /src/lib/dhcpsrv/cfg_hosts.cc
parent[#1418] Fixed ChangeLog number (diff)
downloadkea-99c44ffd314947a20aca781e1a5cc7b58ade0ff4.tar.xz
kea-99c44ffd314947a20aca781e1a5cc7b58ade0ff4.zip
[#1428] Allow non-unique IPs in MySQL and PgSQL
Introduced new host API function which allows for configuring selected backends to accept non-unique IP reservations for multiple hosts. Support for it was added in MySQL, Postgres and Kea config file. It is not supported in Cassandra. New migrations for MySQL and Postgres have been created.
Diffstat (limited to 'src/lib/dhcpsrv/cfg_hosts.cc')
-rw-r--r--src/lib/dhcpsrv/cfg_hosts.cc29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/lib/dhcpsrv/cfg_hosts.cc b/src/lib/dhcpsrv/cfg_hosts.cc
index 544cdf74a4..fe25c071f8 100644
--- a/src/lib/dhcpsrv/cfg_hosts.cc
+++ b/src/lib/dhcpsrv/cfg_hosts.cc
@@ -1009,7 +1009,7 @@ CfgHosts::add4(const HostPtr& host) {
}
// Check if the address is already reserved for the specified IPv4 subnet.
- if (!host->getIPv4Reservation().isV4Zero() &&
+ if (ip_reservations_unique_ && !host->getIPv4Reservation().isV4Zero() &&
(host->getIPv4SubnetID() != SUBNET_ID_UNUSED) &&
get4(host->getIPv4SubnetID(), host->getIPv4Reservation())) {
isc_throw(ReservedAddress, "failed to add new host using the HW"
@@ -1061,15 +1061,17 @@ CfgHosts::add6(const HostPtr& host) {
for (IPv6ResrvIterator it = reservations.first; it != reservations.second;
++it) {
- // If there's an entry for this (subnet-id, address), reject it.
- if (get6(host->getIPv6SubnetID(), it->second.getPrefix())) {
- isc_throw(DuplicateHost, "failed to add address reservation for "
- << "host using the HW address '"
- << (hwaddr ? hwaddr->toText(false) : "(null)")
- << " and DUID '" << (duid ? duid->toText() : "(null)")
- << "' to the IPv6 subnet id '" << host->getIPv6SubnetID()
- << "' for address/prefix " << it->second.getPrefix()
- << ": There's already reservation for this address/prefix");
+ if (ip_reservations_unique_) {
+ // If there's an entry for this (subnet-id, address), reject it.
+ if (get6(host->getIPv6SubnetID(), it->second.getPrefix())) {
+ isc_throw(DuplicateHost, "failed to add address reservation for "
+ << "host using the HW address '"
+ << (hwaddr ? hwaddr->toText(false) : "(null)")
+ << " and DUID '" << (duid ? duid->toText() : "(null)")
+ << "' to the IPv6 subnet id '" << host->getIPv6SubnetID()
+ << "' for address/prefix " << it->second.getPrefix()
+ << ": There's already reservation for this address/prefix");
+ }
}
hosts6_.insert(HostResrv6Tuple(it->second, host));
}
@@ -1132,6 +1134,13 @@ CfgHosts::del6(const SubnetID& /*subnet_id*/,
return (false);
}
+bool
+CfgHosts::setIPReservationUnique(const bool unique) {
+ ip_reservations_unique_ = unique;
+ return (true);
+}
+
+
ElementPtr
CfgHosts::toElement() const {
uint16_t family = CfgMgr::instance().getFamily();