]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd_cli: Open a new hostapd connection on ping failure when using -a
authorSai Pratyusha Magam <smagam@qti.qualcomm.com>
Sat, 2 Aug 2025 16:42:57 +0000 (22:12 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 15 Aug 2025 20:42:03 +0000 (23:42 +0300)
When hostapd_cli is started with the -a option, the process enters an
eloop. Every ping interval (five seconds) hostapd_cli sends a PING to
hostapd and waits to receive a response. In a particular issue scenario,
the hostapd_cli control interface socket file in /tmp/wpa_ctrl_xx gets
deleted due to which hostapd is no longer able respond to the PING.
hostapd_cli times out waiting for the socket to become ready for read
and terminates from eloop causing the hostapd_cli process to exit.

hostapd_cli in interactive mode handles a PING response failure by
closing the current connection and opening a new connection using
hostapd_cli_reconnect(). Adopt the same approach for the action file
case instead of terminating the process.

Signed-off-by: Sai Pratyusha Magam <smagam@qti.qualcomm.com>
hostapd/hostapd_cli.c

index 57702d93b249e04defb3068dbc915db1d819876f..95f7fd2d8e051152b67a8440e8f3d0f7719109d1 100644 (file)
@@ -2182,9 +2182,13 @@ static void hostapd_cli_action_ping(void *eloop_ctx, void *timeout_ctx)
        if (wpa_ctrl_request(ctrl, "PING", 4, buf, &len,
                             hostapd_cli_action_cb) < 0 ||
            len < 4 || os_memcmp(buf, "PONG", 4) != 0) {
-               printf("hostapd did not reply to PING command - exiting\n");
-               eloop_terminate();
-               return;
+               printf("hostapd did not reply to PING command - open a new connection\n");
+               hostapd_cli_close_connection();
+               if (hostapd_cli_reconnect(ctrl_ifname)) {
+                       printf("Failed to establish new connection - exit\n");
+                       eloop_terminate();
+                       return;
+               }
        }
        eloop_register_timeout(ping_interval, 0, hostapd_cli_action_ping,
                               ctrl, NULL);