public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/2] alfred: Handle EPERM on every sendto
@ 2014-04-17 11:19 Sven Eckelmann
  2014-04-17 11:19 ` [B.A.T.M.A.N.] [PATCH 2/2] alfred: Check for changed interface properties Sven Eckelmann
  2014-05-02 11:06 ` [B.A.T.M.A.N.] [PATCH 1/2] alfred: Handle EPERM on every sendto Simon Wunderlich
  0 siblings, 2 replies; 3+ messages in thread
From: Sven Eckelmann @ 2014-04-17 11:19 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Sven Eckelmann

The announcements are currently only sent by alfred instances in master mode.
Slave instances don't announce themself and thus don't detect the broken
socket. To also catch such problems, it is useful to handle the detection of
EPERM during the send in send_alfred_packet which is always called when a
link-local UDP packet is send over the network.

Signed-off-by: Sven Eckelmann <sven@open-mesh.com>
---
 send.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/send.c b/send.c
index 89e9c07..dc0e428 100644
--- a/send.c
+++ b/send.c
@@ -32,7 +32,6 @@
 
 int announce_master(struct globals *globals)
 {
-	ssize_t ret;
 	struct alfred_announce_master_v0 announcement;
 
 	if (globals->netsock < 0)
@@ -42,14 +41,8 @@ int announce_master(struct globals *globals)
 	announcement.header.version = ALFRED_VERSION;
 	announcement.header.length = htons(0);
 
-	ret = send_alfred_packet(globals, &in6addr_localmcast, &announcement,
-				 sizeof(announcement));
-	if (ret == -EPERM) {
-		fprintf(stderr, "Error during announcement\n");
-		netsock_close(globals->netsock);
-		globals->netsock = -1;
-	}
-
+	send_alfred_packet(globals, &in6addr_localmcast, &announcement,
+			   sizeof(announcement));
 
 	return 0;
 }
@@ -176,6 +169,11 @@ ssize_t send_alfred_packet(struct globals *globals, const struct in6_addr *dest,
 	ret = sendto(globals->netsock, buf, length, 0,
 		     (struct sockaddr *)&dest_addr,
 		     sizeof(struct sockaddr_in6));
+	if (ret == -EPERM) {
+		fprintf(stderr, "Error during sent\n");
+		netsock_close(globals->netsock);
+		globals->netsock = -1;
+	}
 
 	return ret;
 }
-- 
1.9.2


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

end of thread, other threads:[~2014-05-02 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-17 11:19 [B.A.T.M.A.N.] [PATCH 1/2] alfred: Handle EPERM on every sendto Sven Eckelmann
2014-04-17 11:19 ` [B.A.T.M.A.N.] [PATCH 2/2] alfred: Check for changed interface properties Sven Eckelmann
2014-05-02 11:06 ` [B.A.T.M.A.N.] [PATCH 1/2] alfred: Handle EPERM on every sendto Simon Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox