]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Clarify error message when lease limit reached. [rt17010]
authorEvan Hunt <each@isc.org>
Fri, 2 Nov 2007 22:09:02 +0000 (22:09 +0000)
committerEvan Hunt <each@isc.org>
Fri, 2 Nov 2007 22:09:02 +0000 (22:09 +0000)
RELNOTES
server/dhcp.c

index 55c7d9868859a0cbf614133cfa44f2472ba25780..3d514cbb9db96266453d859ecc407ef160d9a86d 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -55,6 +55,8 @@ suggested fixes to <dhcp-users@isc.org>.
 
                        Changes since 4.0.0b2
 
+- Clarified error message when lease limit exceeded
+
 - The server will now include multiple IA_NA's and multiple IAADDRs within
   them, if advertised by the client.  It still only seeks to allocate one
   new address.
index b1ec39266db70743396f4136a634b4491aae3eb6..567a0c3f1fc92c930cca05db14f0335fc6f977e2 100644 (file)
@@ -634,7 +634,7 @@ void dhcprequest (packet, ms_nulltp, ip_lease)
        }
 
        /* If the address the client asked for is ours, but it wasn't
-           available for the client, NAK it. */
+          available for the client, NAK it. */
        if (!lease && ours) {
                log_info ("%s: lease %s unavailable.", msgbuf, piaddr (cip));
                nak_lease (packet, &cip);
@@ -669,8 +669,8 @@ void dhcprelease (packet, ms_nulltp)
 
 
        /* DHCPRELEASE must not specify address in requested-address
-           option, but old protocol specs weren't explicit about this,
-           so let it go. */
+          option, but old protocol specs weren't explicit about this,
+          so let it go. */
        if ((oc = lookup_option (&dhcp_universe, packet -> options,
                                 DHO_DHCP_REQUESTED_ADDRESS))) {
                log_info ("DHCPRELEASE from %s specified requested-address.",
@@ -1822,31 +1822,28 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
                        if (i == packet -> class_count)
                                unbill_class (lease, lease -> billing_class);
                }
-               
+
                /* If we don't have an active billing, see if we need
                   one, and if we do, try to do so. */
-               if (!lease -> billing_class) {
-                       for (i = 0; i < packet -> class_count; i++) {
-                               if (packet -> classes [i] -> lease_limit)
-                                       break;
-                       }
-                       if (i != packet -> class_count) {
-                               for (i = 0; i < packet -> class_count; i++)
-                                       if ((packet -> 
-                                            classes [i] -> lease_limit) &&
-                                           bill_class (lease,
-                                                       packet -> classes [i]))
+               if (lease->billing_class == NULL) {
+                       int bill = 0;
+                       for (i = 0; i < packet->class_count; i++) {
+                               if (packet->classes[i]->lease_limit) {
+                                       bill++;
+                                       if (bill_class(lease,
+                                                      packet->classes[i]))
                                                break;
-                               if (i == packet -> class_count) {
-                                       log_info ("%s: no available billing",
-                                                 msg);
-                                       free_lease_state (state, MDL);
-                                       if (host)
-                                               host_dereference (&host, MDL);
-                                       /* XXX possibly not necessary: */
-                                       return;
                                }
                        }
+                       if (bill != 0 && i == packet->class_count) {
+                               log_info("%s: no available billing: lease "
+                                        "limit reached in all matching "
+                                        "classes", msg);
+                               free_lease_state(state, MDL);
+                               if (host)
+                                       host_dereference(&host, MDL);
+                               return;
+                       }
 
                        /* If this is an offer, undo the billing.  We go
                         * through all the steps above to bill a class so
@@ -2485,7 +2482,7 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
        }
 
        /* Now, if appropriate, put in DHCP-specific options that
-           override those. */
+          override those. */
        if (state -> offer) {
                i = DHO_DHCP_MESSAGE_TYPE;
                oc = (struct option_cache *)0;
@@ -3749,7 +3746,7 @@ int mockup_lease (struct lease **lp, struct packet *packet,
    a lease at all. */
 
 int allocate_lease (struct lease **lp, struct packet *packet,
-                    struct pool *pool, int *peer_has_leases)
+                   struct pool *pool, int *peer_has_leases)
 {
        struct lease *lease = (struct lease *)0;
        struct lease *candl = (struct lease *)0;