clear errors before attempting to bring up an interface
[project/netifd.git] / interface.c
index 0a85e6f..9d6a7c1 100644 (file)
@@ -115,7 +115,6 @@ __interface_set_up(struct interface *iface)
        }
 
        return 0;
-
 }
 
 static void
@@ -240,6 +239,7 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
                if (iface->state != IFS_SETUP)
                        return;
 
+               system_flush_routes();
                iface->state = IFS_UP;
                iface->start_time = system_get_rtime();
                interface_event(iface, IFEV_UP);
@@ -249,6 +249,7 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve
                if (iface->state == IFS_DOWN)
                        return;
 
+               system_flush_routes();
                mark_interface_down(iface);
                interface_handle_config_change(iface);
                if (iface->autostart)
@@ -361,14 +362,15 @@ interface_set_up(struct interface *iface)
 {
        iface->autostart = true;
 
+       if (iface->state != IFS_DOWN)
+               return 0;
+
+       interface_clear_errors(iface);
        if (!iface->available) {
                interface_add_error(iface, "interface", "NO_DEVICE", NULL, 0);
                return -1;
        }
 
-       if (iface->state != IFS_DOWN)
-               return 0;
-
        return __interface_set_up(iface);
 }