git: 0f3210b3a7fa - main - ctladm: Only autoload cfiscsi.ko for iSCSI-specific commands

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 27 Dec 2023 18:11:41 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=0f3210b3a7fac2cb247986dae4d68040222cdb33

commit 0f3210b3a7fac2cb247986dae4d68040222cdb33
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-12-27 18:11:19 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-12-27 18:11:19 +0000

    ctladm: Only autoload cfiscsi.ko for iSCSI-specific commands
    
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D42935
---
 usr.sbin/ctladm/ctladm.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/usr.sbin/ctladm/ctladm.c b/usr.sbin/ctladm/ctladm.c
index 49938be9282a..9d2f14de28ed 100644
--- a/usr.sbin/ctladm/ctladm.c
+++ b/usr.sbin/ctladm/ctladm.c
@@ -4144,10 +4144,16 @@ main(int argc, char **argv)
 			goto bailout;
 		}
 #ifdef	WANT_ISCSI
-		else {
+		switch (command) {
+		case CTLADM_CMD_ISLIST:
+		case CTLADM_CMD_ISLOGOUT:
+		case CTLADM_CMD_ISTERMINATE:
 			if (modfind("cfiscsi") == -1 &&
 			    kldload("cfiscsi") == -1)
 				warn("couldn't load cfiscsi");
+			break;
+		default:
+			break;
 		}
 #endif
 	} else if ((command != CTLADM_CMD_HELP)