summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2015-05-14 09:17:37 +0000
committerRoy Marples <roy@marples.name>2015-05-14 09:17:37 +0000
commit33b106d08c6f404935a38e662b40509db9f62668 (patch)
treee37d81346cf2bdc28a715067279c553110f3860d /dhcpcd.c
parent58bbb46ee769fde699f96378d310d086d1260ccf (diff)
downloaddhcpcd-33b106d08c6f404935a38e662b40509db9f62668.tar.xz
Allow waitip to work per interface.
Remove ipwaited from dhcpcd-run-hooks as it's now redundant. Fixes [2095791c47].
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c48
1 files changed, 36 insertions, 12 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 019b78f2..5f21a920 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -212,26 +212,50 @@ dhcpcd_oneup(struct dhcpcd_ctx *ctx)
return 0;
}
-int
-dhcpcd_ipwaited(struct dhcpcd_ctx *ctx)
+static int
+dhcpcd_ifipwaited(struct interface *ifp, unsigned long long opts)
{
- if (ctx->options & DHCPCD_WAITIP4 &&
- !ipv4_addrexists(ctx, NULL))
+ if (opts & DHCPCD_WAITIP4 && !ipv4_ifaddrexists(ifp))
return 0;
- if (ctx->options & DHCPCD_WAITIP6 &&
- !ipv6nd_findaddr(ctx, NULL, 0) &&
- !dhcp6_findaddr(ctx, NULL, 0))
+ if (opts & DHCPCD_WAITIP6 && !ipv6_iffindaddr(ifp, NULL))
return 0;
- if (ctx->options & DHCPCD_WAITIP &&
- !(ctx->options & (DHCPCD_WAITIP4 | DHCPCD_WAITIP6)) &&
- !ipv4_addrexists(ctx, NULL) &&
- !ipv6nd_findaddr(ctx, NULL, 0) &&
- !dhcp6_findaddr(ctx, NULL, 0))
+ if (opts & DHCPCD_WAITIP &&
+ !(opts & (DHCPCD_WAITIP4 | DHCPCD_WAITIP6)) &&
+ !ipv4_ifaddrexists(ifp) &&
+ !ipv6_iffindaddr(ifp, NULL))
return 0;
return 1;
}
+static int
+dhcpcd_ipwaited(struct dhcpcd_ctx *ctx)
+{
+ struct interface *ifp;
+
+ TAILQ_FOREACH(ifp, ctx->ifaces, next) {
+ if (!dhcpcd_ifipwaited(ifp, ifp->options->options)) {
+ if (ifp->options->options & DHCPCD_WAITOPTS) {
+ logger(ctx, LOG_DEBUG,
+ "%s: waiting for an ip address",
+ ifp->name);
+ return 0;
+ }
+ }
+ }
+
+ if (!(ctx->options & DHCPCD_WAITOPTS))
+ return 1;
+
+ TAILQ_FOREACH(ifp, ctx->ifaces, next) {
+ if (dhcpcd_ifipwaited(ifp, ifp->options->options))
+ return 1;
+ }
+
+ logger(ctx, LOG_DEBUG, "waiting for an ip address");
+ return 0;
+}
+
/* Returns the pid of the child, otherwise 0. */
pid_t
dhcpcd_daemonise(struct dhcpcd_ctx *ctx)