alias = calloc(1, sizeof(*alias) + strlen(name) + 1);
strcpy(alias->name, name);
alias->dev.set_state = alias_device_set_state;
+ alias->dev.hidden = true;
device_init_virtual(&alias->dev, &alias_device_type, NULL);
alias->avl.key = alias->name;
avl_insert(&aliases, &alias->avl);
device_remove_user(&alias->dep);
strcpy(alias->dev.ifname, dev->ifname);
device_add_user(&alias->dep, dev);
+ alias->dev.hidden = false;
+ device_broadcast_event(&alias->dev, DEV_EVENT_UPDATE_IFNAME);
}
}
device_set_present(&alias->dev, !!dev);
- if (!dev && alias->dep.dev && !alias->dep.dev->active)
+ if (!dev && alias->dep.dev && !alias->dep.dev->active) {
device_remove_user(&alias->dep);
+ alias->dev.hidden = true;
+ alias->dev.ifname[0] = 0;
+ device_broadcast_event(&alias->dev, DEV_EVENT_UPDATE_IFNAME);
+ }
device_unlock();
}
DEV_EVENT_ADD,
DEV_EVENT_REMOVE,
+ DEV_EVENT_UPDATE_IFNAME,
+
DEV_EVENT_SETUP,
DEV_EVENT_TEARDOWN,
DEV_EVENT_UP,
bool sys_present;
bool present;
int active;
+
bool external;
bool disabled;
bool deferred;
+ bool hidden;
bool current_config;
bool default_config;
blobmsg_add_string(&b, "proto", iface->proto_handler->name);
dev = iface->main_dev.dev;
- if (dev && !(iface->proto_handler->flags & PROTO_FLAG_NODEV))
+ if (dev && !dev->hidden &&
+ !(iface->proto_handler->flags & PROTO_FLAG_NODEV))
blobmsg_add_string(&b, "device", dev->ifname);
if (iface->state == IFS_UP) {
return ret;
}
+static void vlan_dev_set_name(struct vlan_device *vldev, struct device *dev)
+{
+ vldev->dev.hidden = dev->hidden;
+ snprintf(vldev->dev.ifname, IFNAMSIZ, "%s.%d", dev->ifname, vldev->id);
+}
+
static void vlan_dev_cb(struct device_user *dep, enum device_event ev)
{
struct vlan_device *vldev;
case DEV_EVENT_REMOVE:
device_set_present(&vldev->dev, false);
break;
+ case DEV_EVENT_UPDATE_IFNAME:
+ vlan_dev_set_name(vldev, dep->dev);
+ device_broadcast_event(&vldev->dev, ev);
+ break;
default:
break;
}
return NULL;
vldev = calloc(1, sizeof(*vldev));
- snprintf(vldev->dev.ifname, IFNAMSIZ, "%s.%d", dev->ifname, id);
device_init_virtual(&vldev->dev, &vlan_type, NULL);
vldev->dev.default_config = true;
vldev->dev.set_state = vlan_set_device_state;
vldev->id = id;
+ vlan_dev_set_name(vldev, dev);
vldev->dep.cb = vlan_dev_cb;
device_add_user(&vldev->dep, dev);