Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/ROY]: src/external/bsd/dhcpcd/dist/src Import dhcpcd-7.0.0-rc3 with the ...



details:   https://anonhg.NetBSD.org/src/rev/22a900346d5b
branches:  ROY
changeset: 455203:22a900346d5b
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Oct 07 14:05:36 2017 +0000

description:
Import dhcpcd-7.0.0-rc3 with the following noteable changes:
  *  Fixed handling RA's from multiple routers
  *  Fixed changing to a better route based on gateway
  *  IPv6 default route is now deleted when config is not persistent
  *  Use hmac(3) if available in libc to reduce binary size

Fixes PR bin/52554

diffstat:

 external/bsd/dhcpcd/dist/src/auth.c      |  31 ++++++++++++++++++-------------
 external/bsd/dhcpcd/dist/src/defs.h      |   2 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c     |  14 ++++++++------
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in |   6 +++---
 external/bsd/dhcpcd/dist/src/dhcpcd.conf |   4 +++-
 external/bsd/dhcpcd/dist/src/ipv4.c      |   5 +----
 external/bsd/dhcpcd/dist/src/ipv6.c      |  25 ++++++-------------------
 external/bsd/dhcpcd/dist/src/ipv6nd.c    |  21 +++++++++------------
 external/bsd/dhcpcd/dist/src/ipv6nd.h    |   3 ---
 external/bsd/dhcpcd/dist/src/route.c     |  30 ++++++------------------------
 10 files changed, 55 insertions(+), 86 deletions(-)

diffs (truncated from 476 to 300 lines):

diff -r 7288f44a86ae -r 22a900346d5b external/bsd/dhcpcd/dist/src/auth.c
--- a/external/bsd/dhcpcd/dist/src/auth.c       Tue Sep 19 19:16:48 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/auth.c       Sat Oct 07 14:05:36 2017 +0000
@@ -37,11 +37,14 @@
 
 #include "config.h"
 #include "auth.h"
-#include "crypt/crypt.h"
 #include "dhcp.h"
 #include "dhcp6.h"
 #include "dhcpcd.h"
 
+#ifdef HAVE_HMAC_H
+#include <hmac.h>
+#endif
+
 #ifdef __sun
 #define htonll
 #define ntohll
@@ -105,7 +108,7 @@
        size_t realm_len;
        const struct token *t;
        time_t now;
-       uint8_t hmac[HMAC_LENGTH];
+       uint8_t hmac_code[HMAC_LENGTH];
 
        if (dlen < 3 + sizeof(replay)) {
                errno = EINVAL;
@@ -174,7 +177,7 @@
                secretid = 0;
                break;
        case AUTH_PROTO_DELAYED:
-               if (dlen < sizeof(secretid) + sizeof(hmac)) {
+               if (dlen < sizeof(secretid) + sizeof(hmac_code)) {
                        errno = EINVAL;
                        return NULL;
                }
@@ -183,11 +186,11 @@
                dlen -= sizeof(secretid);
                break;
        case AUTH_PROTO_DELAYEDREALM:
-               if (dlen < sizeof(secretid) + sizeof(hmac)) {
+               if (dlen < sizeof(secretid) + sizeof(hmac_code)) {
                        errno = EINVAL;
                        return NULL;
                }
-               realm_len = dlen - (sizeof(secretid) + sizeof(hmac));
+               realm_len = dlen - (sizeof(secretid) + sizeof(hmac_code));
                if (realm_len) {
                        realm = d;
                        d += realm_len;
@@ -320,10 +323,11 @@
                memset(mm + offsetof(struct bootp, giaddr), 0, 4);
        }
 
-       memset(hmac, 0, sizeof(hmac));
+       memset(hmac_code, 0, sizeof(hmac_code));
        switch (algorithm) {
        case AUTH_ALG_HMAC_MD5:
-               hmac_md5(mm, mlen, t->key, t->key_len, hmac);
+               hmac("md5", t->key, t->key_len, mm, mlen,
+                    hmac_code, sizeof(hmac_code));
                break;
        default:
                errno = ENOSYS;
@@ -332,7 +336,7 @@
        }
 
        free(mm);
-       if (memcmp(d, &hmac, dlen)) {
+       if (memcmp(d, &hmac_code, dlen)) {
                errno = EPERM;
                return NULL;
        }
@@ -472,7 +476,7 @@
     void *vdata, size_t dlen)
 {
        uint64_t rdm;
-       uint8_t hmac[HMAC_LENGTH];
+       uint8_t hmac_code[HMAC_LENGTH];
        time_t now;
        uint8_t hops, *p, info, *m, *data;
        uint32_t giaddr, secretid;
@@ -546,7 +550,7 @@
                        /* FALLTHROUGH */
                case AUTH_PROTO_DELAYED:
                        if (info && t)
-                               dlen += sizeof(t->secretid) + sizeof(hmac);
+                               dlen += sizeof(t->secretid) + sizeof(hmac_code);
                        break;
                }
                return (ssize_t)dlen;
@@ -651,8 +655,9 @@
        /* Create our hash and write it out */
        switch(auth->algorithm) {
        case AUTH_ALG_HMAC_MD5:
-               hmac_md5(m, mlen, t->key, t->key_len, hmac);
-               memcpy(data, hmac, sizeof(hmac));
+               hmac("md5", t->key, t->key_len, m, mlen,
+                    hmac_code, sizeof(hmac_code));
+               memcpy(data, hmac_code, sizeof(hmac_code));
                break;
        }
 
@@ -665,5 +670,5 @@
        }
 
        /* Done! */
-       return (int)(dlen - sizeof(hmac)); /* should be zero */
+       return (int)(dlen - sizeof(hmac_code)); /* should be zero */
 }
diff -r 7288f44a86ae -r 22a900346d5b external/bsd/dhcpcd/dist/src/defs.h
--- a/external/bsd/dhcpcd/dist/src/defs.h       Tue Sep 19 19:16:48 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/defs.h       Sat Oct 07 14:05:36 2017 +0000
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE                        "dhcpcd"
-#define VERSION                        "7.0.0-rc2"
+#define VERSION                        "7.0.0-rc3"
 
 #ifndef CONFIG
 # define CONFIG                        SYSCONFDIR "/" PACKAGE ".conf"
diff -r 7288f44a86ae -r 22a900346d5b external/bsd/dhcpcd/dist/src/dhcp6.c
--- a/external/bsd/dhcpcd/dist/src/dhcp6.c      Tue Sep 19 19:16:48 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcp6.c      Sat Oct 07 14:05:36 2017 +0000
@@ -2941,24 +2941,26 @@
        clock_gettime(CLOCK_MONOTONIC, &now);
        if (state->state == DH6S_TIMEDOUT || state->state == DH6S_ITIMEDOUT) {
                struct timespec diff;
+               uint32_t diffsec;
 
                /* Reduce timers */
                timespecsub(&now, &state->acquired, &diff);
+               diffsec = (uint32_t)diff.tv_sec;
                if (state->renew && state->renew != ND6_INFINITE_LIFETIME) {
-                       if (state->renew > diff.tv_sec)
-                               state->renew -= (uint32_t)diff.tv_sec;
+                       if (state->renew > diffsec)
+                               state->renew -= diffsec;
                        else
                                state->renew = 0;
                }
                if (state->rebind && state->rebind != ND6_INFINITE_LIFETIME) {
-                       if (state->rebind > diff.tv_sec)
-                               state->rebind -= (uint32_t)diff.tv_sec;
+                       if (state->rebind > diffsec)
+                               state->rebind -= diffsec;
                        else
                                state->rebind = 0;
                }
                if (state->expire && state->expire != ND6_INFINITE_LIFETIME) {
-                       if (state->expire > diff.tv_sec)
-                               state->expire -= (uint32_t)diff.tv_sec;
+                       if (state->expire > diffsec)
+                               state->expire -= diffsec;
                        else {
                                if (!(ifp->options->options &
                                    DHCPCD_LASTLEASE_EXTEND))
diff -r 7288f44a86ae -r 22a900346d5b external/bsd/dhcpcd/dist/src/dhcpcd.8.in
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Tue Sep 19 19:16:48 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.8.in  Sat Oct 07 14:05:36 2017 +0000
@@ -22,7 +22,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd August 29, 2017
+.Dd October 7, 2017
 .Dt DHCPCD 8
 .Os
 .Sh NAME
@@ -434,7 +434,7 @@
 NFS or SSH clients connect to this host and they need to be notified of
 the host shutting down.
 You can use this option to stop this from happening.
-.It Fl r , Fl Fl request Op Ar address
+.It Fl r , Fl Fl request Ar address
 Request the
 .Ar address
 in the DHCP DISCOVER message.
@@ -444,7 +444,7 @@
 is given then the first address currently assigned to the
 .Ar interface
 is used.
-.It Fl s , Fl Fl inform Op Ar address Ns Op Ar /cidr
+.It Fl s , Fl Fl inform Ar address Ns Op Ar /cidr
 Behaves like
 .Fl r , Fl Fl request
 as above, but sends a DHCP INFORM instead of DISCOVER/REQUEST.
diff -r 7288f44a86ae -r 22a900346d5b external/bsd/dhcpcd/dist/src/dhcpcd.conf
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.conf  Tue Sep 19 19:16:48 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.conf  Sat Oct 07 14:05:36 2017 +0000
@@ -35,5 +35,7 @@
 # A ServerID is required by RFC2131.
 require dhcp_server_identifier
 
-# Generate Stable Private IPv6 Addresses instead of hardware based ones
+# Generate SLAAC address using the Hardware Address of the interface
+#slaac hwaddr
+# OR generate Stable Private IPv6 Addresses based from the DUID
 slaac private
diff -r 7288f44a86ae -r 22a900346d5b external/bsd/dhcpcd/dist/src/ipv4.c
--- a/external/bsd/dhcpcd/dist/src/ipv4.c       Tue Sep 19 19:16:48 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv4.c       Sat Oct 07 14:05:36 2017 +0000
@@ -338,13 +338,11 @@
        struct if_options *ifo;
        const struct dhcp_state *state;
        struct in_addr in;
-       int n;
 
        /* Don't add a host route for these interfaces. */
        if (ifp->flags & (IFF_LOOPBACK | IFF_POINTOPOINT))
                return 0;
 
-       n = 0;
        TAILQ_FOREACH(rt, routes, rt_next) {
                if (rt->rt_dest.sa_family != AF_INET)
                        continue;
@@ -414,9 +412,8 @@
                rth->rt_mtu = dhcp_get_mtu(ifp);
                sa_in_init(&rth->rt_ifa, &state->addr->addr);
                TAILQ_INSERT_BEFORE(rt, rth, rt_next);
-               n++;
        }
-       return n;
+       return 0;
 }
 
 bool
diff -r 7288f44a86ae -r 22a900346d5b external/bsd/dhcpcd/dist/src/ipv6.c
--- a/external/bsd/dhcpcd/dist/src/ipv6.c       Tue Sep 19 19:16:48 2017 +0000
+++ b/external/bsd/dhcpcd/dist/src/ipv6.c       Sat Oct 07 14:05:36 2017 +0000
@@ -2222,9 +2222,7 @@
        struct ipv6_state *state;
        struct ipv6_addr *ia;
        struct rt *rt;
-       int n;
 
-       n = 0;
        TAILQ_FOREACH(ifp, ctx->ifaces, next) {
                if ((state = IPV6_STATE(ifp)) == NULL)
                        continue;
@@ -2233,14 +2231,12 @@
                            (IPV6_AF_ADDED | IPV6_AF_STATIC))
                        {
                                rt = inet6_makeprefix(ifp, NULL, ia);
-                               if (rt) {
+                               if (rt)
                                        TAILQ_INSERT_TAIL(routes, rt, rt_next);
-                                       n++;
-                               }
                        }
                }
        }
-       return n;
+       return 0;
 }
 
 static int
@@ -2250,9 +2246,7 @@
        struct rt *rt;
        struct ra *rap;
        const struct ipv6_addr *addr;
-       int n;
 
-       n = 0;
        TAILQ_FOREACH(rap, ctx->ra_routers, next) {
                if (rap->expired != expired)
                        continue;
@@ -2260,22 +2254,19 @@
                        if (addr->prefix_vltime == 0)
                                continue;
                        rt = inet6_makeprefix(rap->iface, rap, addr);
-                       if (rt) {
+                       if (rt)
                                TAILQ_INSERT_TAIL(routes, rt, rt_next);
-                               n++;
-                       }
                }
                if (rap->lifetime) {
                        rt = inet6_makerouter(rap);
                        if (rt) {
                                TAILQ_INSERT_TAIL(routes, rt, rt_next);
-                               n++;
                                if (have_default)
                                        *have_default = true;
                        }
                }
        }
-       return n;
+       return 0;
 }
 
 static int
@@ -2286,22 +2277,18 @@
        const struct dhcp6_state *d6_state;
        const struct ipv6_addr *addr;
        struct rt *rt;
-       int n;
 



Home | Main Index | Thread Index | Old Index