]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
RFC 5942 Section 5 states DHCPv6 address should not create prefixes
authorRoy Marples <roy@marples.name>
Tue, 3 Sep 2013 11:30:10 +0000 (11:30 +0000)
committerRoy Marples <roy@marples.name>
Tue, 3 Sep 2013 11:30:10 +0000 (11:30 +0000)
based on the assigned address.

dhcp6.c
dhcpcd.8.in
ipv6nd.c
ipv6nd.h

diff --git a/dhcp6.c b/dhcp6.c
index 16eca1c11b5840e2eeb4d4c17cc5130d188e281a..76a7328b57aeb84ea47ca47c02400c21e8719025 100644 (file)
--- 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);
index 618f8cccee43190ba38c9f0f1a00eaed3c1127f8..900544f62fd7786ff61f9bfcbb8c88396e72d3db 100644 (file)
@@ -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
index 7cf3367953fa6540499849f4bbed548d24dba405..79a494dab49f78b12e7e19553b5184052492dadd 100644 (file)
--- 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)
index b904628601628fd1f8d79931fcbc89e37036e2b6..d2529214bb5df8dd78b8a9d17f1b5104e73b1928 100644 (file)
--- 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)