]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
Policy to wait for IPv6 link local address to be available
authorRajendra Dendukuri <rajendra.dendukuri@broadcom.com>
Wed, 29 May 2019 14:25:29 +0000 (10:25 -0400)
committerRajendra Dendukuri <rajendra.dendukuri@broadcom.com>
Sat, 1 Jun 2019 13:44:04 +0000 (09:44 -0400)
Add a ifupdown2 policy attribute to allow user to tune the wait time to be
allowed before the dhclient can be started on an IPv6 enabled interface.

ifupdown2/addons/dhcp.py

index 09251a9ca3fc1bc0febb46b301aaafab7d024592..c3c125ca1d79749c3f187b8550ecacef5ba82570 100644 (file)
@@ -61,6 +61,14 @@ class dhcp(moduleBase):
             dhcp_wait = policymanager.policymanager_api.get_attr_default(
                 module_name=self.__class__.__name__, attr='dhcp-wait')
             wait = not str(dhcp_wait).lower() == "no"
+            inet6_ll_wait = policymanager.policymanager_api.get_iface_default(module_name=self.__class__.__name__, \
+                ifname=ifaceobj.name, attr='inet6-ll-wait')
+            try:
+                ll_wait_time = int(inet6_ll_wait)
+            except:
+                ll_wait_time = 10
+                pass
+
             vrf = ifaceobj.get_attr_value_first('vrf')
             if (vrf and self.vrf_exec_cmd_prefix and
                 self.ipcmd.link_exists(vrf)):
@@ -100,10 +108,13 @@ class dhcp(moduleBase):
                             pass
                     #add delay before starting IPv6 dhclient to
                     #make sure the configured interface/link is up.
-                    time.sleep(2)
-                    timeout = 10
+                    if ll_wait_time:
+                       timeout = ll_wait_time
+                       time.sleep(1)
+                    else:
+                       timeout = ll_wait_time+1
+
                     while timeout:
-                        timeout -= 2
                         addr_output = utils.exec_command('%s -6 addr show %s'
                                                          %(utils.ip_cmd, ifaceobj.name))
                         r = re.search('inet6 .* scope link', addr_output)
@@ -112,7 +123,9 @@ class dhcp(moduleBase):
                                                     wait=wait,
                                                     cmd_prefix=dhclient_cmd_prefix)
                             return
-                        time.sleep(2)
+                        timeout -= 1
+                        if timeout:
+                            time.sleep(1)
 
         except Exception, e:
             self.log_error(str(e), ifaceobj)