summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2015-09-09 15:45:47 +0200
committerFelix Fietkau <nbd@openwrt.org>2015-09-10 22:49:34 +0200
commit001100fd10fb799572e21551b4f9bdad861a1b4f (patch)
treed205828fec4d5dc046eaf2e5173cdc75820e562e
parent3224b809c359107b04c067cc00e652729030c735 (diff)
device: Resolve ifindex for external claimed devices
Fixes regression issues introduced by commit 3224b80 as external (PPP) device ifindex was not in sync with kernel device ifindex due to re-creation of the device by the PPP daemon Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--device.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/device.c b/device.c
index 21b436f..a29c981 100644
--- a/device.c
+++ b/device.c
@@ -74,15 +74,14 @@ void device_unlock(void)
static int set_device_state(struct device *dev, bool state)
{
if (state) {
- /* Set ifindex for all devices being enabled so a valid */
+ /* Get ifindex for all devices being enabled so a valid */
/* ifindex is in place avoiding possible race conditions */
device_set_ifindex(dev, system_if_resolve(dev));
if (!dev->ifindex)
return -1;
- }
- if (state)
system_if_up(dev);
+ }
else
system_if_down(dev);
@@ -332,7 +331,13 @@ int device_claim(struct device_user *dep)
return 0;
device_broadcast_event(dev, DEV_EVENT_SETUP);
- if (!dev->external)
+ if (dev->external) {
+ /* Get ifindex for external claimed devices so a valid */
+ /* ifindex is in place avoiding possible race conditions */
+ device_set_ifindex(dev, system_if_resolve(dev));
+ if (!dev->ifindex)
+ ret = -1;
+ } else
ret = dev->set_state(dev, true);
if (ret == 0)