device.c: use format_macaddr() helper to convert mac addresses to strings, ether_ntoa...
[project/netifd.git] / interface.c
index 036df6c..2456227 100644 (file)
@@ -170,8 +170,6 @@ interface_event(struct interface *iface, enum interface_event ev)
 static void
 interface_flush_state(struct interface *iface)
 {
-       if (iface->main_dev.dev)
-               device_release(&iface->main_dev);
        if (iface->l3_dev.dev)
                device_release(&iface->l3_dev);
        interface_data_flush(iface);
@@ -404,6 +402,8 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
 
                netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name);
                mark_interface_down(iface);
+               if (iface->main_dev.dev)
+                       device_release(&iface->main_dev);
                interface_handle_config_change(iface);
                break;
        case IFPEV_LINK_LOST:
@@ -696,6 +696,7 @@ interface_change_config(struct interface *if_old, struct interface *if_new)
        if (!if_old->config_autostart && if_new->config_autostart)
                if_old->autostart = true;
 
+       if_old->device_config = if_new->device_config;
        if_old->config_autostart = if_new->config_autostart;
        if_old->ifname = if_new->ifname;
        if_old->parent_ifname = if_new->parent_ifname;