public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Matthew Wood <thepacketgeek@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Breno Leitao <leitao@debian.org>
Cc: netdev@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: netconsole: Add continuation line prefix to userdata messages
Date: Wed, 28 Feb 2024 09:32:19 -0800	[thread overview]
Message-ID: <77497701-3bd2-4f5f-9404-b32d9e91683b@gmail.com> (raw)
In-Reply-To: <20240228172948.221910-1-thepacketgeek@gmail.com>

On 2/28/24 09:29, 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>
> ---
>   Documentation/networking/netconsole.rst | 6 +++---
>   drivers/net/netconsole.c                | 4 ++--
>   2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst
> index b28c525e5d1e..c2dec12f6060 100644
> --- a/Documentation/networking/netconsole.rst
> +++ b/Documentation/networking/netconsole.rst
> @@ -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..ffd3e19406b5 100644
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -43,7 +43,7 @@ MODULE_DESCRIPTION("Console driver for network interfaces");
>   MODULE_LICENSE("GPL");
>   
>   #define MAX_PARAM_LENGTH	256
> -#define MAX_USERDATA_NAME_LENGTH	54
> +#define MAX_USERDATA_NAME_LENGTH	53 /* 256 - 200 - 3 (for ' =\n' chars)*/

Could we take this opportunity to define MAX_USERDATA_NAME_LENGTH based 
upon MAX_PARAM_LENGTH - MAX_USERDATA_VALUE_LENGTH - 3 then?

>   #define MAX_USERDATA_VALUE_LENGTH	200
>   #define MAX_USERDATA_ENTRY_LENGTH	256
>   #define MAX_USERDATA_ITEMS		16
> @@ -671,7 +671,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,

-- 
Florian


  reply	other threads:[~2024-02-28 17:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28 17:29 [PATCH net-next] net: netconsole: Add continuation line prefix to userdata messages Matthew Wood
2024-02-28 17:32 ` Florian Fainelli [this message]
2024-02-28 19:51   ` Matthew Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77497701-3bd2-4f5f-9404-b32d9e91683b@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=thepacketgeek@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox