* [PATCH 0/1] lib: Align naming rules with the kernel
@ 2025-12-12 4:18 Christoph Anton Mitterer
2025-12-12 4:18 ` [PATCH 1/1] " Christoph Anton Mitterer
2025-12-12 5:03 ` [PATCH 0/1] " Stephen Hemminger
0 siblings, 2 replies; 6+ messages in thread
From: Christoph Anton Mitterer @ 2025-12-12 4:18 UTC (permalink / raw)
To: netdev
Hey.
Seems the check rules in iproute2 have gotten out of sync with those of the
kernel. This patch brings them up-to-date.
It shall be noted, that these changes would also affect those for alnames (like
before, just without enforcing the maximum length, which AFAIU was the main (or
even whole?) point of altnames[0]).
I made a small test and compiled iproute2 with its `check_altifname()` simply
always returning true.
Turnes out, that the kernel seems to accept any name (i.e. including whitespace
and `/`) and I didn’t find any check functions for altnames in the kernel
either (okay I didn’t look that hard ^^).
Not sure, but maybe altnames should really be allowed to contain anything?
If so, we’d of course need to change this patch.
OTOH, e.g. systemd already assumes that certain characters aren’t allowed in
interface names (see `Name=` in systemd.link(5)) and e.g. `nmcli` uses `:` to
separate fields in its machine readable output.
But then again, the kernel should perhaps check altnames?
Cheers,
Chris.
[0] https://lore.kernel.org/netdev/20190719110029.29466-1-jiri@resnulli.us/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] lib: Align naming rules with the kernel
2025-12-12 4:18 [PATCH 0/1] lib: Align naming rules with the kernel Christoph Anton Mitterer
@ 2025-12-12 4:18 ` Christoph Anton Mitterer
2025-12-12 4:55 ` Stephen Hemminger
2025-12-12 5:03 ` [PATCH 0/1] " Stephen Hemminger
1 sibling, 1 reply; 6+ messages in thread
From: Christoph Anton Mitterer @ 2025-12-12 4:18 UTC (permalink / raw)
To: netdev
This aligns the naming rules with those of the kernel as set in the
`dev_valid_name()`-function in `net/core/dev.c`.
It also affects the validity of altnames.
Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
---
lib/utils.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/utils.c b/lib/utils.c
index 0719281a..e4e5f337 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -851,8 +851,10 @@ static int __check_ifname(const char *name)
{
if (*name == '\0')
return -1;
+ if (!strcmp(name, ".") || !strcmp(name, ".."))
+ return -1;
while (*name) {
- if (*name == '/' || isspace(*name))
+ if (*name == '/' || *name == ':' || isspace(*name))
return -1;
++name;
}
--
2.51.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] lib: Align naming rules with the kernel
2025-12-12 4:18 ` [PATCH 1/1] " Christoph Anton Mitterer
@ 2025-12-12 4:55 ` Stephen Hemminger
2025-12-12 5:32 ` Christoph Anton Mitterer
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2025-12-12 4:55 UTC (permalink / raw)
To: Christoph Anton Mitterer; +Cc: netdev
On Fri, 12 Dec 2025 05:18:13 +0100
Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> wrote:
> This aligns the naming rules with those of the kernel as set in the
> `dev_valid_name()`-function in `net/core/dev.c`.
>
> It also affects the validity of altnames.
>
> Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
> ---
> lib/utils.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/utils.c b/lib/utils.c
> index 0719281a..e4e5f337 100644
> --- a/lib/utils.c
> +++ b/lib/utils.c
> @@ -851,8 +851,10 @@ static int __check_ifname(const char *name)
> {
> if (*name == '\0')
> return -1;
> + if (!strcmp(name, ".") || !strcmp(name, ".."))
> + return -1;
> while (*name) {
> - if (*name == '/' || isspace(*name))
> + if (*name == '/' || *name == ':' || isspace(*name))
Do you check that this didn't break the legacy ifalias stuff?
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH 1/1] lib: Align naming rules with the kernel
2025-12-12 4:55 ` Stephen Hemminger
@ 2025-12-12 5:32 ` Christoph Anton Mitterer
0 siblings, 0 replies; 6+ messages in thread
From: Christoph Anton Mitterer @ 2025-12-12 5:32 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
On Fri, 2025-12-12 at 13:55 +0900, Stephen Hemminger wrote:
> > - if (*name == '/' || isspace(*name))
> > + if (*name == '/' || *name == ':' ||
> > isspace(*name))
>
> Do you check that this didn't break the legacy ifalias stuff?
No, I did not.
Where is __check_ifname() or any of its callers used by it?
Thanks :-)
Chris.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/1] lib: Align naming rules with the kernel
2025-12-12 4:18 [PATCH 0/1] lib: Align naming rules with the kernel Christoph Anton Mitterer
2025-12-12 4:18 ` [PATCH 1/1] " Christoph Anton Mitterer
@ 2025-12-12 5:03 ` Stephen Hemminger
[not found] ` <28a0486bd08d59f8f2e758f73a39bd442547197f.camel@christoph.anton.mitterer.name>
1 sibling, 1 reply; 6+ messages in thread
From: Stephen Hemminger @ 2025-12-12 5:03 UTC (permalink / raw)
To: Christoph Anton Mitterer; +Cc: netdev
On Fri, 12 Dec 2025 05:18:12 +0100
Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> wrote:
> I made a small test and compiled iproute2 with its `check_altifname()` simply
> always returning true.
> Turnes out, that the kernel seems to accept any name (i.e. including whitespace
> and `/`) and I didn’t find any check functions for altnames in the kernel
> either (okay I didn’t look that hard ^^).
>
> Not sure, but maybe altnames should really be allowed to contain anything?
> If so, we’d of course need to change this patch.
> OTOH, e.g. systemd already assumes that certain characters aren’t allowed in
> interface names (see `Name=` in systemd.link(5)) and e.g. `nmcli` uses `:` to
> separate fields in its machine readable output.
>
> But then again, the kernel should perhaps check altnames?
The restrictions in the kernel are because interface names also show up in sysfs
which can't allow invalid filenames. The altnames don't show up in sysfs now.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-12-13 2:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12 4:18 [PATCH 0/1] lib: Align naming rules with the kernel Christoph Anton Mitterer
2025-12-12 4:18 ` [PATCH 1/1] " Christoph Anton Mitterer
2025-12-12 4:55 ` Stephen Hemminger
2025-12-12 5:32 ` Christoph Anton Mitterer
2025-12-12 5:03 ` [PATCH 0/1] " Stephen Hemminger
[not found] ` <28a0486bd08d59f8f2e758f73a39bd442547197f.camel@christoph.anton.mitterer.name>
[not found] ` <20251213092004.079f9cbe@stephen-xps.local>
2025-12-13 1:48 ` Christoph Anton Mitterer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox