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



details:   https://anonhg.NetBSD.org/src/rev/9cbb46a62f1d
branches:  trunk
changeset: 327690:9cbb46a62f1d
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Mar 14 11:27:36 2014 +0000

description:
Import dhcpcd-6.3.2 with the following changes:

  * Improvements to autoconf build emulation
  * CARRIER/NOCARRIER are now run outside of the IPv4 runs
  * validate domains correctly which contain a - on non bash shells
  * don't remove IPv6 addresses from internal state when added as tentative
  * HUP now rebinds, ALRM now releases - the -x and -k flags work as
    they used to
  * Add -M, --master option to force dhcpcd into master mode even if one
    interface is specified on the command line
  * Fix a crash when receiving a reconfigure key
  * Dumping a DHCPv4 lease works again
  * SEND_DAD code removed
  * hoplimit is no longer defined for DHCPv6 messages
  * hoplimit of 255 for IPv6 RS/ND message is now defined at the socket
    instead of ancillary data with the message

diffstat:

 external/bsd/dhcpcd/dist/auth.c                   |   17 +-
 external/bsd/dhcpcd/dist/bpf.c                    |   10 +-
 external/bsd/dhcpcd/dist/defs.h                   |    4 +-
 external/bsd/dhcpcd/dist/dhcp.h                   |    4 +-
 external/bsd/dhcpcd/dist/dhcp6.c                  |  146 ++++++-----
 external/bsd/dhcpcd/dist/dhcpcd-embedded.c        |    4 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/01-test     |    3 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/02-dump     |    3 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/50-ntp.conf |   15 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in      |    8 +-
 external/bsd/dhcpcd/dist/if-options.h             |    4 +-
 external/bsd/dhcpcd/dist/ipv4.c                   |   22 +-
 external/bsd/dhcpcd/dist/ipv6.c                   |  274 +++++++++++----------
 external/bsd/dhcpcd/dist/ipv6.h                   |   40 +--
 external/bsd/dhcpcd/dist/ipv6nd.h                 |   10 +-
 external/bsd/dhcpcd/dist/net.h                    |    4 +-
 external/bsd/dhcpcd/dist/platform-bsd.c           |   10 +-
 17 files changed, 316 insertions(+), 262 deletions(-)

diffs (truncated from 1313 to 300 lines):

diff -r 1f0973c5f589 -r 9cbb46a62f1d external/bsd/dhcpcd/dist/auth.c
--- a/external/bsd/dhcpcd/dist/auth.c   Fri Mar 14 10:06:22 2014 +0000
+++ b/external/bsd/dhcpcd/dist/auth.c   Fri Mar 14 11:27:36 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: auth.c,v 1.1.1.2 2014/03/01 11:00:43 roy Exp $");
+ __RCSID("$NetBSD: auth.c,v 1.1.1.3 2014/03/14 11:27:37 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -142,8 +142,14 @@
                    algorithm != auth->algorithm ||
                    rdm != auth->rdm)
        {
-               errno = EPERM;
-               return NULL;
+               /* As we don't require authentication, we should still
+                * accept a reconfigure key */
+               if (protocol != AUTH_PROTO_RECONFKEY ||
+                   auth->options & DHCPCD_AUTH_REQUIRE)
+               {
+                       errno = EPERM;
+                       return NULL;
+               }
        }
        dlen -= 3;
 
@@ -234,6 +240,11 @@
                        }
                        if (state->reconf == NULL)
                                errno = ENOENT;
+                       /* Free the old token so we log acceptance */
+                       if (state->token) {
+                               free(state->token);
+                               state->token = NULL;
+                       }
                        /* Nothing to validate, just accepting the key */
                        return state->reconf;
                case 2:
diff -r 1f0973c5f589 -r 9cbb46a62f1d external/bsd/dhcpcd/dist/bpf.c
--- a/external/bsd/dhcpcd/dist/bpf.c    Fri Mar 14 10:06:22 2014 +0000
+++ b/external/bsd/dhcpcd/dist/bpf.c    Fri Mar 14 11:27:36 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: bpf.c,v 1.1.1.8 2014/02/25 13:14:29 roy Exp $");
+ __RCSID("$NetBSD: bpf.c,v 1.1.1.9 2014/03/14 11:27:36 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -122,6 +122,14 @@
        }
        if (ioctl(fd, BIOCSETF, &pf) == -1)
                goto eexit;
+
+#ifdef __OpenBSD__
+       /* For some reason OpenBSD fails to open the fd as non blocking */
+       if ((flags = fcntl(fd, F_GETFL, 0)) == -1 ||
+           fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
+               goto eexit;
+#endif
+
        return fd;
 
 eexit:
diff -r 1f0973c5f589 -r 9cbb46a62f1d external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Fri Mar 14 10:06:22 2014 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Fri Mar 14 11:27:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.1.1.36 2014/03/01 11:00:43 roy Exp $ */
+/* $NetBSD: defs.h,v 1.1.1.37 2014/03/14 11:27:38 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.3.1"
+#define VERSION                        "6.3.2"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 1f0973c5f589 -r 9cbb46a62f1d external/bsd/dhcpcd/dist/dhcp.h
--- a/external/bsd/dhcpcd/dist/dhcp.h   Fri Mar 14 10:06:22 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.h   Fri Mar 14 11:27:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp.h,v 1.1.1.17 2014/02/25 13:14:30 roy Exp $ */
+/* $NetBSD: dhcp.h,v 1.1.1.18 2014/03/14 11:27:38 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -287,7 +287,7 @@
 void dhcp_reboot_newopts(struct interface *, int);
 void dhcp_close(struct interface *);
 void dhcp_free(struct interface *);
-int dhcp_dump(const char *);
+int dhcp_dump(struct dhcpcd_ctx *, const char *);
 #else
 #define dhcp_printoptions
 #define dhcp_drop(a, b)
diff -r 1f0973c5f589 -r 9cbb46a62f1d external/bsd/dhcpcd/dist/dhcp6.c
--- a/external/bsd/dhcpcd/dist/dhcp6.c  Fri Mar 14 10:06:22 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp6.c  Fri Mar 14 11:27:36 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.1.1.8 2014/03/01 11:00:43 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.1.1.9 2014/03/14 11:27:37 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -85,6 +85,7 @@
        { DHCP6_CONFIRM, "CONFIRM6" },
        { DHCP6_INFORMATION_REQ, "INFORM6" },
        { DHCP6_RELEASE, "RELEASE6" },
+       { DHCP6_RECONFIGURE, "RECONFIURE6" },
        { 0, NULL }
 };
 
@@ -706,7 +707,7 @@
 {
        struct dhcp6_state *state;
        struct ipv6_ctx *ctx;
-       struct sockaddr_in6 to;
+       struct sockaddr_in6 dst;
        struct cmsghdr *cm;
        struct in6_pktinfo pi;
        struct timeval RTprev;
@@ -716,11 +717,11 @@
        const char *broad_uni;
        const struct in6_addr alldhcp = IN6ADDR_LINKLOCAL_ALLDHCP_INIT;
 
-       memset(&to, 0, sizeof(to));
-       to.sin6_family = AF_INET6;
-       to.sin6_port = htons(DHCP6_SERVER_PORT);
+       memset(&dst, 0, sizeof(dst));
+       dst.sin6_family = AF_INET6;
+       dst.sin6_port = htons(DHCP6_SERVER_PORT);
 #ifdef SIN6_LEN
-       to.sin6_len = sizeof(to);
+       dst.sin6_len = sizeof(dst);
 #endif
 
        state = D6_STATE(ifp);
@@ -731,10 +732,10 @@
            (state->state == DH6S_REQUEST &&
            (!IN6_IS_ADDR_LINKLOCAL(&state->unicast) || !ipv6_linklocal(ifp))))
        {
-               to.sin6_addr = alldhcp;
+               dst.sin6_addr = alldhcp;
                broad_uni = "broadcasting";
        } else {
-               to.sin6_addr = state->unicast;
+               dst.sin6_addr = state->unicast;
                broad_uni = "unicasting";
        }
 
@@ -831,8 +832,8 @@
        }
 
        ctx = ifp->ctx->ipv6;
-       to.sin6_scope_id = ifp->index;
-       ctx->sndhdr.msg_name = (caddr_t)&to;
+       dst.sin6_scope_id = ifp->index;
+       ctx->sndhdr.msg_name = (caddr_t)&dst;
        ctx->sndhdr.msg_iov[0].iov_base = (caddr_t)state->send;
        ctx->sndhdr.msg_iov[0].iov_len = state->send_len;
 
@@ -1261,17 +1262,12 @@
        int wascompleted;
 
        wascompleted = (ap->flags & IPV6_AF_DADCOMPLETED);
-       ipv6nd_cancelprobeaddr(ap);
        ap->flags |= IPV6_AF_DADCOMPLETED;
        if (ap->flags & IPV6_AF_DUPLICATED)
                /* XXX FIXME
                 * We should decline the address */
                syslog(LOG_WARNING, "%s: DAD detected %s",
                    ap->iface->name, ap->saddr);
-#ifdef IPV6_SEND_DAD
-       else
-               ipv6_addaddr(ap);
-#endif
 
        if (!wascompleted) {
                ifp = ap->iface;
@@ -1468,14 +1464,14 @@
        const struct if_options *ifo;
        const struct dhcp6_option *o;
        const uint8_t *p;
-       int i;
+       int i, e;
        uint32_t u32, renew, rebind;
        uint8_t iaid[4];
        size_t ol;
        struct ipv6_addr *ap, *nap;
 
        ifo = ifp->options;
-       i = 0;
+       i = e = 0;
        state = D6_STATE(ifp);
        TAILQ_FOREACH(ap, &state->addrs, next) {
                ap->flags |= IPV6_AF_STALE;
@@ -1508,8 +1504,10 @@
                        ol -= sizeof(u32);
                } else
                        renew = rebind = 0; /* appease gcc */
-               if (dhcp6_checkstatusok(ifp, NULL, p, ol) == -1)
+               if (dhcp6_checkstatusok(ifp, NULL, p, ol) == -1) {
+                       e = 1;
                        continue;
+               }
                if (ifo->ia_type == D6_OPTION_IA_PD) {
                        if (dhcp6_findpd(ifp, iaid, p, ol) == 0) {
                                syslog(LOG_WARNING,
@@ -1548,10 +1546,12 @@
                        TAILQ_REMOVE(&state->addrs, ap, next);
                        if (ap->dadcallback)
                                eloop_q_timeout_delete(ap->iface->ctx->eloop,
-                                   0, NULL, ap->dadcallback);
+                                   0, NULL, ap);
                        free(ap);
                }
        }
+       if (i == 0 && e)
+               return -1;
        return i;
 }
 
@@ -1667,8 +1667,12 @@
                            ifp->name);
                        goto ex;
                }
-               syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
-                   ifp->name, state->auth.token->secretid);
+               if (state->auth.token)
+                       syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
+                           ifp->name, state->auth.token->secretid);
+               else
+                       syslog(LOG_DEBUG, "%s: accepted reconfigure key",
+                           ifp->name);
        } else if (ifp->options->auth.options & DHCPCD_AUTH_REQUIRE) {
                syslog(LOG_ERR, "%s: authentication now required", ifp->name);
                goto ex;
@@ -1902,7 +1906,7 @@
                }
                if (k && !carrier_warned) {
                        ifd_state = D6_STATE(ifd);
-                       ipv6nd_probeaddrs(&ifd_state->addrs);
+                       ipv6_addaddrs(&ifd_state->addrs);
                }
        }
 
@@ -1982,7 +1986,7 @@
                syslog(LOG_INFO, "%s: adding delegated prefixes", ifp->name);
                state = D6_STATE(ifp);
                state->state = DH6S_DELEGATED;
-               ipv6nd_probeaddrs(&state->addrs);
+               ipv6_addaddrs(&state->addrs);
                ipv6_buildroutes(ifp->ctx);
        }
        return k;
@@ -2012,6 +2016,7 @@
 
        dhcpcd_ctx = arg;
        ctx = dhcpcd_ctx->ipv6;
+       ctx->rcvhdr.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));
        len = recvmsg(ctx->dhcp_fd, &ctx->rcvhdr, 0);
        if (len == -1) {
                syslog(LOG_ERR, "recvmsg: %m");
@@ -2063,10 +2068,13 @@
                    ifp->name);
                return;
        }
+
+       r = (struct dhcp6_message *)ctx->rcvhdr.msg_iov[0].iov_base;
+
        /* We're already bound and this message is for another machine */
        /* XXX DELEGATED? */
-       if (state->state == DH6S_BOUND ||
-           state->state == DH6S_INFORMED)
+       if (r->type != DHCP6_RECONFIGURE &&
+           (state->state == DH6S_BOUND || state->state == DH6S_INFORMED))
                return;
 
        r = (struct dhcp6_message *)ctx->rcvhdr.msg_iov[0].iov_base;
@@ -2129,8 +2137,12 @@
                            ifp->name, ctx->sfrom);
                        return;
                }
-               syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
-                   ifp->name, state->auth.token->secretid);
+               if (state->auth.token)
+                       syslog(LOG_DEBUG, "%s: validated using 0x%08" PRIu32,
+                           ifp->name, state->auth.token->secretid);
+               else
+                       syslog(LOG_DEBUG, "%s: accepted reconfigure key",
+                           ifp->name);
        } else if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
                syslog(LOG_ERR, "%s: no authentication from %s",
                    ifp->name, ctx->sfrom);



Home | Main Index | Thread Index | Old Index