diff options
| author | Sebastian Vater | 2025-08-22 08:41:42 +0200 |
|---|---|---|
| committer | Sebastian Vater | 2025-08-22 08:41:42 +0200 |
| commit | dbb585c025698704c50c7c279454bce1c44f54aa (patch) | |
| tree | 1226c7c82501d21a566cc053e8e8cb8e55ea0c17 | |
| parent | Implemented sending iSCSI Ready To Transfer (R2T) packet data. Also added ver... (diff) | |
| download | dnbd3-dbb585c025698704c50c7c279454bce1c44f54aa.tar.gz dnbd3-dbb585c025698704c50c7c279454bce1c44f54aa.tar.xz dnbd3-dbb585c025698704c50c7c279454bce1c44f54aa.zip | |
Added portal group for iSCSI on DNBD3 connection init.
| -rw-r--r-- | src/server/iscsi.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/src/server/iscsi.c b/src/server/iscsi.c index 9394780..d7b13cb 100644 --- a/src/server/iscsi.c +++ b/src/server/iscsi.c @@ -7089,14 +7089,47 @@ void iscsi_connection_handle(dnbd3_client_t *client, const dnbd3_request_t *requ if ( port != NULL ) port++; + iscsi_portal_group *portal_group = iscsi_portal_group_create( 1L, 1L ); + + if ( portal_group == NULL ) { + logadd( LOG_ERROR, "iscsi_connection_handle: Out of memory while allocating iSCSI portal group" ); + + return; + } + + int id = iscsi_hashmap_size( iscsi_globvec->portal_groups ) + 1; + + portal_group->tag = id; + + uint8_t *hash_key = iscsi_hashmap_key_create( (uint8_t *) &id, sizeof(id) ); + + if ( hash_key == NULL ) { + logadd( LOG_ERROR, "iscsi_connection_handle: Out of memory while allocating iSCSI portal group" ); + + return; + } + + int rc = iscsi_hashmap_put( iscsi_globvec->portal_groups, hash_key, sizeof(id), (uint8_t *) portal_group ); + + if ( rc < 0 ) { + iscsi_hashmap_key_destroy( hash_key ); + iscsi_portal_group_destroy( portal_group ); + + return; + } + iscsi_portal *portal = iscsi_portal_create( (uint8_t *) client->hostName, port ); if ( portal == NULL ) { logadd( LOG_ERROR, "iscsi_connection_handle: Out of memory while allocating iSCSI portal" ); + iscsi_portal_group_destroy( portal_group ); + return; } + portal->group = portal_group; + iscsi_connection *conn = iscsi_connection_create( portal, client->sock ); if ( conn == NULL ) { @@ -7107,11 +7140,11 @@ void iscsi_connection_handle(dnbd3_client_t *client, const dnbd3_request_t *requ return; } - const int id = iscsi_hashmap_size( iscsi_globvec->connections ) + 1; + id = iscsi_hashmap_size( iscsi_globvec->connections ) + 1; conn->id = id; - uint8_t *hash_key = iscsi_hashmap_key_create( (uint8_t *) &id, sizeof(id) ); + hash_key = iscsi_hashmap_key_create( (uint8_t *) &id, sizeof(id) ); if ( hash_key == NULL ) { logadd( LOG_ERROR, "iscsi_connection_handle: Out of memory while allocating iSCSI connection" ); @@ -7137,7 +7170,7 @@ void iscsi_connection_handle(dnbd3_client_t *client, const dnbd3_request_t *requ conn->pdu_processing->bhs_read_len = len; conn->pdu_recv_state = ISCSI_CONNECT_PDU_RECV_STATE_WAIT_PDU_HDR; - int rc = iscsi_hashmap_put( iscsi_globvec->connections, hash_key, sizeof(id), (uint8_t *) conn ); + rc = iscsi_hashmap_put( iscsi_globvec->connections, hash_key, sizeof(id), (uint8_t *) conn ); if ( rc < 0 ) { iscsi_connection_pdu_destroy( conn->pdu_processing ); |
