* [PATCH iproute2] utils: do not be restrictive about alternate network device names
@ 2025-12-21 17:49 Stephen Hemminger
2026-01-07 16:54 ` David Ahern
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2025-12-21 17:49 UTC (permalink / raw)
To: netdev; +Cc: 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.
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] utils: do not be restrictive about alternate network device names
2025-12-21 17:49 [PATCH iproute2] utils: do not be restrictive about alternate network device names Stephen Hemminger
@ 2026-01-07 16:54 ` David Ahern
0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2026-01-07 16:54 UTC (permalink / raw)
To: Stephen Hemminger, netdev
On 12/21/25 10:49 AM, Stephen Hemminger wrote:
> 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(-)
>
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-07 16:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-21 17:49 [PATCH iproute2] utils: do not be restrictive about alternate network device names Stephen Hemminger
2026-01-07 16:54 ` David Ahern
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox