Skip to content

Commit 2b39535

Browse files
thepacketgeekkuba-moo
authored andcommitted
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: df03f83 ("net: netconsole: cache userdata formatted string in netconsole_target") Signed-off-by: Matthew Wood <[email protected]> Reviewed-by: Breno Leitao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 031a239 commit 2b39535

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Documentation/networking/netconsole.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Custom user data can be appended to the end of messages with netconsole
180180
dynamic configuration enabled. User data entries can be modified without
181181
changing the "enabled" attribute of a target.
182182

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

186186
cd /sys/kernel/config/netconsole && mkdir cmdline0
@@ -197,8 +197,8 @@ Messages will now include this additional user data::
197197
Sends::
198198

199199
12,607,22085407756,-;This is a message
200-
foo=bar
201-
qux=baz
200+
foo=bar
201+
qux=baz
202202

203203
Preview the userdata that will be appended with::
204204

@@ -218,7 +218,7 @@ The `qux` key is omitted since it has no value::
218218

219219
echo "This is a message" > /dev/kmsg
220220
12,607,22085407756,-;This is a message
221-
foo=bar
221+
foo=bar
222222

223223
Delete `userdata` entries with `rmdir`::
224224

drivers/net/netconsole.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ MODULE_AUTHOR("Maintainer: Matt Mackall <[email protected]>");
4242
MODULE_DESCRIPTION("Console driver for network interfaces");
4343
MODULE_LICENSE("GPL");
4444

45-
#define MAX_PARAM_LENGTH 256
46-
#define MAX_USERDATA_NAME_LENGTH 54
47-
#define MAX_USERDATA_VALUE_LENGTH 200
45+
#define MAX_PARAM_LENGTH 256
4846
#define MAX_USERDATA_ENTRY_LENGTH 256
47+
#define MAX_USERDATA_VALUE_LENGTH 200
48+
/* The number 3 comes from userdata entry format characters (' ', '=', '\n') */
49+
#define MAX_USERDATA_NAME_LENGTH (MAX_USERDATA_ENTRY_LENGTH - \
50+
MAX_USERDATA_VALUE_LENGTH - 3)
4951
#define MAX_USERDATA_ITEMS 16
50-
#define MAX_PRINT_CHUNK 1000
52+
#define MAX_PRINT_CHUNK 1000
5153

5254
static char config[MAX_PARAM_LENGTH];
5355
module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0);
@@ -671,7 +673,7 @@ static void update_userdata(struct netconsole_target *nt)
671673
* checked to not exceed MAX items with child_count above
672674
*/
673675
complete_idx += scnprintf(&nt->userdata_complete[complete_idx],
674-
MAX_USERDATA_ENTRY_LENGTH, "%s=%s\n",
676+
MAX_USERDATA_ENTRY_LENGTH, " %s=%s\n",
675677
item->ci_name, udm_item->value);
676678
}
677679
nt->userdata_length = strnlen(nt->userdata_complete,

0 commit comments

Comments
 (0)