Skip to contentSkip to conversation

netdev: differentiate connect/auth timeouts

PATCH Applied James Prestwood 2 participants 2 messages Sep 26, 2022 – Sep 27, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netdev: differentiate connect/auth timeouts

The warnings in the authenticate and connect events were identical so it could be difficult knowing which print it was if IWD is not in debug mode (to see more context). The prints were changed to indicate which event it was and for the connect event the reason attribute is also parsed.

Note the resp_ies_len is also initialized to zero now. After making the changes gcc was throwing a warning.

---
 src/netdev.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
src/netdev.c +17 -4
index 7f4101be..5af6bb36 100644
@@ -2734,8 +2734,10 @@ static void netdev_connect_event(struct l_genl_msg *msg, struct netdev *netdev)
 	size_t ies_len = 0;
 	struct ie_tlv_iter iter;
 	const uint8_t *resp_ies = NULL;
-	size_t resp_ies_len;
+	size_t resp_ies_len = 0;
 	struct handshake_state *hs = netdev->handshake;
+	bool timeout = false;
+	uint32_t timeout_reason = 0;
 
 	l_debug("");
 
@@ -2763,8 +2765,14 @@ static void netdev_connect_event(struct l_genl_msg *msg, struct netdev *netdev)
 	while (l_genl_attr_next(&attr, &type, &len, &data)) {
 		switch (type) {
 		case NL80211_ATTR_TIMED_OUT:
-			l_warn("authentication timed out");
-			goto error;
+			timeout = true;
+			break;
+		case NL80211_ATTR_TIMEOUT_REASON:
+			if (len != 4)
+				break;
+
+			timeout_reason = l_get_u32(data);
+			break;
 		case NL80211_ATTR_STATUS_CODE:
 			if (len == sizeof(uint16_t))
 				status_code = data;
@@ -2780,6 +2788,11 @@ static void netdev_connect_event(struct l_genl_msg *msg, struct netdev *netdev)
 		}
 	}
 
+	if (timeout) {
+		l_warn("connect event timed out, reason=%u", timeout_reason);
+		goto error;
+	}
+
 	if (netdev->expect_connect_failure) {
 		/*
 		 * The kernel may think we are connected when we are actually
@@ -3106,7 +3119,7 @@ static void netdev_authenticate_event(struct l_genl_msg *msg,
 	while (l_genl_attr_next(&attr, &type, &len, &data)) {
 		switch (type) {
 		case NL80211_ATTR_TIMED_OUT:
-			l_warn("authentication timed out");
+			l_warn("authentication event timed out");
 
 			if (auth_proto_auth_timeout(netdev->ap))
 				return;
Signature · 1 line
2.34.3
#1 lore raw

Hi James,

Quoted 6 lines · James Prestwood

The warnings in the authenticate and connect events were identical so it could be difficult knowing which print it was if IWD is not in debug mode (to see more context). The prints were changed to indicate which event it was and for the connect event the reason attribute is also parsed.

Quoted 6 lines

Note the resp_ies_len is also initialized to zero now. After making the changes gcc was throwing a warning.

---
  src/netdev.c | 21 +++++++++++++++++----
  1 file changed, 17 insertions(+), 4 deletions(-)

Applied, thanks.

Regards,
-Denis