Module Name:    src
Committed By:   roy
Date:           Mon Jan 29 11:13:06 UTC 2018

Modified Files:
        src/external/bsd/dhcpcd/dist/src: dhcp.c dhcpcd.c if-options.c

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcpcd/dist/src/dhcp.c \
    src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcpcd/dist/src/if-options.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/src/dhcp.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7 src/external/bsd/dhcpcd/dist/src/dhcp.c:1.8
--- src/external/bsd/dhcpcd/dist/src/dhcp.c:1.7	Mon Jan  1 11:50:56 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcp.c	Mon Jan 29 11:13:06 2018
@@ -1462,8 +1462,11 @@ get_lease(struct interface *ifp,
 	if (ifp->options->options & (DHCPCD_STATIC | DHCPCD_INFORM)) {
 		if (ifp->options->req_addr.s_addr != INADDR_ANY) {
 			lease->mask = ifp->options->req_mask;
-			lease->brd.s_addr =
-			    lease->addr.s_addr | ~lease->mask.s_addr;
+			if (ifp->options->req_brd.s_addr != INADDR_ANY)
+				lease->brd = ifp->options->req_brd;
+			else
+				lease->brd.s_addr =
+				    lease->addr.s_addr | ~lease->mask.s_addr;
 		} else {
 			const struct ipv4_addr *ia;
 
@@ -2076,7 +2079,7 @@ dhcp_arp_probed(struct arp_state *astate
 
 	logdebugx("%s: DAD completed for %s",
 	    ifp->name, inet_ntoa(astate->addr));
-	if (state->state != DHS_INFORM)
+	if (!(ifo->options & DHCPCD_INFORM))
 		dhcp_bind(ifp);
 #ifndef IN_IFF_TENTATIVE
 	else {
Index: src/external/bsd/dhcpcd/dist/src/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.7 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.8
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.7	Mon Jan  1 11:50:56 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Mon Jan 29 11:13:06 2018
@@ -712,8 +712,10 @@ dhcpcd_handlecarrier(struct dhcpcd_ctx *
 	eloop_timeout_delete(ifp->ctx->eloop, dhcpcd_pollup, ifp);
 
 	if (carrier == LINK_UNKNOWN) {
-		if (errno != ENOTTY) /* For example a PPP link on BSD */
+		if (errno != ENOTTY && errno != ENXIO) {
+			/* Don't log an error if interface departed */
 			logerr("%s: %s", ifp->name, __func__);
+		}
 	} else if (carrier == LINK_DOWN || (ifp->flags & IFF_UP) == 0) {
 		if (ifp->carrier != LINK_DOWN) {
 			if (ifp->carrier == LINK_UP)
@@ -977,9 +979,8 @@ dhcpcd_handleinterface(void *arg, int ac
 	struct dhcpcd_ctx *ctx;
 	struct ifaddrs *ifaddrs;
 	struct if_head *ifs;
-	struct interface *ifp, *iff, *ifn;
+	struct interface *ifp, *iff;
 	const char * const argv[] = { ifname };
-	int i;
 
 	ctx = arg;
 	if (action == -1) {
@@ -998,62 +999,41 @@ dhcpcd_handleinterface(void *arg, int ac
 		return 0;
 	}
 
-	i = -1;
 	ifs = if_discover(ctx, &ifaddrs, -1, UNCONST(argv));
 	if (ifs == NULL) {
 		logerr(__func__);
 		return -1;
 	}
-	TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
-		if (strcmp(ifp->name, ifname) != 0)
-			continue;
-
-		/* If running off an interface list, check it's in it. */
-		if (ctx->ifc || ctx->options & DHCPCD_INACTIVE) {
-			for (i = 0; i < ctx->ifc; i++)
-				if (strcmp(ctx->ifv[i], ifname) == 0)
-					break;
-			if (i >= ctx->ifc) {
-				ifp->active = IF_INACTIVE;
-				ifp->carrier = LINK_UNKNOWN;
-			}
-		}
-
-		i = 0;
-		/* Check if we already have the interface */
-		iff = if_find(ctx->ifaces, ifp->name);
-		if (iff) {
-			if (iff->active)
-				logdebugx("%s: interface updated", iff->name);
-			/* The flags and hwaddr could have changed */
-			iff->flags = ifp->flags;
-			iff->hwlen = ifp->hwlen;
-			if (ifp->hwlen != 0)
-				memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen);
-		} else {
-			TAILQ_REMOVE(ifs, ifp, next);
-			TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
-			if (!ifp->active)
-				continue;
+	ifp = if_find(ifs, ifname);
+	if (ifp == NULL) {
+		/* This can happen if an interface is quickly added
+		 * and then removed. */
+		errno = ENOENT;
+		return -1;
+	}
+	/* Check if we already have the interface */
+	iff = if_find(ctx->ifaces, ifp->name);
+	if (iff != NULL) {
+		if (iff->active)
+			logdebugx("%s: interface updated", iff->name);
+		/* The flags and hwaddr could have changed */
+		iff->flags = ifp->flags;
+		iff->hwlen = ifp->hwlen;
+		if (ifp->hwlen != 0)
+			memcpy(iff->hwaddr, ifp->hwaddr, iff->hwlen);
+	} else {
+		TAILQ_REMOVE(ifs, ifp, next);
+		TAILQ_INSERT_TAIL(ctx->ifaces, ifp, next);
+		if (ifp->active) {
 			logdebugx("%s: interface added", ifp->name);
 			dhcpcd_initstate(ifp, 0);
 			run_preinit(ifp);
-			iff = ifp;
 		}
-		if (action > 0 && iff->active)
-			dhcpcd_prestartinterface(iff);
+		iff = ifp;
 	}
-
 	if_learnaddrs(ctx, ifs, &ifaddrs);
-
-	/* Now we have learned addresses, start the interface */
-	TAILQ_FOREACH_SAFE(ifp, ifs, next, ifn) {
-		if (strcmp(ifp->name, ifname) != 0)
-			continue;
-		iff = if_find(ctx->ifaces, ifp->name);
-		if (action > 0 && iff->active)
-			dhcpcd_prestartinterface(iff);
-	}
+	if (action > 0 && iff->active)
+		dhcpcd_prestartinterface(iff);
 
 	/* Free our discovered list */
 	while ((ifp = TAILQ_FIRST(ifs))) {
@@ -1062,9 +1042,7 @@ dhcpcd_handleinterface(void *arg, int ac
 	}
 	free(ifs);
 
-	if (i == -1)
-		errno = ENOENT;
-	return i;
+	return 1;
 }
 
 void

Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.6 src/external/bsd/dhcpcd/dist/src/if-options.c:1.7
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.6	Mon Jan  1 11:50:56 2018
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Mon Jan 29 11:13:06 2018
@@ -815,8 +815,21 @@ parse_option(struct dhcpcd_ctx *ctx, con
 		break;
 	case 's':
 		if (arg && *arg != '\0') {
-			if (parse_addr(&ifo->req_addr, &ifo->req_mask, arg)
-			    != 0)
+			/* Strip out a broadcast address */
+			p = strchr(arg, '/');
+			if (p != NULL) {
+				p = strchr(p + 1, '/');
+				if (p != NULL)
+					*p = '\0';
+			}
+			i = parse_addr(&ifo->req_addr, &ifo->req_mask, arg);
+			if (p != NULL) {
+				/* Ensure the original string is preserved */
+				*p++ = '/';
+				if (i == 0)
+					i = parse_addr(&ifo->req_brd, NULL, p);
+			}
+			if (i != 0)
 				return -1;
 		} else {
 			ifo->req_addr.s_addr = 0;
@@ -1060,6 +1073,11 @@ parse_option(struct dhcpcd_ctx *ctx, con
 		{
 			if (parse_addr(&ifo->req_mask, NULL, p) != 0)
 				return -1;
+		} else if (strncmp(arg, "broadcast_address=",
+		    strlen("broadcast_address=")) == 0)
+		{
+			if (parse_addr(&ifo->req_brd, NULL, p) != 0)
+				return -1;
 		} else if (strncmp(arg, "routes=", strlen("routes=")) == 0 ||
 		    strncmp(arg, "static_routes=",
 		        strlen("static_routes=")) == 0 ||

Reply via email to