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/e6a8df8414e1
branches:  trunk
changeset: 340067:e6a8df8414e1
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Aug 21 10:39:00 2015 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/control.c                   |   25 +-
 external/bsd/dhcpcd/dist/defs.h                      |    4 +-
 external/bsd/dhcpcd/dist/dhcp.c                      |  131 +++++++--
 external/bsd/dhcpcd/dist/dhcp.h                      |    9 +-
 external/bsd/dhcpcd/dist/dhcp6.c                     |   53 +--
 external/bsd/dhcpcd/dist/dhcpcd-hooks/10-mtu         |   40 ---
 external/bsd/dhcpcd/dist/dhcpcd-hooks/20-resolv.conf |   18 +-
 external/bsd/dhcpcd/dist/dhcpcd-hooks/30-hostname    |    3 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in         |    5 +-
 external/bsd/dhcpcd/dist/dhcpcd.8.in                 |   10 +-
 external/bsd/dhcpcd/dist/dhcpcd.c                    |   47 ++-
 external/bsd/dhcpcd/dist/dhcpcd.conf                 |    7 +-
 external/bsd/dhcpcd/dist/dhcpcd.conf.5.in            |   20 +-
 external/bsd/dhcpcd/dist/dhcpcd.h                    |   19 +-
 external/bsd/dhcpcd/dist/if-bsd.c                    |  250 +++++++-----------
 external/bsd/dhcpcd/dist/if-options.c                |    9 +-
 external/bsd/dhcpcd/dist/if-options.h                |    4 +-
 external/bsd/dhcpcd/dist/if.c                        |  157 ++++++-----
 external/bsd/dhcpcd/dist/if.h                        |   12 +-
 external/bsd/dhcpcd/dist/ipv4.c                      |  173 +++++++++----
 external/bsd/dhcpcd/dist/ipv4.h                      |    4 +-
 external/bsd/dhcpcd/dist/ipv4ll.c                    |   64 ++++-
 external/bsd/dhcpcd/dist/ipv4ll.h                    |    6 +-
 external/bsd/dhcpcd/dist/ipv6.c                      |   59 +++-
 external/bsd/dhcpcd/dist/ipv6nd.c                    |   42 +--
 external/bsd/dhcpcd/dist/script.c                    |    4 +-
 26 files changed, 663 insertions(+), 512 deletions(-)

diffs (truncated from 2447 to 300 lines):

diff -r 82d5cec7f219 -r e6a8df8414e1 external/bsd/dhcpcd/dist/control.c
--- a/external/bsd/dhcpcd/dist/control.c        Fri Aug 21 09:46:43 2015 +0000
+++ b/external/bsd/dhcpcd/dist/control.c        Fri Aug 21 10:39:00 2015 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: control.c,v 1.9 2015/05/16 23:31:32 roy Exp $");
+ __RCSID("$NetBSD: control.c,v 1.10 2015/08/21 10:39:00 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -46,6 +46,7 @@
 #include "dhcpcd.h"
 #include "control.h"
 #include "eloop.h"
+#include "if.h"
 
 #ifndef SUN_LEN
 #define SUN_LEN(su) \
@@ -210,28 +211,8 @@
 {
        int fd;
 
-#ifdef SOCK_CLOEXEC
-       if ((fd = socket(AF_UNIX,
-           SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0)) == -1)
-               return -1;
-#else
-       int flags;
-
-       if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
+       if ((fd = xsocket(AF_UNIX, SOCK_STREAM, 0, O_NONBLOCK|O_CLOEXEC)) == -1)
                return -1;
-       if ((flags = fcntl(fd, F_GETFD, 0)) == -1 ||
-           fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == -1)
-       {
-               close(fd);
-               return -1;
-       }
-       if ((flags = fcntl(fd, F_GETFL, 0)) == -1 ||
-           fcntl(fd, F_SETFL, flags | O_NONBLOCK) == -1)
-       {
-               close(fd);
-               return -1;
-       }
-#endif
        memset(sa, 0, sizeof(*sa));
        sa->sun_family = AF_UNIX;
        if (unpriv)
diff -r 82d5cec7f219 -r e6a8df8414e1 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Fri Aug 21 09:46:43 2015 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Fri Aug 21 10:39:00 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.19 2015/07/09 10:15:34 roy Exp $ */
+/* $NetBSD: defs.h,v 1.20 2015/08/21 10:39:00 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.9.1"
+#define VERSION                        "6.9.2"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 82d5cec7f219 -r e6a8df8414e1 external/bsd/dhcpcd/dist/dhcp.c
--- a/external/bsd/dhcpcd/dist/dhcp.c   Fri Aug 21 09:46:43 2015 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp.c   Fri Aug 21 10:39:00 2015 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.32 2015/07/09 10:15:34 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.33 2015/08/21 10:39:00 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -279,6 +279,23 @@
 }
 
 static int
+get_option_uint16(struct dhcpcd_ctx *ctx,
+    uint16_t *i, const struct dhcp_message *dhcp, uint8_t option)
+{
+       const uint8_t *p;
+       size_t len;
+       uint16_t d;
+
+       p = get_option(ctx, dhcp, option, &len);
+       if (!p || len < (ssize_t)sizeof(d))
+               return -1;
+       memcpy(&d, p, sizeof(d));
+       if (i)
+               *i = ntohs(d);
+       return 0;
+}
+
+static int
 get_option_uint8(struct dhcpcd_ctx *ctx,
     uint8_t *i, const struct dhcp_message *dhcp, uint8_t option)
 {
@@ -586,7 +603,7 @@
 /* We need to obey routing options.
  * If we have a CSR then we only use that.
  * Otherwise we add static routes and then routers. */
-struct rt_head *
+static struct rt_head *
 get_option_routes(struct interface *ifp, const struct dhcp_message *dhcp)
 {
        struct if_options *ifo = ifp->options;
@@ -692,6 +709,40 @@
        return routes;
 }
 
+uint16_t
+dhcp_get_mtu(const struct interface *ifp)
+{
+       const struct dhcp_message *dhcp;
+       uint16_t mtu;
+
+       if ((dhcp = D_CSTATE(ifp)->new) == NULL ||
+           has_option_mask(ifp->options->nomask, DHO_MTU) ||
+           get_option_uint16(ifp->ctx, &mtu, dhcp, DHO_MTU) == -1)
+               return 0;
+       return mtu;
+}
+
+/* Grab our routers from the DHCP message and apply any MTU value
+ * the message contains */
+struct rt_head *
+dhcp_get_routes(struct interface *ifp)
+{
+       struct rt_head *routes;
+       uint16_t mtu;
+       const struct dhcp_message *dhcp;
+
+       dhcp = D_CSTATE(ifp)->new;
+       routes = get_option_routes(ifp, dhcp);
+       if ((mtu = dhcp_get_mtu(ifp)) != 0) {
+               struct rt *rt;
+
+               TAILQ_FOREACH(rt, routes, next) {
+                       rt->mtu = mtu;
+               }
+       }
+       return routes;
+}
+
 #define PUTADDR(_type, _val)                                                 \
        {                                                                     \
                *p++ = _type;                                                 \
@@ -852,21 +903,27 @@
                if (!(ifo->options & DHCPCD_BOOTP)) {
                        int mtu;
 
-                       *p++ = DHO_MAXMESSAGESIZE;
-                       *p++ = 2;
-                       mtu = if_getmtu(ifp->name);
-                       if (mtu < MTU_MIN) {
-                               if (if_setmtu(ifp->name, MTU_MIN) == 0)
-                                       sz = MTU_MIN;
+                       if ((mtu = if_getmtu(ifp)) == -1)
+                               logger(ifp->ctx, LOG_ERR,
+                                   "%s: if_getmtu: %m", ifp->name);
+                       else if (mtu < MTU_MIN) {
+                               if (if_setmtu(ifp, MTU_MIN) == -1)
+                                       logger(ifp->ctx, LOG_ERR,
+                                           "%s: if_setmtu: %m", ifp->name);
+                               mtu = MTU_MIN;
                        } else if (mtu > MTU_MAX) {
                                /* Even though our MTU could be greater than
                                 * MTU_MAX (1500) dhcpcd does not presently
                                 * handle DHCP packets any bigger. */
                                mtu = MTU_MAX;
                        }
-                       sz = htons((uint16_t)mtu);
-                       memcpy(p, &sz, 2);
-                       p += 2;
+                       if (mtu != -1) {
+                               *p++ = DHO_MAXMESSAGESIZE;
+                               *p++ = 2;
+                               sz = htons((uint16_t)mtu);
+                               memcpy(p, &sz, 2);
+                               p += 2;
+                       }
                }
 
                if (ifo->userclass[0]) {
@@ -1184,6 +1241,13 @@
                else
                        logger(ifp->ctx, LOG_DEBUG,
                            "%s: accepted reconfigure key", ifp->name);
+       } else if ((ifp->options->auth.options & DHCPCD_AUTH_SENDREQUIRE) ==
+           DHCPCD_AUTH_SENDREQUIRE)
+       {
+               logger(ifp->ctx, LOG_ERR,
+                   "%s: authentication now required", ifp->name);
+               free(dhcp);
+               return NULL;
        }
 
        return dhcp;
@@ -1483,19 +1547,8 @@
        char *p;
 #endif
 
-#ifdef SOCK_CLOEXEC
-       if ((s = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP)) == -1)
-               return -1;
-#else
-       if ((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
+       if ((s = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP, O_CLOEXEC)) == -1)
                return -1;
-       if ((n = fcntl(s, F_GETFD, 0)) == -1 ||
-           fcntl(s, F_SETFD, n | FD_CLOEXEC) == -1)
-       {
-               close(s);
-               return -1;
-       }
-#endif
 
        n = 1;
        if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n)) == -1)
@@ -2325,6 +2378,8 @@
        dhcp_auth_reset(&state->auth);
        dhcp_close(ifp);
 
+       free(state->offer);
+       state->offer = NULL;
        free(state->old);
        state->old = state->new;
        state->new = NULL;
@@ -2481,12 +2536,15 @@
                else
                        logger(ifp->ctx, LOG_DEBUG,
                            "%s: accepted reconfigure key", ifp->name);
-       } else if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
-               log_dhcp1(LOG_ERR, "no authentication", ifp, dhcp, from, 0);
-               return;
-       } else if (ifo->auth.options & DHCPCD_AUTH_SEND)
+       } else if (ifo->auth.options & DHCPCD_AUTH_SEND) {
+               if (ifo->auth.options & DHCPCD_AUTH_REQUIRE) {
+                       log_dhcp1(LOG_ERR, "no authentication",
+                           ifp, dhcp, from, 0);
+                       return;
+               }
                log_dhcp1(LOG_WARNING, "no authentication",
                    ifp, dhcp, from, 0);
+       }
 
        /* RFC 3203 */
        if (type == DHCP_FORCERENEW) {
@@ -2500,7 +2558,8 @@
                if (auth == NULL) {
                        log_dhcp(LOG_ERR, "unauthenticated Force Renew",
                            ifp, dhcp, from);
-                       return;
+                       if (ifo->auth.options & DHCPCD_AUTH_REQUIRE)
+                               return;
                }
                if (state->state != DHS_BOUND && state->state != DHS_INFORM) {
                        log_dhcp(LOG_DEBUG, "not bound, ignoring Force Renew",
@@ -3203,7 +3262,7 @@
        }
        /* We don't want to read the old lease if we NAK an old test */
        nolease = state->offer && ifp->ctx->options & DHCPCD_TEST;
-       if (!nolease) {
+       if (!nolease && ifo->options & DHCPCD_DHCP) {
                state->offer = read_lease(ifp);
                /* Check the saved lease matches the type we want */
                if (state->offer) {
@@ -3294,13 +3353,8 @@
        }
 
        if (!(ifo->options & DHCPCD_DHCP)) {
-               if (ifo->options & DHCPCD_IPV4LL) {
-                       if (state->offer && state->offer->cookie != 0) {
-                               free(state->offer);
-                               state->offer = NULL;
-                       }
+               if (ifo->options & DHCPCD_IPV4LL)
                        ipv4ll_start(ifp);
-               }
                return;
        }
 
@@ -3338,6 +3392,13 @@
 }
 
 void
+dhcp_abort(struct interface *ifp)
+{
+
+       eloop_timeout_delete(ifp->ctx->eloop, dhcp_start1, ifp);
+}
+
+void
 dhcp_handleifa(int cmd, struct interface *ifp,
        const struct in_addr *addr,
        const struct in_addr *net,
diff -r 82d5cec7f219 -r e6a8df8414e1 external/bsd/dhcpcd/dist/dhcp.h



Home | Main Index | Thread Index | Old Index