Skip to content

Commit

Permalink
Wait on tentative v6 link-local addrs before DHCP (#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
hopkiw authored Nov 12, 2019
1 parent 880daf9 commit ac3db2a
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import os
import subprocess
import time


def CallDhclient(
Expand Down Expand Up @@ -68,6 +69,23 @@ def CallDhclientIpv6(interfaces, logger, dhclient_script=None,
interfaces)
return

# Check for a 'tentative' IPv6 address which would prevent `dhclient -6` from
# succeeding below. This should only take 1 second, but we try for up to 5.
command = ['ip', '-6', '-o', 'a', 's', 'dev', interfaces[0], 'scope',
'link', 'tentative']
for i in range(5):
output = ''
try:
output = subprocess.check_output(command)
except subprocess.CalledProcessError as e:
logger.warning('Could not confirm tentative IPv6 address: %s.', e.output)
if output:
logger.info('Found tentative ipv6 link address %s, sleeping 1 second.',
output.strip())
time.sleep(1)
else:
break

if dhclient_script and os.path.exists(dhclient_script):
dhclient_command += ['-sf', dhclient_script]

Expand Down

0 comments on commit ac3db2a

Please sign in to comment.