All of 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 5/6] alfred: Report failure when the client refuses to change interfaces
Date: Fri, 31 Jul 2026 13:44:54 +0200	[thread overview]
Message-ID: <20260731-bugfixes-interfaces-v1-5-a148ca2f6688@narfation.org> (raw)
In-Reply-To: <20260731-bugfixes-interfaces-v1-0-a148ca2f6688@narfation.org>

alfred_client_change_interface() and alfred_client_change_bat_iface() open
the connection to the daemon and then an interface that fails the local
checks printed a warning but returned 0. That reported success to the
caller even though nothing was changed and left the connected unix socket
open.

Close the socket and return -1 on these paths so the exit status
reflects that the requested change was rejected.

Fixes: babd772a36e1 ("alfred: support for changing interfaces")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 client.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/client.c b/client.c
index f56042a..d25e3bb 100644
--- a/client.c
+++ b/client.c
@@ -265,7 +265,8 @@ int alfred_client_change_interface(struct globals *globals)
 	if (interface_len >= sizeof(change_interface.ifaces)) {
 		fprintf(stderr, "%s: interface name list too long, not changing\n",
 			__func__);
-		return 0;
+		unix_sock_close(globals);
+		return -1;
 	}
 
 	len = sizeof(change_interface);
@@ -286,8 +287,10 @@ int alfred_client_change_interface(struct globals *globals)
 		input = NULL;
 
 		ret = check_interface(token);
-		if (ret < 0)
-			return 0;
+		if (ret < 0) {
+			unix_sock_close(globals);
+			return -1;
+		}
 	}
 
 	ret = write(globals->unix_sock, &change_interface, len);
@@ -314,7 +317,8 @@ int alfred_client_change_bat_iface(struct globals *globals)
 	if (interface_len >= sizeof(change_bat_iface.bat_iface)) {
 		fprintf(stderr, "%s: batman-adv interface name list too long, not changing\n",
 			__func__);
-		return 0;
+		unix_sock_close(globals);
+		return -1;
 	}
 
 	len = sizeof(change_bat_iface);

-- 
2.47.3


  parent reply	other threads:[~2026-07-31 11:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 11:44 [PATCH 0/6] alfred: interfaces: random fixes Sven Eckelmann
2026-07-31 11:44 ` [PATCH 1/6] alfred: fix off-by-one in client interface name length checks Sven Eckelmann
2026-07-31 11:44 ` [PATCH 2/6] alfred: update stored interface list on interface change Sven Eckelmann
2026-07-31 11:44 ` [PATCH 3/6] alfred: don't drop the mesh interface name on OOM Sven Eckelmann
2026-07-31 11:44 ` [PATCH 4/6] alfred: keep the running interfaces when reconfiguration fails Sven Eckelmann
2026-07-31 11:44 ` Sven Eckelmann [this message]
2026-07-31 11:44 ` [PATCH 6/6] alfred: don't check the "none" on network interface change Sven Eckelmann

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=20260731-bugfixes-interfaces-v1-5-a148ca2f6688@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.