netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	jakub.kicinski@netronome.com, andrew@lunn.ch, mlxsw@mellanox.com
Subject: Re: [patch net-next] devlink: add format requirement for devlink param names
Date: Fri, 18 Oct 2019 18:58:23 +0200	[thread overview]
Message-ID: <20191018165823.GF2185@nanopsycho> (raw)
In-Reply-To: <20191018093509.112af620@hermes.lan>

Fri, Oct 18, 2019 at 06:35:09PM CEST, stephen@networkplumber.org wrote:
>On Fri, 18 Oct 2019 18:07:26 +0200
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> +static bool devlink_param_valid_name(const char *name)
>> +{
>> +	int len = strlen(name);
>> +	int i;
>> +
>> +	/* Name can contain lowercase characters or digits.
>> +	 * Underscores are also allowed, but not at the beginning
>> +	 * or end of the name and not more than one in a row.
>> +	 */
>> +
>> +	for (i = 0; i < len; i++) {
>> +		if (islower(name[i]) || isdigit(name[i]))
>> +			continue;
>> +		if (name[i] != '_')
>> +			return false;
>> +		if (i == 0 || i + 1 == len)
>> +			return false;
>> +		if (name[i - 1] == '_')
>> +			return false;
>> +	}
>> +	return true;
>> +}
>
>You might want to also impose a maximum length on name,

Well I don't really see why.

>and not allow slash in name (if you ever plan to use sysfs).

They are not allowed. Only islower, isdigit, '_'. That's it.

  reply	other threads:[~2019-10-18 16:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 16:07 [patch net-next] devlink: add format requirement for devlink param names Jiri Pirko
2019-10-18 16:25 ` Jakub Kicinski
2019-10-18 16:58   ` Jiri Pirko
2019-10-18 16:33 ` Stephen Hemminger
2019-10-18 16:58   ` Jiri Pirko
2019-10-18 16:35 ` Stephen Hemminger
2019-10-18 16:58   ` Jiri Pirko [this message]
2019-10-18 17:43 ` Andrew Lunn
2019-10-18 20:08   ` Jiri Pirko
2019-10-18 20:27     ` Andrew Lunn
2019-10-18 21:34       ` Jakub Kicinski
2019-10-19  5:39       ` Jiri Pirko

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=20191018165823.GF2185@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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;
as well as URLs for NNTP newsgroup(s).