interface: extend interface error messages in interface_set_up()
authorHans Dedecker <dedeckeh@gmail.com>
Mon, 20 Aug 2018 11:53:17 +0000 (13:53 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Mon, 20 Aug 2018 12:12:27 +0000 (14:12 +0200)
Don't return an error code in interface_set_up as it's ignored anyway by the
calling functions; but rather add more interface error messages so the actual
problem is visible for the user by doing ifstatus <interface>

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
interface.c
interface.h

index 6be10e279b4dc8e16b2d98fa328efbc8ca408ac4..e143095d3d4b5688c0aad84cedb999e76f726e79 100644 (file)
@@ -1047,31 +1047,35 @@ out:
        return ret;
 }
 
-int
+void
 interface_set_up(struct interface *iface)
 {
        int ret;
+       const char *error = NULL;
 
        iface->autostart = true;
 
        if (iface->state != IFS_DOWN)
-               return 0;
+               return;
 
        interface_clear_errors(iface);
-       if (!iface->available) {
-               interface_add_error(iface, "interface", "NO_DEVICE", NULL, 0);
-               return -1;
-       }
-
-       if (iface->main_dev.dev) {
-               ret = device_claim(&iface->main_dev);
-               if (!ret)
-                       interface_check_state(iface);
-       }
-       else
-               ret = __interface_set_up(iface);
+       if (iface->available) {
+               if (iface->main_dev.dev) {
+                       ret = device_claim(&iface->main_dev);
+                       if (!ret)
+                               interface_check_state(iface);
+                       else
+                               error = "DEVICE_CLAIM_FAILED";
+               } else {
+                       ret = __interface_set_up(iface);
+                       if (ret)
+                               error = "SETUP_FAILED";
+               }
+       } else
+               error = "NO_DEVICE";
 
-       return ret;
+       if (error)
+               interface_add_error(iface, "interface", error, NULL, 0);
 }
 
 int
index e5639eb326cd425e18d277c67ba983ecbeb68d85..2b8b3b6ee52942d784f7ca0c250c0aecc14804f0 100644 (file)
@@ -184,7 +184,7 @@ bool interface_add_alias(struct interface *iface, struct blob_attr *config);
 void interface_set_proto_state(struct interface *iface, struct interface_proto_state *state);
 
 void interface_set_available(struct interface *iface, bool new_state);
-int interface_set_up(struct interface *iface);
+void interface_set_up(struct interface *iface);
 int interface_set_down(struct interface *iface);
 void __interface_set_down(struct interface *iface, bool force);
 int interface_renew(struct interface *iface);