Skip to content

Commit

Permalink
Always send req for InfoRefreshTime option on Inform-Req (#446)
Browse files Browse the repository at this point in the history
RFC8415 says client must always request Information Request refresh time
option 32.
Client has other logic for handling if server does not include this in
the reply.

Resolves #445.
  • Loading branch information
ColinMcInnes authored Feb 5, 2025
1 parent 84f3264 commit e1ce523
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/dhcp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,16 +1742,22 @@ static void
dhcp6_startdiscover(void *arg)
{
struct interface *ifp;
struct if_options *ifo;
struct dhcp6_state *state;
int llevel;
struct ipv6_addr *ia;

ifp = arg;
state = D6_STATE(ifp);
ifo = ifp->options;
#ifndef SMALL
if (state->reason == NULL || strcmp(state->reason, "TIMEOUT6") != 0)
dhcp6_delete_delegates(ifp);
#endif
/* Ensure we never request INFO_REFRESH_TIME,
* this only belongs in Information-Request messages */
del_option_mask(ifo->requestmask6, D6_OPTION_INFO_REFRESH_TIME);

if (state->new == NULL && !state->failed)
llevel = LOG_INFO;
else
Expand Down Expand Up @@ -1784,9 +1790,11 @@ dhcp6_startinform(void *arg)
struct interface *ifp;
struct dhcp6_state *state;
int llevel;
struct if_options *ifo;

ifp = arg;
state = D6_STATE(ifp);
ifo = ifp->options;
llevel = state->failed ? LOG_DEBUG : LOG_INFO;
logmessage(llevel, "%s: requesting DHCPv6 information", ifp->name);
state->state = DH6S_INFORM;
Expand All @@ -1796,6 +1804,9 @@ dhcp6_startinform(void *arg)
state->MRT = state->inf_max_rt;
state->MRC = 0;

/* Ensure we always request INFO_REFRESH_TIME as per rfc8415 */
add_option_mask(ifo->requestmask6, D6_OPTION_INFO_REFRESH_TIME);

if (dhcp6_makemessage(ifp) == -1) {
logerr("%s: %s", __func__, ifp->name);
return;
Expand Down Expand Up @@ -2815,19 +2826,21 @@ static void
dhcp6_startinit(struct interface *ifp)
{
struct dhcp6_state *state;
struct if_options *ifo;
ssize_t r;
uint8_t has_ta, has_non_ta;
size_t i;

state = D6_STATE(ifp);
ifo = ifp->options;
state->state = DH6S_INIT;
state->expire = ND6_INFINITE_LIFETIME;
state->lowpl = ND6_INFINITE_LIFETIME;

dhcp6_addrequestedaddrs(ifp);
has_ta = has_non_ta = 0;
for (i = 0; i < ifp->options->ia_len; i++) {
switch (ifp->options->ia[i].ia_type) {
for (i = 0; i < ifo->ia_len; i++) {
switch (ifo->ia[i].ia_type) {
case D6_OPTION_IA_TA:
has_ta = 1;
break;
Expand All @@ -2838,14 +2851,14 @@ dhcp6_startinit(struct interface *ifp)

if (!(ifp->ctx->options & DHCPCD_TEST) &&
!(has_ta && !has_non_ta) &&
ifp->options->reboot != 0)
ifo->reboot != 0)
{
r = dhcp6_readlease(ifp, 1);
if (r == -1) {
if (errno != ENOENT && errno != ESRCH)
logerr("%s: %s", __func__, state->leasefile);
} else if (r != 0 &&
!(ifp->options->options & DHCPCD_ANONYMOUS))
!(ifo->options & DHCPCD_ANONYMOUS))
{
/* RFC 3633 section 12.1 */
#ifndef SMALL
Expand Down Expand Up @@ -4059,13 +4072,10 @@ dhcp6_start1(void *arg)
del_option_mask(ifo->requestmask6, D6_OPTION_RAPID_COMMIT);
#endif

if (state->state == DH6S_INFORM) {
add_option_mask(ifo->requestmask6, D6_OPTION_INFO_REFRESH_TIME);
if (state->state == DH6S_INFORM)
dhcp6_startinform(ifp);
} else {
del_option_mask(ifo->requestmask6, D6_OPTION_INFO_REFRESH_TIME);
else
dhcp6_startinit(ifp);
}

#ifndef SMALL
dhcp6_activateinterfaces(ifp);
Expand Down

0 comments on commit e1ce523

Please sign in to comment.