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

 

 

 

Wifi dies after resuming from suspend (i.e. wake from sleep)

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
rlue
Posts: 13
Joined: 2017-10-30 02:04

Wifi dies after resuming from suspend (i.e. wake from sleep)

#1 Post by rlue »

I'm running a very minimal install of Debian 9.2 (no GUI yet). I've manually configured wpa_supplicant per the Debian Wiki Wifi/HowToUse page at https://wiki.debian.org/WiFi/HowToUse#wpa_supplicant (no network-manager or wicd). I'm using a USB wifi adapter that requires a separately compiled driver (https://github.com/lwfinger/rtl8723bu).

Each time I close and reopen the lid of my laptop to suspend/resume the system, I lose my WiFi connection. This does not happen on the ethernet interface — I can suspend and resume and continue using the Internet over a wired connection no problem.

After resume, wpa_supplicant is still running, but I can't ping the gateway:

Code: Select all

$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
From 192.168.1.129 icmp_seq=31 Destination Host Unreachable
From 192.168.1.129 icmp_seq=32 Destination Host Unreachable
From 192.168.1.129 icmp_seq=33 Destination Host Unreachable
From 192.168.1.129 icmp_seq=34 Destination Host Unreachable
^C
--- 192.168.1.1 ping statistics ---
40 packets transmitted, 0 received, +4 errors, 100% packet loss, time 39942ms
pipe 4
'ip link' shows the interface is still UP:

Code: Select all

$ ip link show wlx74da38cfaa36
3: wlx74da38cfaa36: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
    link/ether 74:da:38:cf:aa:36 brd ff:ff:ff:ff:ff:ff
How can I automate reconnection to the network on resume, or better yet, preserve the connection across the suspend/resume process?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Wifi dies after resuming from suspend (i.e. wake from sl

#2 Post by Head_on_a_Stick »

Use https://unix.stackexchange.com/question ... -at-resume to run `ifup wlx74da38cfaa36` (what a memorable interface name that is) after resuming, perhaps?
deadbang

rlue
Posts: 13
Joined: 2017-10-30 02:04

Re: Wifi dies after resuming from suspend (i.e. wake from sl

#3 Post by rlue »

This is great! I haven't gotten the systemd service working yet, but this is the script I've written to reset the interface:

Code: Select all

#!/bin/sh

if iw "$1" info; then
  connection_status="$(iw "$1" link)"
  exit_status=$?

  if [ $exit_status -eq 0 ] && [ "$connection_status" != "Not connected." ]; then
      echo "$1 already connected."
  else
    if [ $exit_status -eq 0 ]; then
      echo "$1 not previously connected." >&2
      echo "If the wireless network was not in range when the system was last suspended, you may ignore this message." >&2
      echo "Otherwise, it may indicate that the interface $1 is improperly configured." >&2
      echo "Resetting the interface anyway..." >&2
    fi

    ifquery --state "$1" >/dev/null 2>&1 && ifdown "$1"
    ifup "$1"  
  fi
else
  echo "$1 is not a valid network interface." >&2
fi
This script accepts the name of a wireless network interface as a single argument.

Surely there must be a way to do this without a home-rolled script, though. Is that one of the features that network-manager provides?

I'm going to look into it and report back when I find out. In the meantime, if anyone has any insight, I'd be very glad to hear it.

User avatar
dilberts_left_nut
Administrator
Administrator
Posts: 5346
Joined: 2009-10-05 07:54
Location: enzed
Has thanked: 12 times
Been thanked: 66 times

Re: Wifi dies after resuming from suspend (i.e. wake from sl

#4 Post by dilberts_left_nut »

It could well be because it is USB connected, and the usb interface is turned off and back on, leaving the wifi.module in a wierd state when it's hardware effectively disappears on it.
AdrianTM wrote:There's no hacker in my grandma...

rlue
Posts: 13
Joined: 2017-10-30 02:04

Re: Wifi dies after resuming from suspend (i.e. wake from sl

#5 Post by rlue »

Well, that certainly sounds plausible. I don't know enough about how to examine/diagnose hardware issues in Linux to test it out, unfortunately.

In any case, installing network-manager was the way to go. Now, my wifi connection resumes almost instantaneously after resuming from suspend or hibernate — significantly faster than an ifup-ifdown cycle would be. And it has a decent cli tool, to boot (nmtui).

Post Reply