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/91982d644f48
branches:  trunk
changeset: 334960:91982d644f48
user:      roy <roy%NetBSD.org@localhost>
date:      Wed Dec 17 20:50:08 2014 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/defs.h           |    4 +-
 external/bsd/dhcpcd/dist/dhcp.c           |   62 ++++--------
 external/bsd/dhcpcd/dist/dhcp6.c          |   43 ++++++--
 external/bsd/dhcpcd/dist/dhcpcd.8.in      |   13 +-
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in |    8 +-
 external/bsd/dhcpcd/dist/if-bsd.c         |  137 ++++++++++++++---------------
 external/bsd/dhcpcd/dist/if.c             |    7 +-
 external/bsd/dhcpcd/dist/if.h             |   21 +---
 external/bsd/dhcpcd/dist/ipv4.c           |   30 +++---
 external/bsd/dhcpcd/dist/ipv6.c           |   49 +++++++++-
 external/bsd/dhcpcd/dist/ipv6.h           |    5 +-
 external/bsd/dhcpcd/dist/ipv6nd.c         |   84 +++++-------------
 external/bsd/dhcpcd/dist/ipv6nd.h         |    5 +-
 13 files changed, 224 insertions(+), 244 deletions(-)

diffs (truncated from 1116 to 300 lines):

diff -r 497a4f664010 -r 91982d644f48 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Wed Dec 17 16:53:43 2014 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Wed Dec 17 20:50:08 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.10 2014/12/09 20:21:05 roy Exp $ */
+/* $NetBSD: defs.h,v 1.11 2014/12/17 20:50:08 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.6.5"
+#define VERSION                        "6.6.6"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 497a4f664010 -r 91982d644f48 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Wed Dec 17 16:53:43 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Wed Dec 17 20:50:08 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.25 2014/12/09 20:21:05 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.26 2014/12/17 20:50:08 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -32,11 +32,6 @@
 #include <sys/socket.h>
 #include <sys/stat.h>
 
-#ifdef __linux__
-#  include <asm/types.h> /* for systems with broken headers */
-#  include <linux/rtnetlink.h>
-#endif
-
 #include <arpa/inet.h>
 #include <net/if.h>
 #include <net/route.h>
@@ -1732,27 +1727,17 @@
        struct interface *ifp = arg;
        struct dhcp_state *state = D_STATE(ifp);
        struct if_options *ifo = ifp->options;
-       time_t timeout = ifo->timeout;
-
-       /* If we're rebooting then we need to shorten the normal timeout
-        * to ensure we try for a fallback or IPv4LL address. */
-       if (state->state == DHS_REBOOT) {
-               if (ifo->reboot >= timeout)
-                       timeout = 2;
-               else
-                       timeout = ifo->reboot;
-       }
 
        state->state = DHS_DISCOVER;
        state->xid = dhcp_xid(ifp);
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
        if (ifo->fallback)
                eloop_timeout_add_sec(ifp->ctx->eloop,
-                   timeout, dhcp_fallback, ifp);
+                   ifo->reboot, dhcp_fallback, ifp);
        else if (ifo->options & DHCPCD_IPV4LL &&
            !IN_LINKLOCAL(htonl(state->addr.s_addr)))
                eloop_timeout_add_sec(ifp->ctx->eloop,
-                   timeout, ipv4ll_start, ifp);
+                   ifo->reboot, ipv4ll_start, ifp);
        if (ifo->options & DHCPCD_REQUEST)
                syslog(LOG_INFO, "%s: soliciting a DHCP lease (requesting %s)",
                    ifp->name, inet_ntoa(ifo->req_addr));
@@ -2119,46 +2104,41 @@
                dhcp_static(ifp);
                return;
        }
+       if (ifo->options & DHCPCD_INFORM) {
+               syslog(LOG_INFO, "%s: informing address of %s",
+                   ifp->name, inet_ntoa(state->lease.addr));
+               dhcp_inform(ifp);
+               return;
+       }
        if (ifo->reboot == 0 || state->offer == NULL) {
                dhcp_discover(ifp);
                return;
        }
-       if (ifo->options & DHCPCD_INFORM) {
-               syslog(LOG_INFO, "%s: informing address of %s",
-                   ifp->name, inet_ntoa(state->lease.addr));
-       } else if (state->offer->cookie == 0) {
+       if (state->offer->cookie == 0)
                return;
-       } else {
-               syslog(LOG_INFO, "%s: rebinding lease of %s",
-                   ifp->name, inet_ntoa(state->lease.addr));
-       }
+
+       syslog(LOG_INFO, "%s: rebinding lease of %s",
+           ifp->name, inet_ntoa(state->lease.addr));
        state->xid = dhcp_xid(ifp);
        state->lease.server.s_addr = 0;
        eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
 
        /* Need to add this before dhcp_expire and friends. */
-       if (!ifo->fallback && ifo->reboot && ifo->options & DHCPCD_IPV4LL &&
+       if (!ifo->fallback && ifo->options & DHCPCD_IPV4LL &&
            !IN_LINKLOCAL(htonl(state->addr.s_addr)))
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    ifo->reboot, ipv4ll_start, ifp);
 
-       if (ifo->fallback)
-               eloop_timeout_add_sec(ifp->ctx->eloop,
-                   ifo->reboot, dhcp_fallback, ifp);
-       else if (ifo->options & DHCPCD_LASTLEASE && state->lease.frominfo)
+       if (ifo->options & DHCPCD_LASTLEASE && state->lease.frominfo)
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    ifo->reboot, dhcp_timeout, ifp);
-       else if (!(ifo->options & DHCPCD_INFORM &&
-           ifp->ctx->options & (DHCPCD_MASTER | DHCPCD_DAEMONISED)))
+       else if (!(ifo->options & DHCPCD_INFORM))
                eloop_timeout_add_sec(ifp->ctx->eloop,
                    ifo->reboot, dhcp_expire, ifp);
-       /* Don't bother ARP checking as the server could NAK us first. */
-       if (ifo->options & DHCPCD_INFORM)
-               dhcp_inform(ifp);
-       else {
-               /* Don't call dhcp_request as that would change the state */
-               send_request(ifp);
-       }
+
+       /* Don't bother ARP checking as the server could NAK us first.
+        * Don't call dhcp_request as that would change the state */
+       send_request(ifp);
 }
 
 void
@@ -2525,6 +2505,8 @@
                            iface->name, msg);
                        free(msg);
                }
+               if (state->state == DHS_INFORM) /* INFORM should not be NAKed */
+                       return;
                if (!(iface->ctx->options & DHCPCD_TEST)) {
                        dhcp_drop(iface, "NAK");
                        unlink(state->leasefile);
diff -r 497a4f664010 -r 91982d644f48 external/bsd/dhcpcd/dist/dhcp6.c
--- a/external/bsd/dhcpcd/dist/dhcp6.c  Wed Dec 17 16:53:43 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp6.c  Wed Dec 17 20:50:08 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.7 2014/11/26 13:43:06 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.8 2014/12/17 20:50:08 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1698,7 +1698,7 @@
 
 static int
 dhcp6_findna(struct interface *ifp, uint16_t ot, const uint8_t *iaid,
-    const uint8_t *d, size_t l)
+    const uint8_t *d, size_t l, const struct timeval *acquired)
 {
        struct dhcp6_state *state;
        const struct dhcp6_option *o;
@@ -1760,6 +1760,7 @@
                                a->flags |= IPV6_AF_ONLINK | IPV6_AF_NEW;
                        a->flags &= ~IPV6_AF_STALE;
                }
+               a->acquired = *acquired;
                a->prefix_pltime = ntohl(iap->pltime);
                u32 = ntohl(iap->vltime);
                if (a->prefix_vltime != u32) {
@@ -1777,7 +1778,7 @@
 
 static int
 dhcp6_findpd(struct interface *ifp, const uint8_t *iaid,
-    const uint8_t *d, size_t l)
+    const uint8_t *d, size_t l, const struct timeval *acquired)
 {
        struct dhcp6_state *state;
        const struct dhcp6_option *o, *ex;
@@ -1838,6 +1839,7 @@
                                a->flags |= IPV6_AF_NEW;
                }
 
+               a->acquired = *acquired;
                a->prefix_pltime = ntohl(pdp->pltime);
                a->prefix_vltime = ntohl(pdp->vltime);
 
@@ -1901,7 +1903,7 @@
 
 static int
 dhcp6_findia(struct interface *ifp, const struct dhcp6_message *m, size_t l,
-    const char *sfrom)
+    const char *sfrom, const struct timeval *acquired)
 {
        struct dhcp6_state *state;
        const struct if_options *ifo;
@@ -1995,7 +1997,7 @@
                }
                if (code == D6_OPTION_IA_PD) {
                        if (!(ifo->options & DHCPCD_NOPFXDLG) &&
-                           dhcp6_findpd(ifp, iaid, p, ol) == 0)
+                           dhcp6_findpd(ifp, iaid, p, ol, acquired) == 0)
                        {
                                syslog(LOG_WARNING,
                                    "%s: %s: DHCPv6 REPLY missing Prefix",
@@ -2003,7 +2005,8 @@
                                continue;
                        }
                } else if (!(ifo->options & DHCPCD_PFXDLGONLY)) {
-                       if (dhcp6_findna(ifp, code, iaid, p, ol) == 0) {
+                       if (dhcp6_findna(ifp, code, iaid, p, ol, acquired) == 0)
+                       {
                                syslog(LOG_WARNING,
                                    "%s: %s: DHCPv6 REPLY missing IA Address",
                                    ifp->name, sfrom);
@@ -2049,10 +2052,11 @@
 static int
 dhcp6_validatelease(struct interface *ifp,
     const struct dhcp6_message *m, size_t len,
-    const char *sfrom)
+    const char *sfrom, const struct timeval *acquired)
 {
        struct dhcp6_state *state;
        int nia;
+       struct timeval aq;
 
        if (len <= sizeof(*m)) {
                syslog(LOG_ERR, "%s: DHCPv6 lease truncated", ifp->name);
@@ -2065,7 +2069,11 @@
 
        state->renew = state->rebind = state->expire = 0;
        state->lowpl = ND6_INFINITE_LIFETIME;
-       nia = dhcp6_findia(ifp, m, len, sfrom);
+       if (!acquired) {
+               get_monotonic(&aq);
+               acquired = &aq;
+       }
+       nia = dhcp6_findia(ifp, m, len, sfrom, acquired);
        if (nia == 0) {
                syslog(LOG_ERR, "%s: no useable IA found in lease",
                    ifp->name);
@@ -2104,6 +2112,7 @@
        ssize_t bytes;
        struct timeval now;
        const struct dhcp6_option *o;
+       struct timeval acquired;
 
        state = D6_STATE(ifp);
        if (stat(state->leasefile, &st) == -1) {
@@ -2137,15 +2146,19 @@
                goto ex;
        }
 
+       gettimeofday(&now, NULL);
+       get_monotonic(&acquired);
+       acquired.tv_sec -= now.tv_sec - st.st_mtime;
+
        /* Check to see if the lease is still valid */
-       fd = dhcp6_validatelease(ifp, state->new, state->new_len, NULL);
+       fd = dhcp6_validatelease(ifp, state->new, state->new_len, NULL,
+           &acquired);
        if (fd == -1)
                goto ex;
 
        if (!(ifp->ctx->options & DHCPCD_DUMPLEASE) &&
            state->expire != ND6_INFINITE_LIFETIME)
        {
-               gettimeofday(&now, NULL);
                if ((time_t)state->expire < now.tv_sec - st.st_mtime) {
                        syslog(LOG_DEBUG,"%s: discarding expired lease",
                            ifp->name);
@@ -2274,6 +2287,7 @@
        a->dadcallback = dhcp6_dadcallback;
        a->delegating_iface = ifs;
        memcpy(&a->iaid, &prefix->iaid, sizeof(a->iaid));
+       a->acquired = prefix->acquired;
        a->prefix_pltime = prefix->prefix_pltime;
        a->prefix_vltime = prefix->prefix_vltime;
        a->prefix = addr;
@@ -2726,7 +2740,8 @@
                        if (error == 1)
                                goto recv;
                        if (error == -1 ||
-                           dhcp6_validatelease(ifp, r, len, ctx->sfrom) == -1)
+                           dhcp6_validatelease(ifp, r, len,
+                           ctx->sfrom, NULL) == -1)
                        {
                                dhcp6_startdiscover(ifp);
                                return;
@@ -2742,7 +2757,9 @@
                case DH6S_REQUEST: /* FALLTHROUGH */
                case DH6S_RENEW: /* FALLTHROUGH */
                case DH6S_REBIND:
-                       if (dhcp6_validatelease(ifp, r, len, ctx->sfrom) == -1){
+                       if (dhcp6_validatelease(ifp, r, len,
+                           ctx->sfrom, NULL) == -1)
+                       {
                                /* PD doesn't use CONFIRM, so REBIND could
                                 * throw up an invalid prefix if we
                                 * changed link */



Home | Main Index | Thread Index | Old Index