Date: Wed, 26 Feb 2025 15:15:53 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: e49db000c493 - main - ctld: Permit targets to use a string for portal-groups in UCL Message-ID: <202502261515.51QFFrba034090@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=e49db000c4932753fb309ad895c02e98723023f3 commit e49db000c4932753fb309ad895c02e98723023f3 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2025-02-26 15:13:56 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2025-02-26 15:13:56 +0000 ctld: Permit targets to use a string for portal-groups in UCL In the case that a separate auth-group is not required, this permits replacing: portal-group = { name = pg0 } with: portal-group = pg0 Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D48938 --- usr.sbin/ctld/ctl.conf.5 | 2 +- usr.sbin/ctld/uclparse.c | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/usr.sbin/ctld/ctl.conf.5 b/usr.sbin/ctld/ctl.conf.5 index 015fc1e12e36..8cc7c85b6f95 100644 --- a/usr.sbin/ctld/ctl.conf.5 +++ b/usr.sbin/ctld/ctl.conf.5 @@ -567,7 +567,7 @@ target { "iqn.2012-06.com.example:target1" { auth-group = ag0 - portal-group { name = pg0 } + portal-group = pg0 lun = [ { number = 0, name = example_1 }, { diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c index b9d88a1d45d2..ab41e328cd90 100644 --- a/usr.sbin/ctld/uclparse.c +++ b/usr.sbin/ctld/uclparse.c @@ -191,6 +191,20 @@ uclparse_target_portal_group(const char *t_name, const ucl_object_t *obj) const ucl_object_t *portal_group, *auth_group; const char *ag_name; + /* + * If the value is a single string, assume it is a + * portal-group name. + */ + if (obj->type == UCL_STRING) + return (target_add_portal_group(ucl_object_tostring(obj), + NULL)); + + if (obj->type != UCL_OBJECT) { + log_warnx("portal-group section in target \"%s\" must be " + "an object or string", t_name); + return (false); + } + portal_group = ucl_object_find_key(obj, "name"); if (!portal_group || portal_group->type != UCL_STRING) { log_warnx("portal-group section in target \"%s\" is missing " @@ -884,11 +898,6 @@ uclparse_target(const char *name, const ucl_object_t *top) } if (strcmp(key, "portal-group") == 0) { - if (obj->type == UCL_OBJECT) { - if (!uclparse_target_portal_group(name, obj)) - goto fail; - } - if (obj->type == UCL_ARRAY) { while ((tmp = ucl_iterate_object(obj, &it2, true))) { @@ -896,6 +905,9 @@ uclparse_target(const char *name, const ucl_object_t *top) tmp)) goto fail; } + } else { + if (!uclparse_target_portal_group(name, obj)) + goto fail; } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502261515.51QFFrba034090>