Issue with wpa_cli and 'PING' check

Ben Greear greearb at candelatech.com
Fri Dec 1 16:41:43 PST 2017


While debugging some strange issues, I noticed that my wpa_cli
in monitor mode was disconnecting because the PING failed.

It looks like the reason it fails goes something like this:

wpa_cli: ping
wpa_supplicant:  do things, post logging message to wpa-cli
wpa_supplicant:  read ping & reply with pong
wpa_cli:  reads 'logging message', decides PONG fails, and disconnects.

So, nasty race I guess?

static void wpa_cli_action_ping(void *eloop_ctx, void *timeout_ctx)
{
	struct wpa_ctrl *ctrl = eloop_ctx;
	char buf[256] = {0};
	size_t len;

	/* verify that connection is still working */
	len = sizeof(buf) - 1;
	if (wpa_ctrl_request(ctrl, "PING", 4, buf, &len,
			     wpa_cli_action_cb) < 0 ||
	    len < 4 || os_memcmp(buf, "PONG", 4) != 0) {
		fprintf(stderr, "wpa-cli: wpa_supplicant did not reply to PING command, len: %d buf: %s - exiting\n",
			(int)len, buf);
		eloop_terminate();
		return;
	}
	eloop_register_timeout(ping_interval, 0, wpa_cli_action_ping,
			       ctrl, NULL);
}

Thanks,
Ben

-- 
Ben Greear <greearb at candelatech.com>
Candela Technologies Inc  http://www.candelatech.com




More information about the Hostap mailing list