]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5683] if clause moved in Lease parsers trac5683
authorTomek Mrugalski <tomasz@isc.org>
Tue, 31 Jul 2018 16:58:13 +0000 (18:58 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Tue, 31 Jul 2018 16:58:13 +0000 (18:58 +0200)
src/hooks/dhcp/lease_cmds/lease_parser.cc

index 27c2b2b128d85a30fca2b0fa687f42f91ecb10e8..db4143d5897c2f0ef5bf4a9fa66aea9659b4d997 100644 (file)
@@ -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.