mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: dhcp: executing dhclient4 and dhclient6 ops independently
Ticket: CM-13817 Reviewed By: CCR-5408 Testing Done: steups explained in the bug Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
This commit is contained in:
@@ -38,11 +38,8 @@ class dhcp(moduleBase):
|
|||||||
|
|
||||||
def _up(self, ifaceobj):
|
def _up(self, ifaceobj):
|
||||||
# if dhclient is already running do not stop and start it
|
# if dhclient is already running do not stop and start it
|
||||||
if self.dhclientcmd.is_running(ifaceobj.name) or \
|
dhclient4_running = self.dhclientcmd.is_running(ifaceobj.name)
|
||||||
self.dhclientcmd.is_running6(ifaceobj.name):
|
dhclient6_running = self.dhclientcmd.is_running6(ifaceobj.name)
|
||||||
self.logger.info('dhclient already running on %s. Not restarting.' % \
|
|
||||||
ifaceobj.name)
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
dhclient_cmd_prefix = None
|
dhclient_cmd_prefix = None
|
||||||
dhcp_wait = policymanager.policymanager_api.get_attr_default(
|
dhcp_wait = policymanager.policymanager_api.get_attr_default(
|
||||||
@@ -54,45 +51,52 @@ class dhcp(moduleBase):
|
|||||||
dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix, vrf)
|
dhclient_cmd_prefix = '%s %s' %(self.vrf_exec_cmd_prefix, vrf)
|
||||||
|
|
||||||
if 'inet' in ifaceobj.addr_family:
|
if 'inet' in ifaceobj.addr_family:
|
||||||
# First release any existing dhclient processes
|
if dhclient4_running:
|
||||||
try:
|
self.logger.info('dhclient4 already running on %s. '
|
||||||
if not ifupdownflags.flags.PERFMODE:
|
'Not restarting.' % ifaceobj.name)
|
||||||
self.dhclientcmd.stop(ifaceobj.name)
|
else:
|
||||||
except:
|
# First release any existing dhclient processes
|
||||||
pass
|
|
||||||
self.dhclientcmd.start(ifaceobj.name, wait=wait,
|
|
||||||
cmd_prefix=dhclient_cmd_prefix)
|
|
||||||
if 'inet6' in ifaceobj.addr_family:
|
|
||||||
accept_ra = ifaceobj.get_attr_value_first('accept_ra')
|
|
||||||
if accept_ra:
|
|
||||||
# XXX: Validate value
|
|
||||||
self.sysctl_set('net.ipv6.conf.%s' %ifaceobj.name +
|
|
||||||
'.accept_ra', accept_ra)
|
|
||||||
autoconf = ifaceobj.get_attr_value_first('autoconf')
|
|
||||||
if autoconf:
|
|
||||||
# XXX: Validate value
|
|
||||||
self.sysctl_set('net.ipv6.conf.%s' %ifaceobj.name +
|
|
||||||
'.autoconf', autoconf)
|
|
||||||
try:
|
try:
|
||||||
self.dhclientcmd.stop6(ifaceobj.name)
|
if not ifupdownflags.flags.PERFMODE:
|
||||||
|
self.dhclientcmd.stop(ifaceobj.name)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
#add delay before starting IPv6 dhclient to
|
self.dhclientcmd.start(ifaceobj.name, wait=wait,
|
||||||
#make sure the configured interface/link is up.
|
cmd_prefix=dhclient_cmd_prefix)
|
||||||
time.sleep(2)
|
if 'inet6' in ifaceobj.addr_family:
|
||||||
timeout = 10
|
if dhclient6_running:
|
||||||
while timeout:
|
self.logger.info('dhclient6 already running on %s. '
|
||||||
timeout -= 2
|
'Not restarting.' % ifaceobj.name)
|
||||||
addr_output = utils.exec_command('ip -6 addr show %s'
|
else:
|
||||||
% ifaceobj.name)
|
accept_ra = ifaceobj.get_attr_value_first('accept_ra')
|
||||||
r = re.search('inet6 .* scope link', addr_output)
|
if accept_ra:
|
||||||
if r:
|
# XXX: Validate value
|
||||||
self.dhclientcmd.start6(ifaceobj.name,
|
self.sysctl_set('net.ipv6.conf.%s' %ifaceobj.name +
|
||||||
wait=wait,
|
'.accept_ra', accept_ra)
|
||||||
cmd_prefix=dhclient_cmd_prefix)
|
autoconf = ifaceobj.get_attr_value_first('autoconf')
|
||||||
return
|
if autoconf:
|
||||||
|
# XXX: Validate value
|
||||||
|
self.sysctl_set('net.ipv6.conf.%s' %ifaceobj.name +
|
||||||
|
'.autoconf', autoconf)
|
||||||
|
try:
|
||||||
|
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)
|
time.sleep(2)
|
||||||
|
timeout = 10
|
||||||
|
while timeout:
|
||||||
|
timeout -= 2
|
||||||
|
addr_output = utils.exec_command('ip -6 addr show %s'
|
||||||
|
% ifaceobj.name)
|
||||||
|
r = re.search('inet6 .* scope link', addr_output)
|
||||||
|
if r:
|
||||||
|
self.dhclientcmd.start6(ifaceobj.name,
|
||||||
|
wait=wait,
|
||||||
|
cmd_prefix=dhclient_cmd_prefix)
|
||||||
|
return
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log_error(str(e), ifaceobj)
|
self.log_error(str(e), ifaceobj)
|
||||||
|
@@ -99,5 +99,6 @@ class dhclient(utilsBase):
|
|||||||
def release6(self, ifacename, cmd_prefix=None):
|
def release6(self, ifacename, cmd_prefix=None):
|
||||||
cmd = ['/sbin/dhclient', '-6', '-r', '-pf',
|
cmd = ['/sbin/dhclient', '-6', '-r', '-pf',
|
||||||
'/run/dhclient6.%s.pid' %ifacename,
|
'/run/dhclient6.%s.pid' %ifacename,
|
||||||
|
'-lf', '/var/lib/dhcp/dhclient6.%s.leases' % ifacename,
|
||||||
'%s' %ifacename]
|
'%s' %ifacename]
|
||||||
self._run_dhclient_cmd(cmd, cmd_prefix)
|
self._run_dhclient_cmd(cmd, cmd_prefix)
|
||||||
|
Reference in New Issue
Block a user