Subject: Re: [PATCH net-next v2 5/8] net: netconsole: add a userdata config_group member to netconsole_target

From: Simon Horman <[email-masked]>
Date: Fri, 2 Feb 2024 12:51:51 +0100

On Fri, Jan 26, 2024 at 03:13:40PM -0800, Matthew Wood wrote:
> Create configfs machinery for netconsole userdata appending, which depends
> on CONFIG_NETCONSOLE_DYNAMIC (for configfs interface). Add a userdata
> config_group to netconsole_target for managing userdata entries as a tree
> under the netconsole configfs subsystem. Directory names created under the
> userdata directory become userdatum keys; the userdatum value is the
> content of the value file.
> 
> Include the minimum-viable-changes for userdata configfs config_group.
> init_target_config_group() ties in the complete configfs machinery to
> avoid unused func/variable errors during build. Initializing the
> netconsole_target->group is moved to init_target_config_group, which
> will also init and add the userdata config_group.
> 
> Each userdatum entry has a limit of 256 bytes (54 for
> the key/directory, 200 for the value, and 2 for '=' and '\n'
> characters), which is enforced by the configfs functions for updating
> the userdata config_group.
> 
> When a new netconsole_target is created, initialize the userdata
> config_group and add it as a default group for netconsole_target
> config_group, allowing the userdata configfs sub-tree to be presented
> in the netconsole configfs tree under the userdata directory.
> 
> Co-developed-by: Breno Leitao <[email-masked]>
> Signed-off-by: Breno Leitao <[email-masked]>
> Signed-off-by: Matthew Wood <[email-masked]>

Hi Matthew,

some minor feedback from my side, as it looks like there will be another
revision of this patchset anyway.

> ---
>  drivers/net/netconsole.c | 143 +++++++++++++++++++++++++++++++++++++--
>  1 file changed, 139 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c

...

> @@ -596,6 +606,123 @@ static ssize_t remote_mac_store(struct config_item *item, const char *buf,
>  	return -EINVAL;
>  }
>  
> +struct userdatum {
> +	struct config_item item;
> +	char value[MAX_USERDATA_VALUE_LENGTH];
> +};
> +
> +static inline struct userdatum *to_userdatum(struct config_item *item)
> +{
> +	return container_of(item, struct userdatum, item);
> +}

Please don't use the inline keyword in C files,
unless there is a demonstrable reason to do so.
Rather, please let the compiler inline code as is sees fit.

...

> @@ -640,6 +767,14 @@ static const struct config_item_type netconsole_target_type = {
>  	.ct_owner		= THIS_MODULE,
>  };
>  
> +static void init_target_config_group(struct netconsole_target *nt, const char *name)

nit: Networking still prefers code to be 80 columns wide or less.

...