diff options
author | Michael Brown | 2008-06-04 00:46:36 +0200 |
---|---|---|
committer | Michael Brown | 2008-06-04 00:47:20 +0200 |
commit | 75965c9c6e9eca6d790710351f054689f4578a85 (patch) | |
tree | 33131a0d6481b36fa1547014ea37d62da9e5010b /src/net | |
parent | [Makefile] Remove obsolete SRCDIRS (diff) | |
download | ipxe-75965c9c6e9eca6d790710351f054689f4578a85.tar.gz ipxe-75965c9c6e9eca6d790710351f054689f4578a85.tar.xz ipxe-75965c9c6e9eca6d790710351f054689f4578a85.zip |
[iSCSI] Produce meaningful errors on login failure
Return the most appropriate of EACCES, EPERM, ENODEV, ENOTSUP, EIO or
EINVAL depending on the exact error returned by the target, rather than
just always returning EPERM.
Also, ensure that error strings exist for these errors.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/tcp/iscsi.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index 3cd54703..a12fca85 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -831,6 +831,35 @@ static int iscsi_rx_buffered_data ( struct iscsi_session *iscsi, } /** + * Convert iSCSI response status to return status code + * + * @v status_class iSCSI status class + * @v status_detail iSCSI status detail + * @ret rc Return status code + */ +static int iscsi_status_to_rc ( unsigned int status_class, + unsigned int status_detail ) { + switch ( status_class ) { + case ISCSI_STATUS_INITIATOR_ERROR : + switch ( status_detail ) { + case ISCSI_STATUS_INITIATOR_ERROR_AUTHENTICATION : + return -EACCES; + case ISCSI_STATUS_INITIATOR_ERROR_AUTHORISATION : + return -EPERM; + case ISCSI_STATUS_INITIATOR_ERROR_NOT_FOUND : + case ISCSI_STATUS_INITIATOR_ERROR_REMOVED : + return -ENODEV; + default : + return -ENOTSUP; + } + case ISCSI_STATUS_TARGET_ERROR : + return -EIO; + default : + return -EINVAL; + } +} + +/** * Receive data segment of an iSCSI login response PDU * * @v iscsi iSCSI session @@ -877,8 +906,10 @@ static int iscsi_rx_login_response ( struct iscsi_session *iscsi, if ( response->status_class != 0 ) { DBGC ( iscsi, "iSCSI login failure: class %02x detail %02x\n", response->status_class, response->status_detail ); - iscsi->instant_rc = -EPERM; - return -EPERM; + rc = iscsi_status_to_rc ( response->status_class, + response->status_detail ); + iscsi->instant_rc = rc; + return rc; } /* Handle login transitions */ @@ -1177,7 +1208,7 @@ static int iscsi_rx_data ( struct iscsi_session *iscsi, const void *data, return 0; DBGC ( iscsi, "iSCSI %p unknown opcode %02x\n", iscsi, response->opcode ); - return -EOPNOTSUPP; + return -ENOTSUP; } } |