Module Name:    src
Committed By:   roy
Date:           Fri Mar 23 11:57:33 UTC 2018

Modified Files:
        src/sbin/route: route.c

Log Message:
Handle the routing socket overflowing gracefully.


To generate a diff of this commit:
cvs rdiff -u -r1.158 -r1.159 src/sbin/route/route.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/route/route.c
diff -u src/sbin/route/route.c:1.158 src/sbin/route/route.c:1.159
--- src/sbin/route/route.c:1.158	Wed Dec 13 17:42:44 2017
+++ src/sbin/route/route.c	Fri Mar 23 11:57:33 2018
@@ -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, 19
 #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[
 			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 *so
 	}
 	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;
 	}

Reply via email to