When Slave is using NetworkManager, polling is used to activate DBus connection. This may result in infinite loop (eg. when device is not in LOWER_UP state, but is in UP state). This patch adds timeout control in _poll_loop method, timeout value is set to 10s.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com --- lnst/Slave/NmConfigDevice.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/lnst/Slave/NmConfigDevice.py b/lnst/Slave/NmConfigDevice.py index 8e2f1dd..c884d70 100644 --- a/lnst/Slave/NmConfigDevice.py +++ b/lnst/Slave/NmConfigDevice.py @@ -28,6 +28,7 @@ from lnst.Common.Config import lnst_config NM_BUS = "org.freedesktop.NetworkManager" OBJ_PRE = "/org/freedesktop/NetworkManager" IF_PRE = NM_BUS +POLL_LOOP_TIMEOUT = 10
#NetworkManager constants for state values _ACON_ACTIVATED = 2 @@ -152,11 +153,15 @@ class NmConfigDeviceGeneric(object): if self._device_state == self._wait_for: self._loop.quit()
- def _poll_loop(self, func, expected_val, *args): - while True: + def _poll_loop(self, func, expected_val, timeout, *args): + timer = 0 + while timer < timeout: if func(*args) == expected_val: - break + return time.sleep(1) + timer += 1 + msg = "Timed out during NetworkManager polling." + raise Exception(msg)
def _convert_hwaddr(self, dev_config): if "hwaddr" in dev_config: @@ -276,6 +281,7 @@ class NmConfigDeviceGeneric(object): "org.freedesktop.DBus.Properties") self._poll_loop(act_con_props.Get, _ACON_ACTIVATED, + POLL_LOOP_TIMEOUT, IF_PRE + ".Connection.Active", "State")
def _nm_deactivate_connection(self): @@ -341,6 +347,7 @@ class NmConfigDeviceEth(NmConfigDeviceGeneric):
self._poll_loop(dev_props.Get, _DEV_DISCONNECTED, + POLL_LOOP_TIMEOUT, IF_PRE + ".Device", "State") else: exec_cmd("ip link set %s up" % config["name"])
On Mon, Jun 29, 2015 at 04:45:14PM +0200, Jiri Prochazka wrote:
When Slave is using NetworkManager, polling is used to activate DBus connection. This may result in infinite loop (eg. when device is not in LOWER_UP state, but is in UP state). This patch adds timeout control in _poll_loop method, timeout value is set to 10s.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com
Acked-by: Ondrej Lichtner olichtne@redhat.com
Mon, Jun 29, 2015 at 04:45:14PM CEST, jprochaz@redhat.com wrote:
When Slave is using NetworkManager, polling is used to activate DBus connection. This may result in infinite loop (eg. when device is not in LOWER_UP state, but is in UP state). This patch adds timeout control in _poll_loop method, timeout value is set to 10s.
Signed-off-by: Jiri Prochazka jprochaz@redhat.com
applied, thanks.
lnst-developers@lists.fedorahosted.org