diff options
| author | Richard Scheffenegger <rscheff@FreeBSD.org> | 2022-02-25 09:33:59 +0000 |
|---|---|---|
| committer | Richard Scheffenegger <rscheff@FreeBSD.org> | 2022-02-25 09:35:47 +0000 |
| commit | bd6bb4939714bf8bf9cf180ffd4ff55cd876d643 (patch) | |
| tree | ea2374b038a9c5e47d69e5a83e6e064d7cd2c66f /sys | |
| parent | 05c3e8e87142a8689503a6731237b48fb43c1bec (diff) | |
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/dev/iscsi/iscsi.c | 43 | ||||
| -rw-r--r-- | sys/dev/iscsi/iscsi.h | 2 | ||||
| -rw-r--r-- | sys/dev/iscsi/iscsi_ioctl.h | 3 |
3 files changed, 43 insertions, 5 deletions
diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 1621e31576cf..c97bfaf0e6c5 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -42,9 +42,11 @@ __FBSDID("$FreeBSD$"); #include <sys/kthread.h> #include <sys/lock.h> #include <sys/malloc.h> +#include <sys/mbuf.h> #include <sys/mutex.h> #include <sys/module.h> #include <sys/socket.h> +#include <sys/sockopt.h> #include <sys/sysctl.h> #include <sys/systm.h> #include <sys/sx.h> @@ -86,6 +88,7 @@ SYSCTL_NODE(_kern, OID_AUTO, iscsi, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, static int debug = 1; SYSCTL_INT(_kern_iscsi, OID_AUTO, debug, CTLFLAG_RWTUN, &debug, 0, "Enable debug messages"); + static int ping_timeout = 5; SYSCTL_INT(_kern_iscsi, OID_AUTO, ping_timeout, CTLFLAG_RWTUN, &ping_timeout, 0, "Timeout for ping (NOP-Out) requests, in seconds"); @@ -380,6 +383,26 @@ iscsi_session_cleanup(struct iscsi_session *is, bool destroy_sim) static void iscsi_maintenance_thread_reconnect(struct iscsi_session *is) { + /* + * As we will be reconnecting shortly, + * discard outstanding data immediately on + * close(), also notify peer via RST if + * any packets come in. + */ + struct socket *so; + so = is->is_conn->ic_socket; + if (so != NULL) { + struct sockopt sopt; + struct linger sl; + sopt.sopt_dir = SOPT_SET; + sopt.sopt_level = SOL_SOCKET; + sopt.sopt_name = SO_LINGER; + sopt.sopt_val = &sl; + sopt.sopt_valsize = sizeof(sl); + sl.l_onoff = 1; /* non-zero value enables linger option in kernel */ + sl.l_linger = 0; /* timeout interval in seconds */ + sosetopt(is->is_conn->ic_socket, &sopt); + } icl_conn_close(is->is_conn); @@ -576,7 +599,7 @@ iscsi_callout(void *context) } if (is->is_login_phase) { - if (login_timeout > 0 && is->is_timeout > login_timeout) { + if (is->is_login_timeout > 0 && is->is_timeout > is->is_login_timeout) { ISCSI_SESSION_WARN(is, "login timed out after %d seconds; " "reconnecting", is->is_timeout); reconnect_needed = true; @@ -584,7 +607,7 @@ iscsi_callout(void *context) goto out; } - if (ping_timeout <= 0) { + if (is->is_ping_timeout <= 0) { /* * Pings are disabled. Don't send NOP-Out in this case. * Reset the timeout, to avoid triggering reconnection, @@ -594,9 +617,9 @@ iscsi_callout(void *context) goto out; } - if (is->is_timeout >= ping_timeout) { + if (is->is_timeout >= is->is_ping_timeout) { ISCSI_SESSION_WARN(is, "no ping reply (NOP-In) after %d seconds; " - "reconnecting", ping_timeout); + "reconnecting", is->is_ping_timeout); reconnect_needed = true; goto out; } @@ -1509,6 +1532,12 @@ iscsi_ioctl_daemon_handoff(struct iscsi_softc *sc, is->is_waiting_for_iscsid = false; is->is_login_phase = false; is->is_timeout = 0; + is->is_ping_timeout = is->is_conf.isc_ping_timeout; + if (is->is_ping_timeout < 0) + is->is_ping_timeout = ping_timeout; + is->is_login_timeout = is->is_conf.isc_login_timeout; + if (is->is_login_timeout < 0) + is->is_login_timeout = login_timeout; is->is_connected = true; is->is_reason[0] = '\0'; @@ -1915,6 +1944,12 @@ iscsi_ioctl_session_add(struct iscsi_softc *sc, struct iscsi_session_add *isa) sx_xunlock(&sc->sc_lock); return (error); } + is->is_ping_timeout = is->is_conf.isc_ping_timeout; + if (is->is_ping_timeout < 0) + is->is_ping_timeout = ping_timeout; + is->is_login_timeout = is->is_conf.isc_login_timeout; + if (is->is_login_timeout < 0) + is->is_login_timeout = login_timeout; sbt = mstosbt(995); pr = mstosbt(10); diff --git a/sys/dev/iscsi/iscsi.h b/sys/dev/iscsi/iscsi.h index 871fc6fc90e9..06a1ecc56890 100644 --- a/sys/dev/iscsi/iscsi.h +++ b/sys/dev/iscsi/iscsi.h @@ -75,6 +75,8 @@ struct iscsi_session { struct callout is_callout; unsigned int is_timeout; + int is_ping_timeout; + int is_login_timeout; /* * XXX: This could be rewritten using a single variable, diff --git a/sys/dev/iscsi/iscsi_ioctl.h b/sys/dev/iscsi/iscsi_ioctl.h index 81e49d8d9a33..c1de089c9d3f 100644 --- a/sys/dev/iscsi/iscsi_ioctl.h +++ b/sys/dev/iscsi/iscsi_ioctl.h @@ -71,7 +71,8 @@ struct iscsi_session_conf { int isc_enable; int isc_dscp; int isc_pcp; - int isc_spare[2]; + int isc_ping_timeout; + int isc_login_timeout; }; /* |
