You are not logged in.

#1 2017-02-20 07:37:13

gdin
Member
Registered: 2017-02-20
Posts: 8

[SOLVED] Networking fails after resume from suspend

Hi, I recently installed Arch Linux on a Dell XPS 13, and things have been going pretty well so far.

I've been using wpa_supplicant with a config and dhcpcd to connect to the internet, and I have a systemd service that runs them both upon startup. Whenever I put the laptop to sleep and then wake it back up, the internet stops working. Each time this happens, I can simply run

sudo dhcpcd wlp58s0

and it fixes, but this is rather tedious and I'm fairly confused as to what the problem is. I tried creating a systemd service that runs the command upon wakeup, but that doesn't seem to work. If it means anything, I'm running plain bspwm and I don't have any other network management tools installed (to my knowledge).
If someone could explain what's actually going on and how to solve it, that would be very appreciated!

Last edited by gdin (2017-02-20 20:20:49)

Offline

#2 2017-02-20 08:04:17

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,679
Website

Re: [SOLVED] Networking fails after resume from suspend

You should probably post the custom unit files and any relevant journal contents in full.

Offline

#3 2017-02-20 08:15:29

gdin
Member
Registered: 2017-02-20
Posts: 8

Re: [SOLVED] Networking fails after resume from suspend

Thanks for the reply!

Here's the service that starts wpa_supplicant and dhcpcd:

[Unit]
Description=Wireless Networking

[Service]
Type=oneshot
RemainAfterExit=yes

ExecStart=/usr/bin/wpa_supplicant -iwlp58s0 -c/home/rygon/.wpa_supplicant.conf -B
ExecStart=/usr/bin/dhcpcd wlp58s0

[Install]
WantedBy=multi-user.target

And the one I wrote for resuming it:

[Unit]
Description=Resume Network after Sleep
After=sleep.target

[Service]
Type=forking
RemainAfterExit=yes

ExecStart=/usr/bin/dhcpcd wlp58s0

[Install]
WantedBy=multi-user.target sleep.target

And here is the output of systemctl status wifi-resume.service:

● wifi-resume.service - Resume Network after Sleep
   Loaded: loaded (/etc/systemd/system/wifi-resume.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2017-02-20 00:35:19 EST; 2h 35min ago
  Process: 27308 ExecStart=/usr/bin/dhcpcd wlp58s0 (code=exited, status=1/FAILURE)

Feb 20 00:35:19 xps13 systemd[1]: Starting Resume Network after Sleep...
Feb 20 00:35:19 xps13 dhcpcd[27308]: dhcpcd already running on pid 3347 (/run/dhcpcd-wlp58s0.pid)
Feb 20 00:35:19 xps13 systemd[1]: wifi-resume.service: Control process exited, code=exited status=1
Feb 20 00:35:19 xps13 systemd[1]: Failed to start Resume Network after Sleep.
Feb 20 00:35:19 xps13 systemd[1]: wifi-resume.service: Unit entered failed state.
Feb 20 00:35:19 xps13 systemd[1]: wifi-resume.service: Failed with result 'exit-code'.

This is strange because it seems that the command was executed but failed because it was already running, but if I go ahead and run the command manually it works fine.

I'm not sure what you mean by journal contents.

Offline

#4 2017-02-20 16:22:55

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: [SOLVED] Networking fails after resume from suspend

gdin wrote:

I'm not sure what you mean by journal contents.

https://wiki.archlinux.org/index.php/Systemd#Journal


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#5 2017-02-20 17:18:39

seth
Member
Registered: 2012-09-03
Posts: 49,951

Re: [SOLVED] Networking fails after resume from suspend

dhcpcd already running on pid 3347 (/run/dhcpcd-wlp58s0.pid)

"dhcpcd -n", maybe  "dhcpcd -N"
Consult the manpage.

Offline

#6 2017-02-20 20:19:44

gdin
Member
Registered: 2017-02-20
Posts: 8

Re: [SOLVED] Networking fails after resume from suspend

Thank you for the replies!

I ended up solving my own problem. I edited the resume unit file slightly, adding hybrid-sleep.target and changing the ExecStart. It had been executing prior to sleep, not after, which was the main problem.

[Unit]
Description=Resume Network after Sleep
After=suspend.target
After=hybrid-sleep.target

[Service]
Type=forking
RemainAfterExit=yes

ExecStart=/home/rygon/.wifi-resume.sh

[Install]
WantedBy=suspend.target
WantedBy=hybrid-sleep.target

The ExecStart leads to a script that includes the command, as well as "sleep 1", or else the interface wouldn't be found.

#!/bin/bash

sleep 1
sudo dhcpcd wlp58s0

It was also necessary to add dhcpcd to the sudoers file, so it could be executed as root.

Marking as solved.

Last edited by gdin (2017-02-20 20:20:01)

Offline

Board footer

Powered by FluxBB