summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2014-12-09 02:27:54 +0000
committerkrw <krw@openbsd.org>2014-12-09 02:27:54 +0000
commitf6f752b0d3a5e17c564e51dc6f42984fe3440e63 (patch)
tree3564fe7dbc78a93449b61b319b23b8b03c6d5c85
parentt_exhaust is too exhausting (diff)
downloadwireguard-openbsd-f6f752b0d3a5e17c564e51dc6f42984fe3440e63.tar.xz
wireguard-openbsd-f6f752b0d3a5e17c564e51dc6f42984fe3440e63.zip
Move the initial link status check and possible forceup back before
the routing socket initialization. Otherwise certain combinations of UP/RUNNING/active will generate the deadly RTM_IFINFO with RTF_UP == 0 and kill the client. Add comment to nail this section in place.
-rw-r--r--sbin/dhclient/dhclient.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 1e6866dcf1c..fb9f9450ae8 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.343 2014/12/08 02:04:58 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.344 2014/12/09 02:27:54 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -559,6 +559,16 @@ main(int argc, char *argv[])
rewrite_client_leases();
close(fd);
+ /*
+ * Do the initial status check and possible force up before creating
+ * the routing socket. If we bounce the interface down and up while
+ * the routing socket is listening, the RTM_IFINFO message with the
+ * RTF_UP flag reset will cause premature exit.
+ */
+ ifi->linkstat = interface_status(ifi->name);
+ if (ifi->linkstat == 0)
+ interface_link_forceup(ifi->name);
+
if ((routefd = socket(PF_ROUTE, SOCK_RAW, 0)) == -1)
error("socket(PF_ROUTE, SOCK_RAW): %s", strerror(errno));
@@ -572,10 +582,6 @@ main(int argc, char *argv[])
sizeof(ifi->rdomain)) == -1)
error("setsockopt(ROUTE_TABLEFILTER): %s", strerror(errno));
- ifi->linkstat = interface_status(ifi->name);
- if (ifi->linkstat == 0)
- interface_link_forceup(ifi->name);
-
/* Register the interface. */
if_register_receive();
if_register_send();