The add/del loop skips a non-existent interface name with a plain continue
and returns a success when no other error class was detected. Which causes
scripts (depending on the return value) to miss the problem.

Remember that a name could not be resolved and return EXIT_FAILURE at
the end, while still processing the remaining interfaces.

Signed-off-by: Sven Eckelmann <[email protected]>
---
 interface.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/interface.c b/interface.c
index c734eda..03f2e45 100644
--- a/interface.c
+++ b/interface.c
@@ -405,6 +405,7 @@ static int set_master_interface(const char *iface, unsigned 
int ifmaster)
 static int interface(struct state *state, int argc, char **argv)
 {
        struct interface_create_params create_params = {};
+       bool iface_error = false;
        bool manual_mode = false;
        unsigned int ifmaster;
        unsigned int ifindex;
@@ -532,6 +533,7 @@ static int interface(struct state *state, int argc, char 
**argv)
 
                if (!ifindex) {
                        fprintf(stderr, "Error - interface does not exist: 
%s\n", rest_argv[i]);
+                       iface_error = true;
                        continue;
                }
 
@@ -562,6 +564,9 @@ static int interface(struct state *state, int argc, char 
**argv)
                                state->mesh_iface, state->mesh_iface);
        }
 
+       if (iface_error)
+               return EXIT_FAILURE;
+
        return EXIT_SUCCESS;
 
 err:

-- 
2.47.3

Reply via email to