projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use calloc_a for interface error allocations
[project/netifd.git]
/
device.c
diff --git
a/device.c
b/device.c
index
f0361d9
..
97fb27f
100644
(file)
--- a/
device.c
+++ b/
device.c
@@
-389,6
+389,17
@@
void device_set_present(struct device *dev, bool state)
device_refresh_present(dev);
}
device_refresh_present(dev);
}
+static int device_refcount(struct device *dev)
+{
+ struct list_head *list;
+ int count = 0;
+
+ list_for_each(list, &dev->users)
+ count++;
+
+ return count;
+}
+
void device_add_user(struct device_user *dep, struct device *dev)
{
struct list_head *head;
void device_add_user(struct device_user *dep, struct device *dev)
{
struct list_head *head;
@@
-406,6
+417,7
@@
void device_add_user(struct device_user *dep, struct device *dev)
else
head = &dev->users;
list_add_tail(&dep->list, head);
else
head = &dev->users;
list_add_tail(&dep->list, head);
+ D(DEVICE, "Add user for device '%s', refcount=%d\n", dev->ifname, device_refcount(dev));
if (dep->cb && dev->present) {
dep->cb(dep, DEV_EVENT_ADD);
if (dep->cb && dev->present) {
dep->cb(dep, DEV_EVENT_ADD);
@@
-446,6
+458,7
@@
void device_remove_user(struct device_user *dep)
list_del(&dep->list);
dep->dev = NULL;
list_del(&dep->list);
dep->dev = NULL;
+ D(DEVICE, "Remove user for device '%s', refcount=%d\n", dev->ifname, device_refcount(dev));
__device_free_unused(dev);
}
__device_free_unused(dev);
}
@@
-571,6
+584,10
@@
device_create(const char *name, const struct device_type *type,
if (odev) {
odev->current_config = true;
change = device_set_config(odev, type, config);
if (odev) {
odev->current_config = true;
change = device_set_config(odev, type, config);
+ if (odev->external) {
+ system_if_apply_settings(odev, &odev->settings);
+ change = DEV_CONFIG_APPLIED;
+ }
switch (change) {
case DEV_CONFIG_RESTART:
case DEV_CONFIG_APPLIED:
switch (change) {
case DEV_CONFIG_RESTART:
case DEV_CONFIG_APPLIED:
@@
-645,7
+662,7
@@
device_dump_status(struct blob_buf *b, struct device *dev)
if (st.flags & DEV_OPT_MTU)
blobmsg_add_u32(b, "mtu", st.mtu);
if (st.flags & DEV_OPT_MACADDR)
if (st.flags & DEV_OPT_MTU)
blobmsg_add_u32(b, "mtu", st.mtu);
if (st.flags & DEV_OPT_MACADDR)
- blobmsg_add_string(b, "macaddr",
ether_ntoa((struct ether_addr *)
st.macaddr));
+ blobmsg_add_string(b, "macaddr",
format_macaddr(
st.macaddr));
if (st.flags & DEV_OPT_TXQUEUELEN)
blobmsg_add_u32(b, "txqueuelen", st.txqueuelen);
}
if (st.flags & DEV_OPT_TXQUEUELEN)
blobmsg_add_u32(b, "txqueuelen", st.txqueuelen);
}