mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons: address: add a settle dad method
_settle_dad will allow ifupdown2 to wait on ipv6 dad tentative.
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#
|
||||
|
||||
import socket
|
||||
import json
|
||||
import time
|
||||
|
||||
try:
|
||||
from ifupdown2.lib.addon import AddonWithIpBlackList
|
||||
@@ -1054,6 +1056,27 @@ class address(AddonWithIpBlackList, moduleBase):
|
||||
except Exception as e:
|
||||
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
|
||||
|
||||
def _settle_dad(self, ifaceobj, ip, attr):
|
||||
def ip_addr_list(what):
|
||||
return json.loads(utils.exec_commandl([
|
||||
'ip', '-j', '-o', '-6', 'address', 'list', 'dev',
|
||||
ifaceobj.name, 'to', str(ip), what
|
||||
]))
|
||||
|
||||
interval = float(attr.get('dad-interval', '0.1')) # 0.1: ifupdown default value
|
||||
attempts = int(attr.get('dad-attempts', '60')) # 60: ifupdown default value
|
||||
if ip.version == 4 or attempts == 0:
|
||||
return
|
||||
for _attempt in range(0, attempts):
|
||||
if not ip_addr_list('tentative'):
|
||||
break
|
||||
time.sleep(interval)
|
||||
else:
|
||||
self.logger.warning('address: %s: dad timeout %s', ifaceobj.name, ip)
|
||||
return
|
||||
if ip_addr_list('dadfailed'):
|
||||
self.logger.warning('address: %s: dad failure %s', ifaceobj.name, ip)
|
||||
|
||||
def _up(self, ifaceobj, ifaceobj_getfunc=None):
|
||||
gateways = ifaceobj.get_attr_value('gateway')
|
||||
if not gateways:
|
||||
|
Reference in New Issue
Block a user