Mercurial > hg > dhcpcd
changeset 5151:3c6da4e11150 draft
DHCP6: don't log when things consitently fail
For example, the RA says obtain more inforamtion via DHCPv6 but
there is no DHCPv6 server to service the request.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Fri, 17 Apr 2020 13:25:33 +0100 |
| parents | 85569e7510f2 |
| children | 352c272ba3c3 |
| files | src/dhcp6.c src/dhcp6.h |
| diffstat | 2 files changed, 44 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcp6.c Fri Apr 17 13:22:54 2020 +0100 +++ b/src/dhcp6.c Fri Apr 17 13:25:33 2020 +0100 @@ -1585,6 +1585,7 @@ { struct interface *ifp; struct dhcp6_state *state; + int llevel; ifp = arg; state = D6_STATE(ifp); @@ -1592,7 +1593,11 @@ if (state->reason == NULL || strcmp(state->reason, "TIMEOUT6") != 0) dhcp6_delete_delegates(ifp); #endif - loginfox("%s: soliciting a DHCPv6 lease", ifp->name); + if (state->new == NULL && !state->failed) + llevel = LOG_INFO; + else + llevel = LOG_DEBUG; + logmessage(llevel, "%s: soliciting a DHCPv6 lease", ifp->name); state->state = DH6S_DISCOVER; state->RTC = 0; state->IMD = SOL_MAX_DELAY; @@ -1616,11 +1621,15 @@ { struct interface *ifp; struct dhcp6_state *state; + int llevel; ifp = arg; state = D6_STATE(ifp); - if (state->new == NULL || ifp->options->options & DHCPCD_DEBUG) - loginfox("%s: requesting DHCPv6 information", ifp->name); + if (state->new == NULL && !state->failed) + llevel = LOG_INFO; + else + llevel = LOG_DEBUG; + logmessage(llevel, "%s: requesting DHCPv6 information", ifp->name); state->state = DH6S_INFORM; state->RTC = 0; state->IMD = INF_MAX_DELAY; @@ -1677,6 +1686,8 @@ { struct dhcp6_state *state = D6_STATE(ifp); + state->failed = true; + /* RFC3315 18.1.2 says that prior addresses SHOULD be used on failure. * RFC2131 3.2.3 says that MAY chose to use the prior address. * Because dhcpcd was written first for RFC2131, we have the LASTLEASE @@ -1711,33 +1722,43 @@ } } +static int +dhcp6_failloglevel(struct interface *ifp) +{ + const struct dhcp6_state *state = D6_CSTATE(ifp); + + return state->failed ? LOG_DEBUG : LOG_ERR; +} + static void dhcp6_failconfirm(void *arg) { - struct interface *ifp; - - ifp = arg; - logerrx("%s: failed to confirm prior address", ifp->name); + struct interface *ifp = arg; + int llevel = dhcp6_failloglevel(ifp); + + logmessage(llevel, "%s: failed to confirm prior DHCPv6 address", + ifp->name); dhcp6_fail(ifp); } static void dhcp6_failrequest(void *arg) { - struct interface *ifp; - - ifp = arg; - logerrx("%s: failed to request address", ifp->name); + struct interface *ifp = arg; + int llevel = dhcp6_failloglevel(ifp); + + logmessage(llevel, "%s: failed to request DHCPv6 address", ifp->name); dhcp6_fail(ifp); } static void dhcp6_failinform(void *arg) { - struct interface *ifp; - - ifp = arg; - logerrx("%s: failed to request information", ifp->name); + struct interface *ifp = arg; + int llevel = dhcp6_failloglevel(ifp); + + logmessage(llevel, "%s: failed to request DHCPv6 information", + ifp->name); dhcp6_fail(ifp); } @@ -1745,10 +1766,9 @@ static void dhcp6_failrebind(void *arg) { - struct interface *ifp; - - ifp = arg; - logerrx("%s: failed to rebind prior delegation", ifp->name); + struct interface *ifp = arg; + + logerrx("%s: failed to rebind prior DHCPv6 delegation", ifp->name); dhcp6_fail(ifp); } @@ -3124,6 +3144,7 @@ state->state = DH6S_INFORMED; else state->state = DH6S_BOUND; + state->failed = false; if (state->renew && state->renew != ND6_INFINITE_LIFETIME) eloop_timeout_add_sec(ifp->ctx->eloop, @@ -3857,6 +3878,7 @@ gogogo: state->state = init_state; state->lerror = 0; + state->failed = false; dhcp_set_leasefile(state->leasefile, sizeof(state->leasefile), AF_INET6, ifp); if (ipv6_linklocal(ifp) == NULL) {
--- a/src/dhcp6.h Fri Apr 17 13:22:54 2020 +0100 +++ b/src/dhcp6.h Fri Apr 17 13:25:33 2020 +0100 @@ -211,7 +211,10 @@ const char *reason; uint16_t lerror; /* Last error received from DHCPv6 reply. */ bool has_no_binding; + bool failed; /* Entered the failed state - used to rate limit log. */ +#ifdef AUTH struct authstate auth; +#endif }; #define D6_STATE(ifp) \
