From: Shawn Routhier Date: Fri, 8 Nov 2013 20:29:20 +0000 (-0800) Subject: [master] Emit log messages when the server is stable X-Git-Tag: v4_3_0a1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f88446f16b9b3be36492f78b0f66a4166e459896;p=thirdparty%2Fdhcp.git [master] Emit log messages when the server is stable Emit a log message when the server had completed initialization and is about to start dispatching. And emit log messages when both peers in a failover pair have reached the normal state. --- diff --git a/RELNOTES b/RELNOTES index 48097249a..18ffd448b 100644 --- a/RELNOTES +++ b/RELNOTES @@ -96,6 +96,15 @@ work on other platforms. Please report any problems and suggested fixes to to a client and before the server stops. Using this option is not recommended. +- Add some logging statements to indicate when the server is ready + to serve. One statement is emitted after the server has finished + reading its files and is about to enter the dispatch loop. + This is "Server starting service.". + The second is emitted when a server determines that both it and + its failover peer are in the normal state. + This is "failover peer : Both servers normal." + [ISC-Bugs 33208] + Changes since 4.2.5 - Address static analysis warnings. diff --git a/server/dhcpd.c b/server/dhcpd.c index 3588349fe..457b3cc09 100644 --- a/server/dhcpd.c +++ b/server/dhcpd.c @@ -785,6 +785,9 @@ main(int argc, char **argv) { signal(SIGINT, dhcp_signal_handler); /* control-c */ signal(SIGTERM, dhcp_signal_handler); /* kill */ + /* Log that we are about to start working */ + log_info("Server starting service."); + /* * Receive packets and dispatch them... * dispatch() will return only when we are shutting down. diff --git a/server/failover.c b/server/failover.c index 7a9ae9e22..3dfe7b99c 100644 --- a/server/failover.c +++ b/server/failover.c @@ -1793,6 +1793,10 @@ isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *state, log_info ("failover peer %s: I move from %s to %s", state -> name, dhcp_failover_state_name_print (saved_state), dhcp_failover_state_name_print (state -> me.state)); + + /* If both servers are now normal log it */ + if ((state->me.state == normal) && (state->partner.state == normal)) + log_info("failover peer %s: Both servers normal", state->name); /* If we were in startup and we just left it, cancel the timeout. */ if (new_state != startup && saved_state == startup) @@ -1986,6 +1990,10 @@ isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *state, state -> name, dhcp_failover_state_name_print (previous_state), dhcp_failover_state_name_print (state -> partner.state)); + + /* If both servers are now normal log it */ + if ((state->me.state == normal) && (state->partner.state == normal)) + log_info("failover peer %s: Both servers normal", state->name); if (!write_failover_state (state) || !commit_leases ()) { /* This is bad, but it's not fatal. Of course, if we diff --git a/server/mdb.c b/server/mdb.c index 53bf34dcd..ba2c3d326 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -2296,13 +2296,48 @@ void hw_hash_delete (lease) lease_dereference (&head, MDL); } +/* Write v4 leases to permanent storage. */ +int write_leases4(void) { + struct lease *l; + struct shared_network *s; + struct pool *p; + struct lease **lptr[RESERVED_LEASES+1]; + int num_written = 0, i; + + /* Write all the leases. */ + for (s = shared_networks; s; s = s->next) { + for (p = s->pools; p; p = p->next) { + lptr[FREE_LEASES] = &p->free; + lptr[ACTIVE_LEASES] = &p->active; + lptr[EXPIRED_LEASES] = &p->expired; + lptr[ABANDONED_LEASES] = &p->abandoned; + lptr[BACKUP_LEASES] = &p->backup; + lptr[RESERVED_LEASES] = &p->reserved; + + for (i = FREE_LEASES; i <= RESERVED_LEASES; i++) { + for (l = *(lptr[i]); l; l = l->next) { +#if !defined (DEBUG_DUMP_ALL_LEASES) + if (l->hardware_addr.hlen != 0 || l->uid_len != 0 || + l->tsfp != 0 || l->binding_state != FTS_FREE) +#endif + { + if (write_lease(l) == 0) + return (0); + num_written++; + } + } + } + } + } + + log_info ("Wrote %d leases to leases file.", num_written); + return (1); +} + /* Write all interesting leases to permanent storage. */ int write_leases () { - struct lease *l; - struct shared_network *s; - struct pool *p; struct host_decl *hp; struct group_object *gp; struct hash_bucket *hb; @@ -2310,7 +2345,6 @@ int write_leases () struct collection *colp; int i; int num_written; - struct lease **lptr[RESERVED_LEASES+1]; /* write all the dynamically-created class declarations. */ if (collections->classes) { @@ -2390,41 +2424,22 @@ int write_leases () return 0; #endif - /* Write all the leases. */ - num_written = 0; - for (s = shared_networks; s; s = s -> next) { - for (p = s -> pools; p; p = p -> next) { - lptr [FREE_LEASES] = &p -> free; - lptr [ACTIVE_LEASES] = &p -> active; - lptr [EXPIRED_LEASES] = &p -> expired; - lptr [ABANDONED_LEASES] = &p -> abandoned; - lptr [BACKUP_LEASES] = &p -> backup; - lptr [RESERVED_LEASES] = &p->reserved; - - for (i = FREE_LEASES; i <= RESERVED_LEASES; i++) { - for (l = *(lptr [i]); l; l = l -> next) { -#if !defined (DEBUG_DUMP_ALL_LEASES) - if (l->hardware_addr.hlen != 0 || l->uid_len != 0 || - l->tsfp != 0 || l->binding_state != FTS_FREE) -#endif - { - if (!write_lease (l)) - return 0; - num_written++; - } - } - } - } - } - log_info ("Wrote %d leases to leases file.", num_written); + switch (local_family) { + case AF_INET: + if (write_leases4() == 0) + return (0); + break; #ifdef DHCPv6 - if (!write_leases6()) { - return 0; - } + case AF_INET6: + if (write_leases6() == 0) + return (0); + break; #endif /* DHCPv6 */ - if (!commit_leases ()) - return 0; - return 1; + } + + if (commit_leases() == 0) + return (0); + return (1); } /* In addition to placing this lease upon a lease queue depending on its diff --git a/server/mdb6.c b/server/mdb6.c index 419e58e35..58fec01ca 100644 --- a/server/mdb6.c +++ b/server/mdb6.c @@ -2166,20 +2166,25 @@ write_ia_leases(const void *name, unsigned len, void *value) { */ int write_leases6(void) { + int nas, tas, pds; + write_error = 0; write_server_duid(); - ia_hash_foreach(ia_na_active, write_ia_leases); + nas = ia_hash_foreach(ia_na_active, write_ia_leases); if (write_error) { return 0; } - ia_hash_foreach(ia_ta_active, write_ia_leases); + tas = ia_hash_foreach(ia_ta_active, write_ia_leases); if (write_error) { return 0; } - ia_hash_foreach(ia_pd_active, write_ia_leases); + pds = ia_hash_foreach(ia_pd_active, write_ia_leases); if (write_error) { return 0; } + + log_info("Wrote %d NA, %d TA, %d PD leases to lease file.", + nas, tas, pds); return 1; } #endif /* DHCPv6 */