Commit 2b395358 authored by Matthew Wood's avatar Matthew Wood Committed by Jakub Kicinski
Browse files

net: netconsole: Add continuation line prefix to userdata messages



Add a space (' ') prefix to every userdata line to match docs for
dev-kmsg. To account for this extra character in each userdata entry,
reduce userdata entry names (directory name) from 54 characters to 53.

According to the dev-kmsg docs, a space is used for subsequent lines to
mark them as continuation lines.

> A line starting with ' ', is a continuation line, adding
> key/value pairs to the log message, which provide the machine
> readable context of the message, for reliable processing in
> userspace.

Testing for this patch::

 cd /sys/kernel/config/netconsole && mkdir cmdline0
 cd cmdline0
 mkdir userdata/test && echo "hello" > userdata/test/value
 mkdir userdata/test2 && echo "hello2" > userdata/test2/value
 echo "message" > /dev/kmsg

Outputs::

 6.8.0-rc5-virtme,12,493,231373579,-;message
  test=hello
  test2=hello2

And I confirmed all testing works as expected from the original patchset

Fixes: df03f830 ("net: netconsole: cache userdata formatted string in netconsole_target")
Signed-off-by: default avatarMatthew Wood <thepacketgeek@gmail.com>
Reviewed-by: default avatarBreno Leitao <leitao@debian.org>
Link: https://lore.kernel.org/r/20240308002525.248672-1-thepacketgeek@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 031a239c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ Custom user data can be appended to the end of messages with netconsole
dynamic configuration enabled. User data entries can be modified without
changing the "enabled" attribute of a target.

Directories (keys) under `userdata` are limited to 54 character length, and
Directories (keys) under `userdata` are limited to 53 character length, and
data in `userdata/<key>/value` are limited to 200 bytes::

 cd /sys/kernel/config/netconsole && mkdir cmdline0
+7 −5
Original line number Diff line number Diff line
@@ -43,9 +43,11 @@ MODULE_DESCRIPTION("Console driver for network interfaces");
MODULE_LICENSE("GPL");

#define MAX_PARAM_LENGTH		256
#define MAX_USERDATA_NAME_LENGTH	54
#define MAX_USERDATA_VALUE_LENGTH	200
#define MAX_USERDATA_ENTRY_LENGTH	256
#define MAX_USERDATA_VALUE_LENGTH	200
/* The number 3 comes from userdata entry format characters (' ', '=', '\n') */
#define MAX_USERDATA_NAME_LENGTH	(MAX_USERDATA_ENTRY_LENGTH - \
					MAX_USERDATA_VALUE_LENGTH - 3)
#define MAX_USERDATA_ITEMS		16
#define MAX_PRINT_CHUNK			1000