iscsi-scstd: Return SVC_UNAVAILABLE while logins are suspended

SIGUSR1/SIGUSR2 set/clear logins_suspended. While set, any login
attempt is rejected with a retriable Target Error instead of the
permanent Initiator Error (TGT_NOT_FOUND) that causes initiators
to give up.
This commit is contained in:
Brian M
2026-03-16 20:19:45 -07:00
committed by Gleb Chesnokov
parent 08eaa7d5ee
commit 0731c421fd
3 changed files with 29 additions and 0 deletions

View File

@@ -858,6 +858,18 @@ static void init_max_params(void)
return;
}
static void suspend_logins(int sig)
{
(void)sig;
logins_suspended = 1;
}
static void resume_logins(int sig)
{
(void)sig;
logins_suspended = 0;
}
int main(int argc, char **argv)
{
int ch, longindex;
@@ -883,6 +895,14 @@ int main(int argc, char **argv)
int rc = sigaction(SIGPIPE, &act, NULL);
assert(rc == 0);
act = (struct sigaction) { .sa_handler = suspend_logins };
rc = sigaction(SIGUSR1, &act, NULL);
assert(rc == 0);
act = (struct sigaction) { .sa_handler = resume_logins };
rc = sigaction(SIGUSR2, &act, NULL);
assert(rc == 0);
while ((ch = getopt_long(argc, argv, "c:fd:s:u:g:a:p:vh", long_options, &longindex)) >= 0) {
switch (ch) {
case 'c':

View File

@@ -28,6 +28,7 @@
int iscsi_enabled;
char *internal_portal;
int logins_suspended;
static u32 ttt;
@@ -811,6 +812,13 @@ static void login_start(struct connection *conn)
return;
}
if (logins_suspended) {
log_info("Initiator %s login rejected: service temporarily unavailable",
conn->initiator);
login_rsp_tgt_err(conn, ISCSI_STATUS_SVC_UNAVAILABLE);
return;
}
session_type = text_key_find(conn, "SessionType");
target_name = text_key_find(conn, "TargetName");

View File

@@ -263,6 +263,7 @@ extern const char *get_error_str(int error);
/* iscsid.c */
extern int iscsi_enabled;
extern char *internal_portal;
extern int logins_suspended;
extern int cmnd_execute(struct connection *conn);
extern void cmnd_finish(struct connection *conn);