For some reason, our ISID has only ever had 8-bits of uniqueness.  We
use the OUI format, which leaves 24-bits of qualifier space that we
could be using.

This simple change uses the lower 24-bits bits of our 32-bit session id.

I've tested this using multiple sessions to a single target portal.
Previously ISIDs would start to be reused after 256 connections, causing
the target to disconnect existing sessions where there was a collision.
With this I can maintain 2048 stable TCP connections to a single target
portal. I tried 4096, but something went wrong with 4027 active sessions
and I'm not sure where the issue was yet.

CC: shiva krishna merla <[email protected]>
Signed-off-by: Chris Leech <[email protected]>
---
 usr/discovery.c | 4 +++-
 usr/initiator.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/usr/discovery.c b/usr/discovery.c
index 43c2359..593d226 100644
--- a/usr/discovery.c
+++ b/usr/discovery.c
@@ -1152,7 +1152,9 @@ static int iscsi_create_leading_conn(struct iscsi_session 
*session)
        }
        log_debug(2, "%s discovery created session %u", __FUNCTION__,
                  session->id);
-       session->isid[3] = session->id;
+       session->isid[3] = (session->id >> 16) & 0xff;
+       session->isid[4] = (session->id >>  8) & 0xff;
+       session->isid[5] = session->id & 0xff;
 
        log_debug(2, "%s discovery create conn", __FUNCTION__);
        rc = ipc->create_conn(t->handle, session->id, conn->id, &conn->id);
diff --git a/usr/initiator.c b/usr/initiator.c
index efaa965..8cd1896 100644
--- a/usr/initiator.c
+++ b/usr/initiator.c
@@ -1571,7 +1571,9 @@ static void session_conn_poll(void *data)
                 * TODO: use the iface number or some other value
                 * so this will be persistent
                 */
-               session->isid[3] = session->id;
+               session->isid[3] = (session->id >> 16) & 0xff;
+               session->isid[4] = (session->id >>  8) & 0xff;
+               session->isid[5] = session->id & 0xff;
 
                if (ipc->bind_conn(session->t->handle, session->id,
                                   conn->id, conn->transport_ep_handle,
-- 
2.5.0

-- 
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/open-iscsi.
For more options, visit https://groups.google.com/d/optout.

Reply via email to