static int set_device_state(struct device *dev, bool state)
{
+ if (state) {
+ /* Set 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 (dev->external)
return 0;
goto out;
struct device *dev = device_get(nla_data(nla[IFLA_IFNAME]), false);
- if (!dev)
- goto out;
-
- device_set_ifindex(dev, ifi->ifi_index);
- if (dev->type->keep_link_status)
+ if (!dev || dev->type->keep_link_status)
goto out;
if (!system_get_dev_sysctl("/sys/class/net/%s/carrier", dev->ifname, buf, sizeof(buf)))
return system_bridge_if(bridge->ifname, dev, SIOCBRDELIF, NULL);
}
-static int system_if_resolve(struct device *dev)
+int system_if_resolve(struct device *dev)
{
struct ifreq ifr;
strncpy(ifr.ifr_name, dev->ifname, sizeof(ifr.ifr_name));
{
system_if_get_settings(dev, &dev->orig_settings);
system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
- device_set_ifindex(dev, system_if_resolve(dev));
return system_if_flags(dev->ifname, IFF_UP, 0);
}
int system_if_up(struct device *dev);
int system_if_down(struct device *dev);
int system_if_check(struct device *dev);
+int system_if_resolve(struct device *dev);
+
int system_if_dump_info(struct device *dev, struct blob_buf *b);
int system_if_dump_stats(struct device *dev, struct blob_buf *b);
struct device *system_if_get_parent(struct device *dev);