hostapd RADIUS network error recovery

Mark Glines mark-hostap
Thu Oct 16 15:35:44 PDT 2003


Hi,

I've been having problems with hostapd's RADIUS protocol stuff if the
interface it was going through goes down and comes back up.  The
following patch makes it re-bind in this case...

Mark
-------------- next part --------------
Index: hostapd/radius_client.c
===================================================================
RCS file: /cvs/hostap/hostapd/radius_client.c,v
retrieving revision 1.4
diff -u -r1.4 radius_client.c
--- hostapd/radius_client.c	9 May 2003 21:45:55 -0000	1.4
+++ hostapd/radius_client.c	16 Oct 2003 22:32:51 -0000
@@ -18,6 +18,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
+#include <errno.h>
 
 #include "hostapd.h"
 #include "radius.h"
@@ -87,6 +88,9 @@
 }
 
 
+static int radius_client_init_acct(hostapd *hapd);
+static int radius_client_init_auth(hostapd *hapd);
+
 static int radius_client_retransmit(hostapd *hapd,
 				    struct radius_msg_list *entry, time_t now)
 {
@@ -102,8 +106,16 @@
 	HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL, "Resending RADIUS message (id=%d)"
 		      "\n", entry->msg->hdr->identifier);
 
-	if (send(s, entry->msg->buf, entry->msg->buf_used, 0) < 0)
+	if (send(s, entry->msg->buf, entry->msg->buf_used, 0) < 0) {
 		perror("send[RADIUS]");
+		if(errno == ENOTCONN) {
+			close(s);
+			if (entry->msg_type == RADIUS_ACCT)
+				radius_client_init_acct(hapd);
+			else
+				radius_client_init_auth(hapd);
+		}
+	}
 
 	entry->next_try = now + entry->next_wait;
 	entry->next_wait *= 2;
@@ -291,8 +303,16 @@
 		radius_msg_dump(msg);
 
 	res = send(s, msg->buf, msg->buf_used, 0);
-	if (res < 0)
+	if (res < 0) {
 		perror("send[RADIUS]");
+		if(errno == ENOTCONN) {
+			close(s);
+			if (msg_type == RADIUS_ACCT)
+				radius_client_init_acct(hapd);
+			else
+				radius_client_init_auth(hapd);
+		}
+	}
 
 	radius_client_list_add(hapd, msg, msg_type, shared_secret,
 			       shared_secret_len);



More information about the Hostap mailing list