mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-03 15:56:00 +00:00
[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.
This commit is contained in:
9
RELNOTES
9
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 <name>: Both servers normal."
|
||||
[ISC-Bugs 33208]
|
||||
|
||||
Changes since 4.2.5
|
||||
|
||||
- Address static analysis warnings.
|
||||
|
@@ -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.
|
||||
|
@@ -1794,6 +1794,10 @@ isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *state,
|
||||
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)
|
||||
cancel_timeout (dhcp_failover_startup_timeout, state);
|
||||
@@ -1987,6 +1991,10 @@ isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *state,
|
||||
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
|
||||
can't write to the lease database, we're not going to
|
||||
|
89
server/mdb.c
89
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
|
||||
|
@@ -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 */
|
||||
|
Reference in New Issue
Block a user