Commit a8ce7a78 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[5683] if clause moved in Lease parsers

parent 0c19bb1c
...@@ -55,6 +55,12 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg, ...@@ -55,6 +55,12 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg,
isc_throw(BadValue, "Invalid subnet-id: No IPv4 subnet with subnet-id=" isc_throw(BadValue, "Invalid subnet-id: No IPv4 subnet with subnet-id="
<< subnet_id << " currently configured."); << subnet_id << " currently configured.");
} }
if (!subnet->inRange(addr)) {
isc_throw(BadValue, "The address " << addr.toText() << " does not belong "
"to subnet " << subnet->toText() << ", subnet-id=" << subnet_id);
}
} else { } else {
// Subnet-id was not specified. Let's try to figure it out on our own. // Subnet-id was not specified. Let's try to figure it out on our own.
subnet = cfg->getCfgSubnets4()->selectSubnet(addr); subnet = cfg->getCfgSubnets4()->selectSubnet(addr);
...@@ -65,11 +71,6 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg, ...@@ -65,11 +71,6 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg,
subnet_id = subnet->getID(); subnet_id = subnet->getID();
} }
if (!subnet->inRange(addr)) {
isc_throw(BadValue, "The address " << addr.toText() << " does not belong "
"to subnet " << subnet->toText() << ", subnet-id=" << subnet_id);
}
// Client-id is optional. // Client-id is optional.
ClientIdPtr client_id; ClientIdPtr client_id;
if (lease_info->contains("client-id")) { if (lease_info->contains("client-id")) {
...@@ -225,6 +226,13 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, ...@@ -225,6 +226,13 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg,
isc_throw(BadValue, "Invalid subnet-id: No IPv6 subnet with subnet-id=" isc_throw(BadValue, "Invalid subnet-id: No IPv6 subnet with subnet-id="
<< subnet_id << " currently configured."); << subnet_id << " currently configured.");
} }
// Check if the address specified really belongs to the subnet.
if ((type == Lease::TYPE_NA) && !subnet->inRange(addr)) {
isc_throw(BadValue, "The address " << addr.toText() << " does not belong "
"to subnet " << subnet->toText() << ", subnet-id=" << subnet_id);
}
} else { } else {
if (type != Lease::TYPE_NA) { if (type != Lease::TYPE_NA) {
isc_throw(BadValue, "Subnet-id is 0 or not specified. This is allowed for" isc_throw(BadValue, "Subnet-id is 0 or not specified. This is allowed for"
...@@ -238,12 +246,6 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, ...@@ -238,12 +246,6 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg,
subnet_id = subnet->getID(); subnet_id = subnet->getID();
} }
// Check if the address specified really belongs to the subnet.
if ((type == Lease::TYPE_NA) && !subnet->inRange(addr)) {
isc_throw(BadValue, "The address " << addr.toText() << " does not belong "
"to subnet " << subnet->toText() << ", subnet-id=" << subnet_id);
}
uint32_t iaid = getUint32(lease_info, "iaid"); uint32_t iaid = getUint32(lease_info, "iaid");
// Hw-address is optional in v6 leases. // Hw-address is optional in v6 leases.
......
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