dhcpcd-discuss

Terminating 'dhcpcd' From a Hook Script

David Hauck

Wed Jun 14 23:04:58 2017

Hi Roy,

I've been trying to determine whether there's a way to terminate the running dhcpcd process from a hook script :). Yes, scary, I know. However I'm running into a bit of a predicament. When our targets (running 'dhcpcd') recognize a specific vendor option in the response to the initial DISCOVER sequence it performs some network related configuration. Specifically, it changes the OS network configuration file (/etc/network/interfaces) to include the static addressing information received along with the vendor option. It thereby effectively switches out of DHCP mode and into a static configuration. This is done in the hook script as part of the BOUND reason. The idea here is that DHCP with this vendor option can be use as a one-shot network configuration sequence (negotiate with DHCP once and transition to a static OSL configuration with the negotiated DHCP addressing information).

The problem currently is that 'dhcpcd' continues to run in this case [ and now even though the OS's configuration indicates a static configuration]. This can cause problems since 'dhcpcd' is still running at this point and it may get triggered for any number of reasons (CARRIER lost, lease timed out, etc.). Each of these events becomes insignificant once the hook script has transitioned the OS configuration (from DHCP) to the static addressing configuration. So I'd like to prevent 'dhcpcd' from running.

I happen to know that the BOUND event is a terminating event in the 'dhcpcd' state machine. In this case, once the hook scripts complete, 'dhcpcd' is daemonized. Is there any way to signal back from the hook scripts (via exit codes) in order to prevent this daemonization and to also not stop the interface the 'dhcpcd' instance is currently operating on? I mention this last part because I thought I could send a signal to the process to stop it, and I can, however, these signals seem to always result in a call to "stop_all_interfaces", which ends up de-configuring the interface (I'd like to prevent this).

Thoughts?

Thanks,
-David

PS: I'm currently using v6.11.5.

Follow-Ups:
Re: Terminating 'dhcpcd' From a Hook ScriptRoy Marples
Archive administrator: postmaster@marples.name