Skip to contentSkip to conversation

longer netdev names proposal

RFC Jiri Pirko 7 participants 22 messages Jun 27, 2019 – Jun 28, 2019

Subsystems (3)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

Hi all.

In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for netdevice name length. Now when we have PF and VF representors with port names like "pfXvfY", it became quite common to hit this limit:
0123456789012345
enp131s0f1npf0vf6
enp131s0f1npf0vf22

Since IFLA_NAME is just a string, I though it might be possible to use it to carry longer names as it is. However, the userspace tools, like iproute2, are doing checks before print out. So for example in output of "ip addr" when IFLA_NAME is longer than IFNAMSIZE, the netdevice is completely avoided.

So here is a proposal that might work:
1) Add a new attribute IFLA_NAME_EXT that could carry names longer than IFNAMSIZE, say 64 bytes. The max size should be only defined in kernel, user should be prepared for any string size.
2) Add a file in sysfs that would indicate that NAME_EXT is supported by the kernel.
3) Udev is going to look for the sysfs indication file. In case when kernel supports long names, it will do rename to longer name, setting IFLA_NAME_EXT. If not, it does what it does now - fail.
4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ
-> both IFLA_NAME and IFLA_NAME_EXT would contain the same string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1
renamed IFLA_NAME_EXT = enp5s0f1npf0vf1
B) The name is longer tha IFNAMSIZ
-> IFLA_NAME would contain the original one, IFLA_NAME_EXT would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

This would allow the old tools to work with "eth0" and the new tools would work with "enp131s0f1npf0vf22". In sysfs, there would be symlink from one name to another.

Also, there might be a warning added to kernel if someone works with IFLA_NAME that the userspace tool should be upgraded.

Eventually, only IFLA_NAME_EXT is going to be used by everyone.

I'm aware there are other places where similar new attribute would have to be introduced too (ip rule for example). I'm not saying this is a simple work.

Question is what to do with the ioctl api (get ifindex etc). I would probably leave it as is and push tools to use rtnetlink instead.

Any ideas why this would not work? Any ideas how to solve this differently?

Thanks!

Jiri

#1 lore raw
Quoted 55 lines · On Thu, 27 Jun 2019 11:43:27 +0200 Jiri Pirko <[email protected]> wrote:

Hi all.

In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for netdevice name length. Now when we have PF and VF representors with port names like "pfXvfY", it became quite common to hit this limit:
0123456789012345
enp131s0f1npf0vf6
enp131s0f1npf0vf22

Since IFLA_NAME is just a string, I though it might be possible to use it to carry longer names as it is. However, the userspace tools, like iproute2, are doing checks before print out. So for example in output of "ip addr" when IFLA_NAME is longer than IFNAMSIZE, the netdevice is completely avoided.

So here is a proposal that might work:
1) Add a new attribute IFLA_NAME_EXT that could carry names longer than IFNAMSIZE, say 64 bytes. The max size should be only defined in kernel, user should be prepared for any string size.
2) Add a file in sysfs that would indicate that NAME_EXT is supported by the kernel.
3) Udev is going to look for the sysfs indication file. In case when kernel supports long names, it will do rename to longer name, setting IFLA_NAME_EXT. If not, it does what it does now - fail.
4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ
-> both IFLA_NAME and IFLA_NAME_EXT would contain the same string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1
renamed IFLA_NAME_EXT = enp5s0f1npf0vf1
B) The name is longer tha IFNAMSIZ
-> IFLA_NAME would contain the original one, IFLA_NAME_EXT would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

This would allow the old tools to work with "eth0" and the new tools would work with "enp131s0f1npf0vf22". In sysfs, there would be symlink from one name to another.

Also, there might be a warning added to kernel if someone works with IFLA_NAME that the userspace tool should be upgraded.

Eventually, only IFLA_NAME_EXT is going to be used by everyone.

I'm aware there are other places where similar new attribute would have to be introduced too (ip rule for example). I'm not saying this is a simple work.

Question is what to do with the ioctl api (get ifindex etc). I would probably leave it as is and push tools to use rtnetlink instead.

Quoted 7 lines

Any ideas why this would not work? Any ideas how to solve this differently?

Thanks!

Jiri

I looked into this in the past, but then rejected it because there are so many tools that use names, not just iproute2. Plus long names are very user unfriendly.

#2 lore raw
Quoted 45 lines · Stephen Hemminger
Quoted 42 lines · On Thu, 27 Jun 2019 11:43:27 +0200 Jiri Pirko <[email protected]> wrote:

Hi all.

In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for
netdevice name length. Now when we have PF and VF representors with port names like "pfXvfY", it became quite common to hit this limit:
0123456789012345
enp131s0f1npf0vf6
enp131s0f1npf0vf22

Since IFLA_NAME is just a string, I though it might be possible to use
it to carry longer names as it is. However, the userspace tools, like
iproute2, are doing checks before print out. So for example in output of
"ip addr" when IFLA_NAME is longer than IFNAMSIZE, the netdevice is completely avoided.

So here is a proposal that might work:
1) Add a new attribute IFLA_NAME_EXT that could carry names longer than
IFNAMSIZE, say 64 bytes. The max size should be only defined in
kernel,
user should be prepared for any string size.
2) Add a file in sysfs that would indicate that NAME_EXT is supported by
the kernel.
3) Udev is going to look for the sysfs indication file. In case when
kernel supports long names, it will do rename to longer name,
setting
IFLA_NAME_EXT. If not, it does what it does now - fail.
4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ

      -> both IFLA_NAME and IFLA_NAME_EXT would contain the same

string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1
renamed IFLA_NAME_EXT = enp5s0f1npf0vf1

Quoted 8 lines
Quoted 8 lines

B) The name is longer tha IFNAMSIZ

      -> IFLA_NAME would contain the original one, IFLA_NAME_EXT

would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

It makes me a bit uncomfortable to allow IFLA_NAME and IFLA_NAME_EXT to be completely different. That sounds like a big source of confusion and debugging problems in production.

Dan

Quoted 28 lines
Quoted 17 lines

This would allow the old tools to work with "eth0" and the new tools would work with "enp131s0f1npf0vf22". In sysfs, there would be symlink from one name to another.

Also, there might be a warning added to kernel if someone works with IFLA_NAME that the userspace tool should be upgraded.

Eventually, only IFLA_NAME_EXT is going to be used by everyone.

I'm aware there are other places where similar new attribute would have to be introduced too (ip rule for example). I'm not saying this is a simple work.

Question is what to do with the ioctl api (get ifindex etc). I would
probably leave it as is and push tools to use rtnetlink instead.

Quoted 7 lines

Any ideas why this would not work? Any ideas how to solve this differently?

Thanks!

Jiri

I looked into this in the past, but then rejected it because there are so many tools that use names, not just iproute2. Plus long names are very user unfriendly.

#3 lore raw
In reply to Jiri Pirko
Quoted 8 lines · Jiri Pirko

Hi all.

In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for netdevice name length. Now when we have PF and VF representors with port names like "pfXvfY", it became quite common to hit this limit:
0123456789012345
enp131s0f1npf0vf6
enp131s0f1npf0vf22

QinQ (stacked vlans) is another example.

Quoted 7 lines

Since IFLA_NAME is just a string, I though it might be possible to use it to carry longer names as it is. However, the userspace tools, like iproute2, are doing checks before print out. So for example in output of "ip addr" when IFLA_NAME is longer than IFNAMSIZE, the netdevice is completely avoided.

Quoted 6 lines

So here is a proposal that might work:
1) Add a new attribute IFLA_NAME_EXT that could carry names longer than IFNAMSIZE, say 64 bytes. The max size should be only defined in kernel, user should be prepared for any string size.
2) Add a file in sysfs that would indicate that NAME_EXT is supported by the kernel.

no sysfs files.

Johannes added infrastructure to retrieve the policy. That is a more flexible and robust option for determining what the kernel supports.

Quoted 9 lines

3) Udev is going to look for the sysfs indication file. In case when kernel supports long names, it will do rename to longer name, setting IFLA_NAME_EXT. If not, it does what it does now - fail.
4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ
-> both IFLA_NAME and IFLA_NAME_EXT would contain the same string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1

Quoted 8 lines

renamed IFLA_NAME_EXT = enp5s0f1npf0vf1
B) The name is longer tha IFNAMSIZ
-> IFLA_NAME would contain the original one, IFLA_NAME_EXT would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

so kernel side there will be 2 names for the same net_device?

Quoted 4 lines

This would allow the old tools to work with "eth0" and the new tools would work with "enp131s0f1npf0vf22". In sysfs, there would be symlink from one name to another.

I would prefer a solution that does not rely on sysfs hooks.

Quoted 3 lines

Also, there might be a warning added to kernel if someone works with IFLA_NAME that the userspace tool should be upgraded.

that seems like spam and confusion for the first few years of a new api.

Quoted 9 lines

Eventually, only IFLA_NAME_EXT is going to be used by everyone.

I'm aware there are other places where similar new attribute would have to be introduced too (ip rule for example). I'm not saying this is a simple work.

Question is what to do with the ioctl api (get ifindex etc). I would probably leave it as is and push tools to use rtnetlink instead.

The ioctl API is going to be a limiter here. ifconfig is still quite prevalent and net-snmp still uses ioctl (as just 2 common examples). snmp showing one set of names and rtnetlink s/w showing another is going to be really confusing.

#20 lore raw
In reply to Jiri Pirko
Quoted 30 lines · Jiri Pirko

Hi all.

In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for netdevice name length. Now when we have PF and VF representors with port names like "pfXvfY", it became quite common to hit this limit:
0123456789012345
enp131s0f1npf0vf6
enp131s0f1npf0vf22

Since IFLA_NAME is just a string, I though it might be possible to use it to carry longer names as it is. However, the userspace tools, like iproute2, are doing checks before print out. So for example in output of "ip addr" when IFLA_NAME is longer than IFNAMSIZE, the netdevice is completely avoided.

So here is a proposal that might work:
1) Add a new attribute IFLA_NAME_EXT that could carry names longer than IFNAMSIZE, say 64 bytes. The max size should be only defined in kernel, user should be prepared for any string size.
2) Add a file in sysfs that would indicate that NAME_EXT is supported by the kernel.
3) Udev is going to look for the sysfs indication file. In case when kernel supports long names, it will do rename to longer name, setting IFLA_NAME_EXT. If not, it does what it does now - fail.
4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ
-> both IFLA_NAME and IFLA_NAME_EXT would contain the same string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1

Quoted 8 lines

renamed IFLA_NAME_EXT = enp5s0f1npf0vf1
B) The name is longer tha IFNAMSIZ
-> IFLA_NAME would contain the original one, IFLA_NAME_EXT would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

I think B is the only way, A risks duplicate IFLA_NAMEs over ioctl, right? And maybe there is some crazy application out there which mixes netlink and ioctl.

I guess it's not worse than status quo, given that today renames will fail and we will either get truncated names or eth0s..

Quoted 13 lines

This would allow the old tools to work with "eth0" and the new tools would work with "enp131s0f1npf0vf22". In sysfs, there would be symlink from one name to another.

Also, there might be a warning added to kernel if someone works with IFLA_NAME that the userspace tool should be upgraded.

Eventually, only IFLA_NAME_EXT is going to be used by everyone.

I'm aware there are other places where similar new attribute would have to be introduced too (ip rule for example). I'm not saying this is a simple work.

Quoted 5 lines

Question is what to do with the ioctl api (get ifindex etc). I would probably leave it as is and push tools to use rtnetlink instead.

Any ideas why this would not work? Any ideas how to solve this differently?

Since we'd have to update all user space to make use of the new names I'd be tempted to move to a more structured device identification.

5: enp131s0f1npf0vf6: <BROADCAST,MULTICAST> ...

vs:

5: eth5 (parent enp131s0f1 pf 0 vf 6 peer X*): <BROADCAST,MULTICAST> ...

* ;)

And allow filtering/selection of device based on more attributes than just name and ifindex. In practice in container workloads, for example, the names are already very much insufficient to identify the device. Refocusing on attributes is probably a big effort and not that practical for traditional CLI users? IDK

Anyway, IMHO your scheme is strictly better than status quo.

#21 lore raw
Quoted 77 lines · On Thu, 27 Jun 2019 10:48:08 -0700 Jakub Kicinski…
Quoted 30 lines · Jiri Pirko

Hi all.

In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for netdevice name length. Now when we have PF and VF representors with port names like "pfXvfY", it became quite common to hit this limit:
0123456789012345
enp131s0f1npf0vf6
enp131s0f1npf0vf22

Since IFLA_NAME is just a string, I though it might be possible to use it to carry longer names as it is. However, the userspace tools, like iproute2, are doing checks before print out. So for example in output of "ip addr" when IFLA_NAME is longer than IFNAMSIZE, the netdevice is completely avoided.

So here is a proposal that might work:
1) Add a new attribute IFLA_NAME_EXT that could carry names longer than IFNAMSIZE, say 64 bytes. The max size should be only defined in kernel, user should be prepared for any string size.
2) Add a file in sysfs that would indicate that NAME_EXT is supported by the kernel.
3) Udev is going to look for the sysfs indication file. In case when kernel supports long names, it will do rename to longer name, setting IFLA_NAME_EXT. If not, it does what it does now - fail.
4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ
-> both IFLA_NAME and IFLA_NAME_EXT would contain the same string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1

Quoted 8 lines

renamed IFLA_NAME_EXT = enp5s0f1npf0vf1
B) The name is longer tha IFNAMSIZ
-> IFLA_NAME would contain the original one, IFLA_NAME_EXT would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

I think B is the only way, A risks duplicate IFLA_NAMEs over ioctl, right? And maybe there is some crazy application out there which mixes netlink and ioctl.

I guess it's not worse than status quo, given that today renames will fail and we will either get truncated names or eth0s..

Quoted 13 lines

This would allow the old tools to work with "eth0" and the new tools would work with "enp131s0f1npf0vf22". In sysfs, there would be symlink from one name to another.

Also, there might be a warning added to kernel if someone works with IFLA_NAME that the userspace tool should be upgraded.

Eventually, only IFLA_NAME_EXT is going to be used by everyone.

I'm aware there are other places where similar new attribute would have to be introduced too (ip rule for example). I'm not saying this is a simple work.

Quoted 5 lines

Question is what to do with the ioctl api (get ifindex etc). I would probably leave it as is and push tools to use rtnetlink instead.

Any ideas why this would not work? Any ideas how to solve this differently?

Since we'd have to update all user space to make use of the new names I'd be tempted to move to a more structured device identification.

5: enp131s0f1npf0vf6: <BROADCAST,MULTICAST> ...

vs:

5: eth5 (parent enp131s0f1 pf 0 vf 6 peer X*): <BROADCAST,MULTICAST> ...

* ;)

Quoted 7 lines

And allow filtering/selection of device based on more attributes than just name and ifindex. In practice in container workloads, for example, the names are already very much insufficient to identify the device. Refocusing on attributes is probably a big effort and not that practical for traditional CLI users? IDK

Anyway, IMHO your scheme is strictly better than status quo.

Or Cisco style naming ;-) Ethernet0/0

There is a better solution for human use already.
the field ifalias allows arbitrary values and hooked into SNMP.

Why not have userspace fill in this field with something by default?

#4 lore raw
In reply to David Ahern
Quoted 15 lines · David Ahern
Quoted 6 lines

4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ
-> both IFLA_NAME and IFLA_NAME_EXT would contain the same string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1

Quoted 8 lines

renamed IFLA_NAME_EXT = enp5s0f1npf0vf1
B) The name is longer tha IFNAMSIZ
-> IFLA_NAME would contain the original one, IFLA_NAME_EXT would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

Quoted 1 line

so kernel side there will be 2 names for the same net_device?

It often feels as a deficiency that unlike block devices where we can keep one name and create multiple symlinks based on different naming schemes, network devices can have only one name. There are aliases but AFAIK they are only used (and can be only used) for SNMP. IMHO this limitation is part of the mess that left us with so-called "predictable names" which are in practice neither persistent nor predictable.

So perhaps we could introduce actual aliases (or altnames or whatever we would call them) for network devices that could be used to identify a network device whenever both kernel and userspace tool supports them. Old (and ancient) tools would have to use the one canonical name limited to current IFNAMSIZ, new tools would allow using any alias which could be longer.

Michal

#5 lore raw
Quoted 7 lines · On Thu, 27 Jun 2019 20:08:03 +0200 Michal Kubecek <[email protected]> wrote:

It often feels as a deficiency that unlike block devices where we can keep one name and create multiple symlinks based on different naming schemes, network devices can have only one name. There are aliases but AFAIK they are only used (and can be only used) for SNMP. IMHO this limitation is part of the mess that left us with so-called "predictable names" which are in practice neither persistent nor predictable.

Quoted 8 lines

So perhaps we could introduce actual aliases (or altnames or whatever we would call them) for network devices that could be used to identify a network device whenever both kernel and userspace tool supports them. Old (and ancient) tools would have to use the one canonical name limited to current IFNAMSIZ, new tools would allow using any alias which could be longer.

Michal

That is already there in current network model.

# ip li set dev eno1 alias 'Onboard Ethernet'
# ip li show dev eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether ac:1f:6b:74:38:c0 brd ff:ff:ff:ff:ff:ff
    alias Onboard Ethernet
#6 lore raw
Quoted 20 lines · Stephen Hemminger
Quoted 7 lines · On Thu, 27 Jun 2019 20:08:03 +0200 Michal Kubecek <[email protected]> wrote:

It often feels as a deficiency that unlike block devices where we can keep one name and create multiple symlinks based on different naming schemes, network devices can have only one name. There are aliases but AFAIK they are only used (and can be only used) for SNMP. IMHO this limitation is part of the mess that left us with so-called "predictable names" which are in practice neither persistent nor predictable.

Quoted 8 lines

So perhaps we could introduce actual aliases (or altnames or whatever we would call them) for network devices that could be used to identify a network device whenever both kernel and userspace tool supports them. Old (and ancient) tools would have to use the one canonical name limited to current IFNAMSIZ, new tools would allow using any alias which could be longer.

Michal

Quoted 6 lines

That is already there in current network model.

# ip li set dev eno1 alias 'Onboard Ethernet'
# ip li show dev eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether ac:1f:6b:74:38:c0 brd ff:ff:ff:ff:ff:ff
    alias Onboard Ethernet

Hi Stephen

$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

Andrew

#7 lore raw
Quoted 24 lines · Andrew Lunn
Quoted 16 lines · Stephen Hemminger
Quoted 7 lines · On Thu, 27 Jun 2019 20:08:03 +0200 Michal Kubecek <[email protected]> wrote:

It often feels as a deficiency that unlike block devices where we can keep one name and create multiple symlinks based on different naming schemes, network devices can have only one name. There are aliases but AFAIK they are only used (and can be only used) for SNMP. IMHO this limitation is part of the mess that left us with so-called "predictable names" which are in practice neither persistent nor predictable.

Quoted 6 lines

So perhaps we could introduce actual aliases (or altnames or whatever we would call them) for network devices that could be used to identify a network device whenever both kernel and userspace tool supports them. Old (and ancient) tools would have to use the one canonical name limited to current IFNAMSIZ, new tools would allow using any alias which could be longer.

Quoted 6 lines

That is already there in current network model.

# ip li set dev eno1 alias 'Onboard Ethernet'
# ip li show dev eno1
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether ac:1f:6b:74:38:c0 brd ff:ff:ff:ff:ff:ff
    alias Onboard Ethernet
Quoted 7 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

That's exactly what I meant: to be really useful, one should be able to use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Michal

#8 lore raw
Quoted 9 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

Quoted 5 lines

That's exactly what I meant: to be really useful, one should be able to use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Michal

The kernel doesn't enforce uniqueness of alias.
Also current kernel RTM_GETLINK doesn't do filter by alias (easily fixed).

If it did, then handling it in iproute would be something like:

lib/ll_map.c +57 -6
index e0ed54bf77c9..c798ba542224 100644
@@ -26,15 +26,18 @@
 struct ll_cache {
 	struct hlist_node idx_hash;
 	struct hlist_node name_hash;
+	struct hlist_node alias_hash;
 	unsigned	flags;
 	unsigned 	index;
 	unsigned short	type;
-	char		name[];
+	char		*alias;
+	char		name[IFNAMSIZ];
 };
 
 #define IDXMAP_SIZE	1024
 static struct hlist_head idx_head[IDXMAP_SIZE];
 static struct hlist_head name_head[IDXMAP_SIZE];
+static struct hlist_head alias_head[IDXMAP_SIZE];
 
 static struct ll_cache *ll_get_by_index(unsigned index)
 {
@@ -77,10 +80,26 @@ static struct ll_cache *ll_get_by_name(const char *name)
 	return NULL;
 }
 
+static struct ll_cache *ll_get_by_alias(const char *alias)
+{
+	struct hlist_node *n;
+	unsigned h = namehash(alias) & (IDXMAP_SIZE - 1);
+
+	hlist_for_each(n, &alias_head[h]) {
+		struct ll_cache *im
+			= container_of(n, struct ll_cache, alias_hash);
+
+		if (strcmp(im->alias, alias) == 0)
+			return im;
+	}
+
+	return NULL;
+}
+
 int ll_remember_index(struct nlmsghdr *n, void *arg)
 {
 	unsigned int h;
-	const char *ifname;
+	const char *ifname, *ifalias;
 	struct ifinfomsg *ifi = NLMSG_DATA(n);
 	struct ll_cache *im;
 	struct rtattr *tb[IFLA_MAX+1];
@@ -96,6 +115,10 @@ int ll_remember_index(struct nlmsghdr *n, void *arg)
 		if (im) {
 			hlist_del(&im->name_hash);
 			hlist_del(&im->idx_hash);
+			if (im->alias) {
+				hlist_del(&im->alias_hash);
+				free(im->alias);
+			}
 			free(im);
 		}
 		return 0;
@@ -106,6 +129,8 @@ int ll_remember_index(struct nlmsghdr *n, void *arg)
 	if (ifname == NULL)
 		return 0;
 
+	ifalias = tb[IFLA_IFALIAS] ? rta_getattr_str(tb[IFLA_IFALIAS]) : NULL;
+
 	if (im) {
 		/* change to existing entry */
 		if (strcmp(im->name, ifname) != 0) {
@@ -114,6 +139,14 @@ int ll_remember_index(struct nlmsghdr *n, void *arg)
 			hlist_add_head(&im->name_hash, &name_head[h]);
 		}
 
+		if (im->alias) {
+			hlist_del(&im->alias_hash);
+			if (ifalias) {
+				h = namehash(ifalias) & (IDXMAP_SIZE - 1);
+				hlist_add_head(&im->alias_hash, &alias_head[h]);
+			}
+		}
+
 		im->flags = ifi->ifi_flags;
 		return 0;
 	}
@@ -132,6 +165,12 @@ int ll_remember_index(struct nlmsghdr *n, void *arg)
 	h = namehash(ifname) & (IDXMAP_SIZE - 1);
 	hlist_add_head(&im->name_hash, &name_head[h]);
 
+	if (ifalias) {
+		im->alias = strdup(ifalias);
+		h = namehash(ifalias) & (IDXMAP_SIZE - 1);
+		hlist_add_head(&im->alias_hash, &alias_head[h]);
+	}		
+	
 	return 0;
 }
 
@@ -152,7 +191,7 @@ static unsigned int ll_idx_a2n(const char *name)
 	return idx;
 }
 
-static int ll_link_get(const char *name, int index)
+static int ll_link_get(const char *name, const char *alias, int index)
 {
 	struct {
 		struct nlmsghdr		n;
@@ -176,6 +215,9 @@ static int ll_link_get(const char *name, int index)
 	if (name)
 		addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name,
 			  strlen(name) + 1);
+	if (alias)
+		addattr_l(&req.n, sizeof(req), IFLA_IFALIAS, alias,
+			  strlen(alias) + 1);
 
 	if (rtnl_talk_suppress_rtnl_errmsg(&rth, &req.n, &answer) < 0)
 		goto out;
@@ -206,7 +248,7 @@ const char *ll_index_to_name(unsigned int idx)
 	if (im)
 		return im->name;
 
-	if (ll_link_get(NULL, idx) == idx) {
+	if (ll_link_get(NULL, NULL, idx) == idx) {
 		im = ll_get_by_index(idx);
 		if (im)
 			return im->name;
@@ -252,7 +294,13 @@ unsigned ll_name_to_index(const char *name)
 	if (im)
 		return im->index;
 
-	idx = ll_link_get(name, 0);
+	im = ll_get_by_alias(name);
+	if (im)
+		return im->index;
+
+	idx = ll_link_get(name, NULL, 0);
+	if (idx == 0)
+		idx = ll_link_get(NULL, name, 0);
 	if (idx == 0)
 		idx = if_nametoindex(name);
 	if (idx == 0)
@@ -270,7 +318,10 @@ void ll_drop_by_index(unsigned index)
 
 	hlist_del(&im->idx_hash);
 	hlist_del(&im->name_hash);
-
+	if (im->alias) {
+		hlist_del(&im->alias_hash);
+		free(im->alias);
+	}
 	free(im);
 }
 
#9 lore raw
Quoted 12 lines · Stephen Hemminger
Quoted 9 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real
alias which you can use.

Quoted 8 lines
Quoted 6 lines

That's exactly what I meant: to be really useful, one should be able to
use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Michal

The kernel doesn't enforce uniqueness of alias.

Can we even enforce unique aliases/labels? Given that the kernel hasn't enforced that in the past there's a good possibility of breaking stuff if it started. (unfortunately)

Dan

Quoted 171 lines

Also current kernel RTM_GETLINK doesn't do filter by alias (easily fixed).

If it did, then handling it in iproute would be something like:

lib/ll_map.c +21 -2
index e0ed54bf77c9..c798ba542224 100644
@@ -26,15 +26,18 @@
 struct ll_cache {
 	struct hlist_node idx_hash;
 	struct hlist_node name_hash;
+	struct hlist_node alias_hash;
 	unsigned	flags;
 	unsigned 	index;
 	unsigned short	type;
-	char		name[];
+	char		*alias;
+	char		name[IFNAMSIZ];
 };
 
 #define IDXMAP_SIZE	1024
 static struct hlist_head idx_head[IDXMAP_SIZE];
 static struct hlist_head name_head[IDXMAP_SIZE];
+static struct hlist_head alias_head[IDXMAP_SIZE];
 
 static struct ll_cache *ll_get_by_index(unsigned index)
 {
@@ -77,10 +80,26 @@ static struct ll_cache *ll_get_by_name(const char
 *name)
 	return NULL;
 }
 
+static struct ll_cache *ll_get_by_alias(const char *alias)
+{
+	struct hlist_node *n;
+	unsigned h = namehash(alias) & (IDXMAP_SIZE - 1);
+
+	hlist_for_each(n, &alias_head[h]) {
+		struct ll_cache *im
+			= container_of(n, struct ll_cache, alias_hash);
+
+		if (strcmp(im->alias, alias) == 0)
+			return im;
+	}
+
+	return NULL;
+}
+
 int ll_remember_index(struct nlmsghdr *n, void *arg)
 {
 	unsigned int h;
-	const char *ifname;
+	const char *ifname, *ifalias;
 	struct ifinfomsg *ifi = NLMSG_DATA(n);
 	struct ll_cache *im;
lib/ll_map.c +4 -0
 	struct rtattr *tb[IFLA_MAX+1];
@@ -96,6 +115,10 @@ int ll_remember_index(struct nlmsghdr *n, void
 *arg)
 		if (im) {
 			hlist_del(&im->name_hash);
 			hlist_del(&im->idx_hash);
+			if (im->alias) {
+				hlist_del(&im->alias_hash);
+				free(im->alias);
+			}
 			free(im);
 		}
lib/ll_map.c +2 -0
 		return 0;
@@ -106,6 +129,8 @@ int ll_remember_index(struct nlmsghdr *n, void
 *arg)
 	if (ifname == NULL)
 		return 0;
 
+	ifalias = tb[IFLA_IFALIAS] ? rta_getattr_str(tb[IFLA_IFALIAS])
 : NULL;
+
 	if (im) {
lib/ll_map.c +8 -0
 		/* change to existing entry */
 		if (strcmp(im->name, ifname) != 0) {
@@ -114,6 +139,14 @@ int ll_remember_index(struct nlmsghdr *n, void
 *arg)
 			hlist_add_head(&im->name_hash, &name_head[h]);
 		}
 
+		if (im->alias) {
+			hlist_del(&im->alias_hash);
+			if (ifalias) {
+				h = namehash(ifalias) & (IDXMAP_SIZE -
 1);
+				hlist_add_head(&im->alias_hash,
 &alias_head[h]);
+			}
+		}
+
lib/ll_map.c +7 -1
 		im->flags = ifi->ifi_flags;
 		return 0;
 	}
@@ -132,6 +165,12 @@ int ll_remember_index(struct nlmsghdr *n, void
 *arg)
 	h = namehash(ifname) & (IDXMAP_SIZE - 1);
 	hlist_add_head(&im->name_hash, &name_head[h]);
 
+	if (ifalias) {
+		im->alias = strdup(ifalias);
+		h = namehash(ifalias) & (IDXMAP_SIZE - 1);
+		hlist_add_head(&im->alias_hash, &alias_head[h]);
+	}		
+	
 	return 0;
 }
@@ -152,7 +191,7 @@ static unsigned int ll_idx_a2n(const char *name)
 	return idx;
 }
 
-static int ll_link_get(const char *name, int index)
+static int ll_link_get(const char *name, const char *alias, int
 index)
 {
 	struct {
lib/ll_map.c +3 -0
 		struct nlmsghdr		n;
@@ -176,6 +215,9 @@ static int ll_link_get(const char *name, int
 index)
 	if (name)
 		addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name,
 			  strlen(name) + 1);
+	if (alias)
+		addattr_l(&req.n, sizeof(req), IFLA_IFALIAS, alias,
+			  strlen(alias) + 1);
 
 	if (rtnl_talk_suppress_rtnl_errmsg(&rth, &req.n, &answer) < 0)
lib/ll_map.c +12 -3
 		goto out;
@@ -206,7 +248,7 @@ const char *ll_index_to_name(unsigned int idx)
 	if (im)
 		return im->name;
 
-	if (ll_link_get(NULL, idx) == idx) {
+	if (ll_link_get(NULL, NULL, idx) == idx) {
 		im = ll_get_by_index(idx);
 		if (im)
 			return im->name;
@@ -252,7 +294,13 @@ unsigned ll_name_to_index(const char *name)
 	if (im)
 		return im->index;
 
-	idx = ll_link_get(name, 0);
+	im = ll_get_by_alias(name);
+	if (im)
+		return im->index;
+
+	idx = ll_link_get(name, NULL, 0);
+	if (idx == 0)
+		idx = ll_link_get(NULL, name, 0);
 	if (idx == 0)
 		idx = if_nametoindex(name);
 	if (idx == 0)
@@ -270,7 +318,10 @@ void ll_drop_by_index(unsigned index)
 
 	hlist_del(&im->idx_hash);
 	hlist_del(&im->name_hash);
-
+	if (im->alias) {
+		hlist_del(&im->alias_hash);
+		free(im->alias);
+	}
 	free(im);
 }
 
author
#19 lore raw
In reply to David Ahern
Quoted 11 lines · Thu, Jun 27, 2019 at 07:14:31PM CEST, [email protected] wrote:
Quoted 8 lines · Jiri Pirko

Hi all.

In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for netdevice name length. Now when we have PF and VF representors with port names like "pfXvfY", it became quite common to hit this limit:
0123456789012345
enp131s0f1npf0vf6
enp131s0f1npf0vf22

QinQ (stacked vlans) is another example.

There are more usecases for this, yes.

Quoted 15 lines
Quoted 8 lines

Since IFLA_NAME is just a string, I though it might be possible to use it to carry longer names as it is. However, the userspace tools, like iproute2, are doing checks before print out. So for example in output of "ip addr" when IFLA_NAME is longer than IFNAMSIZE, the netdevice is completely avoided.

Quoted 6 lines

So here is a proposal that might work:
1) Add a new attribute IFLA_NAME_EXT that could carry names longer than IFNAMSIZE, say 64 bytes. The max size should be only defined in kernel, user should be prepared for any string size.
2) Add a file in sysfs that would indicate that NAME_EXT is supported by the kernel.

Quoted 4 lines

no sysfs files.

Johannes added infrastructure to retrieve the policy. That is a more flexible and robust option for determining what the kernel supports.

Sure, udev can query rtnetlink. I just proposed it as an option, anyway, it's implementation detail.

Quoted 20 lines
Quoted 11 lines

3) Udev is going to look for the sysfs indication file. In case when kernel supports long names, it will do rename to longer name, setting IFLA_NAME_EXT. If not, it does what it does now - fail.
4) There are two cases that can happen during rename:
A) The name is shorter than IFNAMSIZ
-> both IFLA_NAME and IFLA_NAME_EXT would contain the same string:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = enp5s0f1npf0vf1

Quoted 8 lines

renamed IFLA_NAME_EXT = enp5s0f1npf0vf1
B) The name is longer tha IFNAMSIZ
-> IFLA_NAME would contain the original one, IFLA_NAME_EXT would
contain the new one:
original IFLA_NAME = eth0
original IFLA_NAME_EXT = eth0
renamed IFLA_NAME = eth0
renamed IFLA_NAME_EXT = enp131s0f1npf0vf22

Quoted 1 line

so kernel side there will be 2 names for the same net_device?

Yes. However, updated tools (which would be eventually all) are going to show only the ext one.

Quoted 7 lines
Quoted 5 lines

This would allow the old tools to work with "eth0" and the new tools would work with "enp131s0f1npf0vf22". In sysfs, there would be symlink from one name to another.

I would prefer a solution that does not rely on sysfs hooks.

Please note that this /sys/class/net/ifacename dirs are already created. What I propose is to have symlink from ext to the short name or vice versa. The solution really does not "rely" on this...

Quoted 6 lines
Quoted 4 lines

Also, there might be a warning added to kernel if someone works with IFLA_NAME that the userspace tool should be upgraded.

that seems like spam and confusion for the first few years of a new api.

Spam? warn_once?

Quoted 8 lines
Quoted 8 lines

Eventually, only IFLA_NAME_EXT is going to be used by everyone.

I'm aware there are other places where similar new attribute would have to be introduced too (ip rule for example). I'm not saying this is a simple work.

Quoted 7 lines
Quoted 2 lines

Question is what to do with the ioctl api (get ifindex etc). I would probably leave it as is and push tools to use rtnetlink instead.

The ioctl API is going to be a limiter here. ifconfig is still quite prevalent and net-snmp still uses ioctl (as just 2 common examples). snmp showing one set of names and rtnetlink s/w showing another is going to be really confusing.

I don't see other way though, do you? The ioctl names are unextendable :/

author
#10 lore raw
In reply to Dan Williams
Quoted 18 lines · Thu, Jun 27, 2019 at 09:35:27PM CEST, [email protected] wrote:
Quoted 17 lines · Stephen Hemminger
Quoted 14 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real
alias which you can use.

That's exactly what I meant: to be really useful, one should be able to
use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Michal

The kernel doesn't enforce uniqueness of alias.

Can we even enforce unique aliases/labels? Given that the kernel hasn't enforced that in the past there's a good possibility of breaking stuff if it started. (unfortunately)

Correct. I think that Michal's idea to introduce "real aliases" is very intereting. However, the existing "alias" as we have it does not seem right to be used. Also because of the UAPI. We have IFLA_IFALIAS which is a single value. For "real aliases" we need nested array.

[...]

author
#11 lore raw
In reply to Stephen Hemminger
Quoted 16 lines · Thu, Jun 27, 2019 at 09:20:41PM CEST, [email protected] wrote:
Quoted 13 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

That's exactly what I meant: to be really useful, one should be able to use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Quoted 6 lines
Quoted 1 line

Michal

The kernel doesn't enforce uniqueness of alias.
Also current kernel RTM_GETLINK doesn't do filter by alias (easily fixed).

If it did, then handling it in iproute would be something like:

I think that it is desired for kernel to work with "real alias" as a handle. Userspace could either pass ifindex, IFLA_NAME or "real alias". Userspace mapping like you did here might be perhaps okay for iproute2, but I think that we need something and easy to use for all.

Let's call it "altname". Get would return:

IFLA_NAME eth0
IFLA_ALT_NAME_LIST

   IFLA_ALT_NAME  eth0
   IFLA_ALT_NAME  somethingelse
   IFLA_ALT_NAME  somenamethatisreallylong

then userspace would pass with a request (get/set/del):
IFLA_ALT_NAME eth0/somethingelse/somenamethatisreallylong or
IFLA_NAME eth0 if it is talking with older kernel

Then following would do exactly the same:
ip link set eth0 addr 11:22:33:44:55:66
ip link set somethingelse addr 11:22:33:44:55:66 ip link set somenamethatisreallylong addr 11:22:33:44:55:66

We would have to figure out the iproute2 iface to add/del altnames:
ip link add eth0 altname somethingelse
ip link del eth0 altname somethingelse
this might be also:
ip link del somethingelse altname somethingelse

How does this sound?

#12 lore raw
Quoted 19 lines · Jiri Pirko

I think that it is desired for kernel to work with "real alias" as a handle. Userspace could either pass ifindex, IFLA_NAME or "real alias". Userspace mapping like you did here might be perhaps okay for iproute2, but I think that we need something and easy to use for all.

Let's call it "altname". Get would return:

IFLA_NAME eth0
IFLA_ALT_NAME_LIST

   IFLA_ALT_NAME  eth0
   IFLA_ALT_NAME  somethingelse
   IFLA_ALT_NAME  somenamethatisreallylong

then userspace would pass with a request (get/set/del):
IFLA_ALT_NAME eth0/somethingelse/somenamethatisreallylong or
IFLA_NAME eth0 if it is talking with older kernel

Quoted 4 lines

Then following would do exactly the same:
ip link set eth0 addr 11:22:33:44:55:66
ip link set somethingelse addr 11:22:33:44:55:66 ip link set somenamethatisreallylong addr 11:22:33:44:55:66

Yes, this sounds nice.

Quoted 5 lines

We would have to figure out the iproute2 iface to add/del altnames:
ip link add eth0 altname somethingelse
ip link del eth0 altname somethingelse
this might be also:
ip link del somethingelse altname somethingelse

This would be a bit confusing, IMHO, as so far

ip link add $name ...

always means we want to add or delete new device $name which would not be the case here. How about the other way around:

ip link add somethingelse altname_for eth0

(preferrably with a better keyword than "altname_for" :-) ). Or maybe

ip altname add somethingelse dev eth0
ip altname del somethingelse dev eth0

Michal

author
#13 lore raw
Quoted 40 lines · Fri, Jun 28, 2019 at 01:42:12PM CEST, [email protected] wrote:
Quoted 19 lines · Jiri Pirko

I think that it is desired for kernel to work with "real alias" as a handle. Userspace could either pass ifindex, IFLA_NAME or "real alias". Userspace mapping like you did here might be perhaps okay for iproute2, but I think that we need something and easy to use for all.

Let's call it "altname". Get would return:

IFLA_NAME eth0
IFLA_ALT_NAME_LIST

   IFLA_ALT_NAME  eth0
   IFLA_ALT_NAME  somethingelse
   IFLA_ALT_NAME  somenamethatisreallylong

then userspace would pass with a request (get/set/del):
IFLA_ALT_NAME eth0/somethingelse/somenamethatisreallylong or
IFLA_NAME eth0 if it is talking with older kernel

Quoted 4 lines

Then following would do exactly the same:
ip link set eth0 addr 11:22:33:44:55:66
ip link set somethingelse addr 11:22:33:44:55:66 ip link set somenamethatisreallylong addr 11:22:33:44:55:66

Yes, this sounds nice.

Quoted 5 lines

We would have to figure out the iproute2 iface to add/del altnames:
ip link add eth0 altname somethingelse
ip link del eth0 altname somethingelse
this might be also:
ip link del somethingelse altname somethingelse

This would be a bit confusing, IMHO, as so far

ip link add $name ...

always means we want to add or delete new device $name which would not be the case here. How about the other way around:

Quoted 6 lines

ip link add somethingelse altname_for eth0

(preferrably with a better keyword than "altname_for" :-) ). Or maybe

ip altname add somethingelse dev eth0
ip altname del somethingelse dev eth0

Yeah, I like this.

Let's see how it will work during the implementation.

#14 lore raw
In reply to Jiri Pirko
Quoted 29 lines · Jiri Pirko
Quoted 16 lines · Thu, Jun 27, 2019 at 09:20:41PM CEST, [email protected] wrote:
Quoted 13 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

That's exactly what I meant: to be really useful, one should be able to use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Quoted 6 lines
Quoted 1 line

Michal

The kernel doesn't enforce uniqueness of alias.
Also current kernel RTM_GETLINK doesn't do filter by alias (easily fixed).

If it did, then handling it in iproute would be something like:

I think that it is desired for kernel to work with "real alias" as a handle. Userspace could either pass ifindex, IFLA_NAME or "real alias". Userspace mapping like you did here might be perhaps okay for iproute2, but I think that we need something and easy to use for all.

Quoted 7 lines

Let's call it "altname". Get would return:

IFLA_NAME eth0
IFLA_ALT_NAME_LIST

   IFLA_ALT_NAME  eth0
   IFLA_ALT_NAME  somethingelse
   IFLA_ALT_NAME  somenamethatisreallylong

Hi Jiri

What is your user case for having multiple IFLA_ALT_NAME for the same IFLA_NAME?

Thanks
Andrew

author
#15 lore raw
Quoted 38 lines · Fri, Jun 28, 2019 at 03:14:01PM CEST, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Quoted 16 lines · Thu, Jun 27, 2019 at 09:20:41PM CEST, [email protected] wrote:
Quoted 13 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

That's exactly what I meant: to be really useful, one should be able to use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Quoted 6 lines
Quoted 1 line

Michal

The kernel doesn't enforce uniqueness of alias.
Also current kernel RTM_GETLINK doesn't do filter by alias (easily fixed).

If it did, then handling it in iproute would be something like:

I think that it is desired for kernel to work with "real alias" as a handle. Userspace could either pass ifindex, IFLA_NAME or "real alias". Userspace mapping like you did here might be perhaps okay for iproute2, but I think that we need something and easy to use for all.

Quoted 7 lines

Let's call it "altname". Get would return:

IFLA_NAME eth0
IFLA_ALT_NAME_LIST

   IFLA_ALT_NAME  eth0
   IFLA_ALT_NAME  somethingelse
   IFLA_ALT_NAME  somenamethatisreallylong
Quoted 4 lines

Hi Jiri

What is your user case for having multiple IFLA_ALT_NAME for the same IFLA_NAME?

I don't know about specific usecase for having more. Perhaps Michal does.

From the implementation perspective it is handy to have the ifname as the first alt name in kernel, so the userspace would just pass IFLA_ALT_NAME always. Also for avoiding name collisions etc.

Quoted 4 lines

Thanks
Andrew

#16 lore raw
Quoted 44 lines · On Fri, 28 Jun 2019 15:55:53 +0200 Jiri Pirko <[email protected]> wrote:
Quoted 38 lines · Fri, Jun 28, 2019 at 03:14:01PM CEST, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Quoted 16 lines · Thu, Jun 27, 2019 at 09:20:41PM CEST, [email protected] wrote:
Quoted 13 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

That's exactly what I meant: to be really useful, one should be able to use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Quoted 6 lines
Quoted 1 line

Michal

The kernel doesn't enforce uniqueness of alias.
Also current kernel RTM_GETLINK doesn't do filter by alias (easily fixed).

If it did, then handling it in iproute would be something like:

I think that it is desired for kernel to work with "real alias" as a handle. Userspace could either pass ifindex, IFLA_NAME or "real alias". Userspace mapping like you did here might be perhaps okay for iproute2, but I think that we need something and easy to use for all.

Quoted 7 lines

Let's call it "altname". Get would return:

IFLA_NAME eth0
IFLA_ALT_NAME_LIST

   IFLA_ALT_NAME  eth0
   IFLA_ALT_NAME  somethingelse
   IFLA_ALT_NAME  somenamethatisreallylong  
Quoted 4 lines

Hi Jiri

What is your user case for having multiple IFLA_ALT_NAME for the same IFLA_NAME?

Quoted 6 lines

I don't know about specific usecase for having more. Perhaps Michal does.

From the implementation perspective it is handy to have the ifname as the first alt name in kernel, so the userspace would just pass IFLA_ALT_NAME always. Also for avoiding name collisions etc.

I like the alternate name proposal. The kernel would have to impose uniqueness. Does alt_name have to be unique across both regular and alt_name? Having multiple names list seems less interesting but it could be useful.

author
#17 lore raw
Quoted 50 lines · Fri, Jun 28, 2019 at 05:44:47PM CEST, [email protected] wrote:
Quoted 47 lines · On Fri, 28 Jun 2019 15:55:53 +0200 Jiri Pirko <[email protected]> wrote:
Quoted 38 lines · Fri, Jun 28, 2019 at 03:14:01PM CEST, [email protected] wrote:
Quoted 29 lines · Jiri Pirko
Quoted 16 lines · Thu, Jun 27, 2019 at 09:20:41PM CEST, [email protected] wrote:
Quoted 13 lines · On Thu, 27 Jun 2019 20:39:48 +0200 Michal Kubecek <[email protected]> wrote:
Quoted 8 lines
$ ip li set dev enp3s0 alias "Onboard Ethernet"
# ip link show "Onboard Ethernet"
Device "Onboard Ethernet" does not exist.

So it does not really appear to be an alias, it is a label. To be truly useful, it needs to be more than a label, it needs to be a real alias which you can use.

That's exactly what I meant: to be really useful, one should be able to use the alias(es) for setting device options, for adding routes, in netfilter rules etc.

Quoted 6 lines
Quoted 1 line

Michal

The kernel doesn't enforce uniqueness of alias.
Also current kernel RTM_GETLINK doesn't do filter by alias (easily fixed).

If it did, then handling it in iproute would be something like:

I think that it is desired for kernel to work with "real alias" as a handle. Userspace could either pass ifindex, IFLA_NAME or "real alias". Userspace mapping like you did here might be perhaps okay for iproute2, but I think that we need something and easy to use for all.

Quoted 7 lines

Let's call it "altname". Get would return:

IFLA_NAME eth0
IFLA_ALT_NAME_LIST

   IFLA_ALT_NAME  eth0
   IFLA_ALT_NAME  somethingelse
   IFLA_ALT_NAME  somenamethatisreallylong  
Quoted 4 lines

Hi Jiri

What is your user case for having multiple IFLA_ALT_NAME for the same IFLA_NAME?

I don't know about specific usecase for having more. Perhaps Michal does.

Quoted 6 lines
Quoted 3 lines

From the implementation perspective it is handy to have the ifname as the first alt name in kernel, so the userspace would just pass IFLA_ALT_NAME always. Also for avoiding name collisions etc.

I like the alternate name proposal. The kernel would have to impose uniqueness. Does alt_name have to be unique across both regular and alt_name?

Yes. That is my idea. To have one big hashtable to contain them all.

Quoted 1 line

Having multiple names list seems less interesting but it could be useful.

Yeah. Okay, I'm going to jump on this.

#18 lore raw
In reply to Jiri Pirko
Quoted 7 lines · Jiri Pirko
Quoted 3 lines · Fri, Jun 28, 2019 at 03:14:01PM CEST, [email protected] wrote:

What is your user case for having multiple IFLA_ALT_NAME for the same IFLA_NAME?

I don't know about specific usecase for having more. Perhaps Michal does.

One use case that comes to my mind are the "predictable names" implemented by udev/systemd which can be based on different naming schemes (bus address, BIOS numbering, MAC address etc.) and it's not always obvious which scheme is going to be used. I have even seen multiple times that one schemed was used during system installation and another in the installed system so that network configuration created by installer did not work.

For block devices, current practice is not to rename the device and only create multiple symlinks based on different naming schemes (by id, by uuid, by label, etc.). With support for multiple altnames, we could also identify the network device in different ways (all applicable ones).

Michal