Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

networkmanager and wpasupplicant timers on shutdown?

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
dieselnutjob
Posts: 133
Joined: 2011-04-12 10:25

networkmanager and wpasupplicant timers on shutdown?

#1 Post by dieselnutjob »

Hi
I have a Debian Bookworm image for the PineTab2 with plasma-mobile installed.
The problem with this device at the moment is that the bes2600 wifi driver is buggy, and hangs unloading the module (I think that's the problem with it).
The consequence is that it take about six minutes to shutdown/reboot the tablet whilst it waits for networkmanager and wpasupplicant to timeout.
On shutdown you get a call trace from the bes2600 driver.
then: Stopped wpa_supplicant.service - WPA supplicant
then: device enter sleep
then: Job NetworkManager.service/stop running (1min 37s / 3min 3s)
after 3min 3 the timer increases to 4min 33s
then: system-shutdown: waiting for process (NetworkManager)
then: sending SIGKILL to remaining processes
sending SIGKILL to PID 2263 (NetworkManager)
which adds several minutes more

I can't do anything about the bes2600 driver, but, I am wondering if some of these timeouts are configurable and how I could reduce them.

I have also noticed that if I use the pull down menu thing in plasma-mobile (the one that has the shutdown button, airplane mode, etc etc) if I tap on the "WiFi" button to disable WiFi then there is a much shorter delay (two or three seconds) to disable WiFi and then I can shutdown or reboot instantly.

What does that button actually do? and can I do the same thing in a shutdown script?

thanks

dieselnutjob
Posts: 133
Joined: 2011-04-12 10:25

Re: networkmanager and wpasupplicant timers on shutdown?

#2 Post by dieselnutjob »

running "nmcli radio wifi off" prior to shutdown works
how would I (and is it a good idea to) add that to a shutdown script ?

Aki
Global Moderator
Global Moderator
Posts: 2979
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 75 times
Been thanked: 407 times

Re: networkmanager and wpasupplicant timers on shutdown?

#3 Post by Aki »

Hello,
dieselnutjob wrote: 2024-03-01 15:49 running "nmcli radio wifi off" prior to shutdown works
how would I (and is it a good idea to) add that to a shutdown script ?
It could be a good idea if you can do nothing about the bes2600 wireless kernel module, as you reported before.

You can look here for instructions on how to get systemd to run a customised script when shutting down:
  • SYSTEMD-HALT.SERVICE(8):
    [..]
    Immediately before executing the actual system halt/poweroff/reboot/kexec systemd-shutdown will run all executables in /lib/systemd/system-shutdown/ and pass one arguments to them: either "halt", "poweroff", "reboot" or "kexec", depending on the chosen action. All executables in this directory are executed in parallel, and execution of the action is not continued before all executables finished.
    [..]
As an alternative, you can create your own custom system service to run your custom script on shutdown. You can see this here: Hope this helps. Let me know :)
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

dieselnutjob
Posts: 133
Joined: 2011-04-12 10:25

Re: networkmanager and wpasupplicant timers on shutdown?

#4 Post by dieselnutjob »

thanks.
I found that running "modprobe -r bes2600" also stops the shutdown from hanging, but it more user friendly because on boot the status of the wifi set by the user in the gui is restored, whereas, using nmcli the wifi is always off when booted.

however

whilst running "sudo modprobe -r bes2600" in konsole prior to shutdown/reboot results in it shutting down nice and quickly, creating a script in /lib/systemd/system-shutdown doesn't help

It's almost like it doesn't get executed early enough in the shutdown process.

How do I get my shutdown script to execute before anything else?

dieselnutjob
Posts: 133
Joined: 2011-04-12 10:25

Re: networkmanager and wpasupplicant timers on shutdown?

#5 Post by dieselnutjob »

I think what I really want is for the shutdown process to run my script first, and for the shutdown process to be blocked from doing anything until my script has completed.
it needs a two or three seconds to complete
My suspicion is that shutdown is running the script but just carrying on regardless before the script has unloaded bes2600

but I am guessing

Aki
Global Moderator
Global Moderator
Posts: 2979
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 75 times
Been thanked: 407 times

Re: networkmanager and wpasupplicant timers on shutdown?

#6 Post by Aki »

Hello,

You may create a systemd service to be execute before shutdown, i.e. a file named:
  • /etc/systemd/system/before_shutdown_script.service containing:

    Code: Select all

    [Unit]
    Description=Run script before shutdown
    DefaultDependencies=no
    Before=shutdown.target reboot.target halt.target
    
    [Service]
    Type=oneshot
    ExecStart=/before_shutdown_script.sh
    
    [Install]
    WantedBy=halt.target reboot.target shutdown.target
    
Then, you can create the custom script, i.e.:
  • /before_shutdown_script.sh containing:

    Code: Select all

    #! /bin/sh
    logger "this is " $0
    modprobe -r bes2600 
    
Then, you can make the script executable:

Code: Select all

# chmod u+x /before_shutdown_script.sh
# ls /before_shutdown_script.sh -la
-rwxr--r-- 1 root root 32 Mar  3 19:47 /before_shutdown_script.sh
Then, you can enable the /etc/systemd/system/before_shutdown_script.service :

Code: Select all

# systemctl enable before_shutdown_script
# systemctl status  before_shutdown_script
* before_shutdown_script.service - Run script before shutdown
     Loaded: loaded (/etc/systemd/system/before_shutdown_script.service; enabled; preset: enabled)
     Active: inactive (dead)
Then, you can reboot.

The next shutdown it should be executed and a message in the log should be recorded.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

dieselnutjob
Posts: 133
Joined: 2011-04-12 10:25

Re: networkmanager and wpasupplicant timers on shutdown?

#7 Post by dieselnutjob »

thanks for your instructions.
The script sort of works, but there are problems.
Normally the script works, the bes2600 driver is unloaded and the PineTab2 then cleanly reboots or shutsdown.

However....

Sometimes (for example if you select shutdown/reboot from sddm without even logging in) the driver segfaults as modprobe -r is run. This also happens if the tablet isn't associated with any access point).

When the driver segfaults the service just freezes basically nearly forever. It takes something like twenty minutes to shutdown.

I tried adding a TimeoutSec= parameter to the service but it doesn't seem to be enough to solve the problem.

Is there a way to make follow on services to wait for a period of time for my bes2600-shutdown service to do modprobe -r the driver, but then carry on anyway if it doesn't complete?

Aki
Global Moderator
Global Moderator
Posts: 2979
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 75 times
Been thanked: 407 times

Re: networkmanager and wpasupplicant timers on shutdown?

#8 Post by Aki »

Hello,
dieselnutjob wrote: 2024-03-04 09:11 Sometimes (for example if you select shutdown/reboot from sddm without even logging in) the driver segfaults as modprobe -r is run. This also happens if the tablet isn't associated with any access point).

When the driver segfaults the service just freezes basically nearly forever. It takes something like twenty minutes to shutdown.
Can you replicate the kernel segfault running the modprobe -r from command line (i.e. a virtual console, ctrl+alt+f2) and get the logs ?

Is the modprobe command returning (after kernel module segfault) or the modprobe command is stuck (due to kernel segfault) ?

Can you post the kernel backtrace of the kernel module segfault ?
dieselnutjob wrote: 2024-03-04 09:11 I tried adding a TimeoutSec= parameter to the service but it doesn't seem to be enough to solve the problem.

Is there a way to make follow on services to wait for a period of time for my bes2600-shutdown service to do modprobe -r the driver, but then carry on anyway if it doesn't complete?
I suppose it depends on how modprobe and the kernel handle the segfault.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Aki
Global Moderator
Global Moderator
Posts: 2979
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 75 times
Been thanked: 407 times

Re: networkmanager and wpasupplicant timers on shutdown?

#9 Post by Aki »

@dieselnutjob:
Have you made progresses ?
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Post Reply