diff --git a/src/hci/strerror.c b/src/hci/strerror.c index 69675905..74995e8b 100644 --- a/src/hci/strerror.c +++ b/src/hci/strerror.c @@ -108,15 +108,18 @@ const char * strerror ( int errno ) { /** The most common errors */ struct errortab common_errors[] __errortab = { { 0, "No error" }, - { ENOMEM, "Out of memory" }, - { EINVAL, "Invalid argument" }, - { ENOSPC, "No space left on device" }, - { EIO, "Input/output error" }, { EACCES, "Permission denied" }, - { ENOENT, "File not found" }, - { ENETUNREACH, "Network unreachable" }, - { ETIMEDOUT, "Connection timed out" }, - { EPIPE, "Broken pipe" }, { ECANCELED, "Operation cancelled" }, + { ECONNRESET, "Connection reset" }, + { EINVAL, "Invalid argument" }, + { EIO, "Input/output error" }, + { ENETUNREACH, "Network unreachable" }, + { ENODEV, "No such device" }, + { ENOENT, "File not found" }, { ENOEXEC, "Not an executable image" }, + { ENOMEM, "Out of memory" }, + { ENOSPC, "No space left on device" }, + { ENOTSUP, "Not supported" }, + { EPERM, "Operation not permitted" }, + { ETIMEDOUT, "Connection timed out" }, }; diff --git a/src/include/gpxe/iscsi.h b/src/include/gpxe/iscsi.h index e4df6849..5c446757 100644 --- a/src/include/gpxe/iscsi.h +++ b/src/include/gpxe/iscsi.h @@ -224,10 +224,14 @@ struct iscsi_bhs_login_response { #define ISCSI_OPCODE_LOGIN_RESPONSE 0x23 /* Login response status codes */ -#define ISCSI_STATUS_SUCCESS 0x00 -#define ISCSI_STATUS_REDIRECT 0x01 -#define ISCSI_STATUS_INITIATOR_ERROR 0x02 -#define ISCSI_STATUS_TARGET_ERROR 0x03 +#define ISCSI_STATUS_SUCCESS 0x00 +#define ISCSI_STATUS_REDIRECT 0x01 +#define ISCSI_STATUS_INITIATOR_ERROR 0x02 +#define ISCSI_STATUS_INITIATOR_ERROR_AUTHENTICATION 0x01 +#define ISCSI_STATUS_INITIATOR_ERROR_AUTHORISATION 0x02 +#define ISCSI_STATUS_INITIATOR_ERROR_NOT_FOUND 0x03 +#define ISCSI_STATUS_INITIATOR_ERROR_REMOVED 0x04 +#define ISCSI_STATUS_TARGET_ERROR 0x03 /** * iSCSI SCSI command basic header segment 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 @@ -830,6 +830,35 @@ static int iscsi_rx_buffered_data ( struct iscsi_session *iscsi, return 0; } +/** + * 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 * @@ -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; } }