Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/00103d4c4f61
branches:  trunk
changeset: 823825:00103d4c4f61
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/Makefile                          |    2 +-
 external/bsd/dhcpcd/dist/configure                         |    7 +-
 external/bsd/dhcpcd/dist/src/Makefile                      |    4 +-
 external/bsd/dhcpcd/dist/src/defs.h                        |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c                       |  143 +++++++-----
 external/bsd/dhcpcd/dist/src/dhcpcd-definitions-small.conf |    1 +
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in                   |    4 +-
 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-linux.c                    |   17 +-
 external/bsd/dhcpcd/dist/src/if-options.h                  |    4 +-
 external/bsd/dhcpcd/dist/src/if-sun.c                      |    7 +
 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 +
 19 files changed, 296 insertions(+), 122 deletions(-)

diffs (truncated from 927 to 300 lines):

diff -r 3d4aef1c76ce -r 00103d4c4f61 external/bsd/dhcpcd/dist/Makefile
--- a/external/bsd/dhcpcd/dist/Makefile Wed May 10 10:34:30 2017 +0000
+++ b/external/bsd/dhcpcd/dist/Makefile Wed May 10 11:00:37 2017 +0000
@@ -44,7 +44,7 @@
        for x in ${SUBDIRS}; do cd $$x; ${MAKE} $@; cd ..; done
 
 clean:
-       rm -rf cov-int
+       rm -rf cov-int dhcpcd.xz
        for x in ${SUBDIRS} tests; do cd $$x; ${MAKE} $@; cd ..; done
 
 distclean: clean
diff -r 3d4aef1c76ce -r 00103d4c4f61 external/bsd/dhcpcd/dist/configure
--- a/external/bsd/dhcpcd/dist/configure        Wed May 10 10:34:30 2017 +0000
+++ b/external/bsd/dhcpcd/dist/configure        Wed May 10 11:00:37 2017 +0000
@@ -380,6 +380,11 @@
        sunos*);;
        *)              echo "CFLAGS+=  -Wstrict-overflow" >>$CONFIG_MK;;
        esac
+
+       # Turn on extra per compiler debugging
+       case "$CC" in
+       *gcc*)          echo "CFLAGS+=  -Wlogical-op" >>$CONFIG_MK;;
+       esac
 else
        echo "CPPFLAGS+=        -DNDEBUG" >>$CONFIG_MK
 fi
@@ -512,7 +517,7 @@
        echo "$CC does not create executables" >&2
        exit 1
 fi
-[ "$CC" != cc ] && echo "CC=   $CC" >>$CONFIG_MK
+[ "$CC" != cc ] && echo "CC=           $CC" >>$CONFIG_MK
 $CC --version | $SED -e '1!d'
 
 if [ -z "$EMBEDDED" -o "$EMBEDDED" = yes ]; then
diff -r 3d4aef1c76ce -r 00103d4c4f61 external/bsd/dhcpcd/dist/src/Makefile
--- a/external/bsd/dhcpcd/dist/src/Makefile     Wed May 10 10:34:30 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/Makefile     Wed May 10 11:00:37 2017 +0000
@@ -72,8 +72,8 @@
        ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LDADD}
 
 _embeddedinstall: ${DHCPCD_DEFS}
-       ${INSTALL} -d ${DESTDIR}${SCRIPTSDIR}
-       ${INSTALL} -m ${CONFMODE} ${DHCPCD_DEFS} ${DESTDIR}${SCRIPTSDIR}
+       ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
+       ${INSTALL} -m ${CONFMODE} ${DHCPCD_DEFS} ${DESTDIR}${LIBEXECDIR}
 
 _proginstall: ${PROG}
        ${INSTALL} -d ${DESTDIR}${SBINDIR}
diff -r 3d4aef1c76ce -r 00103d4c4f61 external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Wed May 10 10:34:30 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 3d4aef1c76ce -r 00103d4c4f61 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Wed May 10 10:34:30 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);
 



Home | Main Index | Thread Index | Old Index