From nobody Tue Jan 27 18:44:16 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4f0vSw6jtDz6QFwG for ; Tue, 27 Jan 2026 18:44:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f0vSw4WHSz3rQg for ; Tue, 27 Jan 2026 18:44:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769539456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aVFyCOaDZbl7GPsK1PsLFmknzY2FerD0jpAvB83avP8=; b=WS1163+P2InWkqWDCDZ34pCg5xoIu3/YICr6vQTyzXIwa3ECF2FfbQFcXyC6a/EKSvNhvt jc3VRs3CXYVDsZBG0fdKrOcBx7jGGDXTxeNtXpYyQahHrUS1hwBkkc56pyI9U1eDEUolGC ORf97P6UvNRi0bCKvIByYg8YHRNRSGog+5V37M+J07oEFvDpWHX4lnPSeGIfn48RbeGcov Y2+C3QYfoH+mh8ZePP2owEjmMX3PyoYm+ov1ctC4xEGnbHzi219P4j1H0UykmkSh2TF30L gdZIirJCQW0ZzN18nqvWWUhDkRUavCulwmjSrLuiJrMGB19MFBvXRcKSXvquww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769539456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aVFyCOaDZbl7GPsK1PsLFmknzY2FerD0jpAvB83avP8=; b=IXM5RLil6vnI/L34APFSbG2tI8AmGR14VEz/OmePq92L7UEirQxh9GRzJxPq5SWG/I/VC+ Dh4ssJMOqq/taauyjqL1BVqFlaAA7M1ESTxyb/MXgjbImvZs3VdRWoEjCls7QLNlQn3sSb M1Fq9GWI2uwXkzs/9V+pZxPpmDMJoYOxxTCJWyHPKJXO6xLeRgtzKlH8t7UOrCpu/ovNno 3DwlS2XJ6ecyPVrysCghZUtRzHQl4naPufw3ZCCL0VvLqV/Bfq0zY/gYaUOVN3kao5/B5I SBz6utEzuTqOtfQmE82/r53Q9omIFxDOKDQhvM4VhedOXWm7MIodBnZHjOUXuw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1769539456; a=rsa-sha256; cv=none; b=KpLQ2xeVBLGPds4KqdqsUxowKKX8iGC2YHm8+5UDaIZRgHDmLrcKgxJKZWFgA1Z/52o5R0 01rT13gZbRPqh3biq7RoZ5J+C5HSFAi2YalOeVsTGobN4ukTMZzjMJcpDK0cX5ft0+iqgM CrFAw9DaVOfHy1aVJ0K1DMyLtPLll80nB+uAN2loUuS4axVibi8l4LrfCukmBWpEoqoPKq vSDB1eYdbNTZN3jzgtOdlk7y0bEw4lO1STMf6JWYXGMsNZ+7KEJhh6ny2iWfexMeTYWbdM O9L8H0e5D9A40e8ynedGaiWC7BC14KkuuhU774hbIeJqKeG09YBBUf/FJ25/Mg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f0vSw3qRrz3qm for ; Tue, 27 Jan 2026 18:44:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id e2cb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 27 Jan 2026 18:44:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: b7919e0493c8 - stable/14 - ctld: Support anonymous LUN entries in UCL List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: b7919e0493c8b34a6c8ef126c83b4b8a1e9be64c Auto-Submitted: auto-generated Date: Tue, 27 Jan 2026 18:44:16 +0000 Message-Id: <69790780.e2cb.546253b0@gitrepo.freebsd.org> The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=b7919e0493c8b34a6c8ef126c83b4b8a1e9be64c commit b7919e0493c8b34a6c8ef126c83b4b8a1e9be64c Author: John Baldwin AuthorDate: 2025-02-26 15:13:10 +0000 Commit: John Baldwin CommitDate: 2026-01-27 18:15:57 +0000 ctld: Support anonymous LUN entries in UCL If a target LUN entry doesn't have a name property, assume it is an anonymous LUN and parse other properties from the entry to define the LUN. This removes the odd support for target LUNs only named by an integer. My guess is this was meant to implement support for anonymous LUNs based on how the syntax for this works in the non-UCL case, but the prior implementation was useless (it just created unconfigured LUNs). Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48937 (cherry picked from commit b797cc839a12fc358e99635ca3adf3cf80e0825b) --- usr.sbin/ctld/ctl.conf.5 | 30 +++++++------- usr.sbin/ctld/uclparse.c | 106 ++++++++++++++++++++++++++++------------------- 2 files changed, 77 insertions(+), 59 deletions(-) diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5 index 0be873fe512c..015fc1e12e36 100644 --- a/usr.sbin/ctld/ctl.conf.5 +++ b/usr.sbin/ctld/ctl.conf.5 @@ -26,7 +26,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd October 13, 2020 +.Dd February 26, 2025 .Dt CTL.CONF 5 .Os .Sh NAME @@ -543,25 +543,12 @@ portal-group { } lun { - example_0 { - path = /dev/zvol/tank/example_0 - blocksize = 4096 - size = 4GB - } - example_1 { path = /dev/zvol/tank/example_1 options { naa = "0x50015178f369f093" } } - - example_2 { - path = /dev/zvol/tank/example_2 - options { - vendor = "FreeBSD" - } - } } target { @@ -569,7 +556,12 @@ target { alias = "Example target" auth-group = no-authentication lun = [ - { number = 0, name = example_0 }, + { + number = 0 + path = /dev/zvol/tank/example_0 + blocksize = 4096 + size = 4GB + } ] } @@ -578,7 +570,13 @@ target { portal-group { name = pg0 } lun = [ { number = 0, name = example_1 }, - { number = 1, name = example_2 } + { + number = 1 + path = /dev/zvol/tank/example_2 + options { + vendor = "FreeBSD" + } + } ] } diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c index 7c786afb1e93..b9d88a1d45d2 100644 --- a/usr.sbin/ctld/uclparse.c +++ b/usr.sbin/ctld/uclparse.c @@ -48,6 +48,7 @@ static bool uclparse_toplevel(const ucl_object_t *); static bool uclparse_chap(const char *, const ucl_object_t *); static bool uclparse_chap_mutual(const char *, const ucl_object_t *); static bool uclparse_lun(const char *, const ucl_object_t *); +static bool uclparse_lun_entries(const char *, const ucl_object_t *); static bool uclparse_auth_group(const char *, const ucl_object_t *); static bool uclparse_portal_group(const char *, const ucl_object_t *); static bool uclparse_target(const char *, const ucl_object_t *); @@ -216,35 +217,44 @@ uclparse_target_portal_group(const char *t_name, const ucl_object_t *obj) static bool uclparse_target_lun(const char *t_name, const ucl_object_t *obj) { - if (obj->type == UCL_INT) { - if (!target_start_lun(ucl_object_toint(obj))) - return (false); - lun_finish(); - return (true); + const ucl_object_t *num; + const ucl_object_t *name; + char *lun_name; + u_int id; + bool ok; + + if (obj->type != UCL_OBJECT) { + log_warnx("lun section entries in target \"%s\" must be objects", + t_name); + return (false); } - if (obj->type == UCL_OBJECT) { - const ucl_object_t *num = ucl_object_find_key(obj, "number"); - const ucl_object_t *name = ucl_object_find_key(obj, "name"); + num = ucl_object_find_key(obj, "number"); + if (num == NULL || num->type != UCL_INT) { + log_warnx("lun section in target \"%s\" is missing " + "\"number\" integer property", t_name); + return (false); + } + id = ucl_object_toint(num); - if (num == NULL || num->type != UCL_INT) { - log_warnx("lun section in target \"%s\" is missing " - "\"number\" integer property", t_name); + name = ucl_object_find_key(obj, "name"); + if (name == NULL) { + if (!target_start_lun(id)) return (false); - } - if (name == NULL || name->type != UCL_STRING) { - log_warnx("lun section in target \"%s\" is missing " - "\"name\" string property", t_name); - return (false); - } + asprintf(&lun_name, "lun %u for target \"%s\"", id, t_name); + ok = uclparse_lun_entries(lun_name, obj); + free(lun_name); + return (ok); + } - if (!target_add_lun(ucl_object_toint(num), - ucl_object_tostring(name))) - return (false); + if (name->type != UCL_STRING) { + log_warnx("\"name\" property for lun %u for target " + "\"%s\" is not a string", id, t_name); + return (false); } - return (true); + return (target_add_lun(id, ucl_object_tostring(name))); } static bool @@ -929,21 +939,31 @@ fail: static bool uclparse_lun(const char *name, const ucl_object_t *top) { - ucl_object_iter_t it = NULL, child_it = NULL; - const ucl_object_t *obj = NULL, *child = NULL; - const char *key; + char *lun_name; + bool ok; if (!lun_start(name)) return (false); + asprintf(&lun_name, "lun \"%s\"", name); + ok = uclparse_lun_entries(lun_name, top); + free(lun_name); + return (ok); +} + +static bool +uclparse_lun_entries(const char *name, const ucl_object_t *top) +{ + ucl_object_iter_t it = NULL, child_it = NULL; + const ucl_object_t *obj = NULL, *child = NULL; + const char *key; while ((obj = ucl_iterate_object(top, &it, true))) { key = ucl_object_key(obj); if (strcmp(key, "backend") == 0) { if (obj->type != UCL_STRING) { - log_warnx("\"backend\" property of lun " - "\"%s\" is not a string", - name); + log_warnx("\"backend\" property of %s " + "is not a string", name); goto fail; } @@ -953,8 +973,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "blocksize") == 0) { if (obj->type != UCL_INT) { - log_warnx("\"blocksize\" property of lun " - "\"%s\" is not an integer", name); + log_warnx("\"blocksize\" property of %s " + "is not an integer", name); goto fail; } @@ -964,8 +984,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "device-id") == 0) { if (obj->type != UCL_STRING) { - log_warnx("\"device-id\" property of lun " - "\"%s\" is not an integer", name); + log_warnx("\"device-id\" property of %s " + "is not an integer", name); goto fail; } @@ -975,8 +995,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "device-type") == 0) { if (obj->type != UCL_STRING) { - log_warnx("\"device-type\" property of lun " - "\"%s\" is not an integer", name); + log_warnx("\"device-type\" property of %s " + "is not an integer", name); goto fail; } @@ -986,8 +1006,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "ctl-lun") == 0) { if (obj->type != UCL_INT) { - log_warnx("\"ctl-lun\" property of lun " - "\"%s\" is not an integer", name); + log_warnx("\"ctl-lun\" property of %s " + "is not an integer", name); goto fail; } @@ -997,8 +1017,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "options") == 0) { if (obj->type != UCL_OBJECT) { - log_warnx("\"options\" property of lun " - "\"%s\" is not an object", name); + log_warnx("\"options\" property of %s " + "is not an object", name); goto fail; } @@ -1012,8 +1032,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "path") == 0) { if (obj->type != UCL_STRING) { - log_warnx("\"path\" property of lun " - "\"%s\" is not a string", name); + log_warnx("\"path\" property of %s " + "is not a string", name); goto fail; } @@ -1023,8 +1043,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "serial") == 0) { if (obj->type != UCL_STRING) { - log_warnx("\"serial\" property of lun " - "\"%s\" is not a string", name); + log_warnx("\"serial\" property of %s " + "is not a string", name); goto fail; } @@ -1034,8 +1054,8 @@ uclparse_lun(const char *name, const ucl_object_t *top) if (strcmp(key, "size") == 0) { if (obj->type != UCL_INT) { - log_warnx("\"size\" property of lun " - "\"%s\" is not an integer", name); + log_warnx("\"size\" property of %s " + "is not an integer", name); goto fail; }