From d0efa7d5f35cfb862c7004ae37ade3397cadd24c Mon Sep 17 00:00:00 2001 From: Adrien Banlin Date: Mon, 2 May 2022 12:24:58 +0200 Subject: [PATCH] dhcp: fix dhclient client killed on no wait When a policy dhcp-wait is false the dhcp client is run directly in background. But, in most cases, the client won't have the time to find an address before a check occur. This is making the client being killed nearly every time. The obvious solution here is to not check ips differences when no-wait is asked by the policy. --- ifupdown2/addons/dhcp.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ifupdown2/addons/dhcp.py b/ifupdown2/addons/dhcp.py index e65037a..26f852e 100644 --- a/ifupdown2/addons/dhcp.py +++ b/ifupdown2/addons/dhcp.py @@ -96,12 +96,16 @@ class dhcp(Addon, moduleBase): pass return ips - def dhclient_start_and_check(self, ifname, family, handler, **handler_kwargs): + def dhclient_start_and_check(self, ifname, family, handler, wait=True, **handler_kwargs): ip_config_before = self.get_current_ip_configured(ifname, family) retry = self.dhclient_retry_on_failure while retry >= 0: - handler(ifname, **handler_kwargs) + handler(ifname, wait=wait, **handler_kwargs) + if not wait: + # In most case, the client won't have the time to find anything + # with the wait=False param. + return retry = self.dhclient_check(ifname, family, ip_config_before, retry, handler_kwargs.get("cmd_prefix")) def dhclient_check(self, ifname, family, ip_config_before, retry, dhclient_cmd_prefix):