Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 378633 - restarting one interface complains that dhcpcd is already running, even if in fact it is not (race condition)?
Summary: restarting one interface complains that dhcpcd is already running, even if in...
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: netifrc Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-10 10:37 UTC by Saverio Pangoli
Modified: 2016-05-19 17:19 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Saverio Pangoli 2011-08-10 10:37:32 UTC
Hi,

I upgraded to openrc, and noticed that if I restart my dhcp-assigned interfaces, start-stop-daemon complains that it failes to stop dhcpcd, and refuses to restart the interface - even if in face the process is gone, and the PID file is removed.

This is what happens:

Dhcpc is running:

 alix2 ~ # ps ax | grep dhcpc| grep eth1
 28700 ?        Ss     0:00 dhcpcd -t 0 -m 20 -b -C resolv.conf -C yp.conf -C ntp.conf -C hostname -C lookup-hostname eth1

The PID file is there, and contains the right PID:

 alix2 ~ # cat /var/run/dhcpcd-eth1.pid 
 28700

If I restart the interface, this is what I get:

 * Bringing down interface eth1
 *   Stopping dhcpcd on eth1 ...                                                                                                     [ !! ]
 *   Running postdown ...
 * Bringing up interface eth1
 *   Running preup ...
 *   dhcp ...
 *     Running dhcpcd ...
dhcpcd[1581]: dhcpcd already running on pid 28700 (/var/run/dhcpcd-eth1.pid)                                                         [ !! ]
 * ERROR: net.eth1 failed to start

But, in fact the process and PIDS are gone!

 alix2 ~ # ps ax | grep dhcpc| grep eth1

[nothing!]

 alix2 ~ # cat /var/run/dhcpcd-eth1.pid 
 cat: /var/run/dhcpcd-eth1.pid: No such file or directory

This may have something to do with the fact that I use the -b (background) option to dhcpcd.

The same thing happens if I just stop the interface:

alix2 ~ # /etc/init.d/net.eth1 stop 
 * Bringing down interface eth1
 *   Stopping dhcpcd on eth1 ...                                                                                                     [ !! ]
 *   Running postdown ...

.. again. the PID and processes are both gone:

 alix2 ~ # cat /var/run/dhcpcd-eth1.pid 
 cat: /var/run/dhcpcd-eth1.pid: No such file or directory

.. only, in this case I can start the interface again, with no problems; if I try to restart, instead, the interface stays DOWN.

If I try to use -d, this is what I get:

# /etc/init.d/net.eth1 -d stop

...skipping to the relevant section

 + eval 'opts=$dhcp_eth1'
 ++ opts=
 + '[' -z '' ']'
 + opts=
 + case " ${opts} " in
 + start-stop-daemon --stop --quiet --signal SIGTERM --pidfile /var/run/dhcpcd-eth1.pid
 + eend 1                                                                                                                              [ !! ] 
...

so it looks like start-stop-daemon returns 1, even if in fact it is working.



Reproducible: Always

Steps to Reproduce:
1. Configure a dynamic interface with these options:

 config_eth1="dhcp"
 dhcpcd_eth1="-t 0 -m 20 -b -C resolv.conf -C yp.conf -C ntp.conf -C hostname -C lookup-hostname"

2. try and restart the interface

Actual Results:  
start-stop-daemon returns an error, even if it did apparently succeed in stopping dhclient. This caused the interface script to fail.

Expected Results:  
start-stop-daemon should return 0, as it did actually stop dhclient

sys-apps/openrc-0.8.3-r1 
net-misc/dhcpcd-5.2.12
Comment 1 Roy Marples 2014-09-11 13:51:06 UTC
Maybe give start-stop-daemon more time because dhcpcd will run a script per interface AND per protocol when shutting down.

start-stop-daemon --stop --quiet --signal SIGTERM/10

Will allow 10 seconds to exit.
Comment 2 William Hubbs gentoo-dev 2016-05-19 17:19:41 UTC
I am re-assigning this to netifrc since it seems to apply more there
than to OpenRC.