netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Michael Pratt <mcpratt@protonmail.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>, Rafal Milecki <zajec5@gmail.com>,
	Christian Marangi <ansuelsmth@gmail.com>,
	Michael Pratt <mcpratt@pm.me>
Subject: Re: [PATCH 1/2] mac_pton: support MAC addresses with other delimiters
Date: Tue, 3 Oct 2023 09:58:32 -0700	[thread overview]
Message-ID: <20231003095832.2fce1e16@hermes.local> (raw)
In-Reply-To: <20231002233946.16703-2-mcpratt@protonmail.com>

On Mon, 02 Oct 2023 23:40:02 +0000
Michael Pratt <mcpratt@protonmail.com> wrote:

> From: Michael Pratt <mcpratt@pm.me>
> 
> Some network hardware vendors may do something unique
> when storing the MAC address into hardware in ASCII,
> like using hyphens as the delimiter.
> 
> Allow parsing of MAC addresses with a non-standard
> delimiter (punctuation other than a colon).
> 
> e.g. aa-bb-cc-dd-ee-ff
> 
> Signed-off-by: Michael Pratt <mcpratt@pm.me>
> ---
>  lib/net_utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/net_utils.c b/lib/net_utils.c
> index 42bb0473fb22..ecb7625e1dec 100644
> --- a/lib/net_utils.c
> +++ b/lib/net_utils.c
> @@ -18,7 +18,7 @@ bool mac_pton(const char *s, u8 *mac)
>  	for (i = 0; i < ETH_ALEN; i++) {
>  		if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
>  			return false;
> -		if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
> +		if (i != ETH_ALEN - 1 && !ispunct(s[i * 3 + 2]))

Having looked at same thing in DPDK already, this looks overly broad.
There are only two common formats in the standards (isn't it fun
when standards disagree). IETF uses colon separator and IEEE uses
hyphen separator. Linux convention is colon, and  Windows convention
is hyphen. There is also the old Cisco 3 part format with periods
but adding that makes no sense.

Also, it would be bad to allow bogus values where two different
types of punctuation are used.

  reply	other threads:[~2023-10-03 16:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 23:39 [PATCH v1 0/2] mac_pton: support more MAC address formats Michael Pratt
2023-10-02 23:40 ` [PATCH 1/2] mac_pton: support MAC addresses with other delimiters Michael Pratt
2023-10-03 16:58   ` Stephen Hemminger [this message]
2023-10-02 23:40 ` [PATCH 2/2] mac_pton: support MAC addresses without delimiters Michael Pratt
2023-10-03 14:17 ` [PATCH v1 0/2] mac_pton: support more MAC address formats Simon Horman

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=20231003095832.2fce1e16@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcpratt@pm.me \
    --cc=mcpratt@protonmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=zajec5@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;
as well as URLs for NNTP newsgroup(s).