Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/ROY]: src/external/bsd/dhcpcd/dist/src Import dhcpcd-7.0.0-rc1 with the ...



details:   https://anonhg.NetBSD.org/src/rev/46ee3d539b57
branches:  ROY
changeset: 455201:46ee3d539b57
user:      roy <roy%NetBSD.org@localhost>
date:      Wed May 10 11:00:37 2017 +0000

description:
Import dhcpcd-7.0.0-rc1 with the following changes:
  *  Default to use VLANID>0 for IAID instead of MAC address
  *  Stop sharing the DHCPv6 port in master mode with other processes
  *  Fix some prefix delegation issues when the carrier drops or
     addresses become stale
  *  Fix a crash when starting dhcpcd with -n
  *  Fix test for preferring a fake lease over a real one
  *  Show to real address lifetimes being added when adding IPv6
     addresses
  *  Restore the -G, --nogateway option

diffstat:

 external/bsd/dhcpcd/dist/src/defs.h           |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c          |  143 +++++++++++++++----------
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in      |    4 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.c         |   49 +++++---
 external/bsd/dhcpcd/dist/src/dhcpcd.conf.5.in |    9 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.h         |    1 +
 external/bsd/dhcpcd/dist/src/if-bsd.c         |   89 ++++++++++++++-
 external/bsd/dhcpcd/dist/src/if-options.c     |   28 ++++-
 external/bsd/dhcpcd/dist/src/if-options.h     |    4 +-
 external/bsd/dhcpcd/dist/src/if.c             |    2 +
 external/bsd/dhcpcd/dist/src/if.h             |    1 +
 external/bsd/dhcpcd/dist/src/ipv4.c           |    4 +-
 external/bsd/dhcpcd/dist/src/ipv6.c           |  104 +++++++++++-------
 external/bsd/dhcpcd/dist/src/ipv6.h           |    2 +
 external/bsd/dhcpcd/dist/src/route.c          |   15 ++
 15 files changed, 318 insertions(+), 139 deletions(-)

diffs (truncated from 1021 to 300 lines):

diff -r b9f542e9d9d8 -r 46ee3d539b57 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Fri Apr 14 09:53:06 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Wed May 10 11:00:37 2017 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "7.0.0-beta3"
+#define VERSION                        "7.0.0-rc1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r b9f542e9d9d8 -r 46ee3d539b57 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Fri Apr 14 09:53:06 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Wed May 10 11:00:37 2017 +0000
@@ -1353,7 +1353,11 @@
                {
                        struct ipv6_addr *ap2;
 
+#ifdef SMALL
+                       valid = true;
+#else
                        valid = (ap->delegating_prefix == NULL);
+#endif
                        TAILQ_FOREACH(ap2, &state->addrs, next) {
                                if (ap2->flags & IPV6_AF_ADDED &&
                                    !(ap2->flags & IPV6_AF_DADCOMPLETED))
@@ -1366,8 +1370,10 @@
                                logdebugx("%s: DHCPv6 DAD completed",
                                    ifp->name);
                                script_runreason(ifp,
-                                   ap->delegating_prefix ?
-                                   "DELEGATED6" : state->reason);
+#ifndef SMALL
+                                   ap->delegating_prefix ? "DELEGATED6" :
+#endif
+                                   state->reason);
                                if (valid)
                                        dhcpcd_daemonise(ifp->ctx);
                        }
@@ -2039,7 +2045,7 @@
        uint16_t nl;
        uint8_t iaid[4];
        char buf[sizeof(iaid) * 3];
-       struct ipv6_addr *ap, *nap;
+       struct ipv6_addr *ap;
 
        if (l < sizeof(*m)) {
                /* Should be impossible with guards at packet in
@@ -2162,22 +2168,62 @@
                i++;
        }
 
-       TAILQ_FOREACH_SAFE(ap, &state->addrs, next, nap) {
-               if (ap->flags & IPV6_AF_STALE) {
-                       eloop_q_timeout_delete(ifp->ctx->eloop, 0, NULL, ap);
-                       if (ap->flags & IPV6_AF_REQUEST) {
-                               ap->prefix_vltime = ap->prefix_pltime = 0;
-                       } else {
-                               TAILQ_REMOVE(&state->addrs, ap, next);
-                               free(ap);
-                       }
-               }
-       }
        if (i == 0 && e)
                return -1;
        return i;
 }
 
+static void
+dhcp6_deprecateaddrs(struct ipv6_addrhead *addrs)
+{
+       struct ipv6_addr *ia, *ian;
+
+       TAILQ_FOREACH_SAFE(ia, addrs, next, ian) {
+               if (ia->flags & IPV6_AF_STALE) {
+                       if (ia->prefix_vltime != 0)
+                               logdebugx("%s: %s: became stale",
+                                   ia->iface->name, ia->saddr);
+                       ia->prefix_pltime = 0;
+               } else if (ia->prefix_vltime == 0)
+                       loginfox("%s: %s: no valid lifetime",
+                           ia->iface->name, ia->saddr);
+               else
+                       continue;
+
+#ifndef SMALL
+               /* If we delegated from this prefix, deprecate or remove
+                * the delegations. */
+               if (ia->flags & IPV6_AF_DELEGATEDPFX) {
+                       struct ipv6_addr *da;
+                       bool touched = false;
+
+                       TAILQ_FOREACH(da, &ia->pd_pfxs, pd_next) {
+                               if (ia->prefix_vltime == 0) {
+                                       if (da->prefix_vltime != 0) {
+                                               da->prefix_vltime = 0;
+                                               touched = true;
+                                       }
+                               } else if (da->prefix_pltime != 0) {
+                                       da->prefix_pltime = 0;
+                                       touched = true;
+                               }
+                       }
+                       if (touched)
+                               ipv6_addaddrs(&ia->pd_pfxs);
+               }
+#endif
+
+               if (ia->flags & IPV6_AF_REQUEST) {
+                       ia->prefix_vltime = ia->prefix_pltime = 0;
+                       eloop_q_timeout_delete(ia->iface->ctx->eloop,
+                           0, NULL, ia);
+                       continue;
+               }
+               TAILQ_REMOVE(addrs, ia, next);
+               ipv6_freeaddr(ia);
+       }
+}
+
 static int
 dhcp6_validatelease(struct interface *ifp,
     struct dhcp6_message *m, size_t len,
@@ -2416,7 +2462,7 @@
        if (strcmp(ifp->name, prefix->iface->name) == 0) {
                if (prefix->prefix_exclude_len == 0) {
                        /* Don't spam the log automatically */
-                       if (sla)
+                       if (sla != NULL)
                                logwarnx("%s: DHCPv6 server does not support "
                                    "OPTION_PD_EXCLUDE",
                                    ifp->name);
@@ -2428,14 +2474,14 @@
            sla, if_ia)) == -1)
                return NULL;
 
-       if (fls64(sla->suffix) > 128 - pfxlen) {
+       if (sla != NULL && fls64(sla->suffix) > 128 - pfxlen) {
                logerrx("%s: suffix %" PRIu64 " + prefix_len %d > 128",
                    ifp->name, sla->suffix, pfxlen);
                return NULL;
        }
 
        /* Add our suffix */
-       if (sla->suffix) {
+       if (sla != NULL && sla->suffix != 0) {
                daddr = addr;
                vl = be64dec(addr.s6_addr + 8);
                vl |= sla->suffix;
@@ -2510,9 +2556,12 @@
                            ipv6_iffindaddr(ap->iface, &ap->addr,
                                            IN6_IFF_TENTATIVE))
                                ap->flags |= IPV6_AF_DADCOMPLETED;
-                       if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0 &&
-                           ((delegated && ap->delegating_prefix) ||
-                           (!delegated && !ap->delegating_prefix)))
+                       if ((ap->flags & IPV6_AF_DADCOMPLETED) == 0
+#ifndef SMALL
+                           && ((delegated && ap->delegating_prefix) ||
+                           (!delegated && !ap->delegating_prefix))
+#endif
+                           )
                        {
                                completed = 0;
                                break;
@@ -3166,6 +3215,7 @@
                        eloop_timeout_add_sec(ifp->ctx->eloop,
                            (time_t)state->expire, dhcp6_startexpire, ifp);
 
+               dhcp6_deprecateaddrs(&state->addrs);
                ipv6_addaddrs(&state->addrs);
 
                if (state->state == DH6S_INFORMED)
@@ -3213,11 +3263,6 @@
        ctx->dhcp6_fd = xsocket(PF_INET6, SOCK_DGRAM | SOCK_FLAGS, IPPROTO_UDP);
 #undef SOCK_FLAGS
        if (ctx->dhcp6_fd == -1)
-               return -1;
-
-       n = 1;
-       if (setsockopt(ctx->dhcp6_fd, SOL_SOCKET, SO_REUSEADDR,
-           &n, sizeof(n)) == -1)
                goto errexit;
 
        n = 1;
@@ -3225,13 +3270,6 @@
            &n, sizeof(n)) == -1)
                goto errexit;
 
-#ifdef SO_REUSEPORT
-       n = 1;
-       if (setsockopt(ctx->dhcp6_fd, SOL_SOCKET, SO_REUSEPORT,
-           &n, sizeof(n)) == -1)
-               logerr("SO_REUSEPORT");
-#endif
-
        if (!(ctx->options & DHCPCD_MASTER)) {
                /* Bind to the link-local address to allow more than one
                 * DHCPv6 client to work. */
@@ -3260,8 +3298,11 @@
        return 0;
 
 errexit:
-       close(ctx->dhcp6_fd);
-       ctx->dhcp6_fd = -1;
+       logerr(__func__);
+       if (ctx->dhcp6_fd != -1) {
+               close(ctx->dhcp6_fd);
+               ctx->dhcp6_fd = -1;
+       }
        return -1;
 }
 
@@ -3428,40 +3469,20 @@
        struct dhcp6_state *state;
        struct dhcpcd_ctx *ctx;
        unsigned long long options;
-#ifndef SMALL
-       int dropdele;
-#endif
-
-       /*
-        * As the interface is going away from dhcpcd we need to
-        * remove the delegated addresses, otherwise we lose track
-        * of which interface is delegating as we remeber it by pointer.
-        * So if we need to change this behaviour, we need to change
-        * how we remember which interface delegated.
-        *
-        * XXX The below is no longer true due to the change of the
-        * default IAID, but do PPP links have stable ethernet
-        * addresses?
-        *
-        * To make it more interesting, on some OS's with PPP links
-        * there is no guarantee the delegating interface will have
-        * the same name or index so think very hard before changing
-        * this.
-        */
+
        if (ifp->options)
                options = ifp->options->options;
        else
                options = ifp->ctx->options;
-#ifndef SMALL
-       dropdele = (options & (DHCPCD_STOPPING | DHCPCD_RELEASE) &&
-           (options & DHCPCD_NODROP) != DHCPCD_NODROP);
-#endif
 
        if (ifp->ctx->eloop)
                eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
 
 #ifndef SMALL
-       if (dropdele)
+       /* If we're dropping the lease, drop delegated addresses.
+        * If, for whatever reason, we don't drop them in the future
+        * then they should at least be marked as deprecated (pltime 0). */
+       if (drop && (options & DHCPCD_NODROP) != DHCPCD_NODROP)
                dhcp6_delete_delegates(ifp);
 #endif
 
@@ -3573,9 +3594,11 @@
        char *pfx;
        uint32_t en;
        const struct dhcpcd_ctx *ctx;
+#ifndef SMALL
        const struct dhcp6_state *state;
        const struct ipv6_addr *ap;
        char *v, *val;
+#endif
 
        n = 0;
        if (m == NULL)
@@ -3676,6 +3699,7 @@
        free(pfx);
 
 delegated:
+#ifndef SMALL
         /* Needed for Delegated Prefixes */
        state = D6_CSTATE(ifp);
        i = 0;
@@ -3707,6 +3731,7 @@
         }
        if (i)
                n++;
+#endif
 
        return (ssize_t)n;
 }
diff -r b9f542e9d9d8 -r 46ee3d539b57 external/bsd/dhcpcd/dist/src/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Fri Apr 14 09:53:06 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Wed May 10 11:00:37 2017 +0000
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd April 11, 2017
+.Dd May 9, 2017
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -610,6 +610,8 @@



Home | Main Index | Thread Index | Old Index