linux-router icon indicating copy to clipboard operation
linux-router copied to clipboard

Error Device or resource busy

Open Gictorbit opened this issue 4 years ago • 18 comments
trafficstars

an error occurred while bringing the virtual interface up command:

sudo ./lnxrouter --ap wlp0s20f3 victorAP -p 12345678

output:

PID: 213324
Target interface is wlp0s20f3
Use random LAN IPv4 address 192.168.238.1
Creating a virtual WiFi interface... 
x0wlp0s20f3 created)
Set x0wlp0s20f3 unmanaged by NetworkManager
Assigning MAC address 5e:a8:4c:ab:73:5a to virtual interface x0wlp0s20f3 according to wlp0s20f3 ...
RTNETLINK answers: Device or resource busy
Error occured

ERROR: Failed bringing x0wlp0s20f3 up



Doing cleanup.. 
iptables: stop NAT
iptables: unallow DNS
iptables: unallow dhcp
Exiting: This is the only running instance
Cleaning up done

Gictorbit avatar Feb 06 '21 06:02 Gictorbit

Edit: If you see this bug, please report to NM. See https://github.com/garywill/linux-router/issues/12#issuecomment-1004063306


Hi there, thanks for feedback.

The log shows 5e was the first byte of the wifi interface, which was abnormal. device manufacturers' MAC address' first byte should always be multiple of 4.

I found sometimes creating virtual wifi interface causes the real wifi interface turning into a random strange MAC address. I'm still confused why that happends (so I added a delay at https://github.com/garywill/linux-router/blob/2341938b762005230fef8199c478d462f6f9cfc7/lnxrouter#L1598 sometimes the MAC address goes back again automatically)

Please check what wlp0s20f3's original MAC address is. For example macchanger can do that:

macchanger -s wlp0s20f3

it will return something like

Current MAC:  xxxxx
Permanent MAC: xxxxx

Try these:

  1. If MAC changed, use macchanger -p wlp0s20f3 to set it back then try again. If still fail, try increasing the sleep time

  2. rfkill unblock wifi before running lnxrouter

  3. try with --no-virt

  4. are you using the latest commit?

  5. does create_ap work?

garywill avatar Feb 06 '21 13:02 garywill

I found sometimes creating virtual wifi interface causes the real wifi interface turning into a random strange MAC address. I'm still confused why that happends (so I added a delay at

hmm, that's weird. also I tested create_ap on the same device using same linux distribution and it worked fine without any problem

Please check what wlp0s20f3's original MAC address is. For example macchanger can do that:

here is the output of macchanger -s wlp0s20f3

Current MAC:   92:cc:2a:xx:xx:xx (unknown)
Permanent MAC: 80:32:53:xx:xx:xx (unknown)

4. are you using the latest commit?

yes and create_ap was ok and worked great

3. try with --no-virt

I tried this method and works fine without creating virtual interface but sometimes we really need to set a virtual interface up

  1. If MAC changed, use macchanger -p wlp0s20f3 to set it back then try again. If still fail, try increasing the sleep time

also I increased sleep time to 6 and error occurred again also I checked macchanger and here is the output

sudo macchanger -p wlp0s20f3
Current MAC:   f2:39:68:xx:xx:xx (unknown)
Permanent MAC: 80:32:53:xx:xx:xx (unknown)
[ERROR] Could not change MAC: interface up or insufficient permissions: Device or resource busy

Gictorbit avatar Feb 06 '21 15:02 Gictorbit

I tried this method and works fine without creating virtual interface but sometimes we really need to set a virtual interface up increased sleep time to 6 and error occurred again

When creating virtual interface, is the error happening always or sometimes?

NetworkManager is a possible reason. If NM running, it will give the new virtual interface a random MAC. MAC will go back after setting NM unmanaged. But why wlp0s20f3 too? Wired. Only the virtual interface should go a random MAC.

Try increasing this sleep time (after setting NM unmanaged) https://github.com/garywill/linux-router/blob/2341938b762005230fef8199c478d462f6f9cfc7/lnxrouter#L778

garywill avatar Feb 07 '21 03:02 garywill

When creating virtual interface, is the error happening always or sometimes?

This error always happens, but it works fine with create_ap I think it is a bug maybe

Try increasing this sleep time (after setting NM unmanaged)

I tried this,it doesn't help. same error occurs. I increased sleep to 6 second in line 778 and here is the output:

[sudo] password for victor:          
PID: 194580
Target interface is wlp0s20f3
Use random LAN IPv4 address 192.168.197.1
Creating a virtual WiFi interface... 
x0wlp0s20f3 created)
Set x0wlp0s20f3 unmanaged by NetworkManager
Assigning MAC address 42:6d:9b:07:9e:b4 to virtual interface x0wlp0s20f3 according to wlp0s20f3 ...
RTNETLINK answers: Device or resource busy
Error occured

ERROR: Failed bringing x0wlp0s20f3 up



Doing cleanup.. 
iptables: stop NAT
iptables: unallow DNS
iptables: unallow dhcp
Exiting: This is the only running instance
Cleaning up done

Gictorbit avatar Feb 07 '21 06:02 Gictorbit

I did some test with

watch -n 0.1 ip a

I found every time I check/uncheck the "enabe wifi" on NM, my wlan0 MAC changes. Having NM wifi on, runing rfkill (un)block wifi also makes MAC random.

Recently I upgrade Linux last month. Then the strange MAC behavior began. Did you upgrade recently? I'm using

  • NetworkManager 1.22.10
  • util-linux-2.33.1
  • kernel 5.3.18
  • KDE plasma5-session 5.18.6

create_ap writes NM's config file to set unmanaged before creating virtual interface. linux-router uses nmcli to set after creating.

Could you try

sudo systemctl stop NetworkManager

, reset everything, then run lnxrouter

garywill avatar Feb 07 '21 12:02 garywill

found every time I check/uncheck the "enabe wifi" on NM, my wlan0 MAC changes. Having NM wifi on, runing rfkill (un)block wifi also makes MAC random.

Interesting. I use arch Linux. Since it is rolling release, the packages are updated to the last version. the packages specs are below

  • NetworkManager 1.28.1
  • util-linux 2.36.1
  • kernel 5.10.8
  • Gnome 3.38.3

create_ap writes NM's config file to set unmanaged before creating virtual interface. linux-router uses nmcli to set after creating

hmm, so that is why create_ap works and linux-router encounters error

Could you try

sudo systemctl stop NetworkManager

, reset everything, then run lnxrouter

I did it then I restart NetworkManager service and I ran lnxrouter command, same error happened I did this

sudo systemctl stop NetworkManager
sudo systemctl restart NetworkManager
sudo ./lnxrouter --ap wlp0s20f3 victorAP -p 12345678

I think create_ap solution with network manager is better and works great at all situations

Gictorbit avatar Feb 07 '21 13:02 Gictorbit

Hello, just wanted to add that after upgrading to Fedora 32, create_ap doesn't work anymore (the ap is created and accessible, but the connecting device is stuck in the connection step and eventualy timeout)

I tired linux-router to see if it would fix the issue, but I run into the same error with a virtual interface : RTNETLINK answers: Device or resource busy

Is there a fix planned for this issue ?

f-michaut avatar Jul 18 '21 02:07 f-michaut

@fmichaut-dev

after upgrading to Fedora 32, create_ap doesn't work anymore (the ap is created and accessible, but the connecting device is stuck in the connection step and eventualy timeout)

Other Fedora users report similar issue https://github.com/garywill/linux-router/issues/19#issuecomment-873337509 Currently in my mind is that we need someone to disable system services one by one to figure out which service is causing problem.


I tired linux-router to see if it would fix the issue, but I run into the same error with a virtual interface : RTNETLINK answers: Device or resource busy

I said in above posts:

create_ap writes NM's config file to set unmanaged before creating virtual interface. linux-router uses nmcli to set after creating.

So I guess it's the NetworkManager causing that.

So could someone encountering RTNETLINK answers: Device or resource busy try disabling NM then run?


Sorry for these issues but I've been busy on other jobs (still need 1-2 months. or even longer). That's why we need more people for this linux-router

garywill avatar Jul 18 '21 10:07 garywill

So could someone encountering RTNETLINK answers: Device or resource busy try disabling NM then run?

So I just tried that on my fedora and it allows linux-router to start and I can connect with another device. But I fall back to the same issue of device timing out trying connecting to the ap like in the other issue you linked.

f-michaut avatar Jul 18 '21 21:07 f-michaut

I downloaded Arch Linux and Fedora live iso, tested on a laptop with Intel Centrino wifi device. Did not reproduce this problem RTNETLINK answers: Device or resource busy.

archlinux-gui-xfce-pure-2021.08-x86_64.iso Kernel 5.13.6 Network manager 1.32.10

Fedora-Workstation-Live-x86_64-34-1.2.iso Kernel 5.11.12 Network manager 1.30.2

If you still meet that problem, could you provide more info? For example your wifi model, kernel version, dmesg log ....

Seems not every one has that problem. I guess we need to file a bug to NM

garywill avatar Aug 26 '21 12:08 garywill

Hello, I have the same problem. I'm on Archlinux with NM 1.32.12-1. If i stop NM it's start without problem.

lspci -k  
[...]
00:14.3 Network controller: Intel Corporation Cannon Lake PCH CNVi WiFi (rev 10)
DeviceName: Onboard - Ethernet
Subsystem: Intel Corporation Wireless-AC 9560
Kernel driver in use: iwlwifi
Kernel modules: iwlwifi
[...]

The output:

sudo ./lnxrouter  --ap wlan0 test -p 1234567890
linux-router 0.6.6 (https://github.com/garywill/linux-router)
Released under LGPL, with no warranty. Use on your own risk.

PID: 29663
Target interface is wlan0 (90:78:xx:xx:xx:xx)
Use random LAN IPv4 address 192.168.186.1
wlan0 already in channel 6 (2437 MHz)
Channel fallback to 6
Creating a virtual WiFi interface...
x3wlan0 created
Set x3wlan0 unmanaged by NetworkManager
Assigning MAC address 90:78:xx:xx:xx:yy to virtual interface x3wlan0 according to wlan0 ...
RTNETLINK answers: Device or resource busy
Error occured

ERROR: Failed bringing x3wlan0 up



Doing cleanup..
Undoing iptables changes ..
bash: /dev/shm/lnxrouter_tmp/lnxrouter.wlan0.conf.hGRTtF/undo_iptables.sh: No such file or directory
Exiting: This is the only running instance
Killing PGID 29662 ...
Cleaning up done

In Logs (journalctl) if it can help:

déc. 06 17:11:26 archlinux.localhost NetworkManager[23744]: <info>  [1638807086.0581] device (x3wlan0): driver supports Access Point (AP) mode
déc. 06 17:11:26 archlinux.localhost NetworkManager[23744]: <info>  [1638807086.0592] manager: (x3wlan0): new 802.11 Wi-Fi device (/org/freedesktop/NetworkManager/Devices/24)
déc. 06 17:11:26 archlinux.localhost systemd-udevd[29725]: Using default interface naming scheme 'v249'.
déc. 06 17:11:26 archlinux.localhost NetworkManager[23744]: <info>  [1638807086.0852] device (x3wlan0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
déc. 06 17:11:26 archlinux.localhost NetworkManager[23744]: <warn>  [1638807086.0893] platform-linux: do-change-link[57]: failure changing link: failure 16 (Périphérique ou ressource occupé)
déc. 06 17:11:26 archlinux.localhost NetworkManager[23744]: <info>  [1638807086.0900] device (x3wlan0): set-hw-addr: set MAC address to 36:B3:45:F1:A7:CA (scanning)
déc. 06 17:11:26 archlinux.localhost NetworkManager[23744]: <warn>  [1638807086.0901] platform-linux: do-change-link[57]: failure changing link: failure 16 (Périphérique ou ressource occupé)
déc. 06 17:11:26 archlinux.localhost wpa_supplicant[23748]: Could not set interface x3wlan0 flags (UP): Device or resource busy
déc. 06 17:11:26 archlinux.localhost wpa_supplicant[23748]: nl80211: Could not set interface 'x3wlan0' UP
déc. 06 17:11:26 archlinux.localhost wpa_supplicant[23748]: nl80211: deinit ifname=x3wlan0 disabled_11b_rates=0
déc. 06 17:11:26 archlinux.localhost wpa_supplicant[23748]: Could not set interface x3wlan0 flags (UP): Device or resource busy
déc. 06 17:11:26 archlinux.localhost wpa_supplicant[23748]: WEXT: Could not set interface 'x3wlan0' UP
déc. 06 17:11:26 archlinux.localhost wpa_supplicant[23748]: x3wlan0: Failed to initialize driver interface
déc. 06 17:11:26 archlinux.localhost NetworkManager[23744]: <error> [1638807086.1054] device (x3wlan0): Couldn't initialize supplicant interface: GDBus.Error:fi.w1.wpa_supplicant1.UnknownError>
déc. 06 17:11:28 archlinux.localhost NetworkManager[23744]: <info>  [1638807088.3265] device (x3wlan0): state change: unavailable -> unmanaged (reason 'removed', sys-iface-state: 'removed')
déc. 06 17:11:28 archlinux.localhost NetworkManager[23744]: <info>  [1638807088.3270] device (x3wlan0): set-hw-addr: reset MAC address to 90:78:xx:xx:xx:xZ (unmanage)
déc. 06 17:11:28 archlinux.localhost NetworkManager[23744]: <warn>  [1638807088.3272] platform-linux: do-change-link[57]: failure changing link: failure 16 (Périphérique ou ressource occupé)
déc. 06 17:11:28 archlinux.localhost audit[23744]: USYS_CONFIG pid=23744 uid=0 auid=4294967295 ses=4294967295 msg='op=device-managed interface="x3wlan0" ifindex=57 args=false pid=29761 uid=0 r>
déc. 06 17:11:28 archlinux.localhost kernel: audit: type=1111 audit(1638807088.324:989): pid=23744 uid=0 auid=4294967295 ses=4294967295 msg='op=device-managed interface="x3wlan0" ifindex=57 ar>
déc. 06 17:11:28 archlinux.localhost NetworkManager[23744]: <info>  [1638807088.3280] audit: op="device-managed" interface="x3wlan0" ifindex=57 args="false" pid=29761 uid=0 result="success"
déc. 06 17:11:29 archlinux.localhost rfkill[29788]: unblock set for id 1

Kernel version :

uname -a
Linux archlinux.localhost 5.15.6-arch2-1 #1 SMP PREEMPT Thu, 02 Dec 2021 15:47:09 +0000 x86_64 GNU/Linux

I noticed that the line 1995 return the error # bring subnet interface up ip link set up dev ${SUBNET_IFACE} || die "Failed bringing ${SUBNET_IFACE} up"

I also noticed that create_ap works.

Also I tried to use iwd as backend for NM and it works so wpa_supplicant may be responsible for the problem

I hope it could help you... If you need some other information let me know...

ThomasK7775 avatar Dec 06 '21 16:12 ThomasK7775

I added some delays and log gathering code in branch dev-12

@ThomasK7775 Could you who encounter this issue do some tests and show the results for us? I can't do it myself cause I can't reproduce on my machine.

  1. Run the master branch with --no-virt:

    lnxrouter --ap wlan0 wifi -p 12345678 --no-virt
    

    (according to users reported above, this worked. I just want to make sure it still works now)

  2. Run the dev-12 branch (e1ccfac) (without --no-virt), and record the logs

  3. Comment out this line then run again: https://github.com/garywill/linux-router/blob/e1ccfac40cc969863a3bc0581409ce286eed837d/lnxrouter#L1656

  4. Disable MAC randomization during Wi-Fi scanning ( restart NM (also wpa_supplicant) ) then run:

    /etc/NetworkManager/conf.d/wifi_rand_mac.conf
    
    [device]
    wifi.scan-rand-mac-address=no
    

    (https://wiki.archlinux.org/title/NetworkManager#Configuring_MAC_address_randomization)

Thanks in advance. We still need tests and info

garywill avatar Dec 09 '21 03:12 garywill

Recent log on dev-12 branch: https://gist.github.com/DeadSix27/1a6ecc56f2e8addbe1eacae666d2efbe

Facing the same issues as outlined above

DeadSix27 avatar Jan 02 '22 10:01 DeadSix27

I opened an issue on NetworkManager: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/886

They require more verbosed logs.

  1. I updated log-gathering code in dev-12 branch
  2. Before you start the log-gathering, restart wpa_supplicant with -dd to get more log
  3. If you will, do more tests mentioned above to provide more results

~~You can post more logs here~~, or would rather directly submit the logs to them.

garywill avatar Jan 03 '22 12:01 garywill

Run into this error. Setup: Kubuntu 21.04

Screenshot_20220207_202126

Solved this by deactivating wireless connections, (DO NOT TURN ON AIRPLANE MODE), then running the command. The hotspot is created successfully. Then because the wireless connection was disabled, enable it again. Then connect to the target WiFi, and the internet connection should be passed through to the hotspot devices.

Note that I'm using the same, inbuilt WiFi adapter.

From the above, you can only create a Hotspot first, then connect the same interface to an internet connection second.

Wizard254 avatar Feb 07 '22 17:02 Wizard254

create_ap worked fine on me (Slackware 15.0 - Intel Wi-Fi 6 AX201) Using lnxrouter must use these steps for it to work

nmcli radio wifi off
lnxrouter --ap wlan0 MyAccessPoint -p MyPassPhrase &
sleep 6
nmcli radio wifi on

If I use --no-virt then the wifi is disconnected/disabled so I can't share the internet connection.

babam86 avatar Sep 12 '22 01:09 babam86