BB: hostapd: Fix RADIUS connection recovery after initial failure (#18197)
[14.07/openwrt.git] / package / network / services / hostapd / patches / 700-fix-radius-reconnect.patch
1 From 94b39e5927e570e6b0fe41d455dde0a361c71c36 Mon Sep 17 00:00:00 2001
2 From: Jouni Malinen <j@w1.fi>
3 Date: Sat, 28 Feb 2015 11:57:57 +0000
4 Subject: RADIUS client: Fix server connection recovery after initial failure
5
6 If the initial attempt at opening the socket connection to the RADIUS
7 server failed due to missing IP connectivity during startup, e.g., with
8 "connect[radius]: Network is unreachable", hostapd did not try to
9 reconnect when RADIUS messages were sent. Instead, it only reported "No
10 authentication server configured" even if the configuration did have a
11 server entry.
12
13 This was broken by commit 9ed40766735a9628cc6c936076b175e6f66534bb
14 ('RADIUS client: Do not try to send message without socket') for the
15 initial case and the more recent fixes in RADIUS server failover cases
16 did not cover the initial failure case.
17
18 Signed-off-by: Jouni Malinen <j@w1.fi>
19
20 --- a/src/radius/radius_client.c
21 +++ b/src/radius/radius_client.c
22 @@ -658,6 +658,9 @@ int radius_client_send(struct radius_cli
23         }
24  
25         if (msg_type == RADIUS_ACCT || msg_type == RADIUS_ACCT_INTERIM) {
26 +               if (conf->acct_server && radius->acct_sock < 0)
27 +                       radius_client_init_acct(radius);
28 +
29                 if (conf->acct_server == NULL || radius->acct_sock < 0) {
30                         hostapd_logger(radius->ctx, NULL,
31                                        HOSTAPD_MODULE_RADIUS,
32 @@ -672,6 +675,9 @@ int radius_client_send(struct radius_cli
33                 s = radius->acct_sock;
34                 conf->acct_server->requests++;
35         } else {
36 +               if (conf->auth_server && radius->auth_sock < 0)
37 +                       radius_client_init_auth(radius);
38 +
39                 if (conf->auth_server == NULL || radius->auth_sock < 0) {
40                         hostapd_logger(radius->ctx, NULL,
41                                        HOSTAPD_MODULE_RADIUS,