Article View: linux.kernel.netdev
Article #12630Re: [PATCH v2 1/2] lib/net_utils: allow mac_pton() to take a custom delimiter
From: netdev-bot+sashiko
Date: Sun, 08 Nov 2026 03:32
Date: Sun, 08 Nov 2026 03:32
81 lines
11007 bytes
11007 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The new kernel-doc for parse_mac_pton() in lib/net_utils.c says
"@s must be MAC_ADDR_STR_LEN characters long", which reads as anβ¦
--
lib/net_utils: allow mac_pton() to take a custom delimiter
This commit moves the body of mac_pton() into a new exported function,
parse_mac_pton(), which takes a string of accepted delimiter characters.
mac_pton() becomes a static inline wrapper that passes ":", so existing
callers behave as before.
Link: https://lore.kernel.org/all/20261023110113.2969708-1-liuc63@xiaopeng.com/
> diff --git a/lib/net_utils.c b/lib/net_utils.c
> index 215cda672fee1..011857cc978b4 100644
> --- a/lib/net_utils.c
> +++ b/lib/net_utils.c
> @@ -5,7 +5,18 @@
> #include <linux/export.h>
> #include <linux/hex.h>
>
> -bool mac_pton(const char *s, u8 *mac)
> +/**
> + * parse_mac_pton - convert a MAC address string using a custom delimiter
> + * @s: string to be parsed
> + * @mac: buffer to store the result, left untouched if @s is malformed
> + * @delim: characters accepted as a separator between the byte pairs
> + *
> + * @s must be MAC_ADDR_STR_LEN characters long and use a character from
> + * @delim at every separator position, e.g. "aa.bb:cc.dd:ee.ff" with ".:".
> + *
> + * Return: true on success, false if @s is malformed.
> + */
[Severity: Low]
Does this kernel-doc match what parse_mac_pton() actually checks? The text
"@s must be MAC_ADDR_STR_LEN characters long" reads as an exact length, but
the code only checks for a minimum length:
lib/net_utils.c:parse_mac_pton() {
...
if (strnlen(s, MAC_ADDR_STR_LEN) < MAC_ADDR_STR_LEN)
return false;
...
}
strnlen() is capped at MAC_ADDR_STR_LEN (17), and the validation loop only
reads s[0] to s[16]. Nothing after the 17th character is looked at. So
inputs like "aa:bb:cc:dd:ee:ff:00", "aa:bb:cc:dd:ee:ffXYZ" or
"aa:bb:cc:dd:ee:ff\n" return true and fill @mac.
The Return: line says false means "@s is malformed". A caller could read
that as saying true means the whole string was a well-formed MAC address.
The old mac_pton() parsed only the prefix in the same way, and existing
callers depend on it. Sysfs and configfs input usually ends in a newline,
and some callers parse a MAC address embedded in a longer string. So the
code looks right and the comment is what is off.
Since this is a newly exported general-purpose API, could the comment say
something like "@s must contain at least MAC_ADDR_STR_LEN characters; only
the first MAC_ADDR_STR_LEN are parsed and any trailing characters are
ignored"? Enforcing an exact length would break existing mac_pton() users.
> +bool parse_mac_pton(const char *s, u8 *mac, const char *delim)
> {
> int i;
>
[ ... ]
--
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261104025058.2650911-1-liuc63%40xiaopeng.com
Technical Details
Message-ID:
<179410875676.994134.16092814735554237701@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358582-linux-kernel-netdev=dewy.ruReferences:
<20261104025058.2650911-2-liuc63@xiaopeng.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-358582-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v2 1/2] lib/net_utils: allow mac_pton() to take a custom delimiter Date: Sun, 08 Nov 2026 03:32:36 +0000 Organization: Usenet Network Message-ID: <179410875676.994134.16092814735554237701@kernel.org> References: <20261104025058.2650911-2-liuc63@xiaopeng.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="55300"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:QCEuAsdma0kLfW9PWypGBCajPAc= sha256:yIwSY5Sbv51KNPX86k9Q+qlHzxIkLAfE0JC6+mv4p3g= sha1:VNzRs/f7edZAlycjuDo4y6pygQw= sha256:d10p6LdsMp1pso00/U9Z48mNusZJ7x6pYHpCA2PKwx4= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 48798113506; Sun, 8 Nov 2026 06:33:18 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1w9kEiWgOYky; Sun, 8 Nov 2026 06:33:10 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-358582-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id B98E21134FA; Sun, 8 Nov 2026 06:32:59 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id D04402F160; Sun, 8 Nov 2026 03:32:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794108759; b=RQZmMV1shK/J0yw3hhq/nxqKM1+Zh45D1LSzXdw8Nv5H8itTFqgoGHraQ6EggWKaGz7L 6Tuy1JDy9wS1tsaVAflwK1IuulmCWtfSLDqElOEsYm2pnaCSwj82bXzTZ+wNgdV8iEyYL RpuWZ80r7puQLv34FUa5yfO5ZMnLbBXy3IWKQMHGDmPpdbrOjlOtSqMb0pnax433gIQpa LoEhhVq4fUYnCOlojgSwpRtUe52Hx4pf/jjr4Y3WMmk1U0j/dFqu1HpHzvRxF8KZQ9FEh 9OwqsAqOfQzQL0VeMXsU8qu1S3ud0Yix9S1k2zMl1KppvObXx9YZ3HpjxHpo8yXVEDQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794108759; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=1KkunFVOR9hKpVunSG6R4MQyB90H0pMgHHtcvlxeDzU=; b=W6Z0Lj9Mzs2rXRqUaWy92oXCLY9rCriw6pzvywon7RDAlumukGM1Kz8DD4frpnICY5fC Kz6yNjgCXldV7ABniz1yyO395DovHZ4H1gNNG9p252mxRSsXrrLbAP0UKhhp4J7QEVLlI WE8k4aB4r4PRLhJfPmpLvjf+VEWdYozM9tCUQWvcos6nEpKKxLj3Z6DE37QioD4o3T5uS UHb2Y2KtAqXKc5V+usW8X2A2Xubty5GpTVqwGFcbdOguzLFzyTMo08hVXvww1C8D7hYGB ELCuIwahdb1jM5xa1fea1QLh+vZ5EVmN67Ephkv0zysj1AJn3SWOq/Yo1vaLakjAfhQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B5YzOJuM; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93ACA606A323; Sun, 8 Nov 2026 03:32:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B5YzOJuM X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794108758; b=HLt3POnVF6swl4YY6lWQjAKI6xfa29pRFy3JB3UAa7+YAlvWra1fxHjsIa/JMvT/JUMW SCUhNV9hJvwSIHGk6hUXUbWXkaAFqAbhU8uNF1AdSsY4OojuE/Qa93QOTVj8YtlrNS6CH +dal7XU53G7u8JPrtp4QuT+B6N0gJ3oxtANqBMu7KtAhqVuMxbCAeCwWrdCg3VoZ+Z5Oc MFIgzVd3hJKA/qnVFgMzQzs0Xqma0z2p7N5YTytKDYbzAkZ1E19Cnp0M9VHMqBgkkBrYc bDzSdVq5MpCV2EI37P9Fzz8wlBavrTn5wu1K74v1ODTNZnoy+D54qcjsEhoZmueGFyg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794108758; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=1KkunFVOR9hKpVunSG6R4MQyB90H0pMgHHtcvlxeDzU=; b=2G6utFwh1RJYah+TPlRR+NJL5I7wdUT28sWTfiKcsJl6KDCxNXKjl/t+Z+XfJwrbWHiE eWj9S+gdNeWgt5aMr0RfS1RH+ytaYDKuJucocb52xUGgiZ7H13LwcplrL3jyJdfhVOIjo XjY0i1mai5TEri9cTUzLjaJHV/p2OmIyHd0B722L4j9qwxLnpvoDViqls3/JuhPW7ytSm M9SiYBvtLUo8qITsIcypyhj3ayLahXTOtzMqdTix/PfP4lgO+7QJTpL9zPSa6V2HrK69a EUmSp8wsuPavdyFgWgFWsW7Vt7vSMUyhmBSjPvT3hroR7enSH6axHstMvlLbbUobEpQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=B5YzOJuM; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D48D606A31C; Sun, 8 Nov 2026 03:32:38 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A7791F0089F; Sun, 8 Nov 2026 03:32:37 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794108758; bh=1KkunFVOR9hKpVunSG6R4MQyB90H0pMgHHtcvlxeDzU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=B5YzOJuMa07gUCuZW7PeLZxy6As0ZWPv4JoeGCp58HmvMvpliq8tU/M/6DrPbmCIa 5xGE2Kcj+KqL+apcZbC4UDovB5qfgSHe8PXrcZfwYzpUEBYgJa/ylHhrf+JYY6tffN l3kEGi/OP472mI8F9x1ARmKbzCEGWNlnIWec+hUfvJ8unrZmwbIWaqnVUFY8Wl+lUC VFLHvhG6k+Kb9EWYsA15XgPj7fkUiRjz11XFfjkB8GfY5Fh98k8ozktjf57rPbs1RF UPJYQZJMaEO1ZV/K/YbPF1wZNWZMt3sIXQhmYOznybh/33vuYZ60TRcVR8HEqJqIF9 N6BvOaKjzWObQ== X-Cc: gregkh@linuxfoundation.org, akpm@linux-foundation.org, andriy.shevchenko@intel.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, khtsai@google.com, fangxy@xiaopeng.com, rdunlap@infradead.org, dbrownell@users.sourceforge.net, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org X-In-Reply-To: <20261104025058.2650911-2-liuc63@xiaopeng.com> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list