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

addons: dhcp: stop IPv6 dhclient on ifdown and add delay before starting dhclient

Ticket: CM-11043
Reviewed By: roopa
Testing Done: used the config mentioned in bug

This patch adds a delay before starting IPv6 dhclient to
make sure the configured interface/link in up.

Also, ifdown on a IPv6 interface, this patch makes sure
that the link in up before dhcp release. Dhcp release is
done using a default lease file.

Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
This commit is contained in:
Nikhil
2016-07-15 14:21:23 -07:00
parent cb8b16acbf
commit 20fd3a0624
3 changed files with 13 additions and 4 deletions

View File

@ -13,6 +13,9 @@ try:
from ifupdownaddons.dhclient import dhclient
from ifupdownaddons.iproute2 import iproute2
import ifupdown.ifupdownflags as ifupdownflags
from ifupdown.utils import utils
import time
from ifupdown.netlink import netlink
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
@ -65,6 +68,9 @@ class dhcp(moduleBase):
self.dhclientcmd.stop6(ifaceobj.name)
except:
pass
#add delay before starting IPv6 dhclient to
#make sure the configured interface/link is up.
time.sleep(2)
self.dhclientcmd.start6(ifaceobj.name, wait=wait,
cmd_prefix=dhclient_cmd_prefix)
except Exception, e:
@ -76,7 +82,10 @@ class dhcp(moduleBase):
if (vrf and self.vrf_exec_cmd_prefix and
self.ipcmd.link_exists(vrf)):
dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix, vrf)
self.dhclientcmd.release(ifaceobj.name, dhclient_cmd_prefix)
if ifaceobj.addr_family == 'inet6':
self.dhclientcmd.release6(ifaceobj.name, dhclient_cmd_prefix)
else:
self.dhclientcmd.release(ifaceobj.name, dhclient_cmd_prefix)
self.ipcmd.link_down(ifaceobj.name)
def _query_check(self, ifaceobj, ifaceobjcurr):
@ -108,6 +117,7 @@ class dhcp(moduleBase):
_run_ops = {'up' : _up,
'down' : _down,
'pre-down' : _down,
'query-checkcurr' : _query_check,
'query-running' : _query_running }

View File

@ -19,7 +19,7 @@ post-up,vxrd
pre-down,usercmds
pre-down,ethtool
pre-down,vxrd
down,dhcp
pre-down,dhcp
down,addressvirtual
down,address
down,usercmds

View File

@ -98,7 +98,6 @@ class dhclient(utilsBase):
def release6(self, ifacename, cmd_prefix=None):
cmd = ['/sbin/dhclient', '-6', '-r', '-pf',
'/run/dhclient6.%s.pid' %ifacename, '-lf',
'/var/lib/dhcp/dhclient6.%s.leases' %ifacename,
'/run/dhclient6.%s.pid' %ifacename,
'%s' %ifacename]
self._run_dhclient_cmd(cmd, cmd_prefix)