From 5e56e5f5a3b1a6e8660623e5829ae8f9ee1c850f Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 7 Oct 2010 16:19:00 +0100 Subject: [PATCH] [fc] Update ELS port IDs when receiving an ELS frame The port ID assigned by the FLOGI response is implicit in the destination ID used for the response (which will differ from the source ID used for the corresponding request). Signed-off-by: Michael Brown --- src/net/fcels.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/net/fcels.c b/src/net/fcels.c index 67ee5ef5..ef809ad8 100644 --- a/src/net/fcels.c +++ b/src/net/fcels.c @@ -153,8 +153,10 @@ int fc_els_tx ( struct fc_els *els, const void *data, size_t len ) { */ static int fc_els_rx ( struct fc_els *els, struct io_buffer *iobuf, - struct xfer_metadata *meta __unused ) { + struct xfer_metadata *meta ) { struct fc_els_frame_common *frame = iobuf->data; + struct sockaddr_fc *src = ( ( struct sockaddr_fc * ) meta->src ); + struct sockaddr_fc *dest = ( ( struct sockaddr_fc * ) meta->dest ); size_t len = iob_len ( iobuf ); int ( * rx ) ( struct fc_els *els, const void *data, size_t len ); int rc; @@ -167,6 +169,18 @@ static int fc_els_rx ( struct fc_els *els, rc = -EINVAL; goto done; } + if ( ! src ) { + DBGC ( els, FCELS_FMT " received frame missing source " + "address:\n", FCELS_ARGS ( els ) ); + rc = -EINVAL; + goto done; + } + if ( ! dest ) { + DBGC ( els, FCELS_FMT " received frame missing destination " + "address:\n", FCELS_ARGS ( els ) ); + rc = -EINVAL; + goto done; + } /* Check for rejection responses */ if ( fc_els_is_request ( els ) && @@ -177,6 +191,11 @@ static int fc_els_rx ( struct fc_els *els, goto done; } + /* Update port IDs */ + memcpy ( &els->port_id, &dest->sfc_port_id, sizeof ( els->port_id ) ); + memcpy ( &els->peer_port_id, &src->sfc_port_id, + sizeof ( els->peer_port_id ) ); + /* Determine handler, if necessary */ if ( ! els->handler ) els->handler = fc_els_detect ( els, frame, len ); @@ -513,8 +532,8 @@ static int fc_els_flogi_rx ( struct fc_els *els, const void *data, DBGC ( els, FCELS_FMT " has port %s\n", FCELS_ARGS ( els ), fc_ntoa ( &flogi->port_wwn ) ); if ( has_fabric ) { - DBGC ( els, FCELS_FMT " has fabric with local ID %s\n", - FCELS_ARGS ( els ), fc_id_ntoa ( &els->port_id ) ); + DBGC ( els, FCELS_FMT " has fabric with", FCELS_ARGS ( els ) ); + DBGC ( els, " local ID %s\n", fc_id_ntoa ( &els->port_id ) ); } else { DBGC ( els, FCELS_FMT " has point-to-point link\n", FCELS_ARGS ( els ) );