From a484b928acb96d9d0e8f83f8421d48943682bd7c Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Mon, 26 Sep 2022 15:39:10 -0700 Subject: [PATCH] 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(-) diff --git a/src/netdev.c b/src/netdev.c index 7f4101be..5af6bb36 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -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;