]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Log offset and attribute type for nl80211 errors
authorBenjamin Berg <benjamin.berg@intel.com>
Fri, 18 Jul 2025 11:00:57 +0000 (13:00 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 3 Oct 2025 10:30:54 +0000 (13:30 +0300)
This information is easy to provide and it can be useful if the kernel
rejects an operation.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
src/drivers/driver_nl80211.c

index d7692054f1192f1a16bf02891e696847324dc6a4..0b05cc8ac5de2de85c7fa7290110487b236c7347 100644 (file)
@@ -390,17 +390,26 @@ static int error_handler(struct sockaddr_nl *nla, struct nlmsgerr *err,
                                   len, (char *) nla_data(tb[NLMSGERR_ATTR_MSG]));
        }
 
-       if (!err_args->err_info)
-               return NL_SKIP;
-
-       /* Check if it was a per-link error report */
-
+       /* Done if the the problematic attribute was not specified */
        if (!tb[NLMSGERR_ATTR_OFFS] ||
            os_memcmp(orig_nlh, &err->msg, sizeof(err->msg)) != 0)
                return NL_SKIP;
 
        offset = nla_get_u32(tb[NLMSGERR_ATTR_OFFS]);
 
+       if (offset < orig_nlh->nlmsg_len) {
+               struct nlattr *orig_attr =
+                       (void *) ((unsigned char *) orig_nlh + offset);
+
+               wpa_printf(MSG_DEBUG,
+                          "nl80211: kernel reports error at offset %u, attribute type %d",
+                          offset, nla_type(orig_attr));
+       }
+
+       /* Resolve problematic link if err_info is not NULL */
+       if (!err_args->err_info)
+               return NL_SKIP;
+
        mlo_links = nlmsg_find_attr(orig_nlh, GENL_HDRLEN,
                                    NL80211_ATTR_MLO_LINKS);
        if (!mlo_links)