Skip to contentSkip to conversation

utils: do not be restrictive about alternate network device names

PATCH Applied Stephen Hemminger 2 participants 2 messages Dec 21, 2025 – Jan 7

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utils: do not be restrictive about alternate network device names

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

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

---
 lib/utils.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
lib/utils.c +11 -10
index 0719281a..13e8c098 100644
@@ -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 */
Signature · 1 line
2.51.0
Applied
#1 lore raw
Quoted 10 lines · Stephen Hemminger

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

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

---
 lib/utils.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

applied to iproute2-next. I wonder if the checks should be removed from iproute2 and left to the kernel logic to decide if the name is valid.