summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2013-05-05 16:45:01 +0000
committerkrw <krw@openbsd.org>2013-05-05 16:45:01 +0000
commit0f866159c16165503d44c1f81c7c06d0591db2e2 (patch)
treec22819f3da1eb4302ad292604e146aeba2610010
parenttypo in log message. ok sthen@ (diff)
downloadwireguard-openbsd-0f866159c16165503d44c1f81c7c06d0591db2e2.tar.xz
wireguard-openbsd-0f866159c16165503d44c1f81c7c06d0591db2e2.zip
Add a flag to struct client_state (IS_RESPONSIBLE) to record when
the first expected RTM_NEWADDR arrives, which signals that a lease has been bound to the interface. Ignore RTM_NEWADDR and RTM_DELADDR messages until the flag has been set. Makes it more likely that the last dhclient started will be the last dhclient standing. Fixes the problem reported by David Higgs, where restarting an install in a vm consistantly caused the new dhclient to be the one that dies.
-rw-r--r--sbin/dhclient/dhclient.c9
-rw-r--r--sbin/dhclient/dhcpd.h4
2 files changed, 11 insertions, 2 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index d0c45f8bda6..a3f4900f36c 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.246 2013/05/02 16:35:27 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.247 2013/05/05 16:45:01 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -227,9 +227,13 @@ routehandler(void)
inet_ntoa(client->active->address),
(long long)(client->active->renewal -
time(NULL)));
+ client->flags |= IS_RESPONSIBLE;
go_daemon();
break;
}
+ if ((client->flags & IS_RESPONSIBLE) == 0)
+ /* We're not responsible yet! */
+ break;
if (adding.s_addr != INADDR_ANY)
rslt = asprintf(&errmsg, "%s, not %s, added "
"to %s", inet_ntoa(a), inet_ntoa(adding),
@@ -242,6 +246,9 @@ routehandler(void)
deleting.s_addr = INADDR_ANY;
break;
}
+ if ((client->flags & IS_RESPONSIBLE) == 0)
+ /* We're not responsible yet! */
+ break;
if (adding.s_addr == INADDR_ANY && client->active &&
a.s_addr == client->active->address.s_addr) {
/* Tell the priv process active_addr is gone. */
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 0b64c2f4bf7..522b7a3e08d 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.116 2013/05/02 16:35:27 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.117 2013/05/05 16:45:01 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -157,6 +157,8 @@ struct client_state {
TAILQ_HEAD(, client_lease) leases;
enum dhcp_state state;
struct in_addr destination;
+ int flags;
+#define IS_RESPONSIBLE 0x1
u_int32_t xid;
u_int16_t secs;
time_t first_sending;