summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2016-07-25 16:28:07 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2016-07-25 16:28:07 +0000
commitc5a953ae43f81148e8092dd95ce93f408d2909f2 (patch)
tree3eba1c0218112c8d23a2c5153b170ce2df160fac /usr.sbin
parent7f998a48b78fe577bfb04bf67247d7461b3421c5 (diff)
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')
-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);
}