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 Sync



details:   https://anonhg.NetBSD.org/src/rev/3070cc536851
branches:  trunk
changeset: 448716:3070cc536851
user:      roy <roy%NetBSD.org@localhost>
date:      Thu Feb 07 21:37:36 2019 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in |    5 +-
 external/bsd/dhcpcd/dist/src/dhcp.c                |   10 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c               |    8 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.c              |  112 ++++++++++++++++++---
 external/bsd/dhcpcd/dist/src/if-bsd.c              |   41 ++++--
 external/bsd/dhcpcd/dist/src/if-options.c          |   10 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c              |   38 ++++--
 7 files changed, 170 insertions(+), 54 deletions(-)

diffs (truncated from 678 to 300 lines):

diff -r 7c5eedd187e8 -r 3070cc536851 external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in
--- a/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in        Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/hooks/dhcpcd-run-hooks.in        Thu Feb 07 21:37:36 2019 +0000
@@ -239,8 +239,9 @@
                _service_exists="/usr/bin/systemctl --quiet is-enabled \$1.service"
                _service_status="/usr/bin/systemctl --quiet is-active \$1.service"
                _service_cmd="/usr/bin/systemctl \$2 \$1.service"
-       elif [ -x /sbin/rc-service ] && [ -s /libexec/rc/init.d/softlevel ] ||
-            [ -s /run/openrc/softlevel ]
+       elif [ -x /sbin/rc-service ] &&
+            { [ -s /libexec/rc/init.d/softlevel ] ||
+            [ -s /run/openrc/softlevel ]; }
        then
                _service_exists="/sbin/rc-service -e \$1"
                _service_cmd="/sbin/rc-service \$1 -- -D \$2"
diff -r 7c5eedd187e8 -r 3070cc536851 external/bsd/dhcpcd/dist/src/dhcp.c
--- a/external/bsd/dhcpcd/dist/src/dhcp.c       Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp.c       Thu Feb 07 21:37:36 2019 +0000
@@ -1764,7 +1764,7 @@
 
        if (!callback) {
                /* No carrier? Don't bother sending the packet. */
-               if (ifp->carrier == LINK_DOWN)
+               if (ifp->carrier <= LINK_DOWN)
                        return;
                logdebugx("%s: sending %s with xid 0x%x",
                    ifp->name,
@@ -1784,7 +1784,7 @@
                timespecnorm(&tv);
                /* No carrier? Don't bother sending the packet.
                 * However, we do need to advance the timeout. */
-               if (ifp->carrier == LINK_DOWN)
+               if (ifp->carrier <= LINK_DOWN)
                        goto fail;
                logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds",
                    ifp->name,
@@ -1965,7 +1965,7 @@
        dhcp_drop(ifp, "EXPIRE");
        unlink(state->leasefile);
        state->interval = 0;
-       if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier != LINK_DOWN)
+       if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier > LINK_DOWN)
                dhcp_discover(ifp);
 }
 
@@ -2601,7 +2601,7 @@
        state->state = DHS_REBOOT;
        state->interval = 0;
 
-       if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) {
+       if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) {
                loginfox("%s: waiting for carrier", ifp->name);
                return;
        }
@@ -2691,7 +2691,7 @@
                state->state = DHS_RELEASE;
 
                unlink(state->leasefile);
-               if (ifp->carrier != LINK_DOWN &&
+               if (ifp->carrier > LINK_DOWN &&
                    state->new != NULL &&
                    state->lease.server.s_addr != INADDR_ANY)
                {
diff -r 7c5eedd187e8 -r 3070cc536851 external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Thu Feb 07 21:37:36 2019 +0000
@@ -1169,7 +1169,7 @@
        struct ipv6_addr *lla;
        int s;
 
-       if (!callback && ifp->carrier == LINK_DOWN)
+       if (!callback && ifp->carrier <= LINK_DOWN)
                return 0;
 
        memset(&dst, 0, sizeof(dst));
@@ -1262,7 +1262,7 @@
                }
 
 logsend:
-               if (ifp->carrier != LINK_DOWN)
+               if (ifp->carrier > LINK_DOWN)
                        logdebugx("%s: %s %s (xid 0x%02x%02x%02x),"
                            " next in %0.1f seconds",
                            ifp->name,
@@ -1286,7 +1286,7 @@
                }
        }
 
-       if (ifp->carrier == LINK_DOWN)
+       if (ifp->carrier <= LINK_DOWN)
                return 0;
 
        /* Update the elapsed time */
@@ -3416,6 +3416,8 @@
                        break;
                }
                return;
+#else
+               break;
 #endif
        default:
                logerrx("%s: invalid DHCP6 type %s (%d)",
diff -r 7c5eedd187e8 -r 3070cc536851 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Thu Feb 07 21:34:30 2019 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Thu Feb 07 21:37:36 2019 +0000
@@ -52,6 +52,7 @@
 #include "common.h"
 #include "control.h"
 #include "dev.h"
+#include "dhcp-common.h"
 #include "dhcpcd.h"
 #include "dhcp6.h"
 #include "duid.h"
@@ -151,6 +152,7 @@
                free(ctx->nd_opts);
                ctx->nd_opts = NULL;
        }
+#ifdef DHCP6
        if (ctx->dhcp6_opts) {
                for (opt = ctx->dhcp6_opts;
                    ctx->dhcp6_opts_len > 0;
@@ -160,6 +162,7 @@
                ctx->dhcp6_opts = NULL;
        }
 #endif
+#endif
        if (ctx->vivso) {
                for (opt = ctx->vivso;
                    ctx->vivso_len > 0;
@@ -205,18 +208,39 @@
 dhcpcd_ifafwaiting(const struct interface *ifp)
 {
        unsigned long long opts;
+       bool foundany = false;
 
        if (ifp->active != IF_ACTIVE_USER)
                return AF_MAX;
 
+#define DHCPCD_WAITALL (DHCPCD_WAITIP4 | DHCPCD_WAITIP6)
        opts = ifp->options->options;
-       if (opts & DHCPCD_WAITIP4 && !ipv4_hasaddr(ifp))
-               return AF_INET;
-       if (opts & DHCPCD_WAITIP6 && !ipv6_hasaddr(ifp))
-               return AF_INET6;
-       if (opts & DHCPCD_WAITIP &&
-           !(opts & (DHCPCD_WAITIP4 | DHCPCD_WAITIP6)) &&
-           !ipv4_hasaddr(ifp) && !ipv6_hasaddr(ifp))
+#ifdef INET
+       if (opts & DHCPCD_WAITIP4 ||
+           (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL)))
+       {
+               bool foundaddr = ipv4_hasaddr(ifp);
+
+               if (opts & DHCPCD_WAITIP4 && !foundaddr)
+                       return AF_INET;
+               if (foundaddr)
+                       foundany = true;
+       }
+#endif
+#ifdef INET6
+       if (opts & DHCPCD_WAITIP6 ||
+           (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL)))
+       {
+               bool foundaddr = ipv6_hasaddr(ifp);
+
+               if (opts & DHCPCD_WAITIP6 && !foundaddr)
+                       return AF_INET;
+               if (foundaddr)
+                       foundany = true;
+       }
+#endif
+
+       if (opts & DHCPCD_WAITIP && !(opts & DHCPCD_WAITALL) && !foundany)
                return AF_UNSPEC;
        return AF_MAX;
 }
@@ -233,12 +257,16 @@
 
        opts = ctx->options;
        TAILQ_FOREACH(ifp, ctx->ifaces, next) {
+#ifdef INET
                if (opts & (DHCPCD_WAITIP | DHCPCD_WAITIP4) &&
                    ipv4_hasaddr(ifp))
                        opts &= ~(DHCPCD_WAITIP | DHCPCD_WAITIP4);
+#endif
+#ifdef INET6
                if (opts & (DHCPCD_WAITIP | DHCPCD_WAITIP6) &&
                    ipv6_hasaddr(ifp))
                        opts &= ~(DHCPCD_WAITIP | DHCPCD_WAITIP6);
+#endif
                if (!(opts & DHCPCD_WAITOPTS))
                        break;
        }
@@ -529,7 +557,7 @@
                ifo->options |= DHCPCD_IAID;
        }
 
-#ifdef INET6
+#ifdef DHCP6
        if (ifo->ia_len == 0 && ifo->options & DHCPCD_IPV6 &&
            ifp->name[0] != '\0')
        {
@@ -727,18 +755,30 @@
                if (ifp->carrier != LINK_DOWN) {
                        if (ifp->carrier == LINK_UP)
                                loginfox("%s: carrier lost", ifp->name);
-                       ifp->carrier = LINK_DOWN;
+#ifdef NOCARRIER_PRESERVE_IP
+                       if (ifp->flags & IFF_UP)
+                               ifp->carrier = LINK_DOWN_IFFUP;
+                       else
+#endif
+                               ifp->carrier = LINK_DOWN;
                        script_runreason(ifp, "NOCARRIER");
 #ifdef NOCARRIER_PRESERVE_IP
+                       if (ifp->flags & IFF_UP) {
 #ifdef ARP
-                       arp_drop(ifp);
+                               arp_drop(ifp);
+#endif
+#ifdef INET
+                               dhcp_abort(ifp);
 #endif
-                       dhcp_abort(ifp);
-                       ipv6nd_expire(ifp, 0);
-                       dhcp6_abort(ifp);
-#else
-                       dhcpcd_drop(ifp, 0);
+#ifdef INET6
+                               ipv6nd_expire(ifp, 0);
 #endif
+#ifdef DHCP6
+                               dhcp6_abort(ifp);
+#endif
+                       } else
+#endif
+                               dhcpcd_drop(ifp, 0);
                }
        } else if (carrier == LINK_UP && ifp->flags & IFF_UP) {
                if (ifp->carrier != LINK_UP) {
@@ -772,6 +812,7 @@
                        }
                        dhcpcd_initstate(ifp, 0);
                        script_runreason(ifp, "CARRIER");
+#ifdef INET6
 #ifdef NOCARRIER_PRESERVE_IP
                        /* Set any IPv6 Routers we remembered to expire
                         * faster than they would normally as we
@@ -780,6 +821,7 @@
 #endif
                        /* RFC4941 Section 3.5 */
                        ipv6_gentempifid(ifp);
+#endif
                        dhcpcd_startinterface(ifp);
                }
        }
@@ -885,10 +927,12 @@
 #endif
        }
 
+#ifdef INET6
        if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
                logerr("%s: ipv6_start", ifp->name);
                ifo->options &= ~DHCPCD_IPV6;
        }
+
        if (ifo->options & DHCPCD_IPV6) {
                if (ifp->active == IF_ACTIVE_USER) {
                        ipv6_startstatic(ifp);
@@ -897,7 +941,7 @@
                                ipv6nd_startrs(ifp);
                }
 
-
+#ifdef DHCP6
                if (ifo->options & DHCPCD_DHCP6) {
                        dhcp6_find_delegates(ifp);
 
@@ -914,7 +958,9 @@
                                        logerr("%s: dhcp6_start", ifp->name);
                        }
                }
+#endif
        }
+#endif
 
 #ifdef INET
        if (ifo->options & DHCPCD_IPV4 && ifp->active == IF_ACTIVE_USER) {
@@ -1173,8 +1219,12 @@
        oldopts = ifp->options->options;
        script_runreason(ifp, "RECONFIGURE");
        dhcpcd_initstate1(ifp, argc, argv, 0);
+#ifdef INET
        dhcp_reboot_newopts(ifp, oldopts);
+#endif
+#ifdef DHCP6
        dhcp6_reboot(ifp);
+#endif
        dhcpcd_prestartinterface(ifp);
 }



Home | Main Index | Thread Index | Old Index