Skip to content

Commit

Permalink
DHCP6: Don't spam the log when a RA repeatedly triggers an INFORM
Browse files Browse the repository at this point in the history
This can occur if the RA reduces the prefix times in accordance
with it's own lifetimes for example.
dhcpcd only checks if the RA contents have changed to trigger a
new INFORM.

As such, only log about new INFORMs.

Fixes #46.
  • Loading branch information
rsmarples committed Oct 1, 2021
1 parent 18da9b9 commit 3b1f557
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/dhcp6.c
Expand Up @@ -1649,7 +1649,7 @@ dhcp6_startinform(void *arg)

ifp = arg;
state = D6_STATE(ifp);
if (state->new == NULL && !state->failed)
if (state->new_start || (state->new == NULL && !state->failed))
llevel = LOG_INFO;
else
llevel = LOG_DEBUG;
Expand Down Expand Up @@ -3046,18 +3046,25 @@ static void
dhcp6_bind(struct interface *ifp, const char *op, const char *sfrom)
{
struct dhcp6_state *state = D6_STATE(ifp);
bool timedout = (op == NULL), has_new = false, confirmed;
bool timedout = (op == NULL), confirmed;
struct ipv6_addr *ia;
int loglevel;
struct timespec now;

TAILQ_FOREACH(ia, &state->addrs, next) {
if (ia->flags & IPV6_AF_NEW) {
has_new = true;
break;
if (state->state == DH6S_RENEW && !state->new_start) {
loglevel = LOG_DEBUG;
TAILQ_FOREACH(ia, &state->addrs, next) {
if (ia->flags & IPV6_AF_NEW) {
loglevel = LOG_INFO;
break;
}
}
}
loglevel = has_new || state->state != DH6S_RENEW ? LOG_INFO : LOG_DEBUG;
} else if (state->state == DH6S_INFORM)
loglevel = state->new_start ? LOG_INFO : LOG_DEBUG;
else
loglevel = LOG_INFO;
state->new_start = false;

if (!timedout) {
logmessage(loglevel, "%s: %s received from %s",
ifp->name, op, sfrom);
Expand Down Expand Up @@ -3940,7 +3947,13 @@ dhcp6_start(struct interface *ifp, enum DH6S init_state)
(state->state == DH6S_DISCOVER &&
!(ifp->options->options & DHCPCD_IA_FORCED) &&
!ipv6nd_hasradhcp(ifp, true)))
{
/* We don't want log spam when the RA
* has just adjusted it's prefix times. */
if (state->state != DH6S_INFORMED)
state->new_start = true;
dhcp6_startinform(ifp);
}
break;
case DH6S_REQUEST:
if (ifp->options->options & DHCPCD_DHCP6 &&
Expand Down Expand Up @@ -3989,6 +4002,7 @@ dhcp6_start(struct interface *ifp, enum DH6S init_state)
TAILQ_INIT(&state->addrs);

gogogo:
state->new_start = true;
state->state = init_state;
state->lerror = 0;
state->failed = false;
Expand Down
1 change: 1 addition & 0 deletions src/dhcp6.h
Expand Up @@ -213,6 +213,7 @@ struct dhcp6_state {
uint16_t lerror; /* Last error received from DHCPv6 reply. */
bool has_no_binding;
bool failed; /* Entered the failed state - used to rate limit log. */
bool new_start; /* New external start, to determine log type. */
#ifdef AUTH
struct authstate auth;
#endif
Expand Down

0 comments on commit 3b1f557

Please sign in to comment.