All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2] utils: do not be restrictive about alternate network device names
Date: Sun, 21 Dec 2025 09:49:45 -0800	[thread overview]
Message-ID: <20251221174945.8346-1-stephen@networkplumber.org> (raw)

The kernel does not impose restrictions on alternate interface
names; therefore ip commands should not either.

This allows colon, slash, even .. as alternate names.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/utils.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/lib/utils.c b/lib/utils.c
index 0719281a..13e8c098 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -847,10 +847,15 @@ int nodev(const char *dev)
 	return -1;
 }
 
-static int __check_ifname(const char *name)
+/* These checks mimic kernel checks in dev_valid_name */
+int check_ifname(const char *name)
 {
-	if (*name == '\0')
+	if (*name == '\0' || strnlen(name, IFNAMSIZ) == IFNAMSIZ)
+		return -1;
+
+	if (!strcmp(name, ".") || !strcmp(name, ".."))
 		return -1;
+
 	while (*name) {
 		if (*name == '/' || isspace(*name))
 			return -1;
@@ -859,17 +864,13 @@ static int __check_ifname(const char *name)
 	return 0;
 }
 
-int check_ifname(const char *name)
+/* Many less restrictions on altername names */
+int check_altifname(const char *name)
 {
-	/* These checks mimic kernel checks in dev_valid_name */
-	if (strlen(name) >= IFNAMSIZ)
+	if (*name == '\0' || strnlen(name, ALTIFNAMSIZ) == ALTIFNAMSIZ)
 		return -1;
-	return __check_ifname(name);
-}
 
-int check_altifname(const char *name)
-{
-	return __check_ifname(name);
+	return 0;
 }
 
 /* buf is assumed to be IFNAMSIZ */
-- 
2.51.0


             reply	other threads:[~2025-12-21 17:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-21 17:49 Stephen Hemminger [this message]
2026-01-07 16:54 ` [PATCH iproute2] utils: do not be restrictive about alternate network device names David Ahern

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=20251221174945.8346-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.