summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2012-12-19 12:25:39 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2012-12-19 12:25:39 +0000
commit34a68a46f24e361531c34ebbe406fee67e437b85 (patch)
tree18c1aad2533b9a37ac7ce4974aaade97b75223a3
parent773bc16f8498724cebd4866a68effc42993bfa5a (diff)
Don't attempt to delete an address that has already been deleted
by a new dhclient (or anyone else). Instead, use add_address(..., INADDR_ANY, ...) to tell the privileged process that its active address is gone. Thus the cleanup process doesn't try to delete it. Eliminates extraneous log entries complaining that the address can't be deleted. Narrows race window where old dhclient might delete the address the new dhclient has just added. Make rapid-fire starting of dhclient even more reliable.
-rw-r--r--sbin/dhclient/dhclient.c11
-rw-r--r--sbin/dhclient/dhcpd.h3
-rw-r--r--sbin/dhclient/kroute.c9
3 files changed, 19 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 293fb17aa90..f77e1b3ecb6 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.196 2012/12/18 14:34:58 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.197 2012/12/19 12:25:38 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -168,7 +168,7 @@ void
routehandler(void)
{
char msg[2048];
- struct in_addr a;
+ struct in_addr a, b;
ssize_t n;
int linkstat;
struct rt_msghdr *rtm;
@@ -228,6 +228,13 @@ routehandler(void)
deleting.s_addr = INADDR_ANY;
break;
}
+ if (client->active &&
+ a.s_addr == client->active->address.s_addr) {
+ /* Tell the priv process active_addr is gone. */
+ memset(&b, 0, sizeof(b));
+ add_address(ifi->name, 0, b, b);
+ break;
+ }
errmsg = "interface address deleted";
}
goto die;
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 5bf46c5cdb5..42d10167b32 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.97 2012/12/04 19:24:03 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.98 2012/12/19 12:25:38 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -197,6 +197,7 @@ extern struct imsgbuf *unpriv_ibuf;
extern struct in_addr deleting;
extern struct in_addr adding;
extern struct in_addr active_addr;
+extern volatile sig_atomic_t quit;
/* options.c */
int cons_options(struct option_data *);
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c
index e9db894642a..a0aee066dd8 100644
--- a/sbin/dhclient/kroute.c
+++ b/sbin/dhclient/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.24 2012/12/17 22:52:59 krw Exp $ */
+/* $OpenBSD: kroute.c,v 1.25 2012/12/19 12:25:38 krw Exp $ */
/*
* Copyright 2012 Kenneth R Westerback <krw@openbsd.org>
@@ -503,6 +503,13 @@ priv_add_address(struct imsg_add_address *imsg)
struct sockaddr_in *in;
int s, len, i, iovcnt = 0;
+ if (imsg->addr.s_addr == INADDR_ANY) {
+ /* Notification that the active_addr has been deleted. */
+ active_addr.s_addr = INADDR_ANY;
+ quit = 1;
+ return;
+ }
+
/*
* Add specified address on specified interface.
*/