1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

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.
This commit is contained in:
Adrien Banlin
2022-05-02 12:24:58 +02:00
parent bb29085200
commit d0efa7d5f3

View File

@ -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):