]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[iscsi] Ensure ISID is consistent within an iSCSI session
authorMichael Brown <mcb30@ipxe.org>
Mon, 18 Oct 2010 13:37:11 +0000 (14:37 +0100)
committerMichael Brown <mcb30@ipxe.org>
Mon, 18 Oct 2010 13:40:27 +0000 (14:40 +0100)
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>
src/include/ipxe/iscsi.h
src/net/tcp/iscsi.c

index e711459c94fdb0e3dfaf3d66f9a4d336930ae325..4890bcc6ddeb20b2b164ba167e08d21451702fc1 100644 (file)
@@ -539,6 +539,12 @@ struct iscsi_session {
        /** CHAP response (used for both initiator and target auth) */
        struct chap_response chap;
 
+       /** Initiator session ID (IANA format) qualifier
+        *
+        * This is part of the ISID.  It is generated randomly
+        * whenever a new connection is opened.
+        */
+       uint16_t isid_iana_qual;
        /** Initiator task tag
         *
         * This is the tag of the current command.  It is incremented
index a483dd40a324caf08961906e186b256bd99bcbec..5e003a8162e382bbe004abe3a93a342005ae3332 100644 (file)
@@ -246,6 +246,9 @@ static int iscsi_open_connection ( struct iscsi_session *iscsi ) {
        if ( iscsi->target_username )
                iscsi->status |= ISCSI_STATUS_AUTH_REVERSE_REQUIRED;
 
+       /* Assign new ISID */
+       iscsi->isid_iana_qual = ( random() & 0xffff );
+
        /* Assign fresh initiator task tag */
        iscsi_new_itt ( iscsi );
 
@@ -707,7 +710,7 @@ static void iscsi_start_login ( struct iscsi_session *iscsi ) {
        ISCSI_SET_LENGTHS ( request->lengths, 0, len );
        request->isid_iana_en = htonl ( ISCSI_ISID_IANA |
                                        IANA_EN_FEN_SYSTEMS );
-       request->isid_iana_qual = ( random() & 0xffff );
+       request->isid_iana_qual = htons ( iscsi->isid_iana_qual );
        /* tsih left as zero */
        request->itt = htonl ( iscsi->itt );
        /* cid left as zero */