Browse Source

[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 years ago
parent
commit
5e56e5f5a3
1 changed files with 22 additions and 3 deletions
  1. 22
    3
      src/net/fcels.c

+ 22
- 3
src/net/fcels.c View File

153
  */
153
  */
154
 static int fc_els_rx ( struct fc_els *els,
154
 static int fc_els_rx ( struct fc_els *els,
155
 		       struct io_buffer *iobuf,
155
 		       struct io_buffer *iobuf,
156
-		       struct xfer_metadata *meta __unused ) {
156
+		       struct xfer_metadata *meta ) {
157
 	struct fc_els_frame_common *frame = iobuf->data;
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
 	size_t len = iob_len ( iobuf );
160
 	size_t len = iob_len ( iobuf );
159
 	int ( * rx ) ( struct fc_els *els, const void *data, size_t len );
161
 	int ( * rx ) ( struct fc_els *els, const void *data, size_t len );
160
 	int rc;
162
 	int rc;
167
 		rc = -EINVAL;
169
 		rc = -EINVAL;
168
 		goto done;
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
 	/* Check for rejection responses */
185
 	/* Check for rejection responses */
172
 	if ( fc_els_is_request ( els ) &&
186
 	if ( fc_els_is_request ( els ) &&
177
 		goto done;
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
 	/* Determine handler, if necessary */
199
 	/* Determine handler, if necessary */
181
 	if ( ! els->handler )
200
 	if ( ! els->handler )
182
 		els->handler = fc_els_detect ( els, frame, len );
201
 		els->handler = fc_els_detect ( els, frame, len );
513
 	DBGC ( els, FCELS_FMT " has port %s\n", FCELS_ARGS ( els ),
532
 	DBGC ( els, FCELS_FMT " has port %s\n", FCELS_ARGS ( els ),
514
 	       fc_ntoa ( &flogi->port_wwn ) );
533
 	       fc_ntoa ( &flogi->port_wwn ) );
515
 	if ( has_fabric ) {
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
 	} else {
537
 	} else {
519
 		DBGC ( els, FCELS_FMT " has point-to-point link\n",
538
 		DBGC ( els, FCELS_FMT " has point-to-point link\n",
520
 		       FCELS_ARGS ( els ) );
539
 		       FCELS_ARGS ( els ) );

Loading…
Cancel
Save