Module Name:    src
Committed By:   roy
Date:           Fri Apr  6 10:47:47 UTC 2018

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

Log Message:
Sync


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/dhcpcd/dist/src/dhcpcd.c
cvs rdiff -u -r1.7 -r1.8 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/dhcpcd.c
diff -u src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9 src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.10
--- src/external/bsd/dhcpcd/dist/src/dhcpcd.c:1.9	Tue Mar 27 06:16:34 2018
+++ src/external/bsd/dhcpcd/dist/src/dhcpcd.c	Fri Apr  6 10:47:47 2018
@@ -577,7 +577,7 @@ dhcpcd_selectprofile(struct interface *i
 	} else
 		*ifp->profile = '\0';
 
-	free_options(ifp->options);
+	free_options(ifp->ctx, ifp->options);
 	ifp->options = ifo;
 	if (profile) {
 		add_options(ifp->ctx, ifp->name, ifp->options,
@@ -995,6 +995,7 @@ dhcpcd_handleinterface(void *arg, int ac
 	}
 	/* 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);
@@ -1013,9 +1014,12 @@ dhcpcd_handleinterface(void *arg, int ac
 		}
 		iff = ifp;
 	}
-	if_learnaddrs(ctx, ifs, &ifaddrs);
-	if (action > 0 && iff->active)
-		dhcpcd_prestartinterface(iff);
+
+	if (action > 0) {
+		if_learnaddrs(ctx, ifs, &ifaddrs);
+		if (iff->active)
+			dhcpcd_prestartinterface(iff);
+	}
 
 	/* Free our discovered list */
 	while ((ifp = TAILQ_FIRST(ifs))) {
@@ -1161,7 +1165,7 @@ reload_config(struct dhcpcd_ctx *ctx)
 	if (ctx->options & DHCPCD_DAEMONISED)
 		ifo->options |= DHCPCD_DAEMONISED;
 	ctx->options = ifo->options;
-	free_options(ifo);
+	free_options(ctx, ifo);
 }
 
 static void
@@ -1519,6 +1523,8 @@ main(int argc, char **argv)
 #ifdef INET
 	ctx.udp_fd = -1;
 #endif
+	rt_init(&ctx);
+
 	logopts = LOGERR_ERR|LOGERR_LOG|LOGERR_LOG_DATE|LOGERR_LOG_PID;
 	i = 0;
 	while ((opt = getopt_long(argc, argv,
@@ -1613,7 +1619,7 @@ main(int argc, char **argv)
 	if (i == 2) {
 		printf("Interface options:\n");
 		if (optind == argc - 1) {
-			free_options(ifo);
+			free_options(&ctx, ifo);
 			ifo = read_config(&ctx, argv[optind], NULL, NULL);
 			if (ifo == NULL)
 				goto exit_failure;
@@ -1929,8 +1935,6 @@ printpidfile:
 		}
 	}
 
-	rt_init(&ctx);
-
 	TAILQ_FOREACH(ifp, ctx.ifaces, next) {
 		if (ifp->active)
 			dhcpcd_initstate1(ifp, argc, argv, 0);
@@ -1981,7 +1985,7 @@ printpidfile:
 			    handle_exit_timeout, &ctx);
 		}
 	}
-	free_options(ifo);
+	free_options(&ctx, ifo);
 	ifo = NULL;
 
 	if_sortinterfaces(&ctx);
@@ -2018,6 +2022,7 @@ exit1:
 		}
 		free(ctx.ifaces);
 	}
+	free_options(&ctx, ifo);
 	rt_dispose(&ctx);
 	free(ctx.duid);
 	if (ctx.link_fd != -1) {
@@ -2025,7 +2030,6 @@ exit1:
 		close(ctx.link_fd);
 	}
 	if_closesockets(&ctx);
-	free_options(ifo);
 	free_globals(&ctx);
 	ipv6_ctxfree(&ctx);
 	dev_stop(&ctx);

Index: src/external/bsd/dhcpcd/dist/src/if-options.c
diff -u src/external/bsd/dhcpcd/dist/src/if-options.c:1.7 src/external/bsd/dhcpcd/dist/src/if-options.c:1.8
--- src/external/bsd/dhcpcd/dist/src/if-options.c:1.7	Mon Jan 29 11:13:06 2018
+++ src/external/bsd/dhcpcd/dist/src/if-options.c	Fri Apr  6 10:47:47 2018
@@ -1086,14 +1086,8 @@ parse_option(struct dhcpcd_ctx *ctx, con
 		    strncmp(arg, "ms_classless_static_routes=",
 		        strlen("ms_classless_static_routes=")) == 0)
 		{
-			struct interface *ifp;
 			struct in_addr addr3;
 
-			ifp = if_find(ctx->ifaces, ifname);
-			if (ifp == NULL) {
-				logerrx("static routes require an interface");
-				return -1;
-			}
 			fp = np = strwhite(p);
 			if (np == NULL) {
 				logerrx("all routes need a gateway");
@@ -1107,7 +1101,7 @@ parse_option(struct dhcpcd_ctx *ctx, con
 				*fp = ' ';
 				return -1;
 			}
-			if ((rt = rt_new(ifp)) == NULL) {
+			if ((rt = rt_new0(ctx)) == NULL) {
 				*fp = ' ';
 				return -1;
 			}
@@ -1117,16 +1111,9 @@ parse_option(struct dhcpcd_ctx *ctx, con
 			TAILQ_INSERT_TAIL(&ifo->routes, rt, rt_next);
 			*fp = ' ';
 		} else if (strncmp(arg, "routers=", strlen("routers=")) == 0) {
-			struct interface *ifp;
-
-			ifp = if_find(ctx->ifaces, ifname);
-			if (ifp == NULL) {
-				logerrx("static routes require an interface");
-				return -1;
-			}
 			if (parse_addr(&addr, NULL, p) == -1)
 				return -1;
-			if ((rt = rt_new(ifp)) == NULL)
+			if ((rt = rt_new0(ctx)) == NULL)
 				return -1;
 			addr2.s_addr = INADDR_ANY;
 			sa_in_init(&rt->rt_dest, &addr2);
@@ -2367,7 +2354,7 @@ read_config(struct dhcpcd_ctx *ctx,
 		buf = malloc(buflen);
 		if (buf == NULL) {
 			logerr(__func__);
-			free_options(ifo);
+			free_options(ctx, ifo);
 			return NULL;
 		}
 		ldop = edop = NULL;
@@ -2381,7 +2368,7 @@ read_config(struct dhcpcd_ctx *ctx,
 				if (nbuf == NULL) {
 					logerr(__func__);
 					free(buf);
-					free_options(ifo);
+					free_options(ctx, ifo);
 					return NULL;
 				}
 				buf = nbuf;
@@ -2545,7 +2532,7 @@ read_config(struct dhcpcd_ctx *ctx,
 	free(buf);
 
 	if (profile && !have_profile) {
-		free_options(ifo);
+		free_options(ctx, ifo);
 		errno = ENOENT;
 		return NULL;
 	}
@@ -2590,7 +2577,7 @@ add_options(struct dhcpcd_ctx *ctx, cons
 }
 
 void
-free_options(struct if_options *ifo)
+free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo)
 {
 	size_t i;
 	struct dhcp_opt *opt;
@@ -2612,7 +2599,7 @@ free_options(struct if_options *ifo)
 				free(ifo->config[i++]);
 			free(ifo->config);
 		}
-		rt_headclear(&ifo->routes, AF_UNSPEC);
+		rt_headclear0(ctx, &ifo->routes, AF_UNSPEC);
 		free(ifo->script);
 		free(ifo->arping);
 		free(ifo->blacklist);

Reply via email to