[Solved] systemd-networking wireless 1.5 minutes delay

This forum is for topics dealing with problems with software specifically in the AArch64 repo.

[Solved] systemd-networking wireless 1.5 minutes delay

Postby jfabernathy » Sat Dec 04, 2021 8:00 pm

I have aarch64 5.15.1-1 kernel running on a RPI3. I was wanting a minimal wireless headless system administered via ssh.

It seems systemd-networkd is enabled already, and I followed some wiki's and forums to look at doing the wireless within systemd-networkd.

wpa_supplicant was already installed. So I created /etc/systemd/network/25-wireless.network as below:
$this->bbcode_second_pass_code('', '[Match]
Name=wlan0

[Network]
DHCP=yes
')
I also created wpa_supplicant-wlan0.conf as below:
$this->bbcode_second_pass_code('', 'network={
ssid="NGJFA-5G"
#psk="mypassword"
psk=a bunch of hex number
}
')
I then did systemctl enable wpa_supplicant@wlan0

So when I reboot I'm monitoring via the serial console and I see about 15 seconds of kernel messages and then it sits for 1.5 minutes until I see the console login on the serial port and at that point, I can also ssh into the RPI3. wlan0 seems to be up at about 13 seconds. I just don't understand the delay. Everything works fine once I can login.

BTW, I have tried just using NetworkManager and it works great, but I always thought NM was overkill for this application.
Any ideas?
Last edited by jfabernathy on Sun Dec 05, 2021 1:21 pm, edited 1 time in total.
jfabernathy
 
Posts: 30
Joined: Mon Jan 14, 2019 7:36 pm

Re: systemd-networking wireless 1.5 minutes to get to login

Postby bueysitoDiablo » Sat Dec 04, 2021 11:09 pm

Hi,

your culprit most likely is systemd-networkd-wait-online. It's a tiny service which simply checks whether your network connections (defined via systemd-networkd, that is) are ready.

Now, you mention that you wanted a wireless system, so I assume your PI has no ethernet cable plugged in. Thus your eth0 link never becomes ready, and systemd-networkd-wait-online's default behaviour is a logical AND (i.e., if not each and every of our links is ready, then the whole network subsystem is not ready). So the wait-online unit will wait for eth0 until it timeouts, and that's the 1.5 - 2 mins you're seeing.

So you need to change wait-online's behaviour to a logical OR (I am ready whenever ANY of our links is ready). This way the system will continue with the boot process as soon as any of your links (in your case, wlan0) gets ready.

try this:

$this->bbcode_second_pass_code('', '
/usr/lib/systemd/system/systemd-networkd-wait-online.service

[Service]
Type=oneshot
ExecStart=
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any
RemainAfterExit=yes
')

notice the "--any", which is what you need. Also, don't forget the the first blank "ExecStart=".

Lastly, don't forget to re-do this every time systemd gets upgraded... because the service unit file will be restored to its default behaviour, and you will find yourself again waiting for wait-online to timeout ;)
bueysitoDiablo
 
Posts: 5
Joined: Sun Nov 28, 2021 8:46 pm

Re: systemd-networking wireless 1.5 minutes to get to login

Postby jfabernathy » Sun Dec 05, 2021 1:59 am

Thanks for the reply. I'm not sure of how all the systemd-networkd stuff works but after the change I still have the delay. Here is what I see on the 2 services:
$this->bbcode_second_pass_code('', '[root@alarm alarm]# systemctl status systemd-networkd-wait-online
* systemd-networkd-wait-online.service - Wait for Network to be Configured
Loaded: loaded (/usr/lib/systemd/system/systemd-networkd-wait-online.service; enabled; vendor preset:>
Active: inactive (dead)
Docs: man:systemd-networkd-wait-online.service(8)
[root@alarm alarm]# nano /usr/lib/system/systemd-networkd-wait-online.service
[root@alarm alarm]# nano /usr/lib/systemd/system/systemd-networkd-wait-online.service
[root@alarm alarm]# systemctl status systemd-networkd
* systemd-networkd.service - Network Configuration
Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-12-01 00:40:40 UTC; 4 days ago
TriggeredBy: * systemd-networkd.socket
Docs: man:systemd-networkd.service(8)
Main PID: 303 (systemd-network)
Status: "Processing requests..."
Tasks: 1 (limit: 982)
Memory: 2.9M
CPU: 200ms
CGroup: /system.slice/systemd-networkd.service
`-303 /usr/lib/systemd/systemd-networkd

Dec 01 00:40:40 alarm systemd-networkd[303]: lo: Link UP
Dec 01 00:40:40 alarm systemd-networkd[303]: lo: Gained carrier
Dec 01 00:40:40 alarm systemd-networkd[303]: Enumeration completed
Dec 01 00:40:40 alarm systemd[1]: Started Network Configuration.
Dec 01 00:40:41 alarm systemd-networkd[303]: wlan0: Link UP
Dec 05 01:47:48 alarm systemd-networkd[303]: wlan0: Connected WiFi access point: NGJFA-5G (90:9a:4a:ce:af:>
Dec 05 01:47:48 alarm systemd-networkd[303]: wlan0: Gained carrier
Dec 05 01:47:48 alarm systemd-networkd[303]: wlan0: DHCPv4 address 192.168.0.189/24 via 192.168.0.1
Dec 05 01:47:48 alarm systemd-networkd[303]: Could not set hostname: Access denied
Dec 05 01:48:12 alarm systemd-networkd[303]: wlan0: Gained IPv6LL

[root@alarm alarm]# systemctl status systemd-networkd-wait-online
* systemd-networkd-wait-online.service - Wait for Network to be Configured
Loaded: loaded (/usr/lib/systemd/system/systemd-networkd-wait-online.service; enabled; vendor preset:>
Active: inactive (dead)
Docs: man:systemd-networkd-wait-online.service(8)
[root@alarm alarm]#
')
jfabernathy
 
Posts: 30
Joined: Mon Jan 14, 2019 7:36 pm

Re: systemd-networking wireless 1.5 minutes to get to login

Postby jfabernathy » Sun Dec 05, 2021 2:37 am

Never mind. I redid the SDcard and made my original changes and included your suggestions and this time it work. No delay. Not sure what I messed up the first time, but it's fixed now.

Thanks for your advice.
jfabernathy
 
Posts: 30
Joined: Mon Jan 14, 2019 7:36 pm

Re: [Solved] systemd-networking wireless 1.5 minutes delay

Postby jfabernathy » Mon Dec 06, 2021 10:49 am

Could this change to systemd-networkd-wait-online be done with $this->bbcode_second_pass_code('', 'systemctl edit systemd-networkd-wait-online') and make this survive a system update of the systemd software?
jfabernathy
 
Posts: 30
Joined: Mon Jan 14, 2019 7:36 pm

Re: [Solved] systemd-networking wireless 1.5 minutes delay

Postby jfabernathy » Tue Dec 07, 2021 4:00 pm

I thought it might be useful to summarize what I've learned from help here and the Archlinux WIKI

Aarch64 boots up with systemd-networkd enabled/running and with Ethernet DHCP already working. Adding wireless permanently is all documented in the Archlinux.org wiki. Fixing systemd-networkd-wait-online is needed to solve the delay as mentioned in previous responses to this post and is documented here: https://wiki.archlinux.org/title/Systemd-networkd#systemd-networkd-wait-online You can create the override.conf file so the fix doesn't get removed on the next systemd update but using $this->bbcode_second_pass_code('', 'systemctl edit systemd-networkd-wait-online.service') You just need to put in this $this->bbcode_second_pass_code('', '[Service]
ExecStart=
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online --any
') between the commented areas or create the override.conf file manually.

Next, you need to have the wireless.network file like mentioned here: https://wiki.archlinux.org/title/Systemd-networkd#Wireless_adapter Then you need to setup wpa_supplicant with wpa_cli as mentioned here: https://wiki.archlinux.org/title/Wpa_supplicant#Connecting_with_wpa_cli

To make it work in systemd-networkd you need to change the name of the file you create from wpa_supplicant.conf to wpa_supplicant-wlan0.conf if wlan0 is the name of your wifi device. This is pointed out here: https://wiki.archlinux.org/title/Wpa_supplicant#At_boot_(systemd)

Next you need to: $this->bbcode_second_pass_code('', 'systemctl enable wpa_supplicant@wlan0.service')

Then you can reboot and wifi should be up.
jfabernathy
 
Posts: 30
Joined: Mon Jan 14, 2019 7:36 pm


Return to ARMv8

Who is online

Users browsing this forum: No registered users and 8 guests