]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Respect the ONLINK flag the prefix option of the RA
authorRoy Marples <roy@marples.name>
Tue, 11 Dec 2012 09:00:49 +0000 (09:00 +0000)
committerRoy Marples <roy@marples.name>
Tue, 11 Dec 2012 09:00:49 +0000 (09:00 +0000)
dhcp6.c
ipv6.c
ipv6.h
ipv6rs.c

diff --git a/dhcp6.c b/dhcp6.c
index 9026d3e8545a0268f22c97bee1c0ccc6e09e3997..100cfe49f7acce3d9d62208261353955c02c8ada 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -948,6 +948,7 @@ dhcp6_findia(struct interface *ifp, const uint8_t *d, size_t l)
                a = malloc(sizeof(*a));
                if (a) {
                        a->new = 1;
+                       a->onlink = 1; /* XXX: suprised no DHCP opt for this */
                        p = D6_COPTION_DATA(o);
                        memcpy(&a->addr.s6_addr, p,
                            sizeof(a->addr.s6_addr));
diff --git a/ipv6.c b/ipv6.c
index 198cb2d0fccfeff592c6c91dc1fc1c1b89990541..93d2e1cf3daeed51190c9c2f1053e92ff0e8e06c 100644 (file)
--- a/ipv6.c
+++ b/ipv6.c
@@ -439,9 +439,6 @@ ipv6_removesubnet(const struct interface *ifp, struct ipv6_addr *addr)
 #endif
                {
                        r = del_route6(rt);
-                       /* If the subnet route didn't exist, don't
-                        * moan about it.
-                        * We currently do this to silence FreeBSD-7 */
                        if (r == -1 && errno == ESRCH)
                                r = 0;
                }
@@ -473,6 +470,8 @@ ipv6_buildroutes(void)
                d6_state = D6_CSTATE(ifp);
                if (d6_state && d6_state->state == DH6S_BOUND) {
                        TAILQ_FOREACH(addr, &d6_state->addrs, next) {
+                               if (!addr->onlink)
+                                       continue;
                                rt = make_prefix(ifp, NULL, addr);
                                if (rt)
                                        TAILQ_INSERT_TAIL(&dnr, rt, next);
@@ -482,6 +481,8 @@ ipv6_buildroutes(void)
        TAILQ_FOREACH(rap, &ipv6_routers, next) {
                if (options & DHCPCD_IPV6RA_OWN) {
                        TAILQ_FOREACH(addr, &rap->addrs, next) {
+                               if (!addr->onlink)
+                                       continue;
                                rt = make_prefix(rap->iface, rap, addr);
                                if (rt)
                                        TAILQ_INSERT_TAIL(&dnr, rt, next);
diff --git a/ipv6.h b/ipv6.h
index 92a913535df16560761b8f5f29c08699b36b85c7..e4d282212cbc40d3c0619bb00856b15f0a694903 100644 (file)
--- a/ipv6.h
+++ b/ipv6.h
@@ -44,7 +44,8 @@ struct ipv6_addr {
        uint32_t prefix_vltime;
        uint32_t prefix_pltime;
        struct in6_addr addr;
-       int new;
+       uint8_t onlink;
+       uint8_t new;
        char saddr[INET6_ADDRSTRLEN];
 };
 TAILQ_HEAD(ipv6_addrhead, ipv6_addr);
index d04663ff8a15afb2c2887bea4718b316cb0e52a4..d09c09e212cb3927aa4882d8d0414d4c7b243093 100644 (file)
--- a/ipv6rs.c
+++ b/ipv6rs.c
@@ -295,6 +295,7 @@ ipv6rs_freedrop_addrs(struct ra *rap, int drop)
                 * This is safe because the RA is removed from the list
                 * before we are called. */
                if (drop && (options & DHCPCD_IPV6RA_OWN) &&
+                   !IN6_IS_ADDR_UNSPECIFIED(&ap->addr) &&
                    !ipv6rs_addrexists(ap) && !dhcp6_addrexists(ap))
                {
                        syslog(LOG_INFO, "%s: deleting address %s",
@@ -581,6 +582,11 @@ ipv6rs_handledata(_unused void *arg)
                                    sizeof(ap->prefix.s6_addr)) == 0)
                                        break;
                        if (ap == NULL) {
+                               if (!(pi->nd_opt_pi_flags_reserved &
+                                   ND_OPT_PI_FLAG_AUTO) &&
+                                   !(pi->nd_opt_pi_flags_reserved &
+                                   ND_OPT_PI_FLAG_ONLINK))
+                                       break;
                                ap = xmalloc(sizeof(*ap));
                                ap->new = 1;
                                ap->prefix_len = pi->nd_opt_pi_prefix_len;
@@ -615,6 +621,9 @@ ipv6rs_handledata(_unused void *arg)
                                ap->new = 1;
                        else
                                ap->new = 0;
+                       if (pi->nd_opt_pi_flags_reserved &
+                           ND_OPT_PI_FLAG_ONLINK)
+                               ap->onlink = 1;
                        ap->prefix_vltime =
                            ntohl(pi->nd_opt_pi_valid_time);
                        ap->prefix_pltime =