From aff47bebb9cd6cf46cc230bb3c0cf852b152284e Mon Sep 17 00:00:00 2001 From: trasz Date: Fri, 13 Dec 2013 21:41:23 +0000 Subject: [PATCH] MFC r259183: Properly refuse handoff requests on already connected sessions. Previously this would result in dropping the session. Approved by: re (gjb) Sponsored by: The FreeBSD Foundation git-svn-id: svn://svn.freebsd.org/base/releng/10.0@259336 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/iscsi/iscsi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 2f5328db..395c8bb2 100644 --- a/sys/dev/iscsi/iscsi.c +++ b/sys/dev/iscsi/iscsi.c @@ -1247,6 +1247,18 @@ iscsi_ioctl_daemon_handoff(struct iscsi_softc *sc, sx_sunlock(&sc->sc_lock); return (EINVAL); } + if (is->is_connected) { + /* + * This might have happened because another iscsid(8) + * instance handed off the connection in the meantime. + * Just return. + */ + ISCSI_SESSION_WARN(is, "handoff on already connected " + "session"); + ISCSI_SESSION_UNLOCK(is); + sx_sunlock(&sc->sc_lock); + return (EBUSY); + } strlcpy(is->is_target_alias, handoff->idh_target_alias, sizeof(is->is_target_alias)); -- 2.45.0