[LEDE-DEV] [PATCH netifd 7/7] device: Drop device down event during device release if device gets active again

Hans Dedecker dedeckeh at gmail.com
Fri Sep 23 06:08:23 PDT 2016


Fixes a race condition as the device can be active again; due to a device_claim; by the logic
behind the set_state device type function. In this case the down event cannot be sent anymore
as it would bring down the interface(s) referencing the device.
This can be the case for an aliased device when the underlying device is switched during a reload;
the alias_set_device function can add a new dependency on the new active device which will put the
aliased device in active mode again as the aliased device is already claimed by the interface
using it.

Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/device.c b/device.c
index e17df13..996ffab 100644
--- a/device.c
+++ b/device.c
@@ -450,6 +450,10 @@ void device_release(struct device_user *dep)
 	device_broadcast_event(dev, DEV_EVENT_TEARDOWN);
 	if (!dev->external)
 		dev->set_state(dev, false);
+
+	if (dev->active)
+		return;
+
 	device_broadcast_event(dev, DEV_EVENT_DOWN);
 }
 
-- 
1.9.1




More information about the Lede-dev mailing list