} 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,
if (ctx->options & DHCPCD_DAEMONISED)
ifo->options |= DHCPCD_DAEMONISED;
ctx->options = ifo->options;
- free_options(ifo);
+ free_options(ctx, ifo);
}
static void
#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,
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;
}
}
- rt_init(&ctx);
-
TAILQ_FOREACH(ifp, ctx.ifaces, next) {
if (ifp->active)
dhcpcd_initstate1(ifp, argc, argv, 0);
handle_exit_timeout, &ctx);
}
}
- free_options(ifo);
+ free_options(&ctx, ifo);
ifo = NULL;
if_sortinterfaces(&ctx);
close(ctx.link_fd);
}
if_closesockets(&ctx);
- free_options(ifo);
+ free_options(&ctx, ifo);
free_globals(&ctx);
ipv6_ctxfree(&ctx);
dev_stop(&ctx);
buf = malloc(buflen);
if (buf == NULL) {
logerr(__func__);
- free_options(ifo);
+ free_options(ctx, ifo);
return NULL;
}
ldop = edop = NULL;
if (nbuf == NULL) {
logerr(__func__);
free(buf);
- free_options(ifo);
+ free_options(ctx, ifo);
return NULL;
}
buf = nbuf;
free(buf);
if (profile && !have_profile) {
- free_options(ifo);
+ free_options(ctx, ifo);
errno = ENOENT;
return NULL;
}
}
void
-free_options(struct if_options *ifo)
+free_options(struct dhcpcd_ctx *ctx, struct if_options *ifo)
{
size_t i;
struct dhcp_opt *opt;
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);
int add_options(struct dhcpcd_ctx *, const char *,
struct if_options *, int, char **);
void free_dhcp_opt_embenc(struct dhcp_opt *);
-void free_options(struct if_options *);
+void free_options(struct dhcpcd_ctx *, struct if_options *);
#endif
ipv6nd_free(ifp);
ipv6_free(ifp);
rt_freeif(ifp);
- free_options(ifp->options);
+ free_options(ifp->ctx, ifp->options);
free(ifp);
}
}
void
-rt_headclear(struct rt_head *rts, int af)
+rt_headclear0(struct dhcpcd_ctx *ctx, struct rt_head *rts, int af)
{
struct rt *rt, *rtn;
- struct dhcpcd_ctx *ctx;
if (rts == NULL)
return;
-
- if ((rt = TAILQ_FIRST(rts)) == NULL)
- return;
- ctx = rt->rt_ifp->ctx;
+ assert(ctx != NULL);
assert(&ctx->froutes != rts);
TAILQ_FOREACH_SAFE(rt, rts, rt_next, rtn) {
}
}
+void
+rt_headclear(struct rt_head *rts, int af)
+{
+ struct rt *rt;
+
+ if (rts == NULL || (rt = TAILQ_FIRST(rts)) == NULL)
+ return;
+ rt_headclear0(rt->rt_ifp->ctx, rts, af);
+}
+
static void
rt_headfree(struct rt_head *rts)
{
struct rt * rt_find(struct rt_head *, const struct rt *);
void rt_free(struct rt *);
void rt_freeif(struct interface *);
+void rt_headclear0(struct dhcpcd_ctx *, struct rt_head *, int);
void rt_headclear(struct rt_head *, int);
void rt_headfreeif(struct rt_head *);
struct rt * rt_new0(struct dhcpcd_ctx *);