From 30ec0085c3e4a61e49fee229dd17f89372c22720 Mon Sep 17 00:00:00 2001 From: trasz Date: Fri, 13 Dec 2013 15:25:51 +0000 Subject: MFC r259183: Properly refuse handoff requests on already connected sessions. Previously this would result in dropping the session. Sponsored by: The FreeBSD Foundation --- sys/dev/iscsi/iscsi.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'sys/dev/iscsi/iscsi.c') diff --git a/sys/dev/iscsi/iscsi.c b/sys/dev/iscsi/iscsi.c index 2f5328d..395c8bb 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)); -- cgit v1.1