Browse Source

[iscsi] Ensure ISID is consistent within an iSCSI session

Commit 5f4ab0d ("[iscsi] Randomise a portion of the ISID to force new
session instantiation") introduced a regression by randomising the
ISID on each call to iscsi_start_login(), which may be called more
than once per connection, rather than on each call to
iscsi_open_connection(), which is guaranteed to be called only once
per connection.  This is incorrect behaviour that causes our
connection to be rejected by some iSCSI targets (observed with a
COMSTAR target under OpenSolaris).

Fix by generating the ISID in iscsi_open_connection(), and storing the
randomised ISID as part of the session state.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
19c59bb131
2 changed files with 10 additions and 1 deletions
  1. 6
    0
      src/include/ipxe/iscsi.h
  2. 4
    1
      src/net/tcp/iscsi.c

+ 6
- 0
src/include/ipxe/iscsi.h View File

539
 	/** CHAP response (used for both initiator and target auth) */
539
 	/** CHAP response (used for both initiator and target auth) */
540
 	struct chap_response chap;
540
 	struct chap_response chap;
541
 
541
 
542
+	/** Initiator session ID (IANA format) qualifier
543
+	 *
544
+	 * This is part of the ISID.  It is generated randomly
545
+	 * whenever a new connection is opened.
546
+	 */
547
+	uint16_t isid_iana_qual;
542
 	/** Initiator task tag
548
 	/** Initiator task tag
543
 	 *
549
 	 *
544
 	 * This is the tag of the current command.  It is incremented
550
 	 * This is the tag of the current command.  It is incremented

+ 4
- 1
src/net/tcp/iscsi.c View File

246
 	if ( iscsi->target_username )
246
 	if ( iscsi->target_username )
247
 		iscsi->status |= ISCSI_STATUS_AUTH_REVERSE_REQUIRED;
247
 		iscsi->status |= ISCSI_STATUS_AUTH_REVERSE_REQUIRED;
248
 
248
 
249
+	/* Assign new ISID */
250
+	iscsi->isid_iana_qual = ( random() & 0xffff );
251
+
249
 	/* Assign fresh initiator task tag */
252
 	/* Assign fresh initiator task tag */
250
 	iscsi_new_itt ( iscsi );
253
 	iscsi_new_itt ( iscsi );
251
 
254
 
707
 	ISCSI_SET_LENGTHS ( request->lengths, 0, len );
710
 	ISCSI_SET_LENGTHS ( request->lengths, 0, len );
708
 	request->isid_iana_en = htonl ( ISCSI_ISID_IANA |
711
 	request->isid_iana_en = htonl ( ISCSI_ISID_IANA |
709
 					IANA_EN_FEN_SYSTEMS );
712
 					IANA_EN_FEN_SYSTEMS );
710
-	request->isid_iana_qual = ( random() & 0xffff );
713
+	request->isid_iana_qual = htons ( iscsi->isid_iana_qual );
711
 	/* tsih left as zero */
714
 	/* tsih left as zero */
712
 	request->itt = htonl ( iscsi->itt );
715
 	request->itt = htonl ( iscsi->itt );
713
 	/* cid left as zero */
716
 	/* cid left as zero */

Loading…
Cancel
Save