Whamcloud - gitweb
LU-10391 lnet: filter out white spaces 20/53020/3
authorJames Simmons <jsimmons@infradead.org>
Tue, 7 Nov 2023 16:39:52 +0000 (11:39 -0500)
committerOleg Drokin <green@whamcloud.com>
Sat, 18 Nov 2023 21:43:01 +0000 (21:43 +0000)
For the libyaml library two methods exist to construct an internal
YAML document. One is with the creation of yaml_event_t and submitting
it, yaml_emitter_emit(), to the emitter. The second method is using
some source like a file. In both cases the input is processed and
placed into an internal buffer which is passed to the read handler,
yaml_netlink_read_handler(). This buffer ends up looking in the
raw text of the configuration file passed and this includes all
the various whitespaces. Due to an internal processing bug both
creation methods don't yeild the same exact internal buffer
contents. In the sequence case for sources from a file will
contain extra white spacing. Our current Netlink implement
doesn't filter off that extra white spacing so the values packed
into the Netlink pack contains leading white spaces which is
seen as an error. The fix is to skip those extra white space if
they exist.

Change-Id: I7445ffb486d6d39c681ab4e5a85e0b835509c9ee
Test-Parameters: trivial testlist=sanity-lnet
Fixes: 70149f4ea89 ("LU-9680 utils: fix Netlink / YAML library handling")
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53020
Reviewed-by: Feng Lei <flei@whamcloud.com>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lnet/utils/lnetconfig/liblnetconfig_netlink.c

index dc7aed4..b14b6d4 100644 (file)
@@ -1222,7 +1222,8 @@ static enum lnet_nl_key_format yaml_format_type(yaml_emitter_t *emitter,
 
        if (strncmp(line + new_indent, "- ", 2) == 0) {
                memset(line + new_indent, ' ', 2);
-               new_indent += 2;
+               /* Eat white spaces physical YAML config files have */
+               new_indent += strspn(line + new_indent, " ");
                fmt |= LNKF_SEQUENCE;
        }