]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP6: Don't spam the log when a RA repeatedly triggers an INFORM
authorRoy Marples <roy@marples.name>
Fri, 1 Oct 2021 15:25:53 +0000 (16:25 +0100)
committerRoy Marples <roy@marples.name>
Sun, 3 Oct 2021 16:36:54 +0000 (17:36 +0100)
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.

src/dhcp6.c
src/dhcp6.h

index 9af90f1cd60203d922c3d157f74c549be0641c92..21198c42c059d940c7ab77489374ce6744405f15 100644 (file)
@@ -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;
index ece6ba9c1e88c0b36b21d3bb9372b0b4e659fa64..0b257fab6c8da812f8cb087d8960931ddbe9ae4f 100644 (file)
@@ -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