net: netconsole: cache userdata formatted string in netconsole_target
authorMatthew Wood <thepacketgeek@gmail.com>
Sun, 4 Feb 2024 23:27:37 +0000 (15:27 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Feb 2024 10:23:45 +0000 (10:23 +0000)
commitdf03f830d099f0811281a222aefdd9d400fa0b72
tree326779e8fe9c8aac6077ab4b2e7f5caf32a8865d
parent8a6d5fec6c7f952d66ad362c249100d040a21e3f
net: netconsole: cache userdata formatted string in netconsole_target

Store a formatted string for userdata that will be appended to netconsole
messages. The string has a capacity of 4KB, as calculated by the userdatum
entry length of 256 bytes and a max of 16 userdata entries.

Update the stored netconsole_target->userdata_complete string with the new
formatted userdata values when a userdatum is created, edited, or
removed. Each userdata entry contains a trailing newline, which will be
formatted as such in netconsole messages::

    6.7.0-rc8-virtme,12,500,1646292204,-;test
    release=foo
    something=bar
    6.7.0-rc8-virtme,12,500,1646292204,-;another test
    release=foo
    something=bar

Enforcement of MAX_USERDATA_ITEMS is done in userdatum_make_item;
update_userdata will not check for this case but will skip any userdata
children over the limit of MAX_USERDATA_ITEMs.

If a userdata entry/dir is created but no value is provided, that entry
will be skipped. This is in part because update_userdata() can't be
called in userdatum_make_item() since the item will not have been added
to the userdata config_group children yet. To preserve the experience of
adding an empty userdata that doesn't show up in the netconsole
messages, purposefully skip empty userdata items even when
update_userdata() can be called.

Co-developed-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Matthew Wood <thepacketgeek@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netconsole.c