All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] alfred: add more verbose error message
@ 2024-09-10  3:43 noahbpeterson1997
  2024-09-10  8:39 ` Sven Eckelmann
  0 siblings, 1 reply; 2+ messages in thread
From: noahbpeterson1997 @ 2024-09-10  3:43 UTC (permalink / raw)
  To: b.a.t.m.a.n

There is an issue with some Linux distributions where network interfaces are up and
active, but do not have the correct link-local address. This condition is now checked and
output to stderr to help better users troubleshoot this issue.

Signed-off-by: Noah Peterson noahbpeterson1997@gmail.com
---
netsock.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/netsock.c b/netsock.c
index feed21d..a3101df 100644
--- a/netsock.c
+++ b/netsock.c
@@ -21,6 +21,7 @@
 #include <sys/types.h>
 #include <stdlib.h>
 #include <sys/epoll.h>
+#include <arpa/inet.h>
 #ifdef CONFIG_ALFRED_CAPABILITIES
 #include <sys/capability.h>
 #endif
@@ -321,8 +322,19 @@ static int netsock_open(struct globals *globals, struct interface *interface)
 	}
 	enable_raw_bind_capability(0);
 
+
 	if (bind(sock, (struct sockaddr *)&sin6, sizeof(sin6)) < 0) {
-		perror("can't bind");
+		char ipstr_buf[INET6_ADDRSTRLEN];
+		const char *ipstr;
+		ipstr = inet_ntop(AF_INET6, &interface->address.ipv6.s6_addr,
+					ipstr_buf, INET6_ADDRSTRLEN);
+		if (errno == EADDRNOTAVAIL)
+			fprintf(stderr, "can't bind to interface %s; "
+				"expected ipv6 address not found: %s\n",
+				interface->interface,
+				ipstr);
+		else
+			perror("can't bind");
 		goto err;
 	}

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-10  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-10  3:43 [PATCH v2] alfred: add more verbose error message noahbpeterson1997
2024-09-10  8:39 ` Sven Eckelmann

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.