Ver código fonte

[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 anos atrás
pai
commit
19c59bb131
2 arquivos alterados com 10 adições e 1 exclusões
  1. 6
    0
      src/include/ipxe/iscsi.h
  2. 4
    1
      src/net/tcp/iscsi.c

+ 6
- 0
src/include/ipxe/iscsi.h Ver arquivo

@@ -539,6 +539,12 @@ struct iscsi_session {
539 539
 	/** CHAP response (used for both initiator and target auth) */
540 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 548
 	/** Initiator task tag
543 549
 	 *
544 550
 	 * This is the tag of the current command.  It is incremented

+ 4
- 1
src/net/tcp/iscsi.c Ver arquivo

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

Carregando…
Cancelar
Salvar