From: Sai Pratyusha Magam Date: Sat, 2 Aug 2025 16:42:57 +0000 (+0530) Subject: hostapd_cli: Open a new hostapd connection on ping failure when using -a X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acadef1b04d5e9f7b329b8c20d8429b000e7e683;p=thirdparty%2Fhostap.git hostapd_cli: Open a new hostapd connection on ping failure when using -a 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 --- diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c index 57702d93b..95f7fd2d8 100644 --- a/hostapd/hostapd_cli.c +++ b/hostapd/hostapd_cli.c @@ -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);