B.A.T.M.A.N Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: Sven Eckelmann <sven@narfation.org>
Subject: [PATCH 2/2] batctl: interface: return fail for non-existing interface
Date: Sun, 05 Jul 2026 15:04:27 +0200	[thread overview]
Message-ID: <20260705-bugfixes-interface-v1-2-64743906b3d4@narfation.org> (raw)
In-Reply-To: <20260705-bugfixes-interface-v1-0-64743906b3d4@narfation.org>

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 <sven@narfation.org>
---
 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


      parent reply	other threads:[~2026-07-05 13:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-05 13:04 [PATCH 0/2] batctl: interface bugfixes Sven Eckelmann
2026-07-05 13:04 ` [PATCH 1/2] batctl: interface: report rtnl query failures Sven Eckelmann
2026-07-05 13:04 ` Sven Eckelmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260705-bugfixes-interface-v1-2-64743906b3d4@narfation.org \
    --to=sven@narfation.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox