summaryrefslogtreecommitdiff
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2018-01-29 23:16:37 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2018-01-29 23:16:37 +0000
commit193a6cb38c49f3b9808a03e0280182d279aa29b0 (patch)
tree42895688f946add9b4ddb0a81382af628d07eff4 /sbin/dhclient
parentfd875d08a0b85ccf0e852b7c616f493c7bc6ef2b (diff)
Repair botched retry loop when generating RTM_PROPOSAL
messages at startup. Reproducible situation found on vnet(4) and fix tested by jca@.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dhclient.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 29ed2bced20..5302f87b963 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.549 2018/01/29 15:18:05 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.550 2018/01/29 23:16:36 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -2417,20 +2417,24 @@ take_charge(struct interface_info *ifi, int routefd)
rtm.rtm_msglen = sizeof(rtm);
rtm.rtm_tableid = ifi->rdomain;
rtm.rtm_index = ifi->index;
- rtm.rtm_seq = ifi->xid = arc4random();
rtm.rtm_priority = RTP_PROPOSAL_DHCLIENT;
rtm.rtm_addrs = 0;
rtm.rtm_flags = RTF_UP | RTF_PROTO3;
+ rtm.rtm_seq = ifi->xid = arc4random();
+ if (write(routefd, &rtm, sizeof(rtm)) == -1)
+ fatal("write(routefd)");
+
retries = 0;
while ((ifi->flags & IFI_IN_CHARGE) == 0) {
- if (write(routefd, &rtm, sizeof(rtm)) == -1)
- fatal("write(routefd)");
time(&cur_time);
if ((cur_time - start_time) > 3) {
if (++retries <= 3) {
if (time(&start_time) == -1)
fatal("time");
+ rtm.rtm_seq = ifi->xid = arc4random();
+ if (write(routefd, &rtm, sizeof(rtm)) == -1)
+ fatal("write(routefd)");
} else {
fatalx("failed to take charge");
}