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

Kernels & Hardware, configuring network, installing services

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

Postby rlue » 2017-10-30 02:26

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?
rlue
 
Posts: 13
Joined: 2017-10-30 02:04

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

Postby Head_on_a_Stick » 2017-10-30 06:24

Use https://unix.stackexchange.com/question ... -at-resume to run `ifup wlx74da38cfaa36` (what a memorable interface name that is) after resuming, perhaps?
"Only the mediocre are always at their best." — Jean Giraudoux
User avatar
Head_on_a_Stick
 
Posts: 6669
Joined: 2014-06-01 17:46
Location: /dev/chair

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

Postby rlue » 2017-10-31 02:17

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.
rlue
 
Posts: 13
Joined: 2017-10-30 02:04

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

Postby dilberts_left_nut » 2017-10-31 04:40

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...
User avatar
dilberts_left_nut
 
Posts: 4687
Joined: 2009-10-05 07:54
Location: enzed

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

Postby rlue » 2017-10-31 07:14

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).
rlue
 
Posts: 13
Joined: 2017-10-30 02:04


Return to System configuration

Who is online

Users browsing this forum: No registered users and 8 guests

fashionable