Mercurial > hg > dhcpcd
changeset 4282:18aa55c59279 draft
dhcp6: Stop non delegated addresses being delegated
This was caused by allowing matching iaids and should now be resolved.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 10 May 2018 18:51:56 +0100 |
| parents | 0173b37a051b |
| children | c66180322ab9 |
| files | src/dhcp6.c |
| diffstat | 1 files changed, 17 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dhcp6.c Tue May 08 12:39:26 2018 +0100 +++ b/src/dhcp6.c Thu May 10 18:51:56 2018 +0100 @@ -484,20 +484,18 @@ #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 @@ len += sizeof(o.len); } } - if (dhcp6_findselfsla(ifp, NULL)) { + if (dhcp6_findselfsla(ifp)) { n_options++; len += sizeof(o.len); } @@ -1076,7 +1074,7 @@ (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 @@ } 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 @@ 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 @@ 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 @@ #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
