CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Thu Dec 28 15:58:24 UTC 2023 Modified Files: src/sys/dev/iscsi: iscsi_main.c Log Message: Use correct status value SCSI_BUSY (0x08) instead of XS_BUSY (7) when running out of sessions. The bug had no impact as scsipi was only comparing against SCSI_CHECK (0x02) and SCSI_QUEUE_FULL (0x28). To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/iscsi/iscsi_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Thu Dec 28 15:58:24 UTC 2023 Modified Files: src/sys/dev/iscsi: iscsi_main.c Log Message: Use correct status value SCSI_BUSY (0x08) instead of XS_BUSY (7) when running out of sessions. The bug had no impact as scsipi was only comparing against SCSI_CHECK (0x02) and SCSI_QUEUE_FULL (0x28). To generate a diff of this commit: cvs rdiff -u -r1.41 -r1.42 src/sys/dev/iscsi/iscsi_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/iscsi/iscsi_main.c diff -u src/sys/dev/iscsi/iscsi_main.c:1.41 src/sys/dev/iscsi/iscsi_main.c:1.42 --- src/sys/dev/iscsi/iscsi_main.c:1.41 Tue Sep 13 13:09:16 2022 +++ src/sys/dev/iscsi/iscsi_main.c Thu Dec 28 15:58:24 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_main.c,v 1.41 2022/09/13 13:09:16 mlelstv Exp $ */ +/* $NetBSD: iscsi_main.c,v 1.42 2023/12/28 15:58:24 mlelstv Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -490,7 +490,7 @@ iscsi_scsipi_request(struct scsipi_chann DEB(9, ("ISCSI: refcount too high: %d, winsize %d\n", sess->s_refcount, sess->s_send_window)); xs->error = XS_BUSY; - xs->status = XS_BUSY; + xs->status = SCSI_BUSY; scsipi_done(xs); return; }
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Sat Nov 25 10:08:27 UTC 2023 Modified Files: src/sys/dev/iscsi: iscsi.h iscsi_globals.h iscsi_ioctl.c iscsi_send.c iscsi_text.c iscsi_utils.c Log Message: Adapt to bignum representation of target. Fix negotiation for mutual authentication. Prepare for more CHAP types. Fix crashes for invalid socket descriptors passed to kernel. Protect usecount with connection mutex, avoids race on connection close. Minor cosmetics. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/iscsi/iscsi.h cvs rdiff -u -r1.27 -r1.28 src/sys/dev/iscsi/iscsi_globals.h cvs rdiff -u -r1.33 -r1.34 src/sys/dev/iscsi/iscsi_ioctl.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/iscsi/iscsi_send.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/iscsi/iscsi_text.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/iscsi/iscsi_utils.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Sat Nov 25 10:08:27 UTC 2023 Modified Files: src/sys/dev/iscsi: iscsi.h iscsi_globals.h iscsi_ioctl.c iscsi_send.c iscsi_text.c iscsi_utils.c Log Message: Adapt to bignum representation of target. Fix negotiation for mutual authentication. Prepare for more CHAP types. Fix crashes for invalid socket descriptors passed to kernel. Protect usecount with connection mutex, avoids race on connection close. Minor cosmetics. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/dev/iscsi/iscsi.h cvs rdiff -u -r1.27 -r1.28 src/sys/dev/iscsi/iscsi_globals.h cvs rdiff -u -r1.33 -r1.34 src/sys/dev/iscsi/iscsi_ioctl.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/iscsi/iscsi_send.c cvs rdiff -u -r1.13 -r1.14 src/sys/dev/iscsi/iscsi_text.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/iscsi/iscsi_utils.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/iscsi/iscsi.h diff -u src/sys/dev/iscsi/iscsi.h:1.4 src/sys/dev/iscsi/iscsi.h:1.5 --- src/sys/dev/iscsi/iscsi.h:1.4 Wed Jun 15 04:30:30 2016 +++ src/sys/dev/iscsi/iscsi.h Sat Nov 25 10:08:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi.h,v 1.4 2016/06/15 04:30:30 mlelstv Exp $ */ +/* $NetBSD: iscsi.h,v 1.5 2023/11/25 10:08:27 mlelstv Exp $ */ /*- * Copyright (c) 2004,2006,2011 The NetBSD Foundation, Inc. @@ -54,6 +54,13 @@ typedef enum { Indicates SRP authentication (for future use). */ +typedef enum { + ISCSI_CHAP_MD5 = 5, + ISCSI_CHAP_SHA1 = 6, + ISCSI_CHAP_SHA256 = 7, + ISCSI_CHAP_SHA3_256 = 8 +} iscsi_chap_types_t; + typedef struct { unsigned int mutual_auth:1; unsigned int is_secure:1; Index: src/sys/dev/iscsi/iscsi_globals.h diff -u src/sys/dev/iscsi/iscsi_globals.h:1.27 src/sys/dev/iscsi/iscsi_globals.h:1.28 --- src/sys/dev/iscsi/iscsi_globals.h:1.27 Tue Sep 13 13:09:16 2022 +++ src/sys/dev/iscsi/iscsi_globals.h Sat Nov 25 10:08:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_globals.h,v 1.27 2022/09/13 13:09:16 mlelstv Exp $ */ +/* $NetBSD: iscsi_globals.h,v 1.28 2023/11/25 10:08:27 mlelstv Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -135,11 +135,10 @@ /* Connection state */ typedef enum { - /* first three correspond to CSG/NSG coding */ ST_SEC_NEG = 0, /* security negotiation phase */ - ST_OP_NEG = 1, /* operational negotiation phase */ + ST_SEC_FIN = 1, /* switch from SEC after mutual CHAP */ + ST_OP_NEG = 2, /* operational negotiation phase */ ST_FULL_FEATURE = 3, /* full feature phase */ - /* rest is internal */ ST_WINDING_DOWN = 4, /* connection termination initiated, logging out */ ST_LOGOUT_SENT = 5, /* logout has been sent */ ST_SETTLING = 6, /* waiting for things to settle down */ Index: src/sys/dev/iscsi/iscsi_ioctl.c diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.33 src/sys/dev/iscsi/iscsi_ioctl.c:1.34 --- src/sys/dev/iscsi/iscsi_ioctl.c:1.33 Tue Sep 13 13:09:16 2022 +++ src/sys/dev/iscsi/iscsi_ioctl.c Sat Nov 25 10:08:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_ioctl.c,v 1.33 2022/09/13 13:09:16 mlelstv Exp $ */ +/* $NetBSD: iscsi_ioctl.c,v 1.34 2023/11/25 10:08:27 mlelstv Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -728,18 +728,11 @@ create_connection(iscsi_login_parameters } rc = get_socket(par->socket, >c_sock); - fd_close(par->socket); + if (rc != EBADF) + fd_close(par->socket); if (rc) { DEBOUT(("Invalid socket %d\n", par->socket)); - - callout_destroy(>c_timeout); - rw_destroy(>c_sock_rw); - cv_destroy(>c_idle_cv); - cv_destroy(>c_ccb_cv); - cv_destroy(>c_pdu_cv); - cv_destroy(>c_conn_cv); - mutex_destroy(>c_lock); free(conn, M_DEVBUF); par->status = ISCSI_STATUS_INVALID_SOCKET; return rc; @@ -901,11 +894,13 @@ recreate_connection(iscsi_login_paramete DEBOUT(("Too many connections (max = %d, curr = %d)\n", sess->s_MaxConnections, sess->s_active_connections)); - /* Always close the desecriptor */ - fd_close(par->socket); + /* Close the desecriptor */ + rc = EIO; + if (fd_getfile(par->socket) != NULL) + rc = fd_close(par->socket); par->status = ISCSI_STATUS_MAXED_CONNECTIONS; - return EIO; + return rc; } rw_enter(>c_sock_rw, RW_WRITER); @@ -915,7 +910,8 @@ recreate_connection(iscsi_login_paramete } rc = get_socket(par->socket, >c_sock); rw_exit(>c_sock_rw); - fd_close(par->socket); + if (rc != EBADF) + fd_close(par->socket); if (rc) { DEBOUT(("Invalid socket %d\n", par->socket)); @@ -1739,19 +1735,23 @@ iscsi_cleanup_thread(void *par) * the send/recv threads have been killed */ DEBC(conn, 5, ("Cleanup: Waiting for threads to exit\n")); + + mutex_enter(>c_lock); while (conn->c_sendproc || conn->c_rcvproc) -kpause("threads", false, hz, NULL); +kpause("threads", false, hz, >c_lock); for (s=1; conn->c_usecount > 0 && s < 3; ++s) -kpause("usecount", false,
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Tue Sep 13 13:09:16 UTC 2022 Modified Files: src/sys/dev/iscsi: iscsi_globals.h iscsi_ioctl.c iscsi_main.c iscsi_rcv.c iscsi_send.c iscsi_utils.c Log Message: kill_session now uses the session id to avoid stale session pointers. protect network socket with rwlock to handle recconnects. always take over socket from iscsid to prevent leaks. keep a good connection alive. don't forget child device when config_detach fails. fix locking when reassigning CCBs. pducount is protected by lock, no need for atomic. some code rework, refined debug messages. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/iscsi/iscsi_globals.h cvs rdiff -u -r1.32 -r1.33 src/sys/dev/iscsi/iscsi_ioctl.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/iscsi/iscsi_main.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/iscsi/iscsi_rcv.c cvs rdiff -u -r1.38 -r1.39 src/sys/dev/iscsi/iscsi_send.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/iscsi/iscsi_utils.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/iscsi/iscsi_globals.h diff -u src/sys/dev/iscsi/iscsi_globals.h:1.26 src/sys/dev/iscsi/iscsi_globals.h:1.27 --- src/sys/dev/iscsi/iscsi_globals.h:1.26 Sun Jun 21 23:08:16 2020 +++ src/sys/dev/iscsi/iscsi_globals.h Tue Sep 13 13:09:16 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_globals.h,v 1.26 2020/06/21 23:08:16 chs Exp $ */ +/* $NetBSD: iscsi_globals.h,v 1.27 2022/09/13 13:09:16 mlelstv Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -37,6 +37,8 @@ /* Includes we need in all files */ #include +#include +#include #include #include #include @@ -354,6 +356,8 @@ struct connection_s { struct lwp *c_threadobj; /* proc/thread pointer of socket owner */ + + krwlock_t c_sock_rw; struct file *c_sock; /* the connection's socket */ session_t *c_session; /* back pointer to the owning session */ @@ -366,7 +370,7 @@ struct connection_s { intc_recover; /* recovery count */ /* (reset on first successful data transfer) */ volatile unsigned c_usecount; /* number of active CCBs */ - volatile unsigned c_pducount; /* number of active PDUs */ + unsigned c_pducount; /* number of active PDUs */ boolc_destroy; /* conn will be destroyed */ boolc_in_session; @@ -537,8 +541,8 @@ extern bool iscsi_hex_bignums; /* Whethe #define DEBOUT(x) printf x #define DEB(lev,x) { if (iscsi_debug_level >= lev) printf x ;} #define DEBC(conn,lev,x) { if (iscsi_debug_level >= lev) { printf("S%dC%d: ", \ -conn ? conn->c_session->s_id : -1, \ -conn ? conn->c_id : -1); printf x ;}} + conn && conn->c_session ? conn->c_session->s_id : -1, \ + conn ? conn->c_id : -1); printf x ;}} #define STATIC static @@ -646,7 +650,7 @@ void iscsi_notify_cleanup(void); void add_event(iscsi_event_t, uint32_t, uint32_t, uint32_t); void kill_connection(connection_t *, uint32_t, int, bool); -void kill_session(session_t *, uint32_t, int, bool); +void kill_session(uint32_t, uint32_t, int, bool); int kill_all_sessions(void); void handle_connection_error(connection_t *, uint32_t, int); void add_connection_cleanup(connection_t *); Index: src/sys/dev/iscsi/iscsi_ioctl.c diff -u src/sys/dev/iscsi/iscsi_ioctl.c:1.32 src/sys/dev/iscsi/iscsi_ioctl.c:1.33 --- src/sys/dev/iscsi/iscsi_ioctl.c:1.32 Sun Jun 21 23:08:16 2020 +++ src/sys/dev/iscsi/iscsi_ioctl.c Tue Sep 13 13:09:16 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_ioctl.c,v 1.32 2020/06/21 23:08:16 chs Exp $ */ +/* $NetBSD: iscsi_ioctl.c,v 1.33 2022/09/13 13:09:16 mlelstv Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -494,8 +494,8 @@ kill_connection(connection_t *conn, uint if (recover && !conn->c_destroy && conn->c_recover > MAX_RECOVERY_ATTEMPTS) { - DEBC(conn, 1, - ("Kill_connection: Too many recovery attempts, destroying\n")); + DEBC(conn, 1, ("Kill_connection: Too many recovery attempts, " + "destroying\n")); conn->c_destroy = TRUE; } @@ -547,6 +547,8 @@ kill_connection(connection_t *conn, uint } mutex_exit(_cleanup_mtx); + DEBC(conn, 1, ("Send_logout for reason %d\n", logout)); + connection_timeout_start(conn, CONNECTION_TIMEOUT); if (!send_logout(conn, conn, logout, FALSE)) { @@ -591,14 +593,24 @@ done: */ void -kill_session(session_t *sess, uint32_t status, int logout, bool recover) +kill_session(uint32_t sid, uint32_t status, int logout, bool recover) { + session_t *sess; connection_t *conn; DEB(1, ("ISCSI: kill_session %d, status %d, logout %d, recover %d\n", - sess->s_id, status, logout, recover)); + sid, status, logout, recover)); mutex_enter(_cleanup_mtx); + + sess = find_session(sid); + if (sess == NULL) { + mutex_exit(_cleanup_mtx); + + DEB(5, ("Session %u already gone\n", sid)); + return; + } + if (sess->s_terminating)
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Tue Sep 13 13:09:16 UTC 2022 Modified Files: src/sys/dev/iscsi: iscsi_globals.h iscsi_ioctl.c iscsi_main.c iscsi_rcv.c iscsi_send.c iscsi_utils.c Log Message: kill_session now uses the session id to avoid stale session pointers. protect network socket with rwlock to handle recconnects. always take over socket from iscsid to prevent leaks. keep a good connection alive. don't forget child device when config_detach fails. fix locking when reassigning CCBs. pducount is protected by lock, no need for atomic. some code rework, refined debug messages. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/sys/dev/iscsi/iscsi_globals.h cvs rdiff -u -r1.32 -r1.33 src/sys/dev/iscsi/iscsi_ioctl.c cvs rdiff -u -r1.40 -r1.41 src/sys/dev/iscsi/iscsi_main.c cvs rdiff -u -r1.25 -r1.26 src/sys/dev/iscsi/iscsi_rcv.c cvs rdiff -u -r1.38 -r1.39 src/sys/dev/iscsi/iscsi_send.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/iscsi/iscsi_utils.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: riastradh Date: Sun Feb 13 19:03:25 UTC 2022 Modified Files: src/sys/dev/iscsi: iscsi_main.c Log Message: iscsi(4): Fix config_found usage -- needs kernel lock. Candidate fix for PR kern/56709. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/dev/iscsi/iscsi_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/iscsi/iscsi_main.c diff -u src/sys/dev/iscsi/iscsi_main.c:1.37 src/sys/dev/iscsi/iscsi_main.c:1.38 --- src/sys/dev/iscsi/iscsi_main.c:1.37 Sat Aug 7 16:19:12 2021 +++ src/sys/dev/iscsi/iscsi_main.c Sun Feb 13 19:03:25 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_main.c,v 1.37 2021/08/07 16:19:12 thorpej Exp $ */ +/* $NetBSD: iscsi_main.c,v 1.38 2022/02/13 19:03:25 riastradh Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -359,6 +359,7 @@ map_session(session_t *sess, device_t de struct scsipi_adapter *adapt = >s_sc_adapter; struct scsipi_channel *chan = >s_sc_channel; const quirktab_t *tgt; + int found; mutex_enter(>s_lock); sess->s_send_window = max(2, window_size(sess, CCBS_FOR_SCSIPI)); @@ -391,9 +392,12 @@ map_session(session_t *sess, device_t de chan->chan_nluns = 16; chan->chan_id = sess->s_id; + KERNEL_LOCK(1, NULL); sess->s_child_dev = config_found(dev, chan, scsiprint, CFARGS_NONE); + found = (sess->s_child_dev != NULL); + KERNEL_UNLOCK_ONE(NULL); - return sess->s_child_dev != NULL; + return found; }
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: riastradh Date: Sun Feb 13 19:03:25 UTC 2022 Modified Files: src/sys/dev/iscsi: iscsi_main.c Log Message: iscsi(4): Fix config_found usage -- needs kernel lock. Candidate fix for PR kern/56709. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/dev/iscsi/iscsi_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Sat Jul 13 17:06:00 UTC 2019 Modified Files: src/sys/dev/iscsi: iscsi_main.c Log Message: register with pmf to allow suspend. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/iscsi/iscsi_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/iscsi/iscsi_main.c diff -u src/sys/dev/iscsi/iscsi_main.c:1.29 src/sys/dev/iscsi/iscsi_main.c:1.30 --- src/sys/dev/iscsi/iscsi_main.c:1.29 Sun Apr 21 11:26:46 2019 +++ src/sys/dev/iscsi/iscsi_main.c Sat Jul 13 17:06:00 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_main.c,v 1.29 2019/04/21 11:26:46 mlelstv Exp $ */ +/* $NetBSD: iscsi_main.c,v 1.30 2019/07/13 17:06:00 mlelstv Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -252,6 +252,9 @@ iscsi_attach(device_t parent, device_t s iscsi_detaching = false; iscsi_init_cleanup(); + if (!pmf_device_register(self, NULL, NULL)) + aprint_error_dev(self, "couldn't establish power handler\n"); + aprint_normal("%s: attached. major = %d\n", iscsi_cd.cd_name, cdevsw_lookup_major(_cdevsw)); } @@ -285,6 +288,8 @@ iscsi_detach(device_t self, int flags) if (error) return error; + pmf_device_deregister(sc->dev); + mutex_destroy(>lock); return 0;
CVS commit: src/sys/dev/iscsi
Module Name:src Committed By: mlelstv Date: Sat Jul 13 17:06:00 UTC 2019 Modified Files: src/sys/dev/iscsi: iscsi_main.c Log Message: register with pmf to allow suspend. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/dev/iscsi/iscsi_main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sys/dev/iscsi
On 5/28/12 6:12 AM, Christos Zoulas wrote: In article20120528034319.0c66217...@cvs.netbsd.org, Jeff Rizzosource-changes-d@NetBSD.org wrote: -=-=-=-=-=- Module Name:src Committed By: riz Date: Mon May 28 03:43:18 UTC 2012 Modified Files: src/sys/dev/iscsi: iscsi_main.c Log Message: Don't allow iscsi to autounload. The default unload timeout is short, and too much state is lost. This can be done better, I.e. instead of never unload, make it unload when it is not busy. christos Baby steps, baby steps. It can still be manually unloaded. The real problem is all the configuration from userland that gets lost when unloaded - the user needs to anticipate this, so he can reconfigure it when loaded again. +j