From 0f61c9ff72f34270b31e1b0a5d0a67691b815994 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Tue, 7 Nov 2023 11:39:52 -0500 Subject: [PATCH] LU-10391 lnet: filter out white spaces 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 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53020 Reviewed-by: Feng Lei Reviewed-by: Serguei Smirnov Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lnet/utils/lnetconfig/liblnetconfig_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lnet/utils/lnetconfig/liblnetconfig_netlink.c b/lnet/utils/lnetconfig/liblnetconfig_netlink.c index dc7aed4..b14b6d4 100644 --- a/lnet/utils/lnetconfig/liblnetconfig_netlink.c +++ b/lnet/utils/lnetconfig/liblnetconfig_netlink.c @@ -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; } -- 1.8.3.1