Kaynağa Gözat

[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>
tags/v1.20.1
Michael Brown 13 yıl önce
ebeveyn
işleme
5e56e5f5a3
1 değiştirilmiş dosya ile 22 ekleme ve 3 silme
  1. 22
    3
      src/net/fcels.c

+ 22
- 3
src/net/fcels.c Dosyayı Görüntüle

@@ -153,8 +153,10 @@ int fc_els_tx ( struct fc_els *els, const void *data, size_t len ) {
153 153
  */
154 154
 static int fc_els_rx ( struct fc_els *els,
155 155
 		       struct io_buffer *iobuf,
156
-		       struct xfer_metadata *meta __unused ) {
156
+		       struct xfer_metadata *meta ) {
157 157
 	struct fc_els_frame_common *frame = iobuf->data;
158
+	struct sockaddr_fc *src = ( ( struct sockaddr_fc * ) meta->src );
159
+	struct sockaddr_fc *dest = ( ( struct sockaddr_fc * ) meta->dest );
158 160
 	size_t len = iob_len ( iobuf );
159 161
 	int ( * rx ) ( struct fc_els *els, const void *data, size_t len );
160 162
 	int rc;
@@ -167,6 +169,18 @@ static int fc_els_rx ( struct fc_els *els,
167 169
 		rc = -EINVAL;
168 170
 		goto done;
169 171
 	}
172
+	if ( ! src ) {
173
+		DBGC ( els, FCELS_FMT " received frame missing source "
174
+		       "address:\n", FCELS_ARGS ( els ) );
175
+		rc = -EINVAL;
176
+		goto done;
177
+	}
178
+	if ( ! dest ) {
179
+		DBGC ( els, FCELS_FMT " received frame missing destination "
180
+		       "address:\n", FCELS_ARGS ( els ) );
181
+		rc = -EINVAL;
182
+		goto done;
183
+	}
170 184
 
171 185
 	/* Check for rejection responses */
172 186
 	if ( fc_els_is_request ( els ) &&
@@ -177,6 +191,11 @@ static int fc_els_rx ( struct fc_els *els,
177 191
 		goto done;
178 192
 	}
179 193
 
194
+	/* Update port IDs */
195
+	memcpy ( &els->port_id, &dest->sfc_port_id, sizeof ( els->port_id ) );
196
+	memcpy ( &els->peer_port_id, &src->sfc_port_id,
197
+		 sizeof ( els->peer_port_id ) );
198
+
180 199
 	/* Determine handler, if necessary */
181 200
 	if ( ! els->handler )
182 201
 		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,
513 532
 	DBGC ( els, FCELS_FMT " has port %s\n", FCELS_ARGS ( els ),
514 533
 	       fc_ntoa ( &flogi->port_wwn ) );
515 534
 	if ( has_fabric ) {
516
-		DBGC ( els, FCELS_FMT " has fabric with local ID %s\n",
517
-		       FCELS_ARGS ( els ), fc_id_ntoa ( &els->port_id ) );
535
+		DBGC ( els, FCELS_FMT " has fabric with", FCELS_ARGS ( els ) );
536
+		DBGC ( els, " local ID %s\n", fc_id_ntoa ( &els->port_id ) );
518 537
 	} else {
519 538
 		DBGC ( els, FCELS_FMT " has point-to-point link\n",
520 539
 		       FCELS_ARGS ( els ) );

Loading…
İptal
Kaydet