Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wireless interface name truncated to 16 characters, one more than the 15 characters allowed by the kernel #11259

Closed
crass opened this issue Nov 16, 2022 · 7 comments

Comments

@crass
Copy link

crass commented Nov 16, 2022

Currently, if I set a wireless interface to a name with more than 16 characters via option ifname of a wifi-iface config block in /etc/config/wireless the interface will fail to come up. Looking in the logs, I can see that the interface name, "iface678901234567890", is being truncated:

Tue Nov 15 06:45:25 2022 daemon.err hostapd: nl80211: kernel reports: Attribute failed policy validation
Tue Nov 15 06:45:25 2022 daemon.err hostapd: Failed to create interface iface67890123456: -22 (Invalid argument)
Tue Nov 15 06:45:25 2022 daemon.err hostapd: Failed to add BSS (BSSID=00:23:5c:fc:4d:c0)
Tue Nov 15 06:45:25 2022 daemon.err hostapd: Interface initialization failed

This indicated that somewhere (in netifd?) some code is truncating the interface name to 16 bytes. I suspect in an attempt to satisfy the maximum interface length requirement, but is off by 1. The maximum length of an interface name is 15 characters:

root@OpenWRT:~# iw phy phy0 interface add iface67890123456 type monitor
kernel reports: Attribute failed policy validation
command failed: Invalid argument (-22)
root@OpenWRT:~# iw phy phy0 interface add iface6789012345 type monitor
root@OpenWRT:~# iw dev iface6789012345 del
root@OpenWRT:~# 
@pkgadd
Copy link
Contributor

pkgadd commented Nov 16, 2022

That is not a bug, but a well documented -intentional- limit set by the linux kernel.

@crass crass changed the title Wireless interface name can not be longer than 15 characters Wireless interface name truncated to 16 characters, one more than the 15 characters allowed by the kernel Nov 16, 2022
@crass
Copy link
Author

crass commented Nov 16, 2022

@pkgadd I don't think you fully comprehended the bug report. I can see why you responded as you did just by reading the title. So I'm giving it a better title.

The bug is not in the kernel, its in OpenWRT not truncating enough characters to satisfy the 15 character interface name limit set by the kernel.

@pkgadd
Copy link
Contributor

pkgadd commented Nov 17, 2022

It's difficult to say how long the ifname is going to get, with br- or pppoe- prepended, so it's best to keep it short and free of funny characters (or upper case).

@crass
Copy link
Author

crass commented Nov 17, 2022

It's difficult to say how long the ifname is going to get, with br- or pppoe- prepended, so it's best to keep it short and free of funny characters (or upper case).

The option option ifname allows completely specifying the interface name. There is no br- or pppoe- prepended. That only happens for auto generated interface names. The name will be truncated, and that's not the problem. The problem is that the truncating that is already happening isn't enough, ie. it is incorrect. The advice on interface naming is neither her nor there wrt to the bug report.

@stintel
Copy link
Member

stintel commented Dec 9, 2022

@crass
Copy link
Author

crass commented Dec 13, 2022

I'm not setup to test this at the moment (I could test a build with that change, but I'm not setup to build openwrt). But for someone that can easily build OpenWRT, it should be trivial to test x86 build in a VM.

@stintel
Copy link
Member

stintel commented Jan 5, 2023

Should be fixed by 2e61469.

@stintel stintel closed this as completed Jan 5, 2023
aparcar pushed a commit to openwrt/netifd that referenced this issue Feb 4, 2023
The `IFNAMSIZ` macro defines the required buffer size to hold a Linux
interface name including the terminating zero byte while netifd currently
uses an `IFNAMSIZ + 1` limit for interface name buffers.

This causes netifd to use overlong names (16 instead of 15 bytes) in
netlink communication with the kernel, leading to netlink failure replies
due to policy violations.

Fix this issue by applying the correct length, that is `IFNAMSIZ` directly,
to the corresponding buffers.

Ref: openwrt/openwrt#11259
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants