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/f2ab70e345c7
branches:  trunk
changeset: 330568:f2ab70e345c7
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Jul 14 11:49:48 2014 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/dhcp.c           |   92 ++++++---
 external/bsd/dhcpcd/dist/dhcpcd.8.in      |   29 ++-
 external/bsd/dhcpcd/dist/dhcpcd.c         |  273 +++++++++++++++++++----------
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in |   34 ++-
 external/bsd/dhcpcd/dist/if-bsd.c         |   71 +-------
 external/bsd/dhcpcd/dist/if-options.c     |  140 ++++++++++----
 external/bsd/dhcpcd/dist/ipv6nd.c         |   31 +--
 external/bsd/dhcpcd/dist/script.c         |   27 ++-
 8 files changed, 409 insertions(+), 288 deletions(-)

diffs (truncated from 1430 to 300 lines):

diff -r 96981a67cc8c -r f2ab70e345c7 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Mon Jul 14 11:45:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Mon Jul 14 11:49:48 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.13 2014/06/14 20:55:37 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.14 2014/07/14 11:49:48 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -128,16 +128,24 @@
 static int dhcp_open(struct interface *);
 
 void
-dhcp_printoptions(const struct dhcpcd_ctx *ctx)
+dhcp_printoptions(const struct dhcpcd_ctx *ctx,
+    const struct dhcp_opt *opts, size_t opts_len)
 {
        const char * const *p;
-       size_t i;
-       const struct dhcp_opt *opt;
+       size_t i, j;
+       const struct dhcp_opt *opt, *opt2;
 
        for (p = dhcp_params; *p; p++)
                printf("    %s\n", *p);
 
-       for (i = 0, opt = ctx->dhcp_opts; i < ctx->dhcp_opts_len; i++, opt++)
+       for (i = 0, opt = ctx->dhcp_opts; i < ctx->dhcp_opts_len; i++, opt++) {
+               for (j = 0, opt2 = opts; j < opts_len; j++, opt2++)
+                       if (opt->option == opt2->option)
+                               break;
+               if (j == opts_len)
+                       printf("%03d %s\n", opt->option, opt->var);
+       }
+       for (i = 0, opt = opts; i < opts_len; i++, opt++)
                printf("%03d %s\n", opt->option, opt->var);
 }
 
@@ -289,7 +297,7 @@
                        errno = EINVAL;
                        return -1;
                }
-               ocets = (cidr + 7) / 8;
+               ocets = (cidr + 7) / NBBY;
                if (!out) {
                        p += 4 + ocets;
                        bytes += ((4 * 4) * 2) + 4;
@@ -360,7 +368,7 @@
                }
                TAILQ_INSERT_TAIL(routes, rt, next);
 
-               ocets = (cidr + 7) / 8;
+               ocets = (cidr + 7) / NBBY;
                /* If we have ocets then we have a destination and netmask */
                if (ocets > 0) {
                        memcpy(&rt->dest.s_addr, p, ocets);
@@ -946,6 +954,30 @@
                                goto toobig;
                        *p++ = (uint8_t)opt->option;
                }
+               for (i = 0, opt = ifo->dhcp_override;
+                   i < ifo->dhcp_override_len;
+                   i++, opt++)
+               {
+                       /* Check if added above */
+                       for (lp = n_params + 1; lp < p; lp++)
+                               if (*lp == (uint8_t)opt->option)
+                                       break;
+                       if (lp < p)
+                               continue;
+                       if (!(opt->type & REQUEST ||
+                               has_option_mask(ifo->requestmask, opt->option)))
+                               continue;
+                       if (opt->type & NOREQ)
+                               continue;
+                       if (type == DHCP_INFORM &&
+                           (opt->option == DHO_RENEWALTIME ||
+                               opt->option == DHO_REBINDTIME))
+                               continue;
+                       len = (size_t)((p - m) + 2);
+                       if (len > sizeof(*dhcp))
+                               goto toobig;
+                       *p++ = (uint8_t)opt->option;
+               }
                *n_params = (uint8_t)(p - n_params - 1);
        }
 
@@ -2736,40 +2768,23 @@
 }
 
 int
-dhcp_dump(struct dhcpcd_ctx *ctx, const char *ifname)
+dhcp_dump(struct interface *ifp)
 {
-       struct interface *ifp;
        struct dhcp_state *state;
 
-       if (ctx->ifaces == NULL) {
-               ctx->ifaces = malloc(sizeof(*ctx->ifaces));
-               if (ctx->ifaces == NULL)
-                       return -1;
-               TAILQ_INIT(ctx->ifaces);
-       }
-       state = NULL;
-       ifp = calloc(1, sizeof(*ifp));
-       if (ifp == NULL)
-               goto eexit;
-       ifp->ctx = ctx;
-       TAILQ_INSERT_HEAD(ctx->ifaces, ifp, next);
        ifp->if_data[IF_DATA_DHCP] = state = calloc(1, sizeof(*state));
        if (state == NULL)
                goto eexit;
-       ifp->options = calloc(1, sizeof(*ifp->options));
-       if (ifp->options == NULL)
-               goto eexit;
-       strlcpy(ifp->name, ifname, sizeof(ifp->name));
        snprintf(state->leasefile, sizeof(state->leasefile),
            LEASEFILE, ifp->name);
        state->new = read_lease(ifp);
        if (state->new == NULL && errno == ENOENT) {
-               strlcpy(state->leasefile, ifname, sizeof(state->leasefile));
+               strlcpy(state->leasefile, ifp->name, sizeof(state->leasefile));
                state->new = read_lease(ifp);
        }
        if (state->new == NULL) {
                if (errno == ENOENT)
-                       syslog(LOG_ERR, "%s: no lease to dump", ifname);
+                       syslog(LOG_ERR, "%s: no lease to dump", ifp->name);
                return -1;
        }
        state->reason = "DUMP";
@@ -3018,13 +3033,22 @@
        if (!(ifp->options->options & DHCPCD_IPV4))
                return;
 
-       tv.tv_sec = DHCP_MIN_DELAY;
-       tv.tv_usec = (suseconds_t)arc4random_uniform(
-           (DHCP_MAX_DELAY - DHCP_MIN_DELAY) * 1000000);
-       timernorm(&tv);
-       syslog(LOG_DEBUG,
-           "%s: delaying DHCP for %0.1f seconds",
-           ifp->name, timeval_to_double(&tv));
+       /* No point in delaying a static configuration */
+       if (ifp->options->options & DHCPCD_STATIC &&
+           !(ifp->options->options & DHCPCD_INFORM))
+       {
+               tv.tv_sec = 0;
+               tv.tv_usec = 0;
+       } else {
+               tv.tv_sec = DHCP_MIN_DELAY;
+               tv.tv_usec = (suseconds_t)arc4random_uniform(
+                   (DHCP_MAX_DELAY - DHCP_MIN_DELAY) * 1000000);
+               timernorm(&tv);
+               syslog(LOG_DEBUG,
+                   "%s: delaying DHCP for %0.1f seconds",
+                   ifp->name, timeval_to_double(&tv));
+       }
+
        eloop_timeout_add_tv(ifp->ctx->eloop, &tv, dhcp_start1, ifp);
 }
 
diff -r 96981a67cc8c -r f2ab70e345c7 external/bsd/dhcpcd/dist/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/dhcpcd.8.in      Mon Jul 14 11:45:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.8.in      Mon Jul 14 11:49:48 2014 +0000
@@ -1,4 +1,4 @@
-.\"     $NetBSD: dhcpcd.8.in,v 1.28 2014/06/14 20:55:37 roy Exp $
+.\"     $NetBSD: dhcpcd.8.in,v 1.29 2014/07/14 11:49:48 roy Exp $
 .\" Copyright (c) 2006-2014 Roy Marples
 .\" All rights reserved
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd June 2, 2014
+.Dd July 7, 2014
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -76,7 +76,7 @@
 .Sh DESCRIPTION
 .Nm
 is an implementation of the DHCP client specified in
-.%R RFC 2131 .
+.Li RFC 2131 .
 .Nm
 gets the host information
 .Po
@@ -104,17 +104,17 @@
 .Pp
 .Nm
 is also an implementation of the BOOTP client specified in
-.%R RFC 951 .
+.Li RFC 951 .
 .Pp
 .Nm
 is also an implementation of the IPv6 Router Solicitor as specified in
-.%R RFC 4861
+.Li RFC 4861
 and
-.%R RFC 6106 .
+.Li RFC 6106 .
 .Pp
 .Nm
 is also an implemenation of the DHCPv6 client as specified in
-.%R RFC 3315 .
+.Li RFC 3315 .
 By default,
 .Nm
 only starts DHCPv6 when instructed to do so by an IPV6 Router Advertisement.
@@ -212,7 +212,7 @@
 .Pa @SCRIPT@ .
 .It Fl D , Fl Fl duid
 Generate an
-.%R RFC 4361
+.Li RFC 4361
 compliant clientid.
 This requires persistent storage and not all DHCP servers work with it so it
 is not enabled by default.
@@ -260,7 +260,7 @@
 itself never does any DNS updates.
 .Nm
 encodes the FQDN hostname as specified in
-.%R RFC1035 .
+.Li RFC1035 .
 .It Fl f , Fl Fl config Ar file
 Specify a config to load instead of
 .Pa @SYSCONFDIR@/dhcpcd.conf .
@@ -553,6 +553,14 @@
 to stdout.
 .Ar interface
 could also be a path to a DHCP wire formatted file.
+Use the
+.Fl 4
+or
+.Fl 6
+flags to specify an address family.
+Pass a 2nd
+.Fl U, Fl Fl dumplease option to dump a secondary lease, such as
+DHCPv6 Prefix Delegation when not being mixed with another IA type.
 .It Fl V, Fl Fl variables
 Display a list of option codes and the associated variable for use in
 .Xr dhcpcd-run-hooks 8 .
@@ -672,7 +680,8 @@
 RFC\ 3004, RFC\ 3118, RFC\ 3203, RFC\ 3315, RFC\ 3361, RFC\ 3633, RFC\ 3396,
 RFC\ 3397, RFC\ 3442, RFC\ 3495, RFC\ 3925, RFC\ 3927, RFC\ 4039, RFC\ 4075,
 RFC\ 4242, RFC\ 4361, RFC\ 4390, RFC\ 4702, RFC\ 4074, RFC\ 4861, RFC\ 4833,
-RFC\ 5227, RFC\ 5942, RFC\ 5969, RFC\ 6106, RFC\ 6334, RFC\ 6704, RFC\ 7217.
+RFC\ 5227, RFC\ 5942, RFC\ 5969, RFC\ 6106, RFC\ 6334, RFC\ 6603, RFC\ 6704,
+RFC\ 7217.
 .Sh AUTHORS
 .An Roy Marples Aq Mt roy%marples.name@localhost
 .Sh BUGS
diff -r 96981a67cc8c -r f2ab70e345c7 external/bsd/dhcpcd/dist/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/dhcpcd.c Mon Jul 14 11:45:02 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcpcd.c Mon Jul 14 11:49:48 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.5 2014/06/14 20:55:37 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.6 2014/07/14 11:49:48 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -142,14 +142,14 @@
        struct dhcp_opt *opt;
 
        if (ctx->ifac) {
-               for (ctx->ifac--; ctx->ifac >= 0; ctx->ifac--)
-                       free(ctx->ifav[ctx->ifac]);
+               for (; ctx->ifac > 0; ctx->ifac--)
+                       free(ctx->ifav[ctx->ifac - 1]);
                free(ctx->ifav);
                ctx->ifav = NULL;
        }
        if (ctx->ifdc) {
-               for (ctx->ifdc--; ctx->ifdc >= 0; ctx->ifdc--)
-                       free(ctx->ifdv[ctx->ifdc]);
+               for (; ctx->ifdc > 0; ctx->ifdc--)
+                       free(ctx->ifdv[ctx->ifdc - 1]);
                free(ctx->ifdv);
                ctx->ifdv = NULL;
        }
@@ -326,6 +326,9 @@
 {
        struct if_options *ifo = ifp->options;
        int ra_global, ra_iface;
+#ifdef INET6
+       size_t i;
+#endif
 
        /* Do any platform specific configuration */
        if_conf(ifp);
@@ -342,7 +345,7 @@
                ifo->options &= ~(DHCPCD_ARP | DHCPCD_IPV4LL);
        if (!(ifp->flags & (IFF_POINTOPOINT | IFF_LOOPBACK | IFF_MULTICAST)))
                ifo->options &= ~DHCPCD_IPV6RS;
-       if (ifo->options & DHCPCD_LINK && if_carrier(ifp) == LINK_UNKNOWN)
+       if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_UNKNOWN)
                ifo->options &= ~DHCPCD_LINK;



Home | Main Index | Thread Index | Old Index