From: Roy Marples Date: Fri, 1 Oct 2021 15:25:53 +0000 (+0100) Subject: DHCP6: Don't spam the log when a RA repeatedly triggers an INFORM X-Git-Tag: v9.4.1~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e87165f48acc9ddb247f4cb677f245c89333c8f0;p=thirdparty%2Fdhcpcd.git DHCP6: Don't spam the log when a RA repeatedly triggers an INFORM 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. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index 9af90f1c..21198c42 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -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; @@ -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); @@ -3934,7 +3941,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 && @@ -3983,6 +3996,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; diff --git a/src/dhcp6.h b/src/dhcp6.h index ece6ba9c..0b257fab 100644 --- a/src/dhcp6.h +++ b/src/dhcp6.h @@ -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