When connecting to iSCSI targets, they can be given by nickname as specified in /etc/iscsi.conf. For example: # iscsictl -L Target name Target portal State # iscsictl -A -n monolith1-1 # iscsictl -A -n monolith1-2 # iscsictl -L Target name Target portal State iqn.2012-10.org.example:monolith1-1 monolith1.example.org Connected: da12 iqn.2012-10.org.example:monolith1-2 monolith1.example.org Connected: da13 # Now when trying to disconnect a single target by nickname, both are disconnected: # iscsictl -R -n monolith1-1 # iscsictl -L Target name Target portal State # monolith1-2 should have remained connected! If using the full target name with the -t parameter, iscsictl works correctly.
Patch below should fix the bug you've found. Index: sys/dev/iscsi/iscsi.c =================================================================== --- sys/dev/iscsi/iscsi.c (revision 273163) +++ sys/dev/iscsi/iscsi.c (working copy) @@ -1752,18 +1752,16 @@ static bool iscsi_session_conf_matches(unsigned int id1, const struct iscsi_session_conf *c1, unsigned int id2, const struct iscsi_session_conf *c2) { - if (id2 == 0 && c2->isc_target[0] == '\0' && - c2->isc_target_addr[0] == '\0') - return (true); - if (id2 != 0 && id2 == id1) - return (true); + + if (id2 != 0 && id2 != id1) + return (false); if (c2->isc_target[0] != '\0' && - strcmp(c1->isc_target, c2->isc_target) == 0) - return (true); + strcmp(c1->isc_target, c2->isc_target) != 0) + return (false); if (c2->isc_target_addr[0] != '\0' && - strcmp(c1->isc_target_addr, c2->isc_target_addr) == 0) - return (true); - return (false); + strcmp(c1->isc_target_addr, c2->isc_target_addr) != 0) + return (false); + return (true); } static int
A commit references this bug: Author: trasz Date: Thu Oct 16 09:09:43 UTC 2014 New revision: 273164 URL: https://svnweb.freebsd.org/changeset/base/273164 Log: When removing an iSCSI session, check whether all conditions match, not if any of them matches. This fixes "iscsictl -Rn" removing unrelated sessions. PR: 194034 MFC after: 1 month Sponsored by: The FreeBSD Foundation Changes: head/sys/dev/iscsi/iscsi.c
A commit references this bug: Author: trasz Date: Sat Nov 15 05:50:14 UTC 2014 New revision: 274546 URL: https://svnweb.freebsd.org/changeset/base/274546 Log: MFC r273164: When removing an iSCSI session, check whether all conditions match, not if any of them matches. This fixes "iscsictl -Rn" removing unrelated sessions. PR: 194034 Sponsored by: The FreeBSD Foundation Changes: _U stable/10/ stable/10/sys/dev/iscsi/iscsi.c