summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2018-05-10 18:51:56 +0100
committerRoy Marples <roy@marples.name>2018-05-10 18:51:56 +0100
commitf02a620860eb68bd36d498da25c659539e2cac25 (patch)
treedbb370d52f91e3c889bc004c18333786a1f86a4a
parent6b82f328bc50fcb1e652cb6662fa5423026b15d2 (diff)
downloaddhcpcd-f02a620860eb68bd36d498da25c659539e2cac25.tar.xz
dhcp6: Stop non delegated addresses being delegated
This was caused by allowing matching iaids and should now be resolved.
-rw-r--r--src/dhcp6.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/dhcp6.c b/src/dhcp6.c
index 6eb3f448..399f3785 100644
--- a/src/dhcp6.c
+++ b/src/dhcp6.c
@@ -484,20 +484,18 @@ again:
#ifndef SMALL
static const struct if_sla *
-dhcp6_findselfsla(struct interface *ifp, const uint8_t *iaid)
+dhcp6_findselfsla(struct interface *ifp)
{
size_t i, j;
+ struct if_ia *ia;
for (i = 0; i < ifp->options->ia_len; i++) {
- if (iaid == NULL ||
- memcmp(&ifp->options->ia[i].iaid, iaid,
- sizeof(ifp->options->ia[i].iaid)) == 0)
- {
- for (j = 0; j < ifp->options->ia[i].sla_len; j++) {
- if (strcmp(ifp->options->ia[i].sla[j].ifname,
- ifp->name) == 0)
- return &ifp->options->ia[i].sla[j];
- }
+ ia = &ifp->options->ia[i];
+ if (ia->ia_type != D6_OPTION_IA_PD)
+ continue;
+ for (j = 0; j < ia->sla_len; j++) {
+ if (strcmp(ia->sla[j].ifname, ifp->name) == 0)
+ return &ia->sla[j];
}
}
return NULL;
@@ -699,7 +697,7 @@ dhcp6_makemessage(struct interface *ifp)
len += sizeof(o.len);
}
}
- if (dhcp6_findselfsla(ifp, NULL)) {
+ if (dhcp6_findselfsla(ifp)) {
n_options++;
len += sizeof(o.len);
}
@@ -1076,7 +1074,7 @@ dhcp6_makemessage(struct interface *ifp)
(o.len + sizeof(o.code));
}
}
- if (dhcp6_findselfsla(ifp, NULL)) {
+ if (dhcp6_findselfsla(ifp)) {
o.code = htons(D6_OPTION_PD_EXCLUDE);
memcpy(p, &o.code, sizeof(o.code));
p += sizeof(o.code);
@@ -2790,6 +2788,8 @@ dhcp6_delegate_prefix(struct interface *ifp)
}
for (i = 0; i < ifo->ia_len; i++) {
ia = &ifo->ia[i];
+ if (ia->ia_type != D6_OPTION_IA_PD)
+ continue;
if (memcmp(ia->iaid, ap->iaid,
sizeof(ia->iaid)))
continue;
@@ -2886,6 +2886,8 @@ dhcp6_find_delegates(struct interface *ifp)
continue;
for (i = 0; i < ifo->ia_len; i++) {
ia = &ifo->ia[i];
+ if (ia->ia_type != D6_OPTION_IA_PD)
+ continue;
if (memcmp(ia->iaid, ap->iaid,
sizeof(ia->iaid)))
continue;
@@ -3663,6 +3665,8 @@ dhcp6_activateinterfaces(struct interface *ifp)
for (i = 0; i < ifp->options->ia_len; i++) {
ia = &ifp->options->ia[i];
+ if (ia->ia_type != D6_OPTION_IA_PD)
+ continue;
for (j = 0; j < ia->sla_len; j++) {
sla = &ia->sla[j];
ifd = if_find(ifp->ctx->ifaces, sla->ifname);
@@ -3719,7 +3723,7 @@ dhcp6_start1(void *arg)
#ifndef SMALL
/* Rapid commit won't work with Prefix Delegation Exclusion */
- if (dhcp6_findselfsla(ifp, NULL))
+ if (dhcp6_findselfsla(ifp))
del_option_mask(ifo->requestmask6, D6_OPTION_RAPID_COMMIT);
#endif