netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Pratt <mcpratt@protonmail.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "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: [PATCH 1/2] mac_pton: support MAC addresses with other delimiters
Date: Mon, 02 Oct 2023 23:40:02 +0000	[thread overview]
Message-ID: <20231002233946.16703-2-mcpratt@protonmail.com> (raw)
In-Reply-To: <20231002233946.16703-1-mcpratt@protonmail.com>

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]))
 			return false;
 	}
 	for (i = 0; i < ETH_ALEN; i++) {
-- 
2.30.2



  reply	other threads:[~2023-10-02 23:40 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 ` Michael Pratt [this message]
2023-10-03 16:58   ` [PATCH 1/2] mac_pton: support MAC addresses with other delimiters Stephen Hemminger
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=20231002233946.16703-2-mcpratt@protonmail.com \
    --to=mcpratt@protonmail.com \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcpratt@pm.me \
    --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).