summaryrefslogtreecommitdiffstats
path: root/usr.sbin/rarpd/arptab.c
diff options
context:
space:
mode:
authorvisa <visa@openbsd.org>2016-07-25 16:28:06 +0000
committervisa <visa@openbsd.org>2016-07-25 16:28:06 +0000
commit8b5a6ab3ebc9daaa473a2b700b4d6b1a1cef3bed (patch)
tree9e8d88b0b7369c8d7245df5393366b0f4f76637a /usr.sbin/rarpd/arptab.c
parentRevert change to density calculation. David Vasek points out this (diff)
downloadwireguard-openbsd-8b5a6ab3ebc9daaa473a2b700b4d6b1a1cef3bed.tar.xz
wireguard-openbsd-8b5a6ab3ebc9daaa473a2b700b4d6b1a1cef3bed.zip
Fix rarpd hang. The receive buffer of a route socket can become full
while rarpd process is idle. To avoid getting stuck in rtmsg(), the process has to clear the buffer and retry. ok benno@ deraadt@ millert@
Diffstat (limited to 'usr.sbin/rarpd/arptab.c')
-rw-r--r--usr.sbin/rarpd/arptab.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/usr.sbin/rarpd/arptab.c b/usr.sbin/rarpd/arptab.c
index dac132dea16..ddabb26ef22 100644
--- a/usr.sbin/rarpd/arptab.c
+++ b/usr.sbin/rarpd/arptab.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arptab.c,v 1.26 2016/01/26 18:26:19 mmcc Exp $ */
+/* $OpenBSD: arptab.c,v 1.27 2016/07/25 16:28:06 visa Exp $ */
/*
* Copyright (c) 1984, 1993
@@ -172,6 +172,7 @@ rtmsg(int cmd)
char *cp = m_rtmsg.m_space;
int l;
+retry:
errno = 0;
if (cmd == RTM_DELETE)
goto doit;
@@ -224,11 +225,14 @@ doit:
}
}
do {
- l = read(s, (char *)&m_rtmsg, sizeof(m_rtmsg));
+ l = recv(s, (char *)&m_rtmsg, sizeof(m_rtmsg), MSG_DONTWAIT);
} while (l > 0 && (rtm->rtm_version != RTM_VERSION ||
rtm->rtm_seq != seq || rtm->rtm_pid != pid));
- if (l < 0)
+ if (l < 0) {
+ if (errno == EAGAIN || errno == EINTR)
+ goto retry;
syslog(LOG_ERR, "arptab_set: read from routing socket: %m");
+ }
return (0);
}