Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/dhcpcd/dist/src Sync



details:   https://anonhg.NetBSD.org/src/rev/f238a54c3d66
branches:  trunk
changeset: 360910:f238a54c3d66
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Apr 06 10:47:47 2018 +0000

description:
Sync

diffstat:

 external/bsd/dhcpcd/dist/src/dhcpcd.c     |  24 ++++++++++++++----------
 external/bsd/dhcpcd/dist/src/if-options.c |  27 +++++++--------------------
 2 files changed, 21 insertions(+), 30 deletions(-)

diffs (187 lines):

diff -r a9f3b08b0815 -r f238a54c3d66 external/bsd/dhcpcd/dist/src/dhcpcd.c
--- a/external/bsd/dhcpcd/dist/src/dhcpcd.c     Fri Apr 06 10:46:36 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/dhcpcd.c     Fri Apr 06 10:47:47 2018 +0000
@@ -577,7 +577,7 @@
        } 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 @@
        }
        /* 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 @@
                }
                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 @@
        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 @@
 #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 @@
        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 @@
                }
        }
 
-       rt_init(&ctx);
-
        TAILQ_FOREACH(ifp, ctx.ifaces, next) {
                if (ifp->active)
                        dhcpcd_initstate1(ifp, argc, argv, 0);
@@ -1981,7 +1985,7 @@
                            handle_exit_timeout, &ctx);
                }
        }
-       free_options(ifo);
+       free_options(&ctx, ifo);
        ifo = NULL;
 
        if_sortinterfaces(&ctx);
@@ -2018,6 +2022,7 @@
                }
                free(ctx.ifaces);
        }
+       free_options(&ctx, ifo);
        rt_dispose(&ctx);
        free(ctx.duid);
        if (ctx.link_fd != -1) {
@@ -2025,7 +2030,6 @@
                close(ctx.link_fd);
        }
        if_closesockets(&ctx);
-       free_options(ifo);
        free_globals(&ctx);
        ipv6_ctxfree(&ctx);
        dev_stop(&ctx);
diff -r a9f3b08b0815 -r f238a54c3d66 external/bsd/dhcpcd/dist/src/if-options.c
--- a/external/bsd/dhcpcd/dist/src/if-options.c Fri Apr 06 10:46:36 2018 +0000
+++ b/external/bsd/dhcpcd/dist/src/if-options.c Fri Apr 06 10:47:47 2018 +0000
@@ -1086,14 +1086,8 @@
                    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 @@
                                *fp = ' ';
                                return -1;
                        }
-                       if ((rt = rt_new(ifp)) == NULL) {
+                       if ((rt = rt_new0(ctx)) == NULL) {
                                *fp = ' ';
                                return -1;
                        }
@@ -1117,16 +1111,9 @@
                        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 @@
                buf = malloc(buflen);
                if (buf == NULL) {
                        logerr(__func__);
-                       free_options(ifo);
+                       free_options(ctx, ifo);
                        return NULL;
                }
                ldop = edop = NULL;
@@ -2381,7 +2368,7 @@
                                if (nbuf == NULL) {
                                        logerr(__func__);
                                        free(buf);
-                                       free_options(ifo);
+                                       free_options(ctx, ifo);
                                        return NULL;
                                }
                                buf = nbuf;
@@ -2545,7 +2532,7 @@
        free(buf);
 
        if (profile && !have_profile) {
-               free_options(ifo);
+               free_options(ctx, ifo);
                errno = ENOENT;
                return NULL;
        }
@@ -2590,7 +2577,7 @@
 }
 
 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(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);



Home | Main Index | Thread Index | Old Index