From: Tomek Mrugalski Date: Tue, 31 Jul 2018 16:58:13 +0000 (+0200) Subject: [5683] if clause moved in Lease parsers X-Git-Tag: ha_phase2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ftrac5683;p=thirdparty%2Fkea.git [5683] if clause moved in Lease parsers --- diff --git a/src/hooks/dhcp/lease_cmds/lease_parser.cc b/src/hooks/dhcp/lease_cmds/lease_parser.cc index 27c2b2b128..db4143d589 100644 --- a/src/hooks/dhcp/lease_cmds/lease_parser.cc +++ b/src/hooks/dhcp/lease_cmds/lease_parser.cc @@ -55,6 +55,12 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg, isc_throw(BadValue, "Invalid subnet-id: No IPv4 subnet with subnet-id=" << 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 { // Subnet-id was not specified. Let's try to figure it out on our own. subnet = cfg->getCfgSubnets4()->selectSubnet(addr); @@ -65,11 +71,6 @@ Lease4Parser::parse(ConstSrvConfigPtr& cfg, 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. ClientIdPtr client_id; if (lease_info->contains("client-id")) { @@ -225,6 +226,13 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, isc_throw(BadValue, "Invalid subnet-id: No IPv6 subnet with subnet-id=" << 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 { if (type != Lease::TYPE_NA) { isc_throw(BadValue, "Subnet-id is 0 or not specified. This is allowed for" @@ -238,12 +246,6 @@ Lease6Parser::parse(ConstSrvConfigPtr& cfg, 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"); // Hw-address is optional in v6 leases.