summaryrefslogtreecommitdiffstats
path: root/src/net/fcels.c
diff options
context:
space:
mode:
authorMichael Brown2010-10-07 17:19:00 +0200
committerMichael Brown2010-10-07 20:19:50 +0200
commit5e56e5f5a3b1a6e8660623e5829ae8f9ee1c850f (patch)
treedafebc8dc33a45b7f0f5c1ed157e19349df76651 /src/net/fcels.c
parent[fc] Include port IDs in metadata for received Fibre Channel frames (diff)
downloadipxe-5e56e5f5a3b1a6e8660623e5829ae8f9ee1c850f.tar.gz
ipxe-5e56e5f5a3b1a6e8660623e5829ae8f9ee1c850f.tar.xz
ipxe-5e56e5f5a3b1a6e8660623e5829ae8f9ee1c850f.zip
[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 <mcb30@ipxe.org>
Diffstat (limited to 'src/net/fcels.c')
-rw-r--r--src/net/fcels.c25
1 files 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 ) );