projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
make vlan devices virtual to avoid avl tree issues with changing ifnames when bound...
[project/netifd.git]
/
device.c
diff --git
a/device.c
b/device.c
index
9dcd29a
..
017fe03
100644
(file)
--- a/
device.c
+++ b/
device.c
@@
-240,7
+240,7
@@
static void __init dev_init(void)
avl_init(&aliases, avl_strcmp, false, NULL);
}
avl_init(&aliases, avl_strcmp, false, NULL);
}
-
static
void device_broadcast_event(struct device *dev, enum device_event ev)
+void device_broadcast_event(struct device *dev, enum device_event ev)
{
struct device_user *dep, *tmp;
{
struct device_user *dep, *tmp;
@@
-346,6
+346,9
@@
void device_init_virtual(struct device *dev, const struct device_type *type, con
D(DEVICE, "Initialize device '%s'\n", dev->ifname);
INIT_LIST_HEAD(&dev->users);
dev->type = type;
D(DEVICE, "Initialize device '%s'\n", dev->ifname);
INIT_LIST_HEAD(&dev->users);
dev->type = type;
+
+ if (!dev->set_state)
+ dev->set_state = set_device_state;
}
int device_init(struct device *dev, const struct device_type *type, const char *ifname)
}
int device_init(struct device *dev, const struct device_type *type, const char *ifname)
@@
-354,9
+357,6
@@
int device_init(struct device *dev, const struct device_type *type, const char *
device_init_virtual(dev, type, ifname);
device_init_virtual(dev, type, ifname);
- if (!dev->set_state)
- dev->set_state = set_device_state;
-
dev->avl.key = dev->ifname;
ret = avl_insert(&devices, &dev->avl);
dev->avl.key = dev->ifname;
ret = avl_insert(&devices, &dev->avl);
@@
-374,6
+374,9
@@
device_create_default(const char *name, bool external)
{
struct device *dev;
{
struct device *dev;
+ if (!external && system_if_force_external(name))
+ return NULL;
+
D(DEVICE, "Create simple device '%s'\n", name);
dev = calloc(1, sizeof(*dev));
dev->external = external;
D(DEVICE, "Create simple device '%s'\n", name);
dev = calloc(1, sizeof(*dev));
dev->external = external;
@@
-452,26
+455,25
@@
static void __device_set_present(struct device *dev, bool state)
device_broadcast_event(dev, state ? DEV_EVENT_ADD : DEV_EVENT_REMOVE);
}
device_broadcast_event(dev, state ? DEV_EVENT_ADD : DEV_EVENT_REMOVE);
}
-void device_set_present(struct device *dev, bool state)
+void
+device_refresh_present(struct device *dev)
{
{
- if (dev->sys_present == state)
- return;
+ bool state = dev->sys_present;
- dev->sys_present = state;
- D(DEVICE, "%s '%s' %s present\n", dev->type->name, dev->ifname, state ? "is now" : "is no longer" );
-
- if (state && dev->disabled)
- return;
+ if (dev->disabled || dev->deferred)
+ state = false;
__device_set_present(dev, state);
}
__device_set_present(dev, state);
}
-void
-device_set_disabled(struct device *dev, bool value)
+void device_set_present(struct device *dev, bool state)
{
{
- dev->disabled = value;
- if (dev->sys_present)
- __device_set_present(dev, !value);
+ if (dev->sys_present == state)
+ return;
+
+ D(DEVICE, "%s '%s' %s present\n", dev->type->name, dev->ifname, state ? "is now" : "is no longer" );
+ dev->sys_present = state;
+ device_refresh_present(dev);
}
void device_add_user(struct device_user *dep, struct device *dev)
}
void device_add_user(struct device_user *dep, struct device *dev)