netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages
@ 2024-03-08  0:25 Matthew Wood
  2024-03-09  4:17 ` Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Matthew Wood @ 2024-03-08  0:25 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Corbet, Breno Leitao
  Cc: netdev, linux-doc, linux-kernel

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: df03f830d099 ("net: netconsole: cache userdata formatted string in netconsole_target")
Signed-off-by: Matthew Wood <thepacketgeek@gmail.com>
---
 Documentation/networking/netconsole.rst |  8 ++++----
 drivers/net/netconsole.c                | 12 +++++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst
index b28c525e5d1e..d55c2a22ec7a 100644
--- a/Documentation/networking/netconsole.rst
+++ b/Documentation/networking/netconsole.rst
@@ -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
@@ -197,8 +197,8 @@ Messages will now include this additional user data::
 Sends::
 
  12,607,22085407756,-;This is a message
- foo=bar
- qux=baz
+  foo=bar
+  qux=baz
 
 Preview the userdata that will be appended with::
 
@@ -218,7 +218,7 @@ The `qux` key is omitted since it has no value::
 
  echo "This is a message" > /dev/kmsg
  12,607,22085407756,-;This is a message
- foo=bar
+  foo=bar
 
 Delete `userdata` entries with `rmdir`::
 
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 0de108a1c0c8..d7070dd4fe73 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -42,12 +42,14 @@ MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>");
 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_PARAM_LENGTH		256
 #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
+#define MAX_PRINT_CHUNK			1000
 
 static char config[MAX_PARAM_LENGTH];
 module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0);
@@ -671,7 +673,7 @@ static void update_userdata(struct netconsole_target *nt)
 		 * checked to not exceed MAX items with child_count above
 		 */
 		complete_idx += scnprintf(&nt->userdata_complete[complete_idx],
-					  MAX_USERDATA_ENTRY_LENGTH, "%s=%s\n",
+					  MAX_USERDATA_ENTRY_LENGTH, " %s=%s\n",
 					  item->ci_name, udm_item->value);
 	}
 	nt->userdata_length = strnlen(nt->userdata_complete,
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages
  2024-03-08  0:25 [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages Matthew Wood
@ 2024-03-09  4:17 ` Jakub Kicinski
  2024-03-11  9:43   ` Breno Leitao
  2024-03-11  9:43 ` Breno Leitao
  2024-03-11 22:00 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2024-03-09  4:17 UTC (permalink / raw)
  To: Breno Leitao
  Cc: Matthew Wood, David S. Miller, Eric Dumazet, Paolo Abeni,
	Jonathan Corbet, netdev, linux-doc, linux-kernel

On Thu,  7 Mar 2024 16:25:24 -0800 Matthew Wood wrote:
> Fixes: df03f830d099 ("net: netconsole: cache userdata formatted string in netconsole_target")
> Signed-off-by: Matthew Wood <thepacketgeek@gmail.com>

Breno, LG?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages
  2024-03-08  0:25 [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages Matthew Wood
  2024-03-09  4:17 ` Jakub Kicinski
@ 2024-03-11  9:43 ` Breno Leitao
  2024-03-11 22:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Breno Leitao @ 2024-03-11  9:43 UTC (permalink / raw)
  To: Matthew Wood
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Jonathan Corbet, netdev, linux-doc, linux-kernel

On Thu, Mar 07, 2024 at 04:25:24PM -0800, Matthew Wood wrote:
> 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: df03f830d099 ("net: netconsole: cache userdata formatted string in netconsole_target")
> Signed-off-by: Matthew Wood <thepacketgeek@gmail.com>

Reviewed-by: Breno Leitao <leitao@debian.rog>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages
  2024-03-09  4:17 ` Jakub Kicinski
@ 2024-03-11  9:43   ` Breno Leitao
  0 siblings, 0 replies; 5+ messages in thread
From: Breno Leitao @ 2024-03-11  9:43 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Matthew Wood, David S. Miller, Eric Dumazet, Paolo Abeni,
	Jonathan Corbet, netdev, linux-doc, linux-kernel

On Fri, Mar 08, 2024 at 08:17:28PM -0800, Jakub Kicinski wrote:
> On Thu,  7 Mar 2024 16:25:24 -0800 Matthew Wood wrote:
> > Fixes: df03f830d099 ("net: netconsole: cache userdata formatted string in netconsole_target")
> > Signed-off-by: Matthew Wood <thepacketgeek@gmail.com>
> 
> Breno, LG?

Yes, I've just added my "Reviwed-by"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages
  2024-03-08  0:25 [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages Matthew Wood
  2024-03-09  4:17 ` Jakub Kicinski
  2024-03-11  9:43 ` Breno Leitao
@ 2024-03-11 22:00 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-11 22:00 UTC (permalink / raw)
  To: Matthew Wood
  Cc: davem, edumazet, kuba, pabeni, corbet, leitao, netdev, linux-doc,
	linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  7 Mar 2024 16:25:24 -0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,v4] net: netconsole: Add continuation line prefix to userdata messages
    https://git.kernel.org/netdev/net-next/c/2b3953585953

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-03-11 22:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-08  0:25 [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages Matthew Wood
2024-03-09  4:17 ` Jakub Kicinski
2024-03-11  9:43   ` Breno Leitao
2024-03-11  9:43 ` Breno Leitao
2024-03-11 22:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).