Skip to contentSkip to conversation

af_iucv: New error return codes for connect()

PATCH New Ursula Braun 1 participant 1 message Dec 1, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 2/3 af_iucv: New error return codes for connect()

From: Hendrik Brueckner <[email protected]>

If the iucv_path_connect() call fails then return an error code that corresponds to the iucv_path_connect() failure condition; instead of returning -ECONNREFUSED for any failure.

This helps to improve error handling for user space applications (e.g. inform the user that the z/VM guest is not authorized to connect to other guest virtual machines).

The error return codes are based on those described in connect(2).

---

 net/iucv/af_iucv.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)
net/iucv/af_iucv.c +15 -1
Index: net-2.6-uschi/net/iucv/af_iucv.c
===================================================================
@@ -514,7 +514,21 @@ static int iucv_sock_connect(struct sock
 		iucv_path_free(iucv->path);
 		iucv->path = NULL;
 		debug_sprintf_event(afiucv_dbf, 6, "connect error %d\n", err);
-		err = -ECONNREFUSED;
+		switch (err) {
+		case 0x0b:	/* Target communicator is not logged on */
+			err = -ENETUNREACH;
+			break;
+		case 0x0d:	/* Max connections for this guest exceeded */
+		case 0x0e:	/* Max connections for target guest exceeded */
+			err = -EAGAIN;
+			break;
+		case 0x0f:	/* Missing IUCV authorization */
+			err = -EACCES;
+			break;
+		default:
+			err = -ECONNREFUSED;
+			break;
+		}
 		goto done;
 	}