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



details:   https://anonhg.NetBSD.org/src/rev/13b54b0f5fb8
branches:  trunk
changeset: 792449:13b54b0f5fb8
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Jan 03 22:10:42 2014 +0000

description:
Import dhcpcd-6.2.0 with the following changes:

* Fix NAK backoff when a server NAKs a REQUEST after a DISCOVER.
* Fix IPv6 ICMP filtering on Android (RS/RA now works)
* Fix sending of DHCPv6 FQDN when only hostname specified
* Add support for RFC3925 Vendor-Identifying Vendor Options
* Remove hard coded DHCP/DHCPv6 options and embed dhcpcd-definitions.conf.
  This actually results in a slightly smaller binary than before and has the added advantage that the option definitions are now all held within one file.
* Change IAID to default from the last 4 bytes of the MAC address.
  Rationale in the commit, but in a nutshell it allows for a stable IAID between reboots without persistent storage and across different OS's who name or number it differently to each other.
* RFC4242, Information Refresh Time Option for DHCPv6.
* Fix processing of inet4 addr in vendor options and terminate correctly.
* Preserve vendor encapsulated options.
* Fix renewal of Prefix Delegation. Only spam the log if a lease has a new address or changes the vltime of an existing address.
* Add noipv4 and noipv6 options.
* Warn about missing interfaces which require prefix delegation.
* If we timeout, remove any waitip config so that we daemonise correctly.
* Remove the IPv6 forwarding router check as valid use cases exist where you would want IPv6 RS/RA on a router.
* Pass the correct run directory to dhcpcd-run-hooks

diffstat:

 external/bsd/dhcpcd/dist/arp.c                          |   13 +-
 external/bsd/dhcpcd/dist/bpf.c                          |   10 +-
 external/bsd/dhcpcd/dist/defs.h                         |    8 +-
 external/bsd/dhcpcd/dist/dhcp-common.c                  |  278 ++++++-
 external/bsd/dhcpcd/dist/dhcp-common.h                  |   60 +-
 external/bsd/dhcpcd/dist/dhcp.h                         |   10 +-
 external/bsd/dhcpcd/dist/dhcp6.c                        |  639 +++++++++------
 external/bsd/dhcpcd/dist/dhcp6.h                        |   13 +-
 external/bsd/dhcpcd/dist/dhcpcd-definitions.conf        |  255 ++++++
 external/bsd/dhcpcd/dist/dhcpcd-embedded.c              |  210 +++++
 external/bsd/dhcpcd/dist/dhcpcd-embedded.h              |   33 +
 external/bsd/dhcpcd/dist/dhcpcd-embedded.h.in           |   31 +
 external/bsd/dhcpcd/dist/dhcpcd-hooks/10-wpa_supplicant |   13 +-
 external/bsd/dhcpcd/dist/dhcpcd-run-hooks.in            |    4 +-
 external/bsd/dhcpcd/dist/dhcpcd.c                       |  241 +++++-
 external/bsd/dhcpcd/dist/dhcpcd.h                       |    4 +-
 external/bsd/dhcpcd/dist/duid.c                         |   59 +-
 external/bsd/dhcpcd/dist/duid.h                         |    9 +-
 external/bsd/dhcpcd/dist/if-options.h                   |   30 +-
 external/bsd/dhcpcd/dist/ipv4.c                         |   12 +-
 external/bsd/dhcpcd/dist/ipv4.h                         |    6 +-
 external/bsd/dhcpcd/dist/ipv6.h                         |    7 +-
 external/bsd/dhcpcd/dist/platform-bsd.c                 |   20 +-
 23 files changed, 1519 insertions(+), 446 deletions(-)

diffs (truncated from 3166 to 300 lines):

diff -r 6dcae6803304 -r 13b54b0f5fb8 external/bsd/dhcpcd/dist/arp.c
--- a/external/bsd/dhcpcd/dist/arp.c    Fri Jan 03 21:34:40 2014 +0000
+++ b/external/bsd/dhcpcd/dist/arp.c    Fri Jan 03 22:10:42 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.1.1.9 2013/06/21 19:33:07 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.1.1.10 2014/01/03 22:10:43 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -223,7 +223,11 @@
        if (state->new == NULL)
                return;
        if (state->arp_fd == -1) {
-               ipv4_opensocket(ifp, ETHERTYPE_ARP);
+               state->arp_fd = ipv4_opensocket(ifp, ETHERTYPE_ARP);
+               if (state->arp_fd == -1) {
+                       syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
+                       return;
+               }
                eloop_event_add(state->arp_fd, arp_packet, ifp);
        }
        if (++state->claims < ANNOUNCE_NUM)
@@ -270,8 +274,11 @@
        int arping = 0;
 
        if (state->arp_fd == -1) {
-               if (ipv4_opensocket(ifp, ETHERTYPE_ARP) == -1)
+               state->arp_fd = ipv4_opensocket(ifp, ETHERTYPE_ARP);
+               if (state->arp_fd == -1) {
+                       syslog(LOG_ERR, "%s: %s: %m", __func__, ifp->name);
                        return;
+               }
                eloop_event_add(state->arp_fd, arp_packet, ifp);
        }
 
diff -r 6dcae6803304 -r 13b54b0f5fb8 external/bsd/dhcpcd/dist/bpf.c
--- a/external/bsd/dhcpcd/dist/bpf.c    Fri Jan 03 21:34:40 2014 +0000
+++ b/external/bsd/dhcpcd/dist/bpf.c    Fri Jan 03 22:10:42 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: bpf.c,v 1.1.1.5 2013/06/21 19:33:07 roy Exp $");
+ __RCSID("$NetBSD: bpf.c,v 1.1.1.6 2014/01/03 22:10:42 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -56,7 +56,6 @@
 {
        struct dhcp_state *state;
        int fd = -1;
-       int *fdp = NULL;
        struct ifreq ifr;
        int buf_len = 0;
        struct bpf_version pv;
@@ -120,21 +119,14 @@
        if (protocol == ETHERTYPE_ARP) {
                pf.bf_insns = UNCONST(arp_bpf_filter);
                pf.bf_len = arp_bpf_filter_len;
-               fdp = &state->arp_fd;
        } else {
                pf.bf_insns = UNCONST(dhcp_bpf_filter);
                pf.bf_len = dhcp_bpf_filter_len;
-               fdp = &state->raw_fd;
        }
        if (ioctl(fd, BIOCSETF, &pf) == -1)
                goto eexit;
        if (set_cloexec(fd) == -1)
                goto eexit;
-       if (fdp) {
-               if (*fdp != -1)
-                       close(*fdp);
-               *fdp = fd;
-       }
        return fd;
 
 eexit:
diff -r 6dcae6803304 -r 13b54b0f5fb8 external/bsd/dhcpcd/dist/defs.h
--- a/external/bsd/dhcpcd/dist/defs.h   Fri Jan 03 21:34:40 2014 +0000
+++ b/external/bsd/dhcpcd/dist/defs.h   Fri Jan 03 22:10:42 2014 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: defs.h,v 1.1.1.32 2013/09/20 10:51:30 roy Exp $ */
+/* $NetBSD: defs.h,v 1.1.1.33 2014/01/03 22:10:44 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2013 Roy Marples <roy%marples.name@localhost>
+ * Copyright (c) 2006-2014 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
@@ -30,17 +30,17 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "6.1.0"
+#define VERSION                        "6.2.0"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
 #endif
 #ifndef SCRIPT
 # define SCRIPT                        LIBEXECDIR "/" PACKAGE "-run-hooks"
+#endif
 #ifndef DEVDIR
 # define DEVDIR                        LIBDIR "/" PACKAGE "/dev"
 #endif
-#endif
 #ifndef DUID
 # define DUID                  SYSCONFDIR "/" PACKAGE ".duid"
 #endif
diff -r 6dcae6803304 -r 13b54b0f5fb8 external/bsd/dhcpcd/dist/dhcp-common.c
--- a/external/bsd/dhcpcd/dist/dhcp-common.c    Fri Jan 03 21:34:40 2014 +0000
+++ b/external/bsd/dhcpcd/dist/dhcp-common.c    Fri Jan 03 22:10:42 2014 +0000
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.1 2013/06/21 19:33:07 roy Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.1.1.2 2014/01/03 22:10:42 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -41,12 +41,40 @@
 #include "dhcp-common.h"
 #include "dhcp.h"
 
-int make_option_mask(const struct dhcp_opt *dopts,
+/* DHCP Enterprise options, RFC3925 */
+struct dhcp_opt *vivso = NULL;
+size_t vivso_len = 0;
+
+struct dhcp_opt *
+vivso_find(uint16_t iana_en, const void *arg)
+{
+       const struct interface *ifp = arg;
+       size_t i;
+       struct dhcp_opt *opt;
+
+       if (arg) {
+               ifp = arg;
+               for (i = 0, opt = ifp->options->vivso_override;
+                   i < ifp->options->vivso_override_len;
+                   i++, opt++)
+                       if (opt->option == iana_en)
+                               return opt;
+       }
+       for (i = 0, opt = vivso; i < vivso_len; i++, opt++)
+               if (opt->option == iana_en)
+                       return opt;
+       return NULL;
+}
+
+int
+make_option_mask(const struct dhcp_opt *dopts, size_t dopts_len,
     uint8_t *mask, const char *opts, int add)
 {
        char *token, *o, *p, *t;
        const struct dhcp_opt *opt;
-       int match, n;
+       int match;
+       unsigned int n;
+       size_t i;
 
        o = p = strdup(opts);
        if (opts == NULL)
@@ -54,9 +82,7 @@
        while ((token = strsep(&p, ", "))) {
                if (*token == '\0')
                        continue;
-               for (opt = dopts; opt->option; opt++) {
-                       if (!opt->var)
-                               continue;
+               for (i = 0, opt = dopts; i < dopts_len; i++, opt++) {
                        match = 0;
                        if (strcmp(opt->var, token) == 0)
                                match = 1;
@@ -162,9 +188,9 @@
        while (q - p < pl) {
                r = NULL;
                hops = 0;
-               /* We check we are inside our length again incase
-                * the data is NOT terminated correctly. */
-               while ((l = *q++) && q - p < pl) {
+               /* Check we are inside our length again in-case
+                * the name isn't fully qualified (ie, not terminated) */
+               while (q - p < pl && (l = *q++)) {
                        ltype = l & 0xc0;
                        if (ltype == 0x80 || ltype == 0x40)
                                return 0;
@@ -281,6 +307,54 @@
        return bytes;
 }
 
+#define ADDRSZ         4
+#define ADDR6SZ                16
+static size_t
+dhcp_optlen(const struct dhcp_opt *opt, size_t dl)
+{
+       size_t sz;
+
+       if (dl == 0)
+               return 0;
+
+       if (opt->type == 0 ||
+           opt->type & (STRING | BINHEX | RFC3442 | RFC5969))
+       {
+               if (opt->len) {
+                       if ((size_t)opt->len > dl)
+                               return 0;
+                       return opt->len;
+               }
+               return dl;
+       }
+
+       if ((opt->type & (ADDRIPV4 | ARRAY)) == (ADDRIPV4 | ARRAY)) {
+               if (dl < ADDRSZ)
+                       return 0;
+               return dl - (dl % ADDRSZ);
+       }
+
+       if ((opt->type & (ADDRIPV6 | ARRAY)) == (ADDRIPV6 | ARRAY)) {
+               if (dl < ADDR6SZ)
+                       return 0;
+               return dl - (dl % ADDR6SZ);
+       }
+
+       sz = 0;
+       if (opt->type & (UINT32 | ADDRIPV4))
+               sz = sizeof(uint32_t);
+       else if (opt->type & UINT16)
+               sz = sizeof(uint16_t);
+       else if (opt->type & UINT8)
+               sz = sizeof(uint8_t);
+       else if (opt->type & ADDRIPV6)
+               sz = ADDR6SZ;
+       else
+               /* If we don't know the size, assume it's valid */
+               return dl;
+       return (dl < sz ? 0 : sz);
+}
+
 ssize_t
 print_option(char *s, ssize_t len, int type, int dl, const uint8_t *data,
     const char *ifname)
@@ -340,22 +414,6 @@
                return 2;
        }
 
-       /* DHCPv6 status code */
-       if (type & SCODE && dl >= (int)sizeof(u16)) {
-               if (s) {
-                       memcpy(&u16, data, sizeof(u16));
-                       u16 = ntohs(u16);
-                       l = snprintf(s, len, "%d ", u16);
-                       len -= l;
-               } else
-                       l = 7;
-               data += sizeof(u16);
-               dl -= sizeof(u16);
-               if (dl)
-                       l += print_option(s, len, STRING, dl, data, ifname);
-               return l;
-       }
-
        if (!s) {
                if (type & UINT8)
                        l = 3;
@@ -408,12 +466,12 @@
                        len--;
                }
                if (type & UINT8) {
-                       l = snprintf(s, len, "%d", *data);
+                       l = snprintf(s, len, "%u", *data);
                        data++;
                } else if (type & UINT16) {
                        memcpy(&u16, data, sizeof(u16));
                        u16 = ntohs(u16);
-                       l = snprintf(s, len, "%d", u16);
+                       l = snprintf(s, len, "%u", u16);
                        data += sizeof(u16);
                } else if (type & SINT16) {
                        memcpy(&s16, data, sizeof(s16));
@@ -423,7 +481,7 @@
                } else if (type & UINT32) {
                        memcpy(&u32, data, sizeof(u32));
                        u32 = ntohl(u32);
-                       l = snprintf(s, len, "%d", u32);
+                       l = snprintf(s, len, "%u", u32);
                        data += sizeof(u32);
                } else if (type & SINT32) {
                        memcpy(&s32, data, sizeof(s32));
@@ -457,3 +515,167 @@
 
        return bytes;
 }
+
+static size_t
+dhcp_envoption1(char **env, const char *prefix,
+    const struct dhcp_opt *opt, int vname, const uint8_t *od, int ol,
+    const char *ifname)
+{
+       ssize_t len;



Home | Main Index | Thread Index | Old Index