Module Name:    src
Committed By:   roy
Date:           Fri Mar 27 11:33:47 UTC 2015

Modified Files:
        src/external/bsd/dhcpcd/dist: common.c defs.h if-options.c ipv4.c
            ipv6.c
        src/external/bsd/dhcpcd/dist/crypt: hmac_md5.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/common.c \
    src/external/bsd/dhcpcd/dist/ipv6.c
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/dhcpcd/dist/defs.h
cvs rdiff -u -r1.21 -r1.22 src/external/bsd/dhcpcd/dist/if-options.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/ipv4.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/crypt/hmac_md5.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/dhcpcd/dist/common.c
diff -u src/external/bsd/dhcpcd/dist/common.c:1.9 src/external/bsd/dhcpcd/dist/common.c:1.10
--- src/external/bsd/dhcpcd/dist/common.c:1.9	Thu Mar 26 10:26:37 2015
+++ src/external/bsd/dhcpcd/dist/common.c	Fri Mar 27 11:33:46 2015
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: common.c,v 1.9 2015/03/26 10:26:37 roy Exp $");
+ __RCSID("$NetBSD: common.c,v 1.10 2015/03/27 11:33:46 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -231,9 +231,9 @@ logger(struct dhcpcd_ctx *ctx, int pri, 
 				break;
 		}
 		*fp++ = '\0';
+		fmt = fmt_cpy;
 	}
 
-	fmt = fmt_cpy;
 #endif
 
 	if (ctx == NULL || !(ctx->options & DHCPCD_QUIET)) {
Index: src/external/bsd/dhcpcd/dist/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/ipv6.c:1.9 src/external/bsd/dhcpcd/dist/ipv6.c:1.10
--- src/external/bsd/dhcpcd/dist/ipv6.c:1.9	Thu Mar 26 10:26:37 2015
+++ src/external/bsd/dhcpcd/dist/ipv6.c	Fri Mar 27 11:33:46 2015
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv6.c,v 1.9 2015/03/26 10:26:37 roy Exp $");
+ __RCSID("$NetBSD: ipv6.c,v 1.10 2015/03/27 11:33:46 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1822,9 +1822,6 @@ ipv6_handlert(struct dhcpcd_ctx *ctx, in
 static int
 nc_route(struct rt6 *ort, struct rt6 *nrt)
 {
-#ifdef HAVE_ROUTE_METRIC
-	int retval;
-#endif
 
 	/* Don't set default routes if not asked to */
 	if (IN6_IS_ADDR_UNSPECIFIED(&nrt->dest) &&
@@ -1849,22 +1846,30 @@ nc_route(struct rt6 *ort, struct rt6 *nr
 #ifdef HAVE_ROUTE_METRIC
 	/* With route metrics, we can safely add the new route before
 	 * deleting the old route. */
-	if ((retval = if_route6(RTM_ADD, nrt)) == -1)
-		logger(nrt->iface->ctx, LOG_ERR, "if_route6 (ADD): %m");
-	if (ort && if_route6(RTM_DELETE, ort) == -1 &&
-	    errno != ESRCH)
-		logger(nrt->iface->ctx, LOG_ERR, "if_route6 (DEL): %m");
-	return retval;
-#else
+	if (if_route6(RTM_ADD, nrt) == 0) {
+		if (ort && if_route6(RTM_DELETE, ort) == -1 &&
+		    errno != ESRCH)
+			logger(nrt->iface->ctx, LOG_ERR, "if_route6 (DEL): %m");
+		return 0;
+	}
+
+	/* If the kernel claims the route exists we need to rip out the
+	 * old one first. */
+	if (errno != EEXIST || ort == NULL)
+		goto logerr;
+#endif
+
 	/* No route metrics, we need to delete the old route before
 	 * adding the new one. */
 	if (ort && if_route6(RTM_DELETE, ort) == -1 && errno != ESRCH)
 		logger(nrt->iface->ctx, LOG_ERR, "if_route6: %m");
 	if (if_route6(RTM_ADD, nrt) == 0)
 		return 0;
+#ifdef HAVE_ROUTE_METRIC
+logerr:
+#endif
 	logger(nrt->iface->ctx, LOG_ERR, "if_route6 (ADD): %m");
 	return -1;
-#endif
 }
 
 static int

Index: src/external/bsd/dhcpcd/dist/defs.h
diff -u src/external/bsd/dhcpcd/dist/defs.h:1.15 src/external/bsd/dhcpcd/dist/defs.h:1.16
--- src/external/bsd/dhcpcd/dist/defs.h:1.15	Thu Mar 26 10:26:37 2015
+++ src/external/bsd/dhcpcd/dist/defs.h	Fri Mar 27 11:33:46 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.15 2015/03/26 10:26:37 roy Exp $ */
+/* $NetBSD: defs.h,v 1.16 2015/03/27 11:33:46 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE			"dhcpcd"
-#define VERSION			"6.8.0"
+#define VERSION			"6.8.1"
 
 #ifndef CONFIG
 # define CONFIG			SYSCONFDIR "/" PACKAGE ".conf"

Index: src/external/bsd/dhcpcd/dist/if-options.c
diff -u src/external/bsd/dhcpcd/dist/if-options.c:1.21 src/external/bsd/dhcpcd/dist/if-options.c:1.22
--- src/external/bsd/dhcpcd/dist/if-options.c:1.21	Thu Mar 26 10:26:37 2015
+++ src/external/bsd/dhcpcd/dist/if-options.c	Fri Mar 27 11:33:46 2015
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if-options.c,v 1.21 2015/03/26 10:26:37 roy Exp $");
+ __RCSID("$NetBSD: if-options.c,v 1.22 2015/03/27 11:33:46 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -53,6 +53,7 @@
 #include "dhcp.h"
 #include "dhcp6.h"
 #include "dhcpcd-embedded.h"
+#include "if.h"
 #include "if-options.h"
 #include "ipv4.h"
 
@@ -1041,7 +1042,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 				}
 				TAILQ_INIT(ifo->routes);
 			}
-			rt = malloc(sizeof(*rt));
+			rt = calloc(1, sizeof(*rt));
 			if (rt == NULL) {
 				logger(ctx, LOG_ERR, "%s: %m", __func__);
 				*fp = ' ';
@@ -1066,7 +1067,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 				}
 				TAILQ_INIT(ifo->routes);
 			}
-			rt = malloc(sizeof(*rt));
+			rt = calloc(1, sizeof(*rt));
 			if (rt == NULL) {
 				logger(ctx, LOG_ERR, "%s: %m", __func__);
 				return -1;

Index: src/external/bsd/dhcpcd/dist/ipv4.c
diff -u src/external/bsd/dhcpcd/dist/ipv4.c:1.12 src/external/bsd/dhcpcd/dist/ipv4.c:1.13
--- src/external/bsd/dhcpcd/dist/ipv4.c:1.12	Thu Mar 26 10:26:37 2015
+++ src/external/bsd/dhcpcd/dist/ipv4.c	Fri Mar 27 11:33:46 2015
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv4.c,v 1.12 2015/03/26 10:26:37 roy Exp $");
+ __RCSID("$NetBSD: ipv4.c,v 1.13 2015/03/27 11:33:46 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -335,6 +335,12 @@ ipv4_handlert(struct dhcpcd_ctx *ctx, in
 	if (ctx->ipv4_kroutes == NULL)
 		return 0;
 
+	/* DHCP host routes have a gateway of the destination.
+	 * We need to emulate that */
+	if (rt->gate.s_addr == INADDR_ANY &&
+	    rt->net.s_addr == INADDR_BROADCAST)
+		rt->gate = rt->dest;
+
 	f = ipv4_findrt(ctx, rt, 1);
 	switch (cmd) {
 	case RTM_ADD:
@@ -367,9 +373,6 @@ ipv4_handlert(struct dhcpcd_ctx *ctx, in
 static int
 nc_route(struct rt *ort, struct rt *nrt)
 {
-#ifdef HAVE_ROUTE_METRIC
-	int retval;
-#endif
 
 	/* Don't set default routes if not asked to */
 	if (nrt->dest.s_addr == 0 &&
@@ -402,21 +405,29 @@ nc_route(struct rt *ort, struct rt *nrt)
 #ifdef HAVE_ROUTE_METRIC
 	/* With route metrics, we can safely add the new route before
 	 * deleting the old route. */
-	if ((retval = if_route(RTM_ADD, nrt))  == -1)
-		logger(nrt->iface->ctx, LOG_ERR, "if_route (ADD): %m");
-	if (ort && if_route(RTM_DELETE, ort) == -1 && errno != ESRCH)
-		logger(nrt->iface->ctx, LOG_ERR, "if_route (DEL): %m");
-	return retval;
-#else
+	if (if_route(RTM_ADD, nrt)  == 0) {
+		if (ort && if_route(RTM_DELETE, ort) == -1 && errno != ESRCH)
+			logger(nrt->iface->ctx, LOG_ERR, "if_route (DEL): %m");
+		return 0;
+	}
+
+	/* If the kernel claims the route exists we need to rip out the
+	 * old one first. */
+	if (errno != EEXIST || ort == NULL)
+		goto logerr;
+#endif
+
 	/* No route metrics, we need to delete the old route before
 	 * adding the new one. */
 	if (ort && if_route(RTM_DELETE, ort) == -1 && errno != ESRCH)
 		logger(nrt->iface->ctx, LOG_ERR, "if_route (DEL): %m");
 	if (if_route(RTM_ADD, nrt) == 0)
 		return 0;
+#ifdef HAVE_ROUTE_METRIC
+logerr:
+#endif
 	logger(nrt->iface->ctx, LOG_ERR, "if_route (ADD): %m");
 	return -1;
-#endif
 }
 
 static int
@@ -701,8 +712,10 @@ ipv4_buildroutes(struct dhcpcd_ctx *ctx)
 				free(or);
 			} else {
 				if (state->added & STATE_FAKE) {
-					if (!ipv4_findrt(ctx, rt, 1))
-						continue;
+					or = ipv4_findrt(ctx, rt, 1);
+					if (or == NULL ||
+					    or->gate.s_addr != rt->gate.s_addr)
+ 						continue;
 				} else {
 					if (n_route(rt) != 0)
 						continue;

Index: src/external/bsd/dhcpcd/dist/crypt/hmac_md5.c
diff -u src/external/bsd/dhcpcd/dist/crypt/hmac_md5.c:1.6 src/external/bsd/dhcpcd/dist/crypt/hmac_md5.c:1.7
--- src/external/bsd/dhcpcd/dist/crypt/hmac_md5.c:1.6	Fri Jan 30 09:47:05 2015
+++ src/external/bsd/dhcpcd/dist/crypt/hmac_md5.c	Fri Mar 27 11:33:47 2015
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: hmac_md5.c,v 1.6 2015/01/30 09:47:05 roy Exp $");
+ __RCSID("$NetBSD: hmac_md5.c,v 1.7 2015/03/27 11:33:47 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -60,7 +60,7 @@ hmac_md5(const uint8_t *text, size_t tex
 	/* Ensure key is no bigger than HMAC_PAD_LEN */
 	if (key_len > HMAC_PAD_LEN) {
 		MD5Init(&context);
-		MD5Update(&context, key, key_len);
+		MD5Update(&context, key, (unsigned int)key_len);
 		MD5Final(tk, &context);
 		key = tk;
 		key_len = MD5_DIGEST_LENGTH;
@@ -81,7 +81,7 @@ hmac_md5(const uint8_t *text, size_t tex
 	/* inner MD5 */
 	MD5Init(&context);
 	MD5Update(&context, k_ipad, HMAC_PAD_LEN);
-	MD5Update(&context, text, text_len);
+	MD5Update(&context, text, (unsigned int)text_len);
 	MD5Final(digest, &context);
 
 	/* outer MD5 */

Reply via email to