Skip to content

Commit 46928f6

Browse files
Add a "no" config knob for dhcp6-ll-wait
In scenarios where we need to start dhcp6 on several interfaces at once, the mandatory 1 second sleep can add an unacceptable amount of wait time. If an operator guarantees that a link local address for a given interface will exist before we try to start dhcp6, then the wait is not necessary. Add handling for passing "no" as a value to dhcp6-ll-wait (similar to what is done for the "dhcp-wait" knob), and skip the link-local addr check when this knob is configured.
1 parent 164248f commit 46928f6

1 file changed

Lines changed: 17 additions & 14 deletions

File tree

ifupdown2/addons/dhcp.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,16 @@ def _up(self, ifaceobj):
161161
wait = str(dhcp_wait).lower() != "no"
162162
dhcp6_ll_wait = policymanager.policymanager_api.get_iface_default(module_name=self.__class__.__name__, \
163163
ifname=ifaceobj.name, attr='dhcp6-ll-wait')
164-
try:
165-
timeout = int(dhcp6_ll_wait)+1
166-
except Exception:
167-
timeout = 10
164+
timeout = 10
165+
start_dhcp6 = False
166+
if str(dhcp6_ll_wait).lower() == "no":
167+
timeout = 0
168+
start_dhcp6 = True
169+
else:
170+
try:
171+
timeout = int(dhcp6_ll_wait)+1
172+
except Exception:
173+
pass
168174
dhcp6_duid = policymanager.policymanager_api.get_iface_default(module_name=self.__class__.__name__, \
169175
ifname=ifaceobj.name, attr='dhcp6-duid')
170176
vrf = ifaceobj.get_attr_value_first('vrf')
@@ -218,22 +224,19 @@ def _up(self, ifaceobj):
218224
self.dhclientcmd.stop6(ifaceobj.name, duid=dhcp6_duid)
219225
except Exception:
220226
pass
221-
#add delay before starting IPv6 dhclient to
222-
#make sure the configured interface/link is up.
223-
if timeout > 1:
224-
time.sleep(1)
225227
while timeout:
226228
addr_output = utils.exec_command('%s -6 addr show %s'
227229
%(utils.ip_cmd, ifaceobj.name))
228230
r = re.search('inet6 .* scope link', addr_output)
229231
if r:
230-
self.dhclientcmd.start6(ifaceobj.name,
231-
wait=wait,
232-
cmd_prefix=dhclient_cmd_prefix, duid=dhcp6_duid)
233-
return
232+
start_dhcp6 = True
233+
break
234+
time.sleep(1)
234235
timeout -= 1
235-
if timeout:
236-
time.sleep(1)
236+
if start_dhcp6:
237+
self.dhclientcmd.start6(ifaceobj.name,
238+
wait=wait,
239+
cmd_prefix=dhclient_cmd_prefix, duid=dhcp6_duid)
237240
except Exception as e:
238241
self.logger.error("%s: %s" % (ifaceobj.name, str(e)))
239242
ifaceobj.set_status(ifaceStatus.ERROR)

0 commit comments

Comments
 (0)