Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 582484 - net-misc/dhcpcd: provide systemd service which delays network-online.target
Summary: net-misc/dhcpcd: provide systemd service which delays network-online.target
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-08 22:23 UTC by quazgar
Modified: 2019-06-08 07:12 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
proposed patch (0001-net-misc-dhcpcd-make-dhcpcd.service-block-until-a-le.patch,1019 bytes, patch)
2016-05-10 01:49 UTC, Mike Gilbert
Details | Diff
new dhcpcd-waitip service (dhcpcd-waitip.service,230 bytes, text/plain)
2016-05-10 01:53 UTC, Mike Gilbert
Details

Note You need to log in before you can comment on or make changes to this bug.
Description quazgar 2016-05-08 22:23:03 UTC
I found that mounting NFS shares (via systemd's target remote-fs.target) at boot time does not work, because the network (probably more specifically, the Network Manager) is not ready yet.  These are the relevant log lines:

...
May 08 23:41:01 droggelbecher dhcpcd[2268]: dev: loaded udev
May 08 23:41:01 droggelbecher systemd[1]: Network Manager is not active.
May 08 23:41:01 droggelbecher systemd[1]: Dependency failed for Network Manager Wait Online.
May 08 23:41:01 droggelbecher systemd[1]: NetworkManager-wait-online.service: Job NetworkManager-wait-online.service/start failed with result 'dependency'.
May 08 23:41:01 droggelbecher systemd[1]: Reached target Network.
May 08 23:41:01 droggelbecher systemd[1]: Started Privoxy Web Proxy With Advanced Filtering Capabilities.
May 08 23:41:01 droggelbecher systemd[1]: Starting CUPS Scheduler...
May 08 23:41:01 droggelbecher systemd[1]: Starting OpenSSH server daemon...
May 08 23:41:01 droggelbecher systemd[1]: Reached target Network is Online.
May 08 23:41:01 droggelbecher systemd[1]: Mounting /media/backup...
...
May 08 23:41:01 droggelbecher mount[2282]: mount.nfs: Failed to resolve server colossus: Temporary failure in name resolution
...
May 08 23:41:01 droggelbecher systemd[1]: media-backup.mount: Mount process exited, code=exited status=32
May 08 23:41:01 droggelbecher systemd[1]: Failed to mount /media/backup.
May 08 23:41:01 droggelbecher systemd[1]: Dependency failed for Remote File Systems.
May 08 23:41:01 droggelbecher systemd[1]: remote-fs.target: Job remote-fs.target/start failed with result 'dependency'.
...

Manually mounting the shares after logging in with "systemctl restart remote-fs.target" works flawlessly.
Comment 1 Mike Gilbert gentoo-dev 2016-05-09 00:27:56 UTC
What are you using to configure your network interfaces?

I see references to both dhcpcd and Network Manager in that log, but I'm guessing you don't have Network Manager enabled.
Comment 2 quazgar 2016-05-09 20:18:55 UTC
(In reply to Mike Gilbert from comment #1)
> What are you using to configure your network interfaces?
> 
> I see references to both dhcpcd and Network Manager in that log, but I'm
> guessing you don't have Network Manager enabled.

Uh, I don't remember the setup when installing this machine, but from the systemctl status output, I guess that it's only dhcpcd:

# systemctl status dhcpcd.service 
● dhcpcd.service - Lightweight DHCP client daemon
   Loaded: loaded (/usr/lib64/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2016-05-09 17:54:52 CEST; 4h 10min ago
 Main PID: 2270 (dhcpcd)
   CGroup: /system.slice/dhcpcd.service
           └─2270 /sbin/dhcpcd -q --nobackground

# systemctl status "NetworkManager.service" 
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib64/systemd/system/NetworkManager.service; disabled; vendor preset: enabled)
   Active: inactive (dead)

And indeed the mounting is being attempted before the dhcpcd even gets an address:

journalctl -b 0 _SYSTEMD_UNIT=media-backup.mount _SYSTEMD_UNIT=dhcpcd.service
-- Logs begin at Sat 2015-09-12 19:08:00 CEST, end at Mon 2016-05-09 22:10:01 CEST. --
May 09 17:54:52 droggelbecher dhcpcd[2270]: dev: loaded udev
May 09 17:54:52 droggelbecher dhcpcd[2270]: no interfaces have a carrier
May 09 17:54:52 droggelbecher mount[2295]: mount.nfs: Failed to resolve server colossus: Temporary failure in name resolution
May 09 17:54:53 droggelbecher dhcpcd[2270]: enp5s0: waiting for carrier
May 09 17:54:55 droggelbecher dhcpcd[2270]: enp5s0: carrier acquired
May 09 17:54:55 droggelbecher dhcpcd[2270]: enp5s0: adding address xxxx::xxxx:xxxx:xxxx:xxxx
May 09 17:54:55 droggelbecher dhcpcd[2270]: DUID xx:xx:...:xx:xx
May 09 17:54:55 droggelbecher dhcpcd[2270]: enp5s0: IAID ...
May 09 17:54:55 droggelbecher dhcpcd[2270]: enp5s0: rebinding lease of xxx.xxx.xxx.xxx
May 09 17:54:55 droggelbecher dhcpcd[2270]: enp5s0: probing address xxx.xxx.xxx.xxx/24

Maybe adding dhcpcd as a dependency might help?  Or is there a common target which is fulfilled by any kind of available non-local network?
Comment 3 Mike Gilbert gentoo-dev 2016-05-10 01:16:01 UTC
This is a known issue with dhcpcd.service, though I cannot find an existing bug report.

dhcpcd should provide a synchronous unit with Before=network-online.target.
Comment 4 Mike Gilbert gentoo-dev 2016-05-10 01:49:42 UTC
Created attachment 433806 [details, diff]
proposed patch

Here's a patch for dhcpcd.service.
Comment 5 Mike Gilbert gentoo-dev 2016-05-10 01:53:35 UTC
Created attachment 433808 [details]
new dhcpcd-waitip service

Additonally, here's a systemd unit that calls dhcpcd -w, in case dhcpcd starts before the interfaces gain carrier.
Comment 6 quazgar 2016-05-10 16:00:53 UTC
(In reply to Mike Gilbert from comment #5)
> Additonally, here's a systemd unit that calls dhcpcd -w, in case dhcpcd
> starts before the interfaces gain carrier.

I can confirm that the first patch changes nothing (dhcpcd forks and remote-fs is started before the interfaces are completely up), but adding the -w option works for me.
Comment 7 Mike Gilbert gentoo-dev 2016-05-12 15:50:46 UTC
Comment on attachment 433808 [details]
new dhcpcd-waitip service

Discussed this with William Hubbs on IRC. We are going to go with my original patch to switch dhcpcd.service to forking mode and add Before=network-online.target.

For people that need the waitip option, that can be configured in /etc/dhcpcd.conf.
Comment 8 William Hubbs gentoo-dev 2016-05-12 16:01:46 UTC
I have made the changes to the unit but not revbumped yet because I'm
waiting a day or so for another possible bug fix.

To test these changes, just re-emerge dhcpcd then if you need the waitip
option you can configure it in /etc/dhcpcd.conf.
Comment 9 Roy Marples 2016-07-08 20:34:53 UTC
There is no need to "fix" dhcpcd here.
Instead, use dhcpcd-online from the dhcpcd-ui project - it's in portage as net-misc/dhcpcd-ui:
https://packages.gentoo.org/packages/net-misc/dhcpcd-ui

It even has a systemd unit file, just like nm-online from NetworkManager.

Maybe add a not for this to a fine manual?
Comment 10 Mike Gilbert gentoo-dev 2016-07-08 21:20:19 UTC
(In reply to Roy Marples from comment #9)

Nice, had no idea that even existed.

I think the change we made to dhcpcd.service is still valid though; forking allows systemd to detect startup problems.

It might mean that we could drop Before=network-online.target from dhcpcd.service, but that's still useful in case someone uses waitip without dhcpcd-ui installed.