From: Hans Dedecker Date: Fri, 23 Sep 2016 13:08:23 +0000 (+0200) Subject: device: Drop device down event during device release if device gets active again X-Git-Url: http://git.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=2bf80ba8c5ab4d01c6e8eb1b7ecebefea7f2d530;hp=e2dfdffad514acf4f6a55f4608802421b55be236 device: Drop device down event during device release if device gets active again 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 --- 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); }