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-6.4.1 with the follow...



details:   https://anonhg.NetBSD.org/src/rev/96981a67cc8c
branches:  trunk
changeset: 330567:96981a67cc8c
user:      roy <roy%NetBSD.org@localhost>
date:      Mon Jul 14 11:45:02 2014 +0000

description:
Import dhcpcd-6.4.1 with the following changes:

  *  If just given a domain and no search list, make the search list the domain
  *  Skip arpping directives if we have a profile but not parsing one
  *  Allow the request of a DHCPv6 address or prefix, a prefix length must be
     specified
  *  Add the ability to dump DHCPv6 leases
  *  Improve startup with regards to carrier checking and adding a link-local
     IPv6 address
  *  Start the correct interface reference for added devices
  *  Support
     http://datatracker.ietf.org/doc/draft-ietf-dhc-dhcpv6-stateful-issues-06
     via the ia_pd_mix option
  *  Fix link handling where kernel reported flags in LINK_UP may not be
     valid when we actually process them
  *  Fix defining new options in dhcpcd.conf and requesting them
  *  Fix a potential segfault when reloading configurations
  *  Print user defined options via -V
  *  Add support for RFC6603, Prefix Exclude option
  *  When requesting a IA_PD and another IA type, create a psuedo interface
     to handle the IA_PD
  *  Handle truncated DHCPv6 saved leases

diffstat:

 external/bsd/dhcpcd/dist/control.c                   |    33 +-
 external/bsd/dhcpcd/dist/defs.h                      |     6 +-
 external/bsd/dhcpcd/dist/dhcp-common.c               |    49 +-
 external/bsd/dhcpcd/dist/dhcp-common.h               |     3 +-
 external/bsd/dhcpcd/dist/dhcp.h                      |    10 +-
 external/bsd/dhcpcd/dist/dhcp6.c                     |  1067 ++++++++++++-----
 external/bsd/dhcpcd/dist/dhcp6.h                     |    11 +-
 external/bsd/dhcpcd/dist/dhcpcd-definitions.conf     |     8 +-
 external/bsd/dhcpcd/dist/dhcpcd-embedded.c           |     6 +-
 external/bsd/dhcpcd/dist/dhcpcd-embedded.h           |     4 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/02-dump        |     8 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf |    27 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in         |     4 +-
 external/bsd/dhcpcd/dist/dhcpcd.h                    |     6 +-
 external/bsd/dhcpcd/dist/if-options.h                |    25 +-
 external/bsd/dhcpcd/dist/if.c                        |    14 +-
 external/bsd/dhcpcd/dist/if.h                        |     7 +-
 external/bsd/dhcpcd/dist/ipv4.c                      |     6 +-
 external/bsd/dhcpcd/dist/ipv6.c                      |   129 +-
 external/bsd/dhcpcd/dist/ipv6.h                      |    14 +-
 20 files changed, 954 insertions(+), 483 deletions(-)

diffs (truncated from 2533 to 300 lines):

diff -r e44004e12221 -r 96981a67cc8c external/bsd/dhcpcd/dist/control.c
--- a/external/bsd/dhcpcd/dist/control.c        Mon Jul 14 11:36:39 2014 +0000
+++ b/external/bsd/dhcpcd/dist/control.c        Mon Jul 14 11:45:02 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: control.c,v 1.1.1.6 2014/06/14 20:51:03 roy Exp $");
+ __RCSID("$NetBSD: control.c,v 1.1.1.7 2014/07/14 11:45:02 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -55,8 +55,9 @@
 control_handle_data(void *arg)
 {
        struct fd_list *l = arg, *lp, *last;
-       char buffer[1024], *e, *p, *argvp[255], **ap;
+       char buffer[1024], *e, *p, *argvp[255], **ap, *a;
        ssize_t bytes;
+       size_t len;
        int argc;
 
        bytes = read(l->fd, buffer, sizeof(buffer) - 1);
@@ -82,14 +83,28 @@
        buffer[bytes] = '\0';
        p = buffer;
        e = buffer + bytes;
-       argc = 0;
-       ap = argvp;
-       while (p < e && (size_t)argc < sizeof(argvp)) {
-               argc++;
-               *ap++ = p;
-               p += strlen(p) + 1;
+
+       /* Each command is \n terminated
+        * Each argument is NULL separated */
+       while (p < e) {
+               argc = 0;
+               ap = argvp;
+               while (p < e) {
+                       argc++;
+                       if ((size_t)argc > sizeof(argvp)) {
+                               errno = ENOBUFS;
+                               return;
+                       }
+                       a = *ap++ = p;
+                       len = strlen(p);
+                       p += len + 1;
+                       if (a[len - 1] == '\n') {
+                               a[len - 1] = '\0';
+                               break;
+                       }
+               }
+               dhcpcd_handleargs(l->ctx, l, argc, argvp);
        }
-       dhcpcd_handleargs(l->ctx, l, argc, argvp);
 }
 
 static void
diff -r e44004e12221 -r 96981a67cc8c external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Mon Jul 14 11:36:39 2014 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Mon Jul 14 11:45:02 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.1.1.38 2014/06/14 20:51:06 roy Exp $ */
+/* $NetBSD: defs.h,v 1.1.1.39 2014/07/14 11:45:06 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.4.0"
+#define VERSION                        "6.4.1"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
@@ -51,7 +51,7 @@
 # define LEASEFILE             DBDIR "/" PACKAGE "-%s.lease"
 #endif
 #ifndef LEASEFILE6
-# define LEASEFILE6            DBDIR "/" PACKAGE "-%s.lease6"
+# define LEASEFILE6            DBDIR "/" PACKAGE "-%s%s.lease6"
 #endif
 #ifndef PIDFILE
 # define PIDFILE               RUNDIR "/" PACKAGE "%s%s%s.pid"
diff -r e44004e12221 -r 96981a67cc8c external/bsd/dhcpcd/dist/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/dhcp-common.c    Mon Jul 14 11:36:39 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp-common.c    Mon Jul 14 11:45:02 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.6 2014/06/14 20:51:04 roy Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.7 2014/07/14 11:45:03 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -89,6 +89,7 @@
 
 int
 make_option_mask(const struct dhcp_opt *dopts, size_t dopts_len,
+    const struct dhcp_opt *odopts, size_t odopts_len,
     uint8_t *mask, const char *opts, int add)
 {
        char *token, *o, *p, *t;
@@ -97,14 +98,14 @@
        unsigned int n;
        size_t i;
 
-       o = p = strdup(opts);
        if (opts == NULL)
                return -1;
+       o = p = strdup(opts);
        while ((token = strsep(&p, ", "))) {
                if (*token == '\0')
                        continue;
-               for (i = 0, opt = dopts; i < dopts_len; i++, opt++) {
-                       match = 0;
+               match = 0;
+               for (i = 0, opt = odopts; i < odopts_len; i++, opt++) {
                        if (strcmp(opt->var, token) == 0)
                                match = 1;
                        else {
@@ -114,26 +115,40 @@
                                        if (opt->option == n)
                                                match = 1;
                        }
-                       if (match) {
-                               if (add == 2 && !(opt->type & ADDRIPV4)) {
-                                       free(o);
-                                       errno = EINVAL;
-                                       return -1;
+                       if (match)
+                               break;
+               }
+               if (match == 0) {
+                       for (i = 0, opt = dopts; i < dopts_len; i++, opt++) {
+                               if (strcmp(opt->var, token) == 0)
+                                       match = 1;
+                               else {
+                                       errno = 0;
+                                       n = (unsigned int)strtol(token, &t, 0);
+                                       if (errno == 0 && !*t)
+                                               if (opt->option == n)
+                                                       match = 1;
                                }
-                               if (add == 1 || add == 2)
-                                       add_option_mask(mask,
-                                           opt->option);
-                               else
-                                       del_option_mask(mask,
-                                           opt->option);
-                               break;
+                               if (match)
+                                       break;
                        }
                }
-               if (!opt->option) {
+               if (!match || !opt->option) {
                        free(o);
                        errno = ENOENT;
                        return -1;
                }
+               if (add == 2 && !(opt->type & ADDRIPV4)) {
+                       free(o);
+                       errno = EINVAL;
+                       return -1;
+               }
+               if (add == 1 || add == 2)
+                       add_option_mask(mask,
+                           opt->option);
+               else
+                       del_option_mask(mask,
+                           opt->option);
        }
        free(o);
        return 0;
diff -r e44004e12221 -r 96981a67cc8c external/bsd/dhcpcd/dist/dhcp-common.h
--- a/external/bsd/dhcpcd/dist/dhcp-common.h    Mon Jul 14 11:36:39 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp-common.h    Mon Jul 14 11:45:02 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp-common.h,v 1.1.1.4 2014/06/14 20:51:09 roy Exp $ */
+/* $NetBSD: dhcp-common.h,v 1.1.1.5 2014/07/14 11:45:06 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -90,6 +90,7 @@
 #define del_option_mask(var, val) (var[val >> 3] &= ~(1 << (val & 7)))
 #define has_option_mask(var, val) (var[val >>3] & (1 << (val & 7)))
 int make_option_mask(const struct dhcp_opt *, size_t,
+    const struct dhcp_opt *, size_t,
     uint8_t *, const char *, int);
 
 size_t encode_rfc1035(const char *src, uint8_t *dst);
diff -r e44004e12221 -r 96981a67cc8c external/bsd/dhcpcd/dist/dhcp.h
--- a/external/bsd/dhcpcd/dist/dhcp.h   Mon Jul 14 11:36:39 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.h   Mon Jul 14 11:45:02 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp.h,v 1.1.1.19 2014/06/14 20:51:09 roy Exp $ */
+/* $NetBSD: dhcp.h,v 1.1.1.20 2014/07/14 11:45:06 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -252,7 +252,8 @@
 ssize_t decode_rfc3442(char *, size_t, const uint8_t *p, size_t);
 ssize_t decode_rfc5969(char *, size_t, const uint8_t *p, size_t);
 
-void dhcp_printoptions(const struct dhcpcd_ctx *);
+void dhcp_printoptions(const struct dhcpcd_ctx *,
+    const struct dhcp_opt *, size_t);
 int get_option_addr(struct dhcpcd_ctx *,struct in_addr *,
     const struct dhcp_message *, uint8_t);
 #define is_bootp(i, m) ((m) &&                                         \
@@ -287,16 +288,15 @@
 void dhcp_reboot_newopts(struct interface *, unsigned long long);
 void dhcp_close(struct interface *);
 void dhcp_free(struct interface *);
-int dhcp_dump(struct dhcpcd_ctx *, const char *);
+int dhcp_dump(struct interface *);
 #else
-#define dhcp_printoptions
 #define dhcp_drop(a, b)
 #define dhcp_start(a) {}
 #define dhcp_reboot(a, b) b = b
 #define dhcp_reboot_newopts(a, b)
 #define dhcp_close(a)
 #define dhcp_free(a)
-#define dhcp_dump(a, b) -1
+#define dhcp_dump(a) -1
 #endif
 
 #endif
diff -r e44004e12221 -r 96981a67cc8c external/bsd/dhcpcd/dist/dhcp6.c
--- a/external/bsd/dhcpcd/dist/dhcp6.c  Mon Jul 14 11:36:39 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp6.c  Mon Jul 14 11:45:02 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.1.1.10 2014/06/14 20:51:05 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.1.1.11 2014/07/14 11:45:04 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -123,14 +123,36 @@
        "Use Multicast"
 };
 
+struct dhcp6_ia_addr {
+       struct in6_addr addr;
+       uint32_t pltime;
+       uint32_t vltime;
+} __packed;
+
+struct dhcp6_pd_addr {
+       uint32_t pltime;
+       uint32_t vltime;
+       uint8_t prefix_len;
+       struct in6_addr prefix;
+} __packed;
+
 void
-dhcp6_printoptions(const struct dhcpcd_ctx *ctx)
+dhcp6_printoptions(const struct dhcpcd_ctx *ctx,
+    const struct dhcp_opt *opts, size_t opts_len)
 {
-       size_t i;
-       const struct dhcp_opt *opt;
+       size_t i, j;
+       const struct dhcp_opt *opt, *opt2;
 
        for (i = 0, opt = ctx->dhcp6_opts;
            i < ctx->dhcp6_opts_len; i++, opt++)
+       {
+               for (j = 0, opt2 = opts; j < opts_len; j++, opt2++)
+                       if (opt2->option == opt->option)
+                               break;
+               if (j == opts_len)
+                       printf("%05d %s\n", opt->option, opt->var);
+       }
+       for (i = 0, opt = opts; i < opts_len; i++, opt++)
                printf("%05d %s\n", opt->option, opt->var);
 }
 
@@ -201,7 +223,7 @@
 
        code = htons(code);
        for (o = (const struct dhcp6_option *)d;
-           len > (ssize_t)sizeof(*o);
+           len >= sizeof(*o);
            o = D6_CNEXT_OPTION(o))
        {
                ol = sizeof(*o) + ntohs(o->len);
@@ -261,6 +283,10 @@
 dhcp6_getmoption(unsigned int code, const struct dhcp6_message *m, size_t len)
 {
 
+       if (len < sizeof(*m)) {
+               errno = EINVAL;
+               return NULL;
+       }
        len -= sizeof(*m);
        return dhcp6_findoption(code,
            (const uint8_t *)D6_CFIRST_OPTION(m), len);
@@ -307,24 +333,123 @@



Home | Main Index | Thread Index | Old Index