git: 9a99fa3932dd - main - ctld: Fix namespace IDs for exported NVMe namespaces part 2

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 12 Nov 2026 15:45:17 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=9a99fa3932ddd794234becc6eab6519d56ae6947

commit 9a99fa3932ddd794234becc6eab6519d56ae6947
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-11-12 15:43:55 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-11-12 15:43:55 +0000

    ctld: Fix namespace IDs for exported NVMe namespaces part 2
    
    This is the same fix as in commit
    9c8be6518e2e5f396055ecdab8098ce19c4b2218 just applied to another
    method that also accepts namespace IDs.  The original commit handled
    configuration statements assigning a named LUN to a namespace.  This
    change handles anonymous namespaces configured within a controller
    context.
    
    Fixes:          66b5296f1b29 ("ctld: Add support for NVMe over Fabrics")
    Sponsored by:   Chelsio Communications
---
 usr.sbin/ctld/nvmf.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/usr.sbin/ctld/nvmf.cc b/usr.sbin/ctld/nvmf.cc
index a596d32d660c..689c3404af1a 100644
--- a/usr.sbin/ctld/nvmf.cc
+++ b/usr.sbin/ctld/nvmf.cc
@@ -413,9 +413,9 @@ nvmf_controller::start_namespace(u_int id)
 		return nullptr;
 	}
 
-	std::string lun_label = "namespace ID " + std::to_string(id - 1);
+	std::string lun_label = "namespace ID " + std::to_string(id);
 	std::string lun_name = freebsd::stringf("%s,nsid,%u", name(), id);
-	return target::start_lun(id, lun_label.c_str(), lun_name.c_str());
+	return target::start_lun(id - 1, lun_label.c_str(), lun_name.c_str());
 }
 
 struct portal_group *