Module Name:    src
Committed By:   martin
Date:           Sat Aug 25 15:03:00 UTC 2018

Modified Files:
        src/doc [netbsd-7]: 3RDPARTY
        src/external/bsd/dhcpcd/dist/src [netbsd-7]: defs.h dhcp.c dhcp6.c
            if-bsd.c if.c ipv4.c ipv6.c

Log Message:
Sync to head the following, requested by roy in ticket #1633:

        external/bsd/dhcpcd/dist/src/defs.h             up to 1.1.1.16
        external/bsd/dhcpcd/dist/src/dhcp.c             up to 1.13
        external/bsd/dhcpcd/dist/src/dhcp6.c            up to 1.1.1.13
        external/bsd/dhcpcd/dist/src/if-bsd.c           up to 1.1.1.9
        external/bsd/dhcpcd/dist/src/if.c               up to 1.1.1.9
        external/bsd/dhcpcd/dist/src/ipv4.c             up to 1.1.1.10
        external/bsd/dhcpcd/dist/src/ipv6.c             up to 1.1.1.12
        doc/3RDPARTY                                    (manually edited)

Import dhcpcd-7.0.8 with the following changes:
  *  Don't use IP_PKTINFO on NetBSD-7 as it's incomplete.
  *  Workaround RTM_NEWADDR sending the wrong broadcast address
     on NetBSD-7.
  *  Silence diagnostics if an address vanishes when reading
     it's flags on all BSD's.
  *  Misc compiler warnings fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.1145.2.49 -r1.1145.2.50 src/doc/3RDPARTY
cvs rdiff -u -r1.1.1.15.2.2 -r1.1.1.15.2.3 \
    src/external/bsd/dhcpcd/dist/src/defs.h
cvs rdiff -u -r1.11.4.2 -r1.11.4.3 src/external/bsd/dhcpcd/dist/src/dhcp.c
cvs rdiff -u -r1.1.1.12.4.2 -r1.1.1.12.4.3 \
    src/external/bsd/dhcpcd/dist/src/dhcp6.c
cvs rdiff -u -r1.1.1.8.4.2 -r1.1.1.8.4.3 \
    src/external/bsd/dhcpcd/dist/src/if-bsd.c \
    src/external/bsd/dhcpcd/dist/src/if.c
cvs rdiff -u -r1.1.1.9.4.2 -r1.1.1.9.4.3 \
    src/external/bsd/dhcpcd/dist/src/ipv4.c
cvs rdiff -u -r1.1.1.11.2.2 -r1.1.1.11.2.3 \
    src/external/bsd/dhcpcd/dist/src/ipv6.c

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1145.2.49 src/doc/3RDPARTY:1.1145.2.50
--- src/doc/3RDPARTY:1.1145.2.49	Fri Jul 27 10:43:18 2018
+++ src/doc/3RDPARTY	Sat Aug 25 15:02:59 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1145.2.49 2018/07/27 10:43:18 martin Exp $
+#	$NetBSD: 3RDPARTY,v 1.1145.2.50 2018/08/25 15:02:59 martin Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -305,8 +305,8 @@ Notes:
 Use the dhcp2netbsd script.
 
 Package:	dhcpcd
-Version:	7.0.7
-Current Vers:	7.0.7
+Version:	7.0.8
+Current Vers:	7.0.8
 Maintainer:	roy
 Archive Site:	ftp://roy.marples.name/pub/dhcpcd/
 Home Page:	http://roy.marples.name/projects/dhcpcd/

Index: src/external/bsd/dhcpcd/dist/src/defs.h
diff -u src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.15.2.2 src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.15.2.3
--- src/external/bsd/dhcpcd/dist/src/defs.h:1.1.1.15.2.2	Fri Jul 27 10:43:20 2018
+++ src/external/bsd/dhcpcd/dist/src/defs.h	Sat Aug 25 15:03:00 2018
@@ -28,7 +28,7 @@
 #define CONFIG_H
 
 #define PACKAGE			"dhcpcd"
-#define VERSION			"7.0.7"
+#define VERSION			"7.0.8"
 
 #ifndef CONFIG
 # define CONFIG			SYSCONFDIR "/" PACKAGE ".conf"

Index: src/external/bsd/dhcpcd/dist/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11.4.2 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11.4.3
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.11.4.2	Fri Jul 27 10:43:20 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Sat Aug 25 15:03:00 2018
@@ -86,6 +86,11 @@
 #define IPDEFTTL 64 /* RFC1340 */
 #endif
 
+/* NetBSD-7 has an incomplete IP_PKTINFO implementation. */
+#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 800000000
+#undef IP_PKTINFO
+#endif
+
 /* Assert the correct structure size for on wire */
 __CTASSERT(sizeof(struct ip)		== 20);
 __CTASSERT(sizeof(struct udphdr)	== 8);
@@ -3267,7 +3272,7 @@ get_udp_data(void *udp, size_t *len)
 	struct bootp_pkt *p;
 
 	p = (struct bootp_pkt *)udp;
-	*len = ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp);
+	*len = (size_t)ntohs(p->ip.ip_len) - sizeof(p->ip) - sizeof(p->udp);
 	return (char *)udp + offsetof(struct bootp_pkt, bootp);
 }
 

Index: src/external/bsd/dhcpcd/dist/src/dhcp6.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.1.1.12.4.2 src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.1.1.12.4.3
--- src/external/bsd/dhcpcd/dist/src/dhcp6.c:1.1.1.12.4.2	Fri Jul 27 10:43:20 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp6.c	Sat Aug 25 15:03:00 2018
@@ -777,7 +777,6 @@ dhcp6_makemessage(struct interface *ifp)
 		/* FALLTHROUGH */
 	case DH6S_INIT:
 		for (l = 0; l < ifo->ia_len; l++) {
-			ifia = &ifo->ia[l];
 			len += sizeof(o) + sizeof(uint32_t); /* IAID */
 			/* IA_TA does not have T1 or T2 timers */
 			if (ifo->ia[l].ia_type != D6_OPTION_IA_TA)

Index: src/external/bsd/dhcpcd/dist/src/if-bsd.c
diff -u src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.1.1.8.4.2 src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.1.1.8.4.3
--- src/external/bsd/dhcpcd/dist/src/if-bsd.c:1.1.1.8.4.2	Fri Jul 27 10:43:21 2018
+++ src/external/bsd/dhcpcd/dist/src/if-bsd.c	Sat Aug 25 15:03:00 2018
@@ -1103,9 +1103,32 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
 		sin = (const void *)rti_info[RTAX_NETMASK];
 		mask.s_addr = sin != NULL && sin->sin_family == AF_INET ?
 		    sin->sin_addr.s_addr : INADDR_ANY;
+
+#if defined(__NetBSD_Version__) && __NetBSD_Version__ < 800000000
+		/* NetBSD-7 and older send an invalid broadcast address.
+		 * So we need to query the actual address to get
+		 * the right one. */
+		{
+			struct in_aliasreq ifra;
+
+			memset(&ifra, 0, sizeof(ifra));
+			strlcpy(ifra.ifra_name, ifp->name,
+			    sizeof(ifra.ifra_name));
+			ifra.ifra_addr.sin_family = AF_INET;
+			ifra.ifra_addr.sin_len = sizeof(ifra.ifra_addr);
+			ifra.ifra_addr.sin_addr = addr;
+			if (ioctl(ctx->pf_inet_fd, SIOCGIFALIAS, &ifra) == -1) {
+				if (errno != EADDRNOTAVAIL)
+					logerr("%s: SIOCGIFALIAS", __func__);
+				break;
+			}
+			bcast = ifra.ifra_broadaddr.sin_addr;
+		}
+#else
 		sin = (const void *)rti_info[RTAX_BRD];
 		bcast.s_addr = sin != NULL && sin->sin_family == AF_INET ?
 		    sin->sin_addr.s_addr : INADDR_ANY;
+#endif
 
 #if defined(__FreeBSD__) || defined(__DragonFly__)
 		/* FreeBSD sends RTM_DELADDR for each assigned address
@@ -1134,8 +1157,8 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
 		if (ifam->ifam_type == RTM_DELADDR)
 			addrflags = 0 ;
 		else if ((addrflags = if_addrflags(ifp, &addr, NULL)) == -1) {
-			logerr("%s: if_addrflags: %s",
-			    ifp->name, inet_ntoa(addr));
+			if (errno != EADDRNOTAVAIL)
+				logerr("%s: if_addrflags", __func__);
 			break;
 		}
 #endif
@@ -1160,7 +1183,8 @@ if_ifa(struct dhcpcd_ctx *ctx, const str
 		if (ifam->ifam_type == RTM_DELADDR)
 		    addrflags = 0;
 		else if ((addrflags = if_addrflags6(ifp, &addr6, NULL)) == -1) {
-			logerr("%s: if_addrflags6", ifp->name);
+			if (errno != EADDRNOTAVAIL)
+				logerr("%s: if_addrflags6", __func__);
 			break;
 		}
 #endif
Index: src/external/bsd/dhcpcd/dist/src/if.c
diff -u src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.8.4.2 src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.8.4.3
--- src/external/bsd/dhcpcd/dist/src/if.c:1.1.1.8.4.2	Fri Jul 27 10:43:21 2018
+++ src/external/bsd/dhcpcd/dist/src/if.c	Sat Aug 25 15:03:00 2018
@@ -240,10 +240,8 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, st
 			addrflags = if_addrflags(ifp, &addr->sin_addr,
 			    ifa->ifa_name);
 			if (addrflags == -1) {
-				if (errno != EEXIST)
-					logerr("%s: if_addrflags: %s",
-					    __func__,
-					    inet_ntoa(addr->sin_addr));
+				if (errno != EEXIST && errno != EADDRNOTAVAIL)
+					logerr("%s: if_addrflags", __func__);
 				continue;
 			}
 #endif
@@ -266,7 +264,7 @@ if_learnaddrs(struct dhcpcd_ctx *ctx, st
 			addrflags = if_addrflags6(ifp, &sin6->sin6_addr,
 			    ifa->ifa_name);
 			if (addrflags == -1) {
-				if (errno != EEXIST)
+				if (errno != EEXIST && errno != EADDRNOTAVAIL)
 					logerr("%s: if_addrflags6", __func__);
 				continue;
 			}

Index: src/external/bsd/dhcpcd/dist/src/ipv4.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.9.4.2 src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.9.4.3
--- src/external/bsd/dhcpcd/dist/src/ipv4.c:1.1.1.9.4.2	Fri Jul 27 10:43:21 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv4.c	Sat Aug 25 15:03:00 2018
@@ -816,9 +816,17 @@ ipv4_handleifa(struct dhcpcd_ctx *ctx,
 	bool ia_is_new;
 
 #if 0
-	logdebugx("%s: %s %s/%d %d", ifname,
-	    cmd == RTM_NEWADDR ? "RTM_NEWADDR" : cmd == RTM_DELADDR ? "RTM_DELADDR" : "???",
-	    inet_ntoa(*addr), inet_ntocidr(*mask), addrflags);
+	char sbrdbuf[INET_ADDRSTRLEN];
+	const char *sbrd;
+
+	if (brd)
+		sbrd = inet_ntop(AF_INET, brd, sbrdbuf, sizeof(sbrdbuf));
+	else
+		sbrd = NULL;
+	logdebugx("%s: %s %s/%d %s %d", ifname,
+	    cmd == RTM_NEWADDR ? "RTM_NEWADDR" :
+	    cmd == RTM_DELADDR ? "RTM_DELADDR" : "???",
+	    inet_ntoa(*addr), inet_ntocidr(*mask), sbrd, addrflags);
 #endif
 
 	if (ifs == NULL)

Index: src/external/bsd/dhcpcd/dist/src/ipv6.c
diff -u src/external/bsd/dhcpcd/dist/src/ipv6.c:1.1.1.11.2.2 src/external/bsd/dhcpcd/dist/src/ipv6.c:1.1.1.11.2.3
--- src/external/bsd/dhcpcd/dist/src/ipv6.c:1.1.1.11.2.2	Fri Jul 27 10:43:21 2018
+++ src/external/bsd/dhcpcd/dist/src/ipv6.c	Sat Aug 25 15:03:00 2018
@@ -430,7 +430,7 @@ ipv6_mask(struct in6_addr *mask, int len
 	bits = len % NBBY;
 	for (i = 0; i < bytes; i++)
 		mask->s6_addr[i] = 0xff;
-	if (bits) {
+	if (bits != 0) {
 		/* Coverify false positive.
 		 * bytelen cannot be 16 if bitlen is non zero */
 		/* coverity[overrun-local] */
@@ -567,7 +567,8 @@ ipv6_checkaddrflags(void *arg)
 	alias = NULL;
 #endif
 	if ((flags = if_addrflags6(ia->iface, &ia->addr, alias)) == -1) {
-		logerr("%s: if_addrflags6", ia->iface->name);
+		if (errno != EEXIST && errno != EADDRNOTAVAIL)
+			logerr("%s: if_addrflags6", __func__);
 		return;
 	}
 

Reply via email to