diff options
| author | Simon Rettberg | 2025-10-20 16:40:15 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2025-12-09 15:33:20 +0100 |
| commit | 65f3100f7ee79bfc8bda9e7ca2ce6015e8dc02dc (patch) | |
| tree | 7145c4b075b54adb7e37e04700343cad816ce43b /src/server/net.c | |
| parent | [SERVER] iscsi: use sendfile() (diff) | |
| download | dnbd3-65f3100f7ee79bfc8bda9e7ca2ce6015e8dc02dc.tar.gz dnbd3-65f3100f7ee79bfc8bda9e7ca2ce6015e8dc02dc.tar.xz dnbd3-65f3100f7ee79bfc8bda9e7ca2ce6015e8dc02dc.zip | |
[SERVER] Check if iSCSI server is enabled, check opcode
Diffstat (limited to 'src/server/net.c')
| -rw-r--r-- | src/server/net.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/server/net.c b/src/server/net.c index e94e549..4c04462 100644 --- a/src/server/net.c +++ b/src/server/net.c @@ -184,17 +184,21 @@ void* net_handleNewConnection(void *clientPtr) if ( ((char*)&request)[0] == 'G' || ((char*)&request)[0] == 'P' ) { // Close enough... rpc_sendStatsJson( client->sock, &client->host, &request, ret ); - } else if ( true /* check opcode ... */ ) { - initClientStruct( client ); - if ( !addToList( client ) ) { - freeClientStruct( client ); - logadd( LOG_WARNING, "Could not add new iSCSI client to list when connecting" ); + } else if ( ((char*)&request)[0] == 0x43 ) { // Login opcode 0x03 + immediate bit (0x40) set + if ( !_iScsiServer ) { + logadd( LOG_INFO, "Received iSCSI login request from %s, but iSCSI server is not enabled", client->hostName ); } else { - iscsi_connection_handle( client, &request, ret ); - goto exit_client_cleanup; + initClientStruct( client ); + if ( !addToList( client ) ) { + freeClientStruct( client ); + logadd( LOG_WARNING, "Could not add new iSCSI client to list when connecting" ); + } else { + iscsi_connection_handle( client, &request, ret ); + goto exit_client_cleanup; + } } } else { - logadd( LOG_DEBUG1, "Magic in client handshake incorrect" ); + logadd( LOG_DEBUG1, "Magic in client handshake unknown" ); } goto fail_preadd; } |
