You are not logged in.

#1 2025-11-07 16:20:00

franma
Member
Registered: 2025-11-07
Posts: 3

[SOLVED] Problems with IWD + NetworkManager

Hi, first of all thank you for using your time to read my problem
Im not an experienced developer in networking, but in my job I was asked to fix a bug, which im having a lot of trouble to solve:

FIRST PROBLEM: NetworkManager freezes itself when a 2nd network with the same name & password appears. I configured nm to a certain wifi, works ok, but if i turn on a hotspot with my phone (using same ssid and psk), nm bugs and never re connects to any wifi and stays in standby. SOLVED: by adding iwd, i have solved this by adding iwd to handle the backend:
etc/NetworkManager/conf.d/wifi_backend.conf:
[device]
wifi.backend=iwd

SECOND PROBLEM: Ok, now that i fixed the FIRST problem, another one appears, NM only sees wifis in channel 2!!!!!!!!!!!!!
When i remove the file at /etc/NetworkManager/conf.d/wifi_backend.conf where i set:
[device]
wifi.backend=iwd

NM does see other wifi channels, so iwd is having trouble with NM, that it makes NM only see wifis in channel 2!

WHAT HAVE I TRIED:
- Updating every library
- Setting regdom to AR in /var/lib/iwd/main.conf and other configs:
[Regulatory]
Country=AR

[General]
UseDefaultInterface=true
EnableNetworkConfiguration=true

[Scan]
DisableFilteredScan=true

What do you suggest, should i keep trying with IWD+NetworkManager or should i migrate to another way of handling WiFis? Please remember that the second problem starts with the first problem being solved, so if you know another way of solving the first problem that would be very useful too!
I will keep trying to fix this by myself but any recommendations would be very appreciated,
thanks in advance

Last edited by franma (2025-11-19 16:19:41)

Offline

#2 2025-11-07 19:10:58

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 70,997

Re: [SOLVED] Problems with IWD + NetworkManager

NetworkManager freezes itself when a 2nd network with the same name & password appears.

Please post your complete system journal for a boot covering that phenomenon, eg.

sudo journalctl -b -1 | curl -F 'file=@-' 0x0.st

for the previous ("-1")  one.

NM only sees wifis in channel 2

Stop NM and run a manual scan w/ iwd, https://wiki.archlinux.org/title/Iwd#iwctl and post the results of that.
Which other channel(s) do you expect to see? Also in the 2.4GHz band?
https://de.wikipedia.org/wiki/Wireless_ … edingungen (the english article doesn't have this fancy table but shouldn't be a problem)

Offline

#3 2025-11-12 20:13:18

franma
Member
Registered: 2025-11-07
Posts: 3

Re: [SOLVED] Problems with IWD + NetworkManager

Hi seth, sorry for answering late, I had to work on a quick solution and developed a script that fixes this problem, but it looks like a temporary fix, more details at the end. So, thank you very much for your time, here are your requests and more info.
If you need any other output please ask i will be waiting for your response
Thanks a lot,

STEPS FIRST PROBLEM:
1) Boots ok, connects to WIFI50
2) I generate the log file you asked me: http://0x0.st/KpqF.txt
3) Now, i create a wifi hotspot with my phone, with the same ssid and psk than WIFI50
4) I see that in iwconfig everything looks ok, but when i do nmcli dev status I see:
DEVICE         TYPE      STATE                   CONNECTION
eth0           ethernet  connected               eth0
lo             loopback  connected (externally)  lo
wlan0          wifi      disconnected            --
p2p-dev-wlan0  wifi-p2p  disconnected            --
5) If I try to do nmcli conn up WIFI50 (with original router and mobile hotspot turned on both at the same time) it says:
nmcli conn up WIFI50
Passwords or encryption keys are required to access the wireless network 'WIFI50'. Warning: password for '802-11-wireless-security.psk' not given in 'passwd-file' and nmcli cannot ask without '--ask' option. Error: Connection activation failed: Secrets were required, but not provided Hint: use 'journalctl -xe NM_CONNECTION=d6abb2ed-082f-4bfe-8e9e-2e186af97c35 + NM_DEVICE=wlan0' to get more details.
6) But, if I turn off the hotspot and do nmcli conn up WIFI50, the connection works. I did not add any psk or do nothing in between:
nmcli conn up WIFI50
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

So i dont really understand why when a second wifi with the same name appears, the NM bugs itself and never recovers!


STEPS SECOND PROBLEM:
Ok, so, here it goes the temp solution for the first problem:
1) I install IWD, by doing these steps:
sudo apt-get update

sudo apt-get install -y iwd

sudo systemctl enable --now iwd

sudo mkdir -p /etc/NetworkManager/conf.d
printf "[device]\nwifi.backend=iwd\n" | sudo tee /etc/NetworkManager/conf.d/wifi_backend.conf
sudo systemctl restart NetworkManager

nmcli radio wifi on
nmcli dev set wlan0 managed yes
ip link set wlan0 up

2) When I do nmcli dev wifi list:
root@rockpi-s:~# nmcli dev wifi list
IN-USE  BSSID              SSID                     MODE   CHAN  RATE       SIGNAL  BARS  SECURITY
        00:01:02:00:00:01  WIFI50                   Infra  2     65 Mbit/s  24      ▂___  WPA2
        00:01:02:00:00:02  Fibertel 33 2.4-2.4GHz   Infra  2     65 Mbit/s  17      ▂___  WPA2
        00:01:02:00:00:04  Personal Wifi Zone       Infra  2     65 Mbit/s  14      ▂___  --
        00:01:02:00:0:0A   Fibertel WiFi656 2.4GHz  Infra  2     65 Mbit/s  9       ▂___  WPA2
3) nmcli dev wifi status returns:
DEVICE  TYPE      STATE                   CONNECTION
eth0    ethernet  connected               eth0
lo      loopback  connected (externally)  lo
wlan0   wifi      disconnected            --

If I try to nmcli conn up WIFI50 (only the original router turned on) it says:
Passwords or encryption keys are required to access the wireless network 'WIFI50'.
Warning: password for '802-11-wireless-security.psk' not given in 'passwd-file' and nmcli cannot ask without '--ask' option.
Error: Connection activation failed: Secrets were required, but not provided
Hint: use 'journalctl -xe NM_CONNECTION=d6abb2ed-082f-4bfe-8e9e-2e186af97c35 + NM_DEVICE=wlan0' to get more details.

So now, it only sees wifis in channel 2. as I said before tried to set regdom but no success, still in this error.


TEMPORARY FIX TO FIRST PROBLEM:
- Created a script that checks if wifi conn is OK, if it is disconnected, it reboots NetworkManager and then it connects OK to any of the WIFI50 (router or hotspot)

Offline

#4 2025-11-12 20:59:59

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 70,997

Re: [SOLVED] Problems with IWD + NetworkManager

So i dont really understand why when a second wifi with the same name appears, the NM bugs itself and never recovers!

Nov 12 16:21:28 rockpi-s wpa_supplicant[612]: wlan0: WPA: Key negotiation completed with 84:46:fe:92:0e:bc [PTK=CCMP GTK=TKIP]
Nov 12 16:21:28 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-CONNECTED - Connection to 84:46:fe:92:0e:bc completed [id=0 id_str=]
Nov 12 16:21:28 rockpi-s NetworkManager[591]: <info>  [1762975288.1602] device (wlan0): Activation: (wifi) Stage 2 of 5 (Device Configure) successful. Connected to wireless network "WIFI50"
Nov 12 16:21:30 rockpi-s NetworkManager[591]: <info>  [1762975290.5720] manager: NetworkManager state is now CONNECTED_SITE
Nov 12 16:21:30 rockpi-s NetworkManager[591]: <info>  [1762975290.5865] manager: NetworkManager state is now CONNECTED_GLOBAL
Nov 12 16:32:17 rockpi-s NetworkManager[591]: <info>  [1762975937.4443] device (eth0): carrier: link connected
Nov 12 16:32:17 rockpi-s NetworkManager[591]: <info>  [1762975937.4479] device (eth0): state change: unavailable -> disconnected (reason 'carrier-changed', sys-iface-state: 'managed')
Nov 12 16:32:17 rockpi-s NetworkManager[591]: <info>  [1762975937.4602] device (eth0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Nov 12 16:32:20 rockpi-s NetworkManager[591]: <info>  [1762975940.5481] device (eth0): carrier: link connected
Nov 12 16:32:55 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-DISCONNECTED bssid=e2:3b:75:54:7e:00 reason=0
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.4708] device (wlan0): supplicant interface state: associating -> disconnected
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.4712] device (p2p-dev-wlan0): supplicant management interface state: associating -> disconnected
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.5807] device (wlan0): supplicant interface state: disconnected -> associated
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.5810] device (p2p-dev-wlan0): supplicant management interface state: disconnected -> associated
Nov 12 16:32:56 rockpi-s wpa_supplicant[612]: nl80211: kernel reports: key not allowed
Nov 12 16:32:56 rockpi-s wpa_supplicant[612]: wlan0: WPA: Failed to set PTK to the driver (alg=3 keylen=16 bssid=e2:3b:75:54:7e:00)
Nov 12 16:32:56 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-DISCONNECTED bssid=e2:3b:75:54:7e:00 reason=1 locally_generated=1
Nov 12 16:32:56 rockpi-s wpa_supplicant[612]: wlan0: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
Nov 12 16:32:56 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="WIFI50" auth_failures=1 duration=10 reason=WRONG_KEY

You're connected to 84:46:fe:92:0e:bc then a wired carrier takes precedence, then you try to connect to e2:3b:75:54:7e:00 and that fails for a wrong key, but that might be driven by

Nov 12 16:32:55 rockpi-s wpa_supplicant[612]: wlan0: Trying to associate with e2:3b:75:54:7e:00 (SSID='WIFI50' freq=2412 MHz)
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.4471] device (wlan0): supplicant interface state: completed -> associating
Nov 12 16:32:55 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-DISCONNECTED bssid=e2:3b:75:54:7e:00 reason=0
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.4475] device (p2p-dev-wlan0): supplicant management interface state: completed -> associating
Nov 12 16:32:55 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-REGDOM-CHANGE init=CORE type=WORLD
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.4708] device (wlan0): supplicant interface state: associating -> disconnected
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.4712] device (p2p-dev-wlan0): supplicant management interface state: associating -> disconnected
Nov 12 16:32:55 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-SCAN-FAILED ret=-16 retry=1
Nov 12 16:32:55 rockpi-s kernel: ------------[ cut here ]------------
Nov 12 16:32:55 rockpi-s kernel: WARNING: CPU: 3 PID: 136 at net/wireless/sme.c:756 __cfg80211_connect_result+0x380/0x420 [cfg80211]
Nov 12 16:32:55 rockpi-s kernel: Modules linked in: 8723ds cfg80211 rfkill snd_soc_rk3308 snd_soc_pcm5102a snd_soc_simple_card snd_soc_simple_card_utils snd_soc_core snd_pcm_dmaengine snd_pcm nvmem_rockchip_otp snd_timer snd soundcore cpufreq_dt zram ip_tables x_tables autofs4 realtek dwmac_rk stmmac_platform stmmac pcs_xpcs
Nov 12 16:32:55 rockpi-s kernel: CPU: 3 PID: 136 Comm: kworker/u8:1 Not tainted 5.15.58-rockchip64 #trunk
Nov 12 16:32:55 rockpi-s kernel: Hardware name: Radxa ROCK Pi S (DT)
Nov 12 16:32:55 rockpi-s kernel: Workqueue: cfg80211 cfg80211_event_work [cfg80211]
Nov 12 16:32:55 rockpi-s kernel: pstate: 80000005 (Nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
Nov 12 16:32:55 rockpi-s kernel: pc : __cfg80211_connect_result+0x380/0x420 [cfg80211]
Nov 12 16:32:55 rockpi-s kernel: lr : __cfg80211_connect_result+0x23c/0x420 [cfg80211]
Nov 12 16:32:55 rockpi-s kernel: sp : ffff80000a8bbcd0
Nov 12 16:32:55 rockpi-s kernel: x29: ffff80000a8bbcd0 x28: 0000000000000000 x27: 0000000000000000
Nov 12 16:32:55 rockpi-s kernel: x26: ffff000002f58074 x25: dead000000000100 x24: dead000000000122
Nov 12 16:32:55 rockpi-s kernel: x23: ffff80000a8bbd18 x22: ffff00001dad8000 x21: ffff80000954b528
Nov 12 16:32:55 rockpi-s kernel: x20: ffff000005b02818 x19: ffff0000058b3000 x18: 000000000000ceb2
Nov 12 16:32:55 rockpi-s kernel: x17: 0000000000000000 x16: 0000000000000011 x15: 0001163d00010000
Nov 12 16:32:55 rockpi-s kernel: x14: ffffffffffffffff x13: 0000000000000000 x12: 007e54753be20001
Nov 12 16:32:55 rockpi-s kernel: x11: 7f7f7f7f7f7f7f7f x10: fefefefefefefeff x9 : 7f7f7f7f7f7f7f7f
Nov 12 16:32:55 rockpi-s kernel: x8 : ffff00001d9d5044 x7 : 0000000000000001 x6 : 0000000000000001
Nov 12 16:32:55 rockpi-s kernel: x5 : ffff80001676b000 x4 : 0000000000000001 x3 : 0000000000000001
Nov 12 16:32:55 rockpi-s kernel: x2 : 0000000000000000 x1 : ffff000002d38ec0 x0 : 0000000000000000
Nov 12 16:32:55 rockpi-s kernel: Call trace:
Nov 12 16:32:55 rockpi-s kernel:  __cfg80211_connect_result+0x380/0x420 [cfg80211]
Nov 12 16:32:55 rockpi-s kernel:  cfg80211_process_wdev_events+0x11c/0x180 [cfg80211]
Nov 12 16:32:55 rockpi-s kernel:  cfg80211_process_rdev_events+0x30/0x50 [cfg80211]
Nov 12 16:32:55 rockpi-s kernel:  cfg80211_event_work+0x28/0x40 [cfg80211]
Nov 12 16:32:55 rockpi-s kernel:  process_one_work+0x20c/0x4c8
Nov 12 16:32:55 rockpi-s kernel:  worker_thread+0x48/0x478
Nov 12 16:32:55 rockpi-s kernel:  kthread+0x138/0x150
Nov 12 16:32:55 rockpi-s kernel:  ret_from_fork+0x10/0x20
Nov 12 16:32:55 rockpi-s kernel: ---[ end trace 6fdbd74e7c070bb6 ]---
Nov 12 16:32:55 rockpi-s wpa_supplicant[612]: wlan0: Associated with e2:3b:75:54:7e:00
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.5807] device (wlan0): supplicant interface state: disconnected -> associated
Nov 12 16:32:55 rockpi-s wpa_supplicant[612]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
Nov 12 16:32:55 rockpi-s NetworkManager[591]: <info>  [1762975975.5810] device (p2p-dev-wlan0): supplicant management interface state: disconnected -> associated
Nov 12 16:32:56 rockpi-s NetworkManager[591]: <info>  [1762975976.5897] device (wlan0): supplicant interface state: associated -> 4way_handshake
Nov 12 16:32:56 rockpi-s NetworkManager[591]: <info>  [1762975976.5914] device (p2p-dev-wlan0): supplicant management interface state: associated -> 4way_handshake

Nov 12 16:32:56 rockpi-s wpa_supplicant[612]: nl80211: kernel reports: key not allowed
Nov 12 16:32:56 rockpi-s wpa_supplicant[612]: wlan0: WPA: Failed to set PTK to the driver (alg=3 keylen=16 bssid=e2:3b:75:54:7e:00)

ie. if the key is actually correct, this would be a problem w/ the device/driver what brings us to

Nov 12 16:21:17 rockpi-s kernel: Linux version 5.15.58-rockchip64 (root@8937d8418510) (aarch64-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0, GNU ld (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 2.32.0.20190321) #trunk SMP PREEMPT Mon Aug 1 02:56:32 UTC 2022
sudo apt-get update

and thus https://bbs.archlinux.org/misc.php?action=rules

The journal doesn't cover any iwd attempts so I cannot comment on that.

Offline

#5 2025-11-19 16:17:06

franma
Member
Registered: 2025-11-07
Posts: 3

Re: [SOLVED] Problems with IWD + NetworkManager

Hi seth, yes, sorry for posting in the wrong forum i didnt read the rules. I wont continue this conversation, im posting this message for if anyone finds it useful, and marking as this post as SOLVED.

Ive tried creating a new image by using the latest armbian for rockpi, and still no luck, ive imported my old .nmconnection files and combining them with netplan (i guess new library for wifi)
But I will try using the new image + new network settings using armbian-config.
Thanks a lot for your time and dedication, i really appreciate it

This is the temp fix that solved my problem for now:
I have solved this network bug by doing this script called nm-wlan-guard.sh. It is executed by a timer every 5mins and checks if the network is OK, if its not, it takes action and solves it, script:
cat nm-wlan-guard.sh

#!/usr/bin/env bash
set -euo pipefail

IFACE="${IFACE:-wlan0}"
COOLDOWN_SECONDS="${COOLDOWN_SECONDS:-300}"   # no más de un restart cada 5 min
STATE_FILE="/run/nm-wlan-guard.last"
LOG_TAG="nm-wlan-guard"

log(){ logger -t "$LOG_TAG" -- "$"; echo "[$LOG_TAG] $"; }

# 1) prereqs
command -v nmcli >/dev/null || { log "ERROR: nmcli no encontrado"; exit 1; }
systemctl status NetworkManager >/dev/null 2>&1 || { log "ERROR: NetworkManager no está activo"; exit 1; }

# 2) estado del dispositivo
# Formato: DEVICE:TYPE:STATE
line="$(nmcli -t -f DEVICE,TYPE,STATE device status | awk -F: -v i="$IFACE" '$1==i{print $0}')"
if [[ -z "$line" ]]; then
  log "WARN: la interfaz $IFACE no existe en nmcli"; exit 0
fi

state="$(awk -F: '{print $3}' <<<"$line")"
# Estados a tratar como problema
problem_states=("disconnected" "unavailable" "failed" "unmanaged")

is_problem=0
for s in "${problem_states[@]}"; do
  [[ "$state" == "$s" ]] && { is_problem=1; break; }
done

# 3) chequeo de conectividad opcional si dice "connected"
#    (a veces está asociado pero sin salida)
if [[ $is_problem -eq 0 && "$state" == "connected" ]]; then
  gw="$(nmcli -t -g IP4.GATEWAY device show "$IFACE" 2>/dev/null | head -n1 || true)"
  target="${gw:-1.1.1.1}"
  if ! ping -c1 -W2 "$target" >/dev/null 2>&1; then
    log "CONNECTED pero sin conectividad a $target → tratar como problema"
    is_problem=1
  fi
fi

if [[ $is_problem -eq 0 ]]; then
  log "OK: $IFACE estado=$state"
  exit 0
fi

# 4) rate-limit
now="$(date +%s)"
last=0
[[ -f "$STATE_FILE" ]] && last="$(cat "$STATE_FILE" 2>/dev/null || echo 0)"
elapsed=$(( now - last ))
if (( elapsed < COOLDOWN_SECONDS )); then
  log "SKIP: $IFACE=$state (cooldown ${elapsed}s < ${COOLDOWN_SECONDS}s)"
  exit 0
fi

# 5) intento suave primero (evita reiniciar NM si alcanza)
log "Intento reconectar $IFACE (estado=$state)"
nmcli device disconnect "$IFACE" >/dev/null 2>&1 || true
sleep 1
if nmcli device connect "$IFACE" >/dev/null 2>&1; then
  sleep 2
  if nmcli -t -f DEVICE,STATE device | grep -q "^${IFACE}:connected$"; then
    log "Reconexion de $IFACE exitosa sin reiniciar NM"
    echo "$now" > "$STATE_FILE"
    exit 0
  fi
fi

# 6) reinicio de NetworkManager
log "Reiniciando NetworkManager por $IFACE=$state"
systemctl restart NetworkManager
echo "$now" > "$STATE_FILE"
sleep 3

# 7) verificación rápida post-restart
if nmcli -t -f DEVICE,STATE device | grep -q "^${IFACE}:connected$"; then
  log "OK tras restart: $IFACE conectado"
else
  log "WARN tras restart: $IFACE sigue en estado problemático"
fi

Offline

Board footer

Powered by FluxBB