Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[infiniband] Disambiguate CM connection rejection reasons
There is diagnostic value in being able to disambiguate between the
various reasons why an IB CM has rejected a connection attempt.  In
particular, reason 8 "invalid service ID" can be used to identify an
incorrect SRP service_id root-path component, and reason 28 "consumer
reject" corresponds to a genuine SRP login rejection IU, which can be
passed up to the SRP layer.

For rejection reasons other than "consumer reject", we should not pass
through the private data, since it is most likely generated by the CM
without any protocol-specific knowledge.
  • Loading branch information
Michael Brown committed Aug 10, 2009
1 parent 965a0f7 commit 0ff5c45
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/include/gpxe/ib_mad.h
Expand Up @@ -402,6 +402,11 @@ struct ib_cm_connect_reject {
uint8_t private_data[148];
} __attribute__ (( packed ));

/** CM rejection reasons */
#define IB_CM_REJECT_BAD_SERVICE_ID 8
#define IB_CM_REJECT_STALE_CONN 10
#define IB_CM_REJECT_CONSUMER 28

/** A communication management connection reply
*
* Defined in section 12.6.8 of the IBA.
Expand Down
28 changes: 25 additions & 3 deletions src/net/infiniband/ib_cm.c
Expand Up @@ -122,6 +122,25 @@ struct ib_mad_agent ib_cm_agent[] __ib_mad_agent = {
},
};

/**
* Convert connection rejection reason to return status code
*
* @v reason Rejection reason (in network byte order)
* @ret rc Return status code
*/
static int ib_cm_rejection_reason_to_rc ( uint16_t reason ) {
switch ( reason ) {
case htons ( IB_CM_REJECT_BAD_SERVICE_ID ) :
return -ENODEV;
case htons ( IB_CM_REJECT_STALE_CONN ) :
return -EALREADY;
case htons ( IB_CM_REJECT_CONSUMER ) :
return -ENOTTY;
default:
return -EPERM;
}
}

/**
* Handle connection request transaction completion
*
Expand Down Expand Up @@ -189,9 +208,12 @@ static void ib_cm_req_complete ( struct ib_device *ibdev,
/* Extract fields */
DBGC ( conn, "CM %p connection rejected (reason %d)\n",
conn, ntohs ( connect_rej->reason ) );
private_data = &connect_rej->private_data;
private_data_len = sizeof ( connect_rej->private_data );
rc = -ENOTCONN;
/* Private data is valid only for a Consumer Reject */
if ( connect_rej->reason == htons ( IB_CM_REJECT_CONSUMER ) ) {
private_data = &connect_rej->private_data;
private_data_len = sizeof (connect_rej->private_data);
}
rc = ib_cm_rejection_reason_to_rc ( connect_rej->reason );
break;

default:
Expand Down
3 changes: 2 additions & 1 deletion src/net/infiniband/ib_cmrc.c
Expand Up @@ -172,7 +172,8 @@ static void ib_cmrc_changed ( struct ib_device *ibdev __unused,
/* Pass up any private data */
DBGC2 ( cmrc, "CMRC %p received private data:\n", cmrc );
DBGC2_HDA ( cmrc, 0, private_data, private_data_len );
if ( ( rc_xfer = xfer_deliver_raw ( &cmrc->xfer, private_data,
if ( private_data &&
( rc_xfer = xfer_deliver_raw ( &cmrc->xfer, private_data,
private_data_len ) ) != 0 ) {
DBGC ( cmrc, "CMRC %p could not deliver private data: %s\n",
cmrc, strerror ( rc_xfer ) );
Expand Down

0 comments on commit 0ff5c45

Please sign in to comment.