Module Name:    src
Committed By:   roy
Date:           Wed Apr 20 08:53:01 UTC 2016

Modified Files:
        src/external/bsd/dhcpcd/dist: arp.c arp.h control.c defs.h
            dhcp-common.c dhcp-common.h dhcp.c dhcp6.c dhcpcd-definitions.conf
            dhcpcd-embedded.c dhcpcd-embedded.h dhcpcd.c dhcpcd.conf.5.in
            if-bsd.c if-options.c if.c if.h ipv4ll.c ipv6nd.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/dhcpcd/dist/arp.c
cvs rdiff -u -r1.11 -r1.12 src/external/bsd/dhcpcd/dist/arp.h \
    src/external/bsd/dhcpcd/dist/control.c \
    src/external/bsd/dhcpcd/dist/dhcp-common.h \
    src/external/bsd/dhcpcd/dist/dhcpcd-definitions.conf
cvs rdiff -u -r1.25 -r1.26 src/external/bsd/dhcpcd/dist/defs.h \
    src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
cvs rdiff -u -r1.13 -r1.14 src/external/bsd/dhcpcd/dist/dhcp-common.c
cvs rdiff -u -r1.38 -r1.39 src/external/bsd/dhcpcd/dist/dhcp.c
cvs rdiff -u -r1.19 -r1.20 src/external/bsd/dhcpcd/dist/dhcp6.c \
    src/external/bsd/dhcpcd/dist/if.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h
cvs rdiff -u -r1.32 -r1.33 src/external/bsd/dhcpcd/dist/dhcpcd.c
cvs rdiff -u -r1.28 -r1.29 src/external/bsd/dhcpcd/dist/if-bsd.c \
    src/external/bsd/dhcpcd/dist/ipv6nd.c
cvs rdiff -u -r1.31 -r1.32 src/external/bsd/dhcpcd/dist/if-options.c
cvs rdiff -u -r1.14 -r1.15 src/external/bsd/dhcpcd/dist/if.h \
    src/external/bsd/dhcpcd/dist/ipv4ll.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/arp.c
diff -u src/external/bsd/dhcpcd/dist/arp.c:1.17 src/external/bsd/dhcpcd/dist/arp.c:1.18
--- src/external/bsd/dhcpcd/dist/arp.c:1.17	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/arp.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: arp.c,v 1.17 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: arp.c,v 1.18 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -58,7 +58,7 @@
 #define ARP_LEN								      \
 	(sizeof(struct arphdr) + (2 * sizeof(uint32_t)) + (2 * HWADDR_LEN))
 
-static ssize_t
+ssize_t
 arp_request(const struct interface *ifp, in_addr_t sip, in_addr_t tip)
 {
 	uint8_t arp_buffer[ARP_LEN];

Index: src/external/bsd/dhcpcd/dist/arp.h
diff -u src/external/bsd/dhcpcd/dist/arp.h:1.11 src/external/bsd/dhcpcd/dist/arp.h:1.12
--- src/external/bsd/dhcpcd/dist/arp.h:1.11	Thu Jul  9 10:15:34 2015
+++ src/external/bsd/dhcpcd/dist/arp.h	Wed Apr 20 08:53:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: arp.h,v 1.11 2015/07/09 10:15:34 roy Exp $ */
+/* $NetBSD: arp.h,v 1.12 2016/04/20 08:53:01 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -79,6 +79,7 @@ struct iarp_state {
 	((const struct iarp_state *)(ifp)->if_data[IF_DATA_ARP])
 
 #ifdef INET
+ssize_t arp_request(const struct interface *, in_addr_t, in_addr_t);
 void arp_report_conflicted(const struct arp_state *, const struct arp_msg *);
 void arp_announce(struct arp_state *);
 void arp_probe(struct arp_state *);
Index: src/external/bsd/dhcpcd/dist/control.c
diff -u src/external/bsd/dhcpcd/dist/control.c:1.11 src/external/bsd/dhcpcd/dist/control.c:1.12
--- src/external/bsd/dhcpcd/dist/control.c:1.11	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/control.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: control.c,v 1.11 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: control.c,v 1.12 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -211,7 +211,7 @@ make_sock(struct sockaddr_un *sa, const 
 	int fd;
 
 #define SOCK_FLAGS	SOCK_CLOEXEC | SOCK_NONBLOCK
-	if ((fd = xsocket(AF_UNIX, SOCK_STREAM, 0, SOCK_FLAGS)) == -1)
+	if ((fd = xsocket(AF_UNIX, SOCK_STREAM | SOCK_FLAGS, 0)) == -1)
 		return -1;
 #undef SOCK_FLAGS
 	memset(sa, 0, sizeof(*sa));
Index: src/external/bsd/dhcpcd/dist/dhcp-common.h
diff -u src/external/bsd/dhcpcd/dist/dhcp-common.h:1.11 src/external/bsd/dhcpcd/dist/dhcp-common.h:1.12
--- src/external/bsd/dhcpcd/dist/dhcp-common.h:1.11	Mon Nov 30 16:33:00 2015
+++ src/external/bsd/dhcpcd/dist/dhcp-common.h	Wed Apr 20 08:53:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcp-common.h,v 1.11 2015/11/30 16:33:00 roy Exp $ */
+/* $NetBSD: dhcp-common.h,v 1.12 2016/04/20 08:53:01 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -44,32 +44,33 @@
 
 #define REQUEST		(1 << 0)
 #define UINT8		(1 << 1)
-#define UINT16		(1 << 2)
-#define SINT16		(1 << 3)
-#define UINT32		(1 << 4)
-#define SINT32		(1 << 5)
-#define ADDRIPV4	(1 << 6)
-#define STRING		(1 << 7)
-#define ARRAY		(1 << 8)
-#define RFC3361		(1 << 9)
-#define RFC1035		(1 << 10)
-#define RFC3442		(1 << 11)
-#define OPTIONAL	(1 << 12)
-#define ADDRIPV6	(1 << 13)
-#define BINHEX		(1 << 14)
-#define FLAG		(1 << 15)
-#define NOREQ		(1 << 16)
-#define EMBED		(1 << 17)
-#define ENCAP		(1 << 18)
-#define INDEX		(1 << 19)
-#define OPTION		(1 << 20)
-#define DOMAIN		(1 << 21)
-#define ASCII		(1 << 22)
-#define RAW		(1 << 23)
-#define ESCSTRING	(1 << 24)
-#define ESCFILE		(1 << 25)
-#define BITFLAG		(1 << 26)
-#define RESERVED	(1 << 27)
+#define INT8		(1 << 2)
+#define UINT16		(1 << 3)
+#define INT16		(1 << 4)
+#define UINT32		(1 << 5)
+#define INT32		(1 << 6)
+#define ADDRIPV4	(1 << 7)
+#define STRING		(1 << 8)
+#define ARRAY		(1 << 9)
+#define RFC3361		(1 << 10)
+#define RFC1035		(1 << 11)
+#define RFC3442		(1 << 12)
+#define OPTIONAL	(1 << 13)
+#define ADDRIPV6	(1 << 14)
+#define BINHEX		(1 << 15)
+#define FLAG		(1 << 16)
+#define NOREQ		(1 << 17)
+#define EMBED		(1 << 18)
+#define ENCAP		(1 << 19)
+#define INDEX		(1 << 20)
+#define OPTION		(1 << 21)
+#define DOMAIN		(1 << 22)
+#define ASCII		(1 << 23)
+#define RAW		(1 << 24)
+#define ESCSTRING	(1 << 25)
+#define ESCFILE		(1 << 26)
+#define BITFLAG		(1 << 27)
+#define RESERVED	(1 << 28)
 
 struct dhcp_opt {
 	uint32_t option; /* Also used for IANA Enterpise Number */
Index: src/external/bsd/dhcpcd/dist/dhcpcd-definitions.conf
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-definitions.conf:1.11 src/external/bsd/dhcpcd/dist/dhcpcd-definitions.conf:1.12
--- src/external/bsd/dhcpcd/dist/dhcpcd-definitions.conf:1.11	Thu Jan  7 20:09:43 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd-definitions.conf	Wed Apr 20 08:53:01 2016
@@ -1,4 +1,4 @@
-# $NetBSD: dhcpcd-definitions.conf,v 1.11 2016/01/07 20:09:43 roy Exp $
+# $NetBSD: dhcpcd-definitions.conf,v 1.12 2016/04/20 08:53:01 roy Exp $
 
 # Copyright (c) 2006-2016 Roy Marples
 # All rights reserved
@@ -120,7 +120,20 @@ embed		optional domain		fqdn
 
 # Option 82 is for Relay Agents and DHCP servers
 
-# Options 83 ad 84 are unused, RFC3679
+# iSNS, RFC4174
+define 83	embed			isns
+embed		byte			reserved1
+embed		bitflags=00000SAE	functions
+embed		byte			reserved2
+embed		bitflags=00fFsSCE	dd
+embed		byte			reserved3
+embed		bitflags=0000DMHE	admin
+embed		uint16			reserved4
+embed		byte			reserved5
+embed		bitflags=0TXPAMSE	server_security
+embed		array ipaddress		servers
+
+# Option 84 are unused, RFC3679
 
 # DHCP Novell Directory Services, RFC2241
 define 85	array ipaddress		nds_servers

Index: src/external/bsd/dhcpcd/dist/defs.h
diff -u src/external/bsd/dhcpcd/dist/defs.h:1.25 src/external/bsd/dhcpcd/dist/defs.h:1.26
--- src/external/bsd/dhcpcd/dist/defs.h:1.25	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/defs.h	Wed Apr 20 08:53:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.25 2016/04/10 21:00:53 roy Exp $ */
+/* $NetBSD: defs.h,v 1.26 2016/04/20 08:53:01 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -30,7 +30,7 @@
 #define CONFIG_H
 
 #define PACKAGE			"dhcpcd"
-#define VERSION			"6.10.2"
+#define VERSION			"6.10.3"
 
 #ifndef CONFIG
 # define CONFIG			SYSCONFDIR "/" PACKAGE ".conf"
Index: src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.25 src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.26
--- src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in:1.25	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd.conf.5.in	Wed Apr 20 08:53:01 2016
@@ -1,4 +1,4 @@
-.\"     $NetBSD: dhcpcd.conf.5.in,v 1.25 2016/04/10 21:00:53 roy Exp $
+.\"     $NetBSD: dhcpcd.conf.5.in,v 1.26 2016/04/20 08:53:01 roy Exp $
 .\" Copyright (c) 2006-2016 Roy Marples
 .\" All rights reserved
 .\"
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd March 30, 2016
+.Dd April 16, 2016
 .Dt DHCPCD.CONF 5
 .Os
 .Sh NAME
@@ -303,10 +303,9 @@ This option must be used in an
 block.
 Unless a
 .Ar sla_id
-of 0 is assigned, a reject route is installed for the Delegated Prefix to
+of 0 is assigned with the same resultant prefix length as the delegation,
+a reject route is installed for the Delegated Prefix to
 stop unallocated addresses being resolved upstream.
-This reject route is in essence SLA 0, thus you need space within the prefix
-to assign a SLA per interface.
 If no
 .Ar interface
 is given then we will assign a prefix to every other interface with a
@@ -341,7 +340,10 @@ is increased to the highest multiple of 
 is an integer and is added to the prefix which must fit inside
 .Ar prefix_len
 less the length of the delegated prefix.
-.Ar sla_id can be 0 only if the Delegated Prefix is assigned to one interface.
+.Ar sla_id
+can be 0 only if the Delegated Prefix is assigned to one interface.
+This violates RFC3633 12.1 and should only be used if the Delegated Prefix
+length is 64 and you need to delegate it to a downstream interface.
 You can specify multiple
 .Ar interface /
 .Ar sla_id /

Index: src/external/bsd/dhcpcd/dist/dhcp-common.c
diff -u src/external/bsd/dhcpcd/dist/dhcp-common.c:1.13 src/external/bsd/dhcpcd/dist/dhcp-common.c:1.14
--- src/external/bsd/dhcpcd/dist/dhcp-common.c:1.13	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcp-common.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp-common.c,v 1.13 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: dhcp-common.c,v 1.14 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -103,15 +103,17 @@ dhcp_print_option_encoding(const struct 
 	if (opt->type & ARRAY)
 		printf(" array");
 	if (opt->type & UINT8)
-		printf(" byte");
+		printf(" uint8");
+	else if (opt->type & INT8)
+		printf(" int8");
 	else if (opt->type & UINT16)
 		printf(" uint16");
-	else if (opt->type & SINT16)
-		printf(" sint16");
+	else if (opt->type & INT16)
+		printf(" int16");
 	else if (opt->type & UINT32)
 		printf(" uint32");
-	else if (opt->type & SINT32)
-		printf(" sint32");
+	else if (opt->type & INT32)
+		printf(" int32");
 	else if (opt->type & ADDRIPV4)
 		printf(" ipaddress");
 	else if (opt->type & ADDRIPV6)
@@ -208,6 +210,8 @@ make_option_mask(const struct dhcp_opt *
 			continue;
 		match = 0;
 		for (i = 0, opt = odopts; i < odopts_len; i++, opt++) {
+			if (opt->var == NULL && opt->option == 0)
+				continue; /* buggy dhcpcd-definitions.conf */
 			if (strcmp(opt->var, token) == 0)
 				match = 1;
 			else {
@@ -590,11 +594,11 @@ dhcp_optlen(const struct dhcp_opt *opt, 
 
 	if (opt->type & ADDRIPV6)
 		sz = ADDR6SZ;
-	else if (opt->type & (UINT32 | ADDRIPV4))
+	else if (opt->type & (INT32 | UINT32 | ADDRIPV4))
 		sz = sizeof(uint32_t);
-	else if (opt->type & UINT16)
+	else if (opt->type & (INT16 | UINT16))
 		sz = sizeof(uint16_t);
-	else if (opt->type & (UINT8 | BITFLAG))
+	else if (opt->type & (INT8 | UINT8 | BITFLAG))
 		sz = sizeof(uint8_t);
 	else if (opt->type & FLAG)
 		return 0;
@@ -733,16 +737,18 @@ print_option(char *s, size_t len, const 
 	if (!s) {
 		if (opt->type & UINT8)
 			l = 3;
+		else if (opt->type & INT8)
+			l = 4;
 		else if (opt->type & UINT16) {
 			l = 5;
 			dl /= 2;
-		} else if (opt->type & SINT16) {
+		} else if (opt->type & INT16) {
 			l = 6;
 			dl /= 2;
 		} else if (opt->type & UINT32) {
 			l = 10;
 			dl /= 4;
-		} else if (opt->type & SINT32) {
+		} else if (opt->type & INT32) {
 			l = 11;
 			dl /= 4;
 		} else if (opt->type & ADDRIPV4) {
@@ -779,12 +785,15 @@ print_option(char *s, size_t len, const 
 		if (opt->type & UINT8) {
 			sl = snprintf(s, len, "%u", *data);
 			data++;
+		} else if (opt->type & INT8) {
+			sl = snprintf(s, len, "%d", *data);
+			data++;
 		} else if (opt->type & UINT16) {
 			memcpy(&u16, data, sizeof(u16));
 			u16 = ntohs(u16);
 			sl = snprintf(s, len, "%u", u16);
 			data += sizeof(u16);
-		} else if (opt->type & SINT16) {
+		} else if (opt->type & INT16) {
 			memcpy(&u16, data, sizeof(u16));
 			s16 = (int16_t)ntohs(u16);
 			sl = snprintf(s, len, "%d", s16);
@@ -794,7 +803,7 @@ print_option(char *s, size_t len, const 
 			u32 = ntohl(u32);
 			sl = snprintf(s, len, "%u", u32);
 			data += sizeof(u32);
-		} else if (opt->type & SINT32) {
+		} else if (opt->type & INT32) {
 			memcpy(&u32, data, sizeof(u32));
 			s32 = (int32_t)ntohl(u32);
 			sl = snprintf(s, len, "%d", s32);

Index: src/external/bsd/dhcpcd/dist/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/dhcp.c:1.38 src/external/bsd/dhcpcd/dist/dhcp.c:1.39
--- src/external/bsd/dhcpcd/dist/dhcp.c:1.38	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcp.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp.c,v 1.38 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: dhcp.c,v 1.39 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1492,7 +1492,7 @@ dhcp_openudp(struct interface *ifp)
 	char *p;
 #endif
 
-	if ((s = xsocket(PF_INET, SOCK_DGRAM, IPPROTO_UDP, SOCK_CLOEXEC)) == -1)
+	if ((s = xsocket(PF_INET, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP)) == -1)
 		return -1;
 
 	n = 1;

Index: src/external/bsd/dhcpcd/dist/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/dhcp6.c:1.19 src/external/bsd/dhcpcd/dist/dhcp6.c:1.20
--- src/external/bsd/dhcpcd/dist/dhcp6.c:1.19	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcp6.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcp6.c,v 1.19 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: dhcp6.c,v 1.20 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -440,7 +440,7 @@ dhcp6_delegateaddr(struct in6_addr *addr
 		else {
 			asla.prefix_len = (uint8_t)(prefix->prefix_len + bits);
 
-			/* Make a 64 prefix by default, as this maks SLAAC
+			/* Make a 64 prefix by default, as this makes SLAAC
 			 * possible.
 			 * Otherwise round up to the nearest 4 bits. */
 			if (asla.prefix_len <= 64)
@@ -458,7 +458,9 @@ dhcp6_delegateaddr(struct in6_addr *addr
 			    prefix->prefix_len);
 	}
 
-	if (ipv6_userprefix(&prefix->prefix, prefix->prefix_len,
+	if (sla->sla == 0) {
+		*addr = prefix->prefix;
+	} else if (ipv6_userprefix(&prefix->prefix, prefix->prefix_len,
 		sla->sla, addr, sla->prefix_len) == -1)
 	{
 		sa = inet_ntop(AF_INET6, &prefix->prefix,
@@ -2392,6 +2394,11 @@ dhcp6_ifdelegateaddr(struct interface *i
 	a->prefix = addr;
 	a->prefix_len = (uint8_t)pfxlen;
 
+	/* If sla is zero and the prefix length hasn't changed,
+	 * don't install a blackhole route. */
+	if (sla->sla_set && sla->sla == 0 && prefix->prefix_len == pfxlen)
+		prefix->flags |= IPV6_AF_DELEGATEDZERO;
+
 	/* Add our suffix */
 	if (sla->suffix) {
 		a->addr = addr;
@@ -2515,9 +2522,6 @@ dhcp6_delegate_prefix(struct interface *
 				}
 				for (j = 0; j < ia->sla_len; j++) {
 					sla = &ia->sla[j];
-					if (sla->sla_set && sla->sla == 0)
-						ap->flags |=
-						    IPV6_AF_DELEGATEDZERO;
 					if (strcmp(ifd->name, sla->ifname))
 						continue;
 					if (ifd->carrier != LINK_UP) {
@@ -3139,7 +3143,7 @@ dhcp6_open(struct dhcpcd_ctx *dctx)
 
 	ctx = dctx->ipv6;
 #define SOCK_FLAGS	SOCK_CLOEXEC | SOCK_NONBLOCK
-	ctx->dhcp_fd = xsocket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP, SOCK_FLAGS);
+	ctx->dhcp_fd = xsocket(PF_INET6, SOCK_DGRAM | SOCK_FLAGS, IPPROTO_UDP);
 #undef SOCK_FLAGS
 	if (ctx->dhcp_fd == -1)
 		return -1;
Index: src/external/bsd/dhcpcd/dist/if.c
diff -u src/external/bsd/dhcpcd/dist/if.c:1.19 src/external/bsd/dhcpcd/dist/if.c:1.20
--- src/external/bsd/dhcpcd/dist/if.c:1.19	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/if.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if.c,v 1.19 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: if.c,v 1.20 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -96,12 +96,12 @@ if_opensockets(struct dhcpcd_ctx *ctx)
 		return -1;
 
 	/* We use this socket for some operations without INET. */
-	ctx->pf_inet_fd = xsocket(PF_INET, SOCK_DGRAM, 0, SOCK_CLOEXEC);
+	ctx->pf_inet_fd = xsocket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
 	if (ctx->pf_inet_fd == -1)
 		return -1;
 
 #ifdef IFLR_ACTIVE
-	ctx->pf_link_fd = xsocket(PF_LINK, SOCK_DGRAM, 0, SOCK_CLOEXEC);
+	ctx->pf_link_fd = xsocket(PF_LINK, SOCK_DGRAM | SOCK_CLOEXEC, 0);
 	if (ctx->pf_link_fd == -1)
 		return -1;
 #endif
@@ -686,32 +686,32 @@ if_sortinterfaces(struct dhcpcd_ctx *ctx
 }
 
 int
-xsocket(int domain, int type, int protocol, int flags)
+xsocket(int domain, int type, int protocol)
 {
 	int s;
 #if !defined(HAVE_SOCK_CLOEXEC) || !defined(HAVE_SOCK_NONBLOCK)
-	int xflags;
+	int xflags, xtype = type;
 #endif
 
-#ifdef HAVE_SOCK_CLOEXEC
-	if (flags & SOCK_CLOEXEC)
-		type |= SOCK_CLOEXEC;
+#ifndef HAVE_SOCK_CLOEXEC
+	if (xtype & SOCK_CLOEXEC)
+		type &= ~SOCK_CLOEXEC;
 #endif
-#ifdef HAVE_SOCK_NONBLOCK
-	if (flags & SOCK_NONBLOCK)
-		type |= SOCK_NONBLOCK;
+#ifndef HAVE_SOCK_NONBLOCK
+	if (xtype & SOCK_NONBLOCK)
+		type &= ~SOCK_NONBLOCK;
 #endif
 
 	if ((s = socket(domain, type, protocol)) == -1)
 		return -1;
 
 #ifndef HAVE_SOCK_CLOEXEC
-	if ((flags & SOCK_CLOEXEC) && ((xflags = fcntl(s, F_GETFD)) == -1 ||
+	if ((xtype & SOCK_CLOEXEC) && ((xflags = fcntl(s, F_GETFD)) == -1 ||
 	    fcntl(s, F_SETFD, xflags | FD_CLOEXEC) == -1))
 		goto out;
 #endif
 #ifndef HAVE_SOCK_NONBLOCK
-	if ((flags & SOCK_NONBLOCK) && ((xflags = fcntl(s, F_GETFL)) == -1 ||
+	if ((xtype & SOCK_NONBLOCK) && ((xflags = fcntl(s, F_GETFL)) == -1 ||
 	    fcntl(s, F_SETFL, xflags | O_NONBLOCK) == -1))
 		goto out;
 #endif

Index: src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c:1.12 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c:1.13
--- src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c:1.12	Thu Jan  7 20:09:43 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd-embedded.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd-embedded.c,v 1.12 2016/01/07 20:09:43 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd-embedded.c,v 1.13 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * DO NOT EDIT!
@@ -126,6 +126,17 @@ const char * const dhcpcd_embedded_conf[
 "embed byte rcode1",
 "embed byte rcode2",
 "embed optional domain fqdn",
+"define 83 embed isns",
+"embed byte reserved1",
+"embed bitflags=00000SAE functions",
+"embed byte reserved2",
+"embed bitflags=00fFsSCE dd",
+"embed byte reserved3",
+"embed bitflags=0000DMHE admin",
+"embed uint16 reserved4",
+"embed byte reserved5",
+"embed bitflags=0TXPAMSE server_security",
+"embed array ipaddress servers",
 "define 85 array ipaddress nds_servers",
 "define 86 raw nds_tree_name",
 "define 87 raw nds_context",

Index: src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h
diff -u src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h:1.9 src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h:1.10
--- src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h:1.9	Thu Jul  9 10:15:34 2015
+++ src/external/bsd/dhcpcd/dist/dhcpcd-embedded.h	Wed Apr 20 08:53:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: dhcpcd-embedded.h,v 1.9 2015/07/09 10:15:34 roy Exp $ */
+/* $NetBSD: dhcpcd-embedded.h,v 1.10 2016/04/20 08:53:01 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  */
 
-#define INITDEFINES	     122
+#define INITDEFINES	     123
 #define INITDEFINENDS	       6
 #define INITDEFINE6S	      68
 

Index: src/external/bsd/dhcpcd/dist/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/dhcpcd.c:1.32 src/external/bsd/dhcpcd/dist/dhcpcd.c:1.33
--- src/external/bsd/dhcpcd/dist/dhcpcd.c:1.32	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/dhcpcd.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: dhcpcd.c,v 1.32 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: dhcpcd.c,v 1.33 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -348,24 +348,19 @@ dhcpcd_daemonise(struct dhcpcd_ctx *ctx)
 			dup2(fd, STDERR_FILENO);
 			close(fd);
 		}
-		break;
+		ctx->options |= DHCPCD_DAEMONISED;
+		return 0;
 	default:
 		/* Wait for child to detach */
 		close(sidpipe[1]);
 		if (read(sidpipe[0], &buf, 1) == -1)
 			logger(ctx, LOG_ERR, "failed to read child: %m");
 		close(sidpipe[0]);
-		break;
-	}
-	/* Done with the fd now */
-	if (pid != 0) {
 		logger(ctx, LOG_INFO, "forked to background, child pid %d", pid);
 		ctx->options |= DHCPCD_FORKED;
 		eloop_exit(ctx->eloop, EXIT_SUCCESS);
 		return pid;
 	}
-	ctx->options |= DHCPCD_DAEMONISED;
-	return pid;
 #endif
 }
 
@@ -1803,7 +1798,7 @@ printpidfile:
 			if (pid == -1)
 				logger(&ctx, LOG_ERR, "%s: pidfile_lock: %m",
 				    __func__);
-			else	
+			else
 				logger(&ctx, LOG_ERR, ""PACKAGE
 				    " already running on pid %d (%s)",
 				    pid, ctx.pidfile);

Index: src/external/bsd/dhcpcd/dist/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/if-bsd.c:1.28 src/external/bsd/dhcpcd/dist/if-bsd.c:1.29
--- src/external/bsd/dhcpcd/dist/if-bsd.c:1.28	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/if-bsd.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if-bsd.c,v 1.28 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: if-bsd.c,v 1.29 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -136,7 +136,7 @@ if_opensockets_os(struct dhcpcd_ctx *ctx
 	ctx->priv = priv;
 
 #ifdef INET6
-	priv->pf_inet6_fd = xsocket(PF_INET6, SOCK_DGRAM, 0, SOCK_CLOEXEC);
+	priv->pf_inet6_fd = xsocket(PF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0);
 	/* Don't return an error so we at least work on kernels witout INET6
 	 * even though we expect INET6 support.
 	 * We will fail noisily elsewhere anyway. */
@@ -144,8 +144,9 @@ if_opensockets_os(struct dhcpcd_ctx *ctx
 	priv->pf_inet6_fd = -1;
 #endif
 
-	ctx->link_fd = xsocket(PF_ROUTE, SOCK_RAW, 0,
-	    SOCK_CLOEXEC | SOCK_NONBLOCK);
+#define SOCK_FLAGS	(SOCK_CLOEXEC | SOCK_NONBLOCK)
+	ctx->link_fd = xsocket(PF_ROUTE, SOCK_RAW | SOCK_FLAGS, 0);
+#undef SOCK_FLAGS
 	return ctx->link_fd == -1 ? -1 : 0;
 }
 
Index: src/external/bsd/dhcpcd/dist/ipv6nd.c
diff -u src/external/bsd/dhcpcd/dist/ipv6nd.c:1.28 src/external/bsd/dhcpcd/dist/ipv6nd.c:1.29
--- src/external/bsd/dhcpcd/dist/ipv6nd.c:1.28	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/ipv6nd.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv6nd.c,v 1.28 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: ipv6nd.c,v 1.29 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -193,7 +193,7 @@ ipv6nd_open(struct dhcpcd_ctx *dctx)
 	if (ctx->nd_fd != -1)
 		return ctx->nd_fd;
 #define SOCK_FLAGS	SOCK_CLOEXEC | SOCK_NONBLOCK
-	ctx->nd_fd = xsocket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6, SOCK_FLAGS);
+	ctx->nd_fd = xsocket(PF_INET6, SOCK_RAW | SOCK_FLAGS, IPPROTO_ICMPV6);
 #undef SOCK_FLAGS
 	if (ctx->nd_fd == -1)
 		return -1;
@@ -258,6 +258,15 @@ ipv6nd_makersprobe(struct interface *ifp
 	return 0;
 }
 
+static void ipv6nd_dropdhcp6(struct interface *ifp)
+{
+	const struct dhcp6_state *d6;
+
+	/* Don't drop DHCP6 if the interface is delegated to. */
+	if ((d6 = D6_CSTATE(ifp)) != NULL && d6->state != DH6S_DELEGATED)
+		dhcp6_drop(ifp, "EXPIRE6");
+}
+
 static void
 ipv6nd_sendrsprobe(void *arg)
 {
@@ -321,7 +330,7 @@ ipv6nd_sendrsprobe(void *arg)
 		logger(ifp->ctx, LOG_WARNING,
 		    "%s: no IPv6 Routers available", ifp->name);
 		ipv6nd_drop(ifp);
-		dhcp6_drop(ifp, "EXPIRE6");
+		ipv6nd_dropdhcp6(ifp);
 	}
 }
 
@@ -1386,7 +1395,7 @@ ipv6nd_expirera(void *arg)
 
 	/* No valid routers? Kill any DHCPv6. */
 	if (!validone)
-		dhcp6_drop(ifp, "EXPIRE6");
+		ipv6nd_dropdhcp6(ifp);
 }
 
 void

Index: src/external/bsd/dhcpcd/dist/if-options.c
diff -u src/external/bsd/dhcpcd/dist/if-options.c:1.31 src/external/bsd/dhcpcd/dist/if-options.c:1.32
--- src/external/bsd/dhcpcd/dist/if-options.c:1.31	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/if-options.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: if-options.c,v 1.31 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: if-options.c,v 1.32 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -1447,6 +1447,13 @@ parse_option(struct dhcpcd_ctx *ctx, con
 						    ifname);
 						goto err_sla;
 					}
+					if (sla->sla == 0) {
+						logger(ctx, LOG_WARNING,
+						    "%s: sla of 0 is not "
+						    "RFC3633 (section 12.1) "
+						    "compliant",
+						    ifname);
+					}
 				}
 				p = np;
 			}
@@ -1686,14 +1693,18 @@ err_sla:
 			t |= UINT8;
 		else if (strcasecmp(arg, "bitflags") == 0)
 			t |= BITFLAG;
+		else if (strcasecmp(arg, "uint8") == 0)
+			t |= UINT8;
+		else if (strcasecmp(arg, "int8") == 0)
+			t |= INT8;
 		else if (strcasecmp(arg, "uint16") == 0)
 			t |= UINT16;
 		else if (strcasecmp(arg, "int16") == 0)
-			t |= SINT16;
+			t |= INT16;
 		else if (strcasecmp(arg, "uint32") == 0)
 			t |= UINT32;
 		else if (strcasecmp(arg, "int32") == 0)
-			t |= SINT32;
+			t |= INT32;
 		else if (strcasecmp(arg, "flag") == 0)
 			t |= FLAG;
 		else if (strcasecmp(arg, "raw") == 0)

Index: src/external/bsd/dhcpcd/dist/if.h
diff -u src/external/bsd/dhcpcd/dist/if.h:1.14 src/external/bsd/dhcpcd/dist/if.h:1.15
--- src/external/bsd/dhcpcd/dist/if.h:1.14	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/if.h	Wed Apr 20 08:53:01 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.14 2016/04/10 21:00:53 roy Exp $ */
+/* $NetBSD: if.h,v 1.15 2016/04/20 08:53:01 roy Exp $ */
 
 /*
  * dhcpcd - DHCP client daemon
@@ -176,5 +176,5 @@ int if_initrt6(struct interface *);
 #endif
 
 int if_machinearch(char *, size_t);
-int xsocket(int, int, int, int);
+int xsocket(int, int, int);
 #endif
Index: src/external/bsd/dhcpcd/dist/ipv4ll.c
diff -u src/external/bsd/dhcpcd/dist/ipv4ll.c:1.14 src/external/bsd/dhcpcd/dist/ipv4ll.c:1.15
--- src/external/bsd/dhcpcd/dist/ipv4ll.c:1.14	Sun Apr 10 21:00:53 2016
+++ src/external/bsd/dhcpcd/dist/ipv4ll.c	Wed Apr 20 08:53:01 2016
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
- __RCSID("$NetBSD: ipv4ll.c,v 1.14 2016/04/10 21:00:53 roy Exp $");
+ __RCSID("$NetBSD: ipv4ll.c,v 1.15 2016/04/20 08:53:01 roy Exp $");
 
 /*
  * dhcpcd - DHCP client daemon
@@ -262,26 +262,38 @@ ipv4ll_conflicted(struct arp_state *asta
 	if (astate->failed.s_addr == state->addr.s_addr) {
 		struct timespec now, defend;
 
-		/* RFC 3927 Section 2.5 */
+		/* RFC 3927 Section 2.5 says a defence should
+		 * broadcast an ARP announcement.
+		 * Because the kernel will also unicast a reply to the
+		 * hardware address which requested the IP address
+		 * the other IPv4LL client will receieve two ARP
+		 * messages.
+		 * If another conflict happens within DEFEND_INTERVAL
+		 * then we must drop our address and negotiate a new one. */
 		defend.tv_sec = state->defend.tv_sec + DEFEND_INTERVAL;
 		defend.tv_nsec = state->defend.tv_nsec;
 		clock_gettime(CLOCK_MONOTONIC, &now);
-		if (timespeccmp(&defend, &now, >)) {
+		if (timespeccmp(&defend, &now, >))
 			logger(ifp->ctx, LOG_WARNING,
 			    "%s: IPv4LL %d second defence failed for %s",
 			    ifp->name, DEFEND_INTERVAL,
 			    inet_ntoa(state->addr));
-			ipv4_deladdr(ifp, &state->addr, &inaddr_llmask, 1);
-			state->down = 1;
-			script_runreason(ifp, "IPV4LL");
-			state->addr.s_addr = INADDR_ANY;
-		} else {
+		else if (arp_request(ifp,
+		    state->addr.s_addr, state->addr.s_addr) == -1)
+			logger(ifp->ctx, LOG_ERR,
+			    "%s: arp_request: %m", __func__);
+		else {
 			logger(ifp->ctx, LOG_DEBUG,
 			    "%s: defended IPv4LL address %s",
 			    ifp->name, inet_ntoa(state->addr));
 			state->defend = now;
 			return;
 		}
+
+		ipv4_deladdr(ifp, &state->addr, &inaddr_llmask, 1);
+		state->down = 1;
+		script_runreason(ifp, "IPV4LL");
+		state->addr.s_addr = INADDR_ANY;
 	}
 
 	arp_cancel(astate);

Reply via email to