diff options
author | Shawn Routhier <sar@isc.org> | 2013-11-08 12:29:20 -0800 |
---|---|---|
committer | Shawn Routhier <sar@isc.org> | 2013-11-08 12:29:20 -0800 |
commit | f88446f16b9b3be36492f78b0f66a4166e459896 (patch) | |
tree | feed6e4e28d73aae7447220be33d3f772bc5ca07 /server | |
parent | cde11a4cdb79f5447f4459d156d759620949539f (diff) | |
download | isc-dhcp-f88446f16b9b3be36492f78b0f66a4166e459896.tar.gz |
[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.
Diffstat (limited to 'server')
-rw-r--r-- | server/dhcpd.c | 3 | ||||
-rw-r--r-- | server/failover.c | 8 | ||||
-rw-r--r-- | server/mdb.c | 89 | ||||
-rw-r--r-- | server/mdb6.c | 11 |
4 files changed, 71 insertions, 40 deletions
diff --git a/server/dhcpd.c b/server/dhcpd.c index 3588349f..457b3cc0 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 7a9ae9e2..3dfe7b99 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 53bf34dc..ba2c3d32 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 419e58e3..58fec01c 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 */ |