USB NICs get too long name for ifupdown aliases or bridge names

Bug #1567744 reported by Andres Rodriguez on 2016-04-08
This bug affects 8 people
Affects Status Importance Assigned to Milestone
systemd (Ubuntu)
Mathieu Trudel-Lapierre

Bug Description

I have a USB NIC that is connected to my denial system. I tried to create an alias, and after reboot, it wasn't created. When I manually try to bring it up I have the error.


auto enx000ec688b79f
iface enx000ec688b79f inet static

auto enx000ec688b79f:1
iface enx000ec688b79f:1 inet static

ubuntu@maas00:~$ sudo ifup enx000ec688b79f
ubuntu@maas00:~$ sudo ifup enx000ec688b79f:1
RTNETLINK answers: Numerical result out of range
Failed to bring up enx000ec688b79f:1.

description: updated
description: updated
Steve Langasek (vorlon) on 2016-04-11
Changed in ifupdown (Ubuntu):
assignee: nobody → Mathieu Trudel-Lapierre (cyphermox)
Changed in ifupdown (Ubuntu):
importance: Undecided → Critical

Looks like at first glance ifupdown is confused by this naming format together with the subif. I'll try to reproduce here, I do happen to have a USB ethernet dongle that should show this problem.

ifupdown handles the passed names correctly, but it looks like iproute2 is very unhappy about something in these long names like "enx000be608397d:1"; when setting the label for the address. Since the label must match the device and it otherwise works with "eth1:1", I'll looking into the iproute2 code now.

affects: ifupdown (Ubuntu) → iproute2 (Ubuntu)
Changed in iproute2 (Ubuntu):
status: New → In Progress

This isn't a simple problem at all.

The new naming scheme from systemd makes it so that these specific devices (USB dongles) get their MAC address encoded in the device name, which brings it up to a length of 15 characters + \0; so 16 bytes. This happens to also be the size limit for interface names (set as IFNAMSIZ to 16). Adding more characters to the end of this string makes it too long to be allowed by {libnl3, kernel, iproute2}. This is because while we're not strictly dealing with interface names here, we're dealing with a label which is bound by the same sized buffer (limited to IFNAMSIZ size).

There are a few possible avenues for a solution:
 - Rename the address yourself to something smaller. This should be possible using udev rules.
 - Fix systemd to pick a different naming method.
 - Fix ip addr to better deal with address labels, which may mean dropping some backward compatibility (more below)
 - Increasing the buffer size for address labels (which means changes in the kernel, libnl, iproute2 at the very least, and probably many more userland utilities).

For iproute2:
       label LABEL
              Each address may be tagged with a label string. In order to preserve compatibility with Linux-2.0 net aliases, this string must coincide with the name of the device
              or must be prefixed with the device name followed by colon.
It may be possible to strip out anything before the colon if a label is passed in that format to hand to the netlink layer a shorter label, but I haven't looked more closely at what such a change might impact.

I pinged pitti on IRC earlier today, and just subscribed him for guidance on whether this can be fixed in systemd; which seems to be the least intrusive way to handle this (aside from expecting users to know about this limitation and renaming interfaces themselves).

Changed in iproute2 (Ubuntu):
status: In Progress → Triaged
status: Triaged → Confirmed
status: Confirmed → Incomplete
Martin Pitt (pitti) wrote :

I actually re-started the discussion about that (about the third time) a few days ago on . This is actually another point in favor of moving to location based USB names by default.

@Andres: For the time being, please see /usr/share/doc/udev/README.Debian.gz for an overview how to configure the naming.

This isn't iproute's fault IMHO. There hasn't been much response to the thread so far, and it's getting tight.

Reassigning to udev as that's where USB NIC names are set.

summary: - RTNETLINK answers: Numerical result out of range for alias interface
- from a usb NIC
+ USB NICs get too long name for ifupdown aliases
affects: iproute2 (Ubuntu) → systemd (Ubuntu)
Changed in systemd (Ubuntu):
assignee: Mathieu Trudel-Lapierre (cyphermox) → nobody
importance: Critical → Medium
status: Incomplete → Triaged

Indeed it's not iproute's fault, it's just an unforseen consequence of using a long string like a MAC to name the device. Perhaps reducing it by half and using just the second half of the MAC might be good? The chance of collisions would remain pretty low.

Mike Pontillo (mpontillo) wrote :

This is also an issue for VLAN interfaces. To support VLANs, 10 characters should be the max. (16 - 1 [for \0], -1 [.], -4 [vid])

Throw in VLANs plus aliases, and, well, I guess we ought to use shorter names, such as (I don't know) "eth0". ;-)

Dimiter Naydenov (dimitern) wrote :

Additionally, Juju creates bridges on top of both physical and VLAN interfaces to allow for the same level of addressability for containers as regular machines. The bridges currently use the "br-" prefix and the underlying device name, which if it happens to be "enxxaabbccddeef0.1234" already, obviously won't work. So the length limit on interface names can be even lower than what Mike suggested.

Andreas Hasenack (ahasenack) wrote :

I just hit this deploying a MAAS2 xenial node that has a usb nic:

# ifup br-enx0023552c6029

Waiting for br-enx0023552c6029 to get ready (MAXWAIT is 76 seconds).
RTNETLINK answers: Numerical result out of range
Failed to bring up br-enx0023552c6029.

It went far enough to create the bridge, but with a truncated name and no IP:
# brctl show
br-enx0023552c6 8000.0023552c6029 no enx0023552c6029

Andreas Hasenack (ahasenack) wrote :

I renamed the NIC in the MAAS node page to enx0 to workaround this issue.

Andreas Hasenack (ahasenack) wrote :

@andres that's a cool feature, btw :)

David A. Desrosiers (setuid) wrote :

Doesn't adding "net.ifnames=0 biosdevname=0" to your kernel boot line fix this for you? It will stop udev from creating the longer-than-desired names.

Andreas Hasenack (ahasenack) wrote :

Maybe, but that will affect all nics in all nodes.

summary: - USB NICs get too long name for ifupdown aliases
+ USB NICs get too long name for ifupdown aliases or bridge names
Kalle Tuulos (kalle-tuulos) wrote :

This feature worked well in my earlier installation (16.04LTS), but when I re-installed the system yesterday, adding an alias to my USB network adapter didn't work any more.

$ sudo ifup enx000000000016:0
RTNETLINK answers: Numerical result out of range
Failed to bring up enx000000000016:0.

The earlier installation was made using Xubuntu 16.04 installation media and this time I installed the system using Ubuntu 16.04.01 mini iso media, if this makes any difference.

I just lost 3 days to this issue before I realized what was happening. I realize this is an edge case, and understand the issues with fixing this, but at least some type of better error messages would have helped prevent that waste of time.

I was trying to setup a host to run docker with macvlan networks mapped to vlan interfaces on a pair of USB ethernet adapters connected to a BRIX used for testing. Couldn't get a bond on the pair to work, couldn't figure out why, then tried for just VLAN interfaces, and that didn't work either. Thought I was losing it, didn't seem that hard.

Not sure how I figured it out, but realized if I switched back to using eth1, eth2 for the USB ethernet devices, using "net.ifnames=0 biosdevname=0" boot options + old-style mac-address rules to map, I could get everything to work. But, wasn't happy with the workaround, as I'd prefer to use the new predictable names.

I like the idea of using last 6 digits of Mac address. I thought of doing this:
sudo ln -s /dev/null /etc/udev/rules.d/73-usb-net-by-mac.rules
to go back to slot names, but if I plug into different ports, names change, so no.

Perhaps some different prefix other than enx to avoid confusion, usb123456 anyone?

Milestoning, since we should try to not drop the ball on this bug; I will need to revisit the mailing list thread and how exactly we do the naming for these devices.

Changed in systemd (Ubuntu):
assignee: nobody → Mathieu Trudel-Lapierre (cyphermox)
milestone: none → ubuntu-17.03
Peter Ziobrzynski (pzi-j) wrote :

Good that we have a workaround - "net.ifnames=0 biosdevname=0". Still, I think we need to reevaluate the importance level of "medium" - this is toxic.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers