From: Roy Marples Date: Tue, 3 Sep 2013 11:30:10 +0000 (+0000) Subject: RFC 5942 Section 5 states DHCPv6 address should not create prefixes X-Git-Tag: v6.1.0~32 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6204b80e3f6c39a122918ea258da3aef4d79efac;p=thirdparty%2Fdhcpcd.git RFC 5942 Section 5 states DHCPv6 address should not create prefixes based on the assigned address. --- diff --git a/dhcp6.c b/dhcp6.c index 16eca1c1..76a7328b 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -1295,7 +1295,6 @@ dhcp6_findna(struct interface *ifp, const uint8_t *iaid, const uint8_t *p; struct in6_addr in6; struct ipv6_addr *a; - const struct ipv6_addr *pa; char iabuf[INET6_ADDRSTRLEN]; const char *ia; int i; @@ -1332,18 +1331,18 @@ dhcp6_findna(struct interface *ifp, const uint8_t *iaid, memcpy(&a->addr.s6_addr, &in6.s6_addr, sizeof(in6.s6_addr)); } - pa = ipv6nd_findprefix(a); - if (pa) { - memcpy(&a->prefix, &pa->prefix, - sizeof(a->prefix)); - a->prefix_len = pa->prefix_len; - } else { - a->prefix_len = 64; - if (ipv6_makeprefix(&a->prefix, &a->addr, 64) == -1) { - syslog(LOG_ERR, "%s: %m", __func__); - free(a); - continue; - } + /* + * RFC 5942 Section 5 + * We cannot assume any prefix length, nor tie the address + * to an existing one as it could expire before the address. + * As such we just give it a 128 prefix. + */ + a->prefix_len = 128; + if (ipv6_makeprefix(&a->prefix, &a->addr, a->prefix_len) == -1) + { + syslog(LOG_ERR, "%s: %m", __func__); + free(a); + continue; } memcpy(&u32, p, sizeof(u32)); a->prefix_pltime = ntohl(u32); diff --git a/dhcpcd.8.in b/dhcpcd.8.in index 618f8ccc..900544f6 100644 --- a/dhcpcd.8.in +++ b/dhcpcd.8.in @@ -624,7 +624,7 @@ running on the RFC\ 951 RFC\ 1534 RFC\ 2131, RFC\ 2132, RFC\ 2855, RFC\ 3004, RFC\ 3315, RFC\ 3361, RFC\ 3633, RFC\ 3396, RFC\ 3397, RFC\ 3442, RFC\ 3927, RFC\ 4039 RFC\ 4075, RFC\ 4361, RFC\ 4390, RFC\ 4702, RFC\ 4704, RFC\ 4861, RFC\ 4833, -RFC\ 5227, RFC\ 5969, RFC\ 6106. +RFC\ 5227, RFC\ 5942, RFC\ 5969, RFC\ 6106. .Sh AUTHORS .An Roy Marples Aq Mt roy@marples.name .Sh BUGS diff --git a/ipv6nd.c b/ipv6nd.c index 7cf33679..79a494da 100644 --- a/ipv6nd.c +++ b/ipv6nd.c @@ -1121,34 +1121,6 @@ ipv6nd_env(char **env, const char *prefix, const struct interface *ifp) return l; } -const struct ipv6_addr * -ipv6nd_findprefix(const struct ipv6_addr *a) -{ - const struct ra *rap; - const struct ipv6_addr *ap; - const struct in6_addr *p1, *p2; - int bytelen, bitlen; - - p1 = &a->addr; - TAILQ_FOREACH(rap, &ipv6_routers, next) { - TAILQ_FOREACH(ap, &rap->addrs, next) { - p2 = & ap->prefix; - bytelen = ap->prefix_len / NBBY; - bitlen = ap->prefix_len % NBBY; - if (memcmp(&p1->s6_addr, &p2->s6_addr, bytelen)) - continue; - if (bitlen != 0) { - bitlen = NBBY - bitlen; - if (p1->s6_addr[bytelen] >> bitlen != - p2->s6_addr[bytelen] >> bitlen) - continue; - } - return ap; - } - } - return NULL; -} - void ipv6nd_handleifa(int cmd, const char *ifname, const struct in6_addr *addr, int flags) diff --git a/ipv6nd.h b/ipv6nd.h index b9046286..d2529214 100644 --- a/ipv6nd.h +++ b/ipv6nd.h @@ -83,7 +83,6 @@ struct rs_state { #ifdef INET6 int ipv6nd_startrs(struct interface *); ssize_t ipv6nd_env(char **, const char *, const struct interface *); -const struct ipv6_addr * ipv6nd_findprefix(const struct ipv6_addr *); int ipv6nd_addrexists(const struct ipv6_addr *); void ipv6nd_freedrop_ra(struct ra *, int); #define ipv6nd_free_ra(ra) ipv6nd_freedrop_ra((ra), 0)