Network Manager issue

Hi.
I am getting the following issue on RPI with network manager config.

When installing the correct config for wifi - everything works, no issues.
Now the problem arises when user installs config that has an invalid password like this.

network:
  version: 2
  renderer: NetworkManager
  wifis:
    wlan0:
      access-points:
        "POINT":
          password: "WRONG"
      dhcp4: true

Now if he installs correct config:

network:
  version: 2
  renderer: NetworkManager
  wifis:
    wlan0:
      access-points:
        "NAME":
          password: "CORRECT"
      dhcp4: true

There is still no network connection. I double-checked the behavior. It is completely reproducible. Any ideas what’s wrong? How can it be worked around?

The only workaround I found was changing from NetwokManager to networkd. Which did not work every time.

After changing config, have you called
$ netplan apply ?
Also are you really using benefits of NM. It seems to me that for simple network configuration like this, default networkd rendered should be sufficient.

That been said, NM plugin which will read config without need to call netplan apply is also in works and will be available in the future

We do not call netplan apply explicitly. When user inserts USB stick with network config we overwrite the old config if it changed and reboot. Do we need to if we reboot?
Works fine in all cases except for this one.

The reason we use NM is that we want to also support creating wi-fi access point in the future (so for now, yes, we could default to networkd).

nope, if you reboot the netplan generate/apply dance happens automatically (you do not need to reboot anymore if you do a dbus call for the netplan generate/appl bits instead though, the network-setup-control interface got enhanced)

I think it’s worth pointing out that this is for Core 16. Not sure if that changes anything.

And as mentioned in the parent post. The issue is reproducible 100% (at lease on core 16). The issue happens only when correct access point name is entered with incorrect password.

So I understand it fully
You say if you do following:

  • set netplan config with WRONG Wi-Fi password
  • reboot
  • set netplan config with CORECT Wi-Fi password
  • reboot
    Device still has no network. And this is reproducible on Core 16 every time

Can you please try same thing, but instead of reboot call $ netplan generate; netplan apply
If you have some problem
Just trying to narrow down the problem.
@abeato any idea what can be causing this?

netplan on core16 had a bug so netplan apply did not restart the network services sometimes. Said this, if you restart things should be fine.

Do you see the old or the new password when you run:

nmcli c show <conn> -s  | grep 802-11-wireless-security.psk

Also, which is the content of these folders:

/run/NetworkManager/system-connections/
/var/snap/network-manager/current/conf/system-connections/

Hi guys. Here are some logs:

journalctl -u snap.network-manager.networkmanager
journalctl -u wpa_supplicant.service

@abeato, @ondra, I executed the commands you asked:

Troubleshooting Netplan and NetworkManager integration

All the following steps are done over UART communication.

Step 1 - A clean installation

Netplan:

pi@localhost:/$ tail /etc/netplan/*
==> /etc/netplan/00-default-nm-renderer.yaml <==
network:
  renderer: NetworkManager

==> /etc/netplan/00-snapd-config.yaml <==
    version: 2
    ethernets:
        all-en:
            match:
                name: "en*"
            dhcp4: true
        all-eth:
            match:
                name: "eth*"
            dhcp4: true

Network manager:

pi@localhost:/$ nmcli c show
NAME                UUID                                  TYPE            DEVICE
Wired connection 1  981a2d2f-1efb-30b5-af46-86acb237915c  802-3-ethernet  --

Step 2 - Install an incorrect password

Netplan:

pi@localhost:/$ tail /etc/netplan/*
==> /etc/netplan/00-default-nm-renderer.yaml <==
network:
  renderer: NetworkManager

==> /etc/netplan/00-snapd-config.yaml <==
network:
  renderer: NetworkManager
  version: 2
  wifis:
    wlan0:
      access-points:
        HUAWEI-R5:
          password: *****-c4a
      dhcp4: true

Network manager:

pi@localhost:/$ \
> nmcli c show -s netplan-wlan0-HUAWEI-R5 | grep 802-11-wireless-security.psk
802-11-wireless-security.psk:           *****-c4a
802-11-wireless-security.psk-flags:     0 (none)

Directory content:

pi@localhost:/$ sudo ls /run/NetworkManager/system-connections/
netplan-wlan0-HUAWEI-R5

localhost:/$ sudo cat /run/NetworkManager/system-connections/netplan-wlan0-HUAWEI-R5
[connection]
id=netplan-wlan0-HUAWEI-R5
type=wifi
interface-name=wlan0

[ethernet]
wake-on-lan=0

[ipv4]
method=auto

[ipv6]
method=ignore

[wifi]
ssid=HUAWEI-R5
mode=infrastructure

[wifi-security]
key-mgmt=wpa-psk
psk=*****-c4a


pi@localhost:/$ \
> sudo ls /var/snap/network-manager/current/conf/system-connections/
pi@localhost:/$

Step 3 - Install a correct password

Netplan:

This code block contains correct password.

pi@localhost:~$ tail /etc/netplan/*
==> /etc/netplan/00-default-nm-renderer.yaml <==
network:
  renderer: NetworkManager

==> /etc/netplan/00-snapd-config.yaml <==
network:
  renderer: NetworkManager
  version: 2
  wifis:
    wlan0:
      access-points:
        HUAWEI-R5:
          password: *****-c4a9
      dhcp4: true

Network manager:

pi@localhost:~$ \
> nmcli c show -s netplan-wlan0-HUAWEI-R5 | grep 802-11-wireless-security.psk
802-11-wireless-security.psk:           *****-c4a9
802-11-wireless-security.psk-flags:     0 (none)

Directory content:

pi@localhost:~$ \
> sudo ls /run/NetworkManager/system-connections/
netplan-wlan0-HUAWEI-R5
pi@localhost:~$ \
> sudo cat /run/NetworkManager/system-connections/netplan-wlan0-HUAWEI-R5
[connection]
id=netplan-wlan0-HUAWEI-R5
type=wifi
interface-name=wlan0

[ethernet]
wake-on-lan=0

[ipv4]
method=auto

[ipv6]
method=ignore

[wifi]
ssid=HUAWEI-R5
mode=infrastructure

[wifi-security]
key-mgmt=wpa-psk
psk=*****-c4a9

pi@localhost:~$ > sudo ls /var/snap/network-manager/current/conf/system-connections/
pi@localhost:/$

Proofs of missing internet connection:

pi@localhost:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 10
00
    link/ether b8:27:eb:0a:a6:1c brd ff:ff:ff:ff:ff:ff
3: wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1
000
    link/ether b8:27:eb:5f:f3:49 brd ff:ff:ff:ff:ff:ff

After netplan generate and apply

apply ecurity.pskt:~$ nmcli c show -s netplan-wlan0-HUAWEI-R5 | grep
802-11-wireless-s 802-11-wireless-security.psk: *****-c4a9
802-11-wireless-security.psk-flags: 0 (none) pi@localhost:~$ sudo ls
/run/NetworkManager/system-connections/ netplan-wlan0-HUAWEI-R5
AWEI-R5lhost:~$ sudo cat
/run/NetworkManager/system-connections/netplan-wlan0-HU [connection]
id=netplan-wlan0-HUAWEI-R5 type=wifi interface-name=wlan0

[ethernet]
wake-on-lan=0

[ipv4]
method=auto

[ipv6]
method=ignore

[wifi]
ssid=HUAWEI-R5
mode=infrastructure

[wifi-security]
key-mgmt=wpa-psk
psk=*****-c4a9
s/@localhost:~$ sudo ls /var/snap/network-manager/current/conf/system-connection
pi@localhost:~$

After switching from NetworkManager to networkd with a correct password

Netplan:

pi@localhost:~$ tail /etc/netplan/*
==> /etc/netplan/00-default-nm-renderer.yaml <==
network:
  renderer: NetworkManager

==> /etc/netplan/00-snapd-config.yaml <==
network:
  renderer: networkd
  version: 2
  wifis:
    wlan0:
      access-points:
        HUAWEI-R5:
          password: *****-c4a9
      dhcp4: true

Network is up:

pi@localhost:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:0a:a6:1c brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:5f:f3:49 brd ff:ff:ff:ff:ff:ff
    inet 192.168.3.12/24 brd 192.168.3.255 scope global dynamic wlan0
       valid_lft 86220sec preferred_lft 86220sec

It is difficult to say what is happening, NM apparently is not finding a connection for wlan0:

policy: Device 'wlan0' has no connection; scheduling activate_check in 0 seconds.

What happens if you reboot after setting a good password for NM?