summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-10-18 18:07:21 +0200
committerChristian Poessinger <christian@poessinger.com>2019-10-18 18:07:26 +0200
commit04c02bcd100f253832e9a57736cf0d1a9f32fc5f (patch)
tree5346fc5d6da57cd1fecbde8d42c979348c934167 /python
parentca4f0dc76f918323c69905399a2dba9b2a21a8ec (diff)
downloadvyos-1x-04c02bcd100f253832e9a57736cf0d1a9f32fc5f.tar.gz
vyos-1x-04c02bcd100f253832e9a57736cf0d1a9f32fc5f.zip
Python/ifconfig: T1712: always start DHCP when configured
DHCP was only started when the interface operstate was set to up but this is wrong. An interface can be configured as DHCP interface and DHCP client must be launched even when the physical interface becomes available n-minutes later. DHCP client then can ask for an IP assignemnt by DHCP. Tested by starting DHCP client on a not connected ethernet interface. Address was assigned later on after link became ready.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/ifconfig.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index 1ffa10978..3470b3aa6 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -521,14 +521,13 @@ class Interface:
with open(self._dhcp_cfg_file, 'w') as f:
f.write(dhcp_text)
- if self.get_state() == 'up':
- cmd = 'start-stop-daemon --start --quiet --pidfile ' + \
- self._dhcp_pid_file
- cmd += ' --exec /sbin/dhclient --'
- # now pass arguments to dhclient binary
- cmd += ' -4 -nw -cf {} -pf {} -lf {} {}'.format(
- self._dhcp_cfg_file, self._dhcp_pid_file, self._dhcp_lease_file, self._ifname)
- return self._cmd(cmd)
+ cmd = 'start-stop-daemon --start --quiet --pidfile ' + \
+ self._dhcp_pid_file
+ cmd += ' --exec /sbin/dhclient --'
+ # now pass arguments to dhclient binary
+ cmd += ' -4 -nw -cf {} -pf {} -lf {} {}'.format(
+ self._dhcp_cfg_file, self._dhcp_pid_file, self._dhcp_lease_file, self._ifname)
+ return self._cmd(cmd)
def _del_dhcp(self):