diff options
| author | roy <roy@NetBSD.org> | 2018-03-23 11:57:33 +0000 |
|---|---|---|
| committer | roy <roy@NetBSD.org> | 2018-03-23 11:57:33 +0000 |
| commit | bb6e552c53e6431991e28a01e9d2a07e0121d64a (patch) | |
| tree | 4929878a530003ea62057024f9ff2a0f2b2383f2 | |
| parent | e40ffd8757a74dda24401cba0e403391149c714e (diff) | |
Handle the routing socket overflowing gracefully.
| -rw-r--r-- | sbin/route/route.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index cb87102dfe4..6f237286714 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $ */ +/* $NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $ */ /* * Copyright (c) 1983, 1989, 1991, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 1989, 1991, 1993\ #if 0 static char sccsid[] = "@(#)route.c 8.6 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: route.c,v 1.158 2017/12/13 17:42:44 christos Exp $"); +__RCSID("$NetBSD: route.c,v 1.159 2018/03/23 11:57:33 roy Exp $"); #endif #endif /* not lint */ @@ -341,8 +341,10 @@ flushroutes(int argc, char * const argv[], int doall) continue; rtm->rtm_type = RTM_DELETE; rtm->rtm_seq = seqno; - if ((rlen = prog_write(sock, next, - rtm->rtm_msglen)) < 0) { + do { + rlen = prog_write(sock, next, rtm->rtm_msglen); + } while (rlen == -1 && errno == ENOBUFS); + if (rlen == -1) { warnx("writing to routing socket: %s", route_strerror(errno)); return 1; @@ -1139,6 +1141,10 @@ monitor(int argc, char * const *argv) for(i = 0; count == 0 || i < count; i++) { time_t now; n = prog_read(sock, &u, sizeof(u)); + if (n == -1) { + warn("read"); + continue; + } now = time(NULL); (void)printf("got message of size %d on %s", n, ctime(&now)); print_rtmsg(&u.hdr, n); @@ -1214,7 +1220,10 @@ rtmsg(int cmd, int flags, struct sou *soup) } if (debugonly) return 0; - if ((rlen = prog_write(sock, (char *)&m_rtmsg, l)) < 0) { + do { + rlen = prog_write(sock, (char *)&m_rtmsg, l); + } while (rlen == -1 && errno == ENOBUFS); + if (rlen == -1) { warnx("writing to routing socket: %s", route_strerror(errno)); return -1; } |
