]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[fc] Update ELS port IDs when receiving an ELS frame
authorMichael Brown <mcb30@ipxe.org>
Thu, 7 Oct 2010 15:19:00 +0000 (16:19 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 7 Oct 2010 18:19:50 +0000 (19:19 +0100)
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>
src/net/fcels.c

index 67ee5ef5042a576cd0c572299e6bc4c86c1d8775..ef809ad86e1f0306ce6337531dd98b38574a8346 100644 (file)
@@ -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 ) );