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



details:   https://anonhg.NetBSD.org/src/rev/20d099339eac
branches:  trunk
changeset: 790124:20d099339eac
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Sep 20 10:51:29 2013 +0000

description:
Import dhcpcd-6.1.0 with the following changes:
* Fixed a segfault when configuring a static route in dhcpcd.conf
* Merged IPv6 ND and RA codebases
* Persistent configuration is now a default option in dhcpcd.conf
* Store configured IPv4 addresses against the interface so we only add
  them if actually missing to avoid RTM_DELADDR/NEWADDR loops on some OS's
* waitip now supports waiting for any, IPv4, IPv6 or both protocols
* DHCPv6 addresses are added with a /128 prefix and should not attempt to
  associate with any existing prefix or make one up as per RFC 5942
* Fix initial carrier status
* Fix requesting >1 DHCPv6 address

Fixes PR bin/48140

diffstat:

 external/bsd/dhcpcd/dist/config.h                    |     3 +-
 external/bsd/dhcpcd/dist/defs.h                      |     7 +-
 external/bsd/dhcpcd/dist/dev.h                       |    61 +
 external/bsd/dhcpcd/dist/dhcp.h                      |     9 +-
 external/bsd/dhcpcd/dist/dhcp6.c                     |    91 +-
 external/bsd/dhcpcd/dist/dhcp6.h                     |     4 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf |     4 +-
 external/bsd/dhcpcd/dist/dhcpcd.c                    |    56 +-
 external/bsd/dhcpcd/dist/dhcpcd.h                    |    13 +-
 external/bsd/dhcpcd/dist/eloop.h                     |     6 +-
 external/bsd/dhcpcd/dist/if-bsd.c                    |    10 +-
 external/bsd/dhcpcd/dist/if-options.c                |    50 +-
 external/bsd/dhcpcd/dist/if-options.h                |     9 +-
 external/bsd/dhcpcd/dist/ipv4.c                      |   262 +-
 external/bsd/dhcpcd/dist/ipv4.h                      |    33 +-
 external/bsd/dhcpcd/dist/ipv6.c                      |    24 +-
 external/bsd/dhcpcd/dist/ipv6.h                      |     5 +-
 external/bsd/dhcpcd/dist/ipv6nd.c                    |  1806 ++++++++++++++++++
 external/bsd/dhcpcd/dist/ipv6nd.h                    |   117 +
 external/bsd/dhcpcd/dist/platform-bsd.c              |     3 +-
 external/bsd/dhcpcd/dist/platform.h                  |     4 +-
 external/bsd/dhcpcd/dist/script.c                    |    14 +-
 22 files changed, 2367 insertions(+), 224 deletions(-)

diffs (truncated from 3415 to 300 lines):

diff -r 1145114b2d38 -r 20d099339eac external/bsd/dhcpcd/dist/config.h
--- a/external/bsd/dhcpcd/dist/config.h Fri Sep 20 09:05:53 2013 +0000
+++ b/external/bsd/dhcpcd/dist/config.h Fri Sep 20 10:51:29 2013 +0000
@@ -1,8 +1,9 @@
-/* $NetBSD: config.h,v 1.1.1.24 2013/06/21 19:33:08 roy Exp $ */
+/* $NetBSD: config.h,v 1.1.1.25 2013/09/20 10:51:30 roy Exp $ */
 
 /* netbsd */
 #define SYSCONFDIR     "/etc"
 #define SBINDIR                "/sbin"
+#define LIBDIR         "/lib"
 #define LIBEXECDIR     "/libexec"
 #define DBDIR          "/var/db"
 #define RUNDIR         "/var/run"
diff -r 1145114b2d38 -r 20d099339eac external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Fri Sep 20 09:05:53 2013 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Fri Sep 20 10:51:29 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.1.1.31 2013/08/03 10:30:01 roy Exp $ */
+/* $NetBSD: defs.h,v 1.1.1.32 2013/09/20 10:51:30 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,13 +30,16 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.0.5"
+#define VERSION                        "6.1.0"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
 #endif
 #ifndef SCRIPT
 # define SCRIPT                        LIBEXECDIR "/" PACKAGE "-run-hooks"
+#ifndef DEVDIR
+# define DEVDIR                        LIBDIR "/" PACKAGE "/dev"
+#endif
 #endif
 #ifndef DUID
 # define DUID                  SYSCONFDIR "/" PACKAGE ".duid"
diff -r 1145114b2d38 -r 20d099339eac external/bsd/dhcpcd/dist/dev.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/dev.h    Fri Sep 20 10:51:29 2013 +0000
@@ -0,0 +1,61 @@
+/* $NetBSD: dev.h,v 1.1.1.1 2013/09/20 10:51:30 roy Exp $ */
+
+/*
+ * dhcpcd - DHCP client daemon
+ * Copyright (c) 2006-2013 Roy Marples <roy%marples.name@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef DEV_H
+#define DEV_H
+
+// dev plugin setup
+struct dev {
+       const char *name;
+       int (*initialized)(const char *);
+       int (*listening)(void);
+       int (*handle_device)(void);
+       int (*start)(void);
+       void (*stop)(void);
+};
+
+struct dev_dhcpcd {
+       void (*handle_interface)(int, const char *);
+};
+
+int dev_init(struct dev *, const struct dev_dhcpcd *);
+
+// hooks for dhcpcd
+#ifdef PLUGIN_DEV
+int dev_initialized(const char *);
+int dev_listening(void);
+int dev_start(const char *);
+void dev_stop(void);
+#else
+#define dev_initialized(a) 1
+#define dev_listening() 0
+#define dev_start(a) {}
+#define dev_stop() {}
+#endif
+
+#endif
diff -r 1145114b2d38 -r 20d099339eac external/bsd/dhcpcd/dist/dhcp.h
--- a/external/bsd/dhcpcd/dist/dhcp.h   Fri Sep 20 09:05:53 2013 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.h   Fri Sep 20 10:51:29 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp.h,v 1.1.1.14 2013/06/21 19:33:08 roy Exp $ */
+/* $NetBSD: dhcp.h,v 1.1.1.15 2013/09/20 10:51:30 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -261,8 +261,8 @@
     const struct interface *);
 
 uint32_t dhcp_xid(const struct interface *);
-struct dhcp_message *dhcp_message_new(struct in_addr *addr,
-    struct in_addr *mask);
+struct dhcp_message *dhcp_message_new(const struct in_addr *addr,
+    const struct in_addr *mask);
 int dhcp_message_add_addr(struct dhcp_message *, uint8_t, struct in_addr);
 ssize_t make_message(struct dhcp_message **, const struct interface *,
     uint8_t);
@@ -272,6 +272,9 @@
 struct dhcp_message *read_lease(const struct interface *);
 void get_lease(struct dhcp_lease *, const struct dhcp_message *);
 
+void dhcp_handleifa(int, struct interface *,
+    const struct in_addr *, const struct in_addr *, const struct in_addr *);
+
 void dhcp_drop(struct interface *, const char *);
 void dhcp_start(struct interface *);
 void dhcp_stop(struct interface *);
diff -r 1145114b2d38 -r 20d099339eac external/bsd/dhcpcd/dist/dhcp6.c
--- a/external/bsd/dhcpcd/dist/dhcp6.c  Fri Sep 20 09:05:53 2013 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp6.c  Fri Sep 20 10:51:29 2013 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.1.1.3 2013/07/29 20:35:33 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.1.1.4 2013/09/20 10:51:30 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -56,8 +56,7 @@
 #include "dhcp6.h"
 #include "duid.h"
 #include "eloop.h"
-#include "ipv6ns.h"
-#include "ipv6rs.h"
+#include "ipv6nd.h"
 #include "platform.h"
 #include "script.h"
 
@@ -1215,7 +1214,7 @@
 }
 
 static struct ipv6_addr *
-dhcp6_findaddr(const struct in6_addr *a, struct interface *ifp)
+dhcp6_findaddr(struct interface *ifp, const struct in6_addr *addr)
 {
        const struct dhcp6_state *state;
        struct ipv6_addr *ap;
@@ -1223,7 +1222,12 @@
        state = D6_CSTATE(ifp);
        if (state) {
                TAILQ_FOREACH(ap, &state->addrs, next) {
-                       if (IN6_ARE_ADDR_EQUAL(&ap->addr, a))
+                       if (addr == NULL) {
+                               if ((ap->flags &
+                                   (IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED)) ==
+                                   (IPV6_AF_ADDED | IPV6_AF_DADCOMPLETED))
+                                       return ap;
+                       } else if (IN6_ARE_ADDR_EQUAL(&ap->addr, addr))
                                return ap;
                }
        }
@@ -1231,12 +1235,12 @@
 }
 
 int
-dhcp6_addrexists(const struct ipv6_addr *a)
+dhcp6_addrexists(const struct ipv6_addr *addr)
 {
        struct interface *ifp;
 
        TAILQ_FOREACH(ifp, ifaces, next) {
-               if (dhcp6_findaddr(&a->addr, ifp))
+               if (dhcp6_findaddr(ifp, addr == NULL ? NULL : &addr->addr))
                        return 1;
        }
        return 0;
@@ -1251,7 +1255,7 @@
        int wascompleted;
 
        wascompleted = (ap->flags & IPV6_AF_DADCOMPLETED);
-       ipv6ns_cancelprobeaddr(ap);
+       ipv6nd_cancelprobeaddr(ap);
        ap->flags |= IPV6_AF_DADCOMPLETED;
        if (ap->flags & IPV6_AF_DUPLICATED)
                /* XXX FIXME
@@ -1294,7 +1298,6 @@
        const uint8_t *p;
        struct in6_addr in6;
        struct ipv6_addr *a;
-       const struct ipv6_addr *pa;
        char iabuf[INET6_ADDRSTRLEN];
        const char *ia;
        int i;
@@ -1317,7 +1320,7 @@
                p = D6_COPTION_DATA(o);
                memcpy(&in6.s6_addr, p, sizeof(in6.s6_addr));
                p += sizeof(in6.s6_addr);
-               a = dhcp6_findaddr(&in6, ifp);
+               a = dhcp6_findaddr(ifp, &in6);
                if (a == NULL) {
                        a = calloc(1, sizeof(*a));
                        if (a == NULL) {
@@ -1331,18 +1334,18 @@
                        memcpy(&a->addr.s6_addr, &in6.s6_addr,
                            sizeof(in6.s6_addr));
                }
-               pa = ipv6rs_findprefix(a);
-               if (pa) {
-                       memcpy(&a->prefix, &pa->prefix,
-                           sizeof(a->prefix));
-                       a->prefix_len = pa->prefix_len;
-               } else {
-                       a->prefix_len = 64;
-                       if (ipv6_makeprefix(&a->prefix, &a->addr, 64) == -1) {
-                               syslog(LOG_ERR, "%s: %m", __func__);
-                               free(a);
-                               continue;
-                       }
+               /*
+                * RFC 5942 Section 5
+                * We cannot assume any prefix length, nor tie the address
+                * to an existing one as it could expire before the address.
+                * As such we just give it a 128 prefix.
+                */
+               a->prefix_len = 128;
+               if (ipv6_makeprefix(&a->prefix, &a->addr, a->prefix_len) == -1)
+               {
+                       syslog(LOG_ERR, "%s: %m", __func__);
+                       free(a);
+                       continue;
                }
                memcpy(&u32, p, sizeof(u32));
                a->prefix_pltime = ntohl(u32);
@@ -1447,6 +1450,11 @@
        ifo = ifp->options;
        i = 0;
        state = D6_STATE(ifp);
+       if (ifo->ia_type != D6_OPTION_IA_PD) {
+               TAILQ_FOREACH(ap, &state->addrs, next) {
+                       ap->flags |= IPV6_AF_STALE;
+               }
+       }
        while ((o = dhcp6_findoption(ifo->ia_type, d, l))) {
                l -= ((const uint8_t *)o - d);
                d += ((const uint8_t *)o - d);
@@ -1499,26 +1507,25 @@
                                return -1;
                        }
                } else {
-                       TAILQ_FOREACH(ap, &state->addrs, next) {
-                               ap->flags |= IPV6_AF_STALE;
-                       }
                        if (dhcp6_findna(ifp, iaid, p, ol) == 0) {
                                syslog(LOG_ERR,
                                    "%s: %s: DHCPv6 REPLY missing IA Address",
                                    ifp->name, sfrom);
                                return -1;
                        }
-                       TAILQ_FOREACH_SAFE(ap, &state->addrs, next, nap) {
-                               if (ap->flags & IPV6_AF_STALE) {
-                                       TAILQ_REMOVE(&state->addrs, ap, next);
-                                       if (ap->dadcallback)
-                                               eloop_q_timeout_delete(0, NULL,
-                                                   ap->dadcallback);
-                                       free(ap);
-                               }
+               }
+               i++;
+       }
+       if (ifo->ia_type != D6_OPTION_IA_PD) {
+               TAILQ_FOREACH_SAFE(ap, &state->addrs, next, nap) {
+                       if (ap->flags & IPV6_AF_STALE) {
+                               TAILQ_REMOVE(&state->addrs, ap, next);
+                               if (ap->dadcallback)
+                                       eloop_q_timeout_delete(0, NULL,
+                                           ap->dadcallback);
+                               free(ap);
                        }
                }
-               i++;
        }
        return i;



Home | Main Index | Thread Index | Old Index