system-linux: always set the ifindex for hotplug devices on init
[project/netifd.git] / system-linux.c
index 8f46705..7a194ca 100644 (file)
@@ -611,11 +611,8 @@ void system_if_clear_state(struct device *dev)
        static char buf[256];
        char *bridge;
 
-       if (dev->external)
-               return;
-
        device_set_ifindex(dev, system_if_resolve(dev));
-       if (!dev->ifindex)
+       if (dev->external || !dev->ifindex)
                return;
 
        system_if_flags(dev->ifname, 0, IFF_UP);
@@ -1260,7 +1257,22 @@ static int system_rt(struct device *dev, struct device_route *route, int cmd)
        if (table >= 256)
                nla_put_u32(msg, RTA_TABLE, table);
 
+       if (route->flags & DEVROUTE_MTU) {
+               struct nlattr *metrics;
+
+               if (!(metrics = nla_nest_start(msg, RTA_METRICS)))
+                       goto nla_put_failure;
+
+               nla_put_u32(msg, RTAX_MTU, route->mtu);
+
+               nla_nest_end(msg, metrics);
+       }
+
        return system_rtnl_call(msg);
+
+nla_put_failure:
+       nlmsg_free(msg);
+       return -ENOMEM;
 }
 
 int system_add_route(struct device *dev, struct device_route *route)