All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rpcbind: don't ignore bind and init_transport errors
@ 2010-09-17 18:12 Jan Rękorajski
  2010-09-17 18:26 ` Chuck Lever
  0 siblings, 1 reply; 16+ messages in thread
From: Jan Rękorajski @ 2010-09-17 18:12 UTC (permalink / raw)
  To: Steve Dickson; +Cc: linux-nfs

Hi,
rpcbind currently silently ignores any errors that occur during
init_transport, it also happily continues if bind(2) fails for
UDP socket - it's enough if just one UDP socket is bound.

This patch makes rpcbind fail if there are problems with
setting up any transport, so we don't end up with
semi/non functional running daemon.

Signed-off-by: Jan Rękorajski <baggins@sith.mimuw.edu.pl>

diff --git a/src/rpcbind.c b/src/rpcbind.c
index 63023e1..06e5b08 100644
--- a/src/rpcbind.c
+++ b/src/rpcbind.c
@@ -179,11 +179,17 @@ main(int argc, char *argv[])
 	
 	rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
 
-	init_transport(nconf);
+	if (init_transport(nconf)) {
+		syslog(LOG_ERR, "%s: can't init local transport\n", argv[0]);
+		exit(1);
+	}
 
 	while ((nconf = getnetconfig(nc_handle))) {
 		if (nconf->nc_flag & NC_VISIBLE)
-			init_transport(nconf);
+			if (init_transport(nconf)) {
+				syslog(LOG_ERR, "%s: can't init %s transport\n", argv[0], nconf->nc_netid);
+				exit(1);
+			}
 	}
 	endnetconfig(nc_handle);
 
@@ -276,7 +282,6 @@ init_transport(struct netconfig *nconf)
 	int aicode;
 	int addrlen = 0;
 	int nhostsbak;
-	int checkbind;
 	int on = 1;
 	struct sockaddr *sa = NULL;
 	u_int32_t host_addr[4];  /* IPv4 or IPv6 */
@@ -358,7 +363,6 @@ init_transport(struct netconfig *nconf)
 	       /*
 		* Bind to specific IPs if asked to
 		*/
-		checkbind = 0;
 		while (nhostsbak > 0) {
 			--nhostsbak;
 			/*
@@ -425,9 +429,8 @@ init_transport(struct netconfig *nconf)
 					hosts[nhostsbak], nconf->nc_netid);
 				if (res != NULL)
 					freeaddrinfo(res);
-				continue;
-			} else
-				checkbind++;
+				return 1;
+			}
 			(void) umask(oldmask);
 
 			/* Copy the address */
@@ -476,8 +479,6 @@ init_transport(struct netconfig *nconf)
 				goto error;
 			}
 		}
-		if (!checkbind)
-			return 1;
 	} else {	/* NC_TPI_COTS */
 		if ((strcmp(nconf->nc_netid, "local") != 0) &&
 		    (strcmp(nconf->nc_netid, "unix") != 0)) {

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-09-21 15:23 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-17 18:12 [PATCH] rpcbind: don't ignore bind and init_transport errors Jan Rękorajski
2010-09-17 18:26 ` Chuck Lever
2010-09-17 19:04   ` Jan Rękorajski
2010-09-17 19:27     ` Chuck Lever
2010-09-17 22:22       ` Jan Rękorajski
2010-09-20 14:29         ` Chuck Lever
2010-09-20 15:31           ` Jan Rękorajski
2010-09-20 16:21             ` Chuck Lever
2010-09-20 16:33               ` Ben Greear
2010-09-20 16:48               ` Jan Rękorajski
2010-09-20 18:53                 ` Chuck Lever
2010-09-20 19:03                   ` Ben Greear
2010-09-20 19:24                     ` Chuck Lever
2010-09-21  9:08                   ` Jan Rękorajski
2010-09-21 11:55                   ` Steve Dickson
2010-09-21 15:23                     ` Chuck Lever

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.