From 8b5a6ab3ebc9daaa473a2b700b4d6b1a1cef3bed Mon Sep 17 00:00:00 2001 From: visa Date: Mon, 25 Jul 2016 16:28:06 +0000 Subject: [PATCH] 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@ --- usr.sbin/rarpd/arptab.c | 10 +++++++--- 1 file 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); } -- 2.20.1