mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: dhcp: release dhclient4/6 if it's still running but inet/inet6 is not configured
Ticket: CM-13817 Reviewed By: Roopa, Kanna, Nikhil G Testing Done: 1) use inet and inet6 dhcp in interfaces file 2) do a ifup -v 3) make sure dhclient v4 and v6 is running 4) now remove inet6 dhcp section 5) ifreload -a -v (should kill dhclient6) 6) replace inet by inet6 7) ifreload -a -v (should kill dhclient4 and exec dhclient6) etc.. I played with all possible combinations Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@@ -40,6 +40,13 @@ class dhcp(moduleBase):
|
||||
# if dhclient is already running do not stop and start it
|
||||
dhclient4_running = self.dhclientcmd.is_running(ifaceobj.name)
|
||||
dhclient6_running = self.dhclientcmd.is_running6(ifaceobj.name)
|
||||
|
||||
# today if we have an interface with both inet and inet6, if we
|
||||
# remove the inet or inet6 or both then execute ifreload, we need
|
||||
# to release/kill the appropriate dhclient(4/6) if they are running
|
||||
self._down_stale_dhcp_config(ifaceobj, 'inet', dhclient4_running)
|
||||
self._down_stale_dhcp_config(ifaceobj, 'inet6', dhclient6_running)
|
||||
|
||||
try:
|
||||
dhclient_cmd_prefix = None
|
||||
dhcp_wait = policymanager.policymanager_api.get_attr_default(
|
||||
@@ -101,7 +108,18 @@ class dhcp(moduleBase):
|
||||
except Exception, e:
|
||||
self.log_error(str(e), ifaceobj)
|
||||
|
||||
def _down(self, ifaceobj):
|
||||
def _down_stale_dhcp_config(self, ifaceobj, family, dhclientX_running):
|
||||
addr_family = ifaceobj.addr_family
|
||||
try:
|
||||
if not family in ifaceobj.addr_family and dhclientX_running:
|
||||
ifaceobj.addr_family = [family]
|
||||
self._dhcp_down(ifaceobj)
|
||||
except:
|
||||
pass
|
||||
finally:
|
||||
ifaceobj.addr_family = addr_family
|
||||
|
||||
def _dhcp_down(self, ifaceobj):
|
||||
dhclient_cmd_prefix = None
|
||||
vrf = ifaceobj.get_attr_value_first('vrf')
|
||||
if (vrf and self.vrf_exec_cmd_prefix and
|
||||
@@ -111,6 +129,9 @@ class dhcp(moduleBase):
|
||||
self.dhclientcmd.release6(ifaceobj.name, dhclient_cmd_prefix)
|
||||
if 'inet' in ifaceobj.addr_family:
|
||||
self.dhclientcmd.release(ifaceobj.name, dhclient_cmd_prefix)
|
||||
|
||||
def _down(self, ifaceobj):
|
||||
self._dhcp_down(ifaceobj)
|
||||
self.ipcmd.link_down(ifaceobj.name)
|
||||
|
||||
def _query_check(self, ifaceobj, ifaceobjcurr):
|
||||
|
Reference in New Issue
Block a user