]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: dhcp: check if iface has link-local address before starting dhclient6
authorJulien Fortin <julien@cumulusnetworks.com>
Thu, 1 Dec 2016 05:34:02 +0000 (06:34 +0100)
committerJulien Fortin <julien@cumulusnetworks.com>
Thu, 1 Dec 2016 05:34:02 +0000 (06:34 +0100)
Ticket: CM-13248
Reviewed By: Roopa, Kanna, Nikhil G
Testing Done: See bug

Today before starting dhclient6, we are sleeping 2 seconds we need to make sure
the configured interface is up and has a link-local address.
In some cases 2 seconds is not enough. This patch will install a retry loop
with a 10 sec timeout.
We are querying ip -6 addr show to make sure the interface is properly confi-
-gured but in the future the plan is to move this call to netlink.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
addons/dhcp.py

index f8852e3912c912cc25ee9e78619dc2e06b6e5771..af832652fae267c045b985cfec33fe9bb1621cd6 100644 (file)
@@ -5,6 +5,7 @@
 #
 
 try:
+    import re
     from ipaddr import IPNetwork
     from sets import Set
     from ifupdown.iface import *
@@ -79,8 +80,20 @@ class dhcp(moduleBase):
                 #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)
+                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:
             self.log_error(str(e), ifaceobj)