public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: "Vivek Das Mohapatra" <vivek@collabora.com>
To: iwd@lists.linux.dev
Subject: [PATCH 2/2] mpdu: tolerate technically illegal but harmless cloned IEs
Date: Sat,  5 Oct 2024 03:19:29 +0100	[thread overview]
Message-ID: <20241005021929.2075817-3-vivek@collabora.com> (raw)
In-Reply-To: <20241005021929.2075817-1-vivek@collabora.com>

---
 src/ie.h   | 17 +++++++++++++++++
 src/mpdu.c | 10 +++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/ie.h b/src/ie.h
index 4498785a..bc750696 100644
--- a/src/ie.h
+++ b/src/ie.h
@@ -598,6 +598,23 @@ static inline const unsigned char *ie_tlv_iter_get_data(
 	return iter->data;
 }
 
+static inline bool ie_tlv_iter_data_eq(struct ie_tlv_iter *a,
+					struct ie_tlv_iter *b)
+{
+	if (a == b)
+		return true;
+
+	if (a == NULL || b == NULL)
+		return false;
+
+	if (ie_tlv_iter_get_length(a) != ie_tlv_iter_get_length(b))
+		return false;
+
+	return memcmp(ie_tlv_iter_get_data(a),
+			ie_tlv_iter_get_data(b),
+			ie_tlv_iter_get_length(a)) == 0;
+}
+
 void *ie_tlv_extract_wsc_payload(const uint8_t *ies, size_t len,
 							ssize_t *out_len);
 void *ie_tlv_encapsulate_wsc_payload(const uint8_t *data, size_t len,
diff --git a/src/mpdu.c b/src/mpdu.c
index 9d0409d2..09df696e 100644
--- a/src/mpdu.c
+++ b/src/mpdu.c
@@ -398,9 +398,17 @@ static bool validate_mgmt_ies(const uint8_t *ies, size_t ies_len,
 
 			memcpy(&clone, &iter, sizeof(clone));
 
+			/*
+			 * Some APs send completely identical duplicate IEs:
+			 * Since these are harmless (and ignored by us) we're
+			 * going to allow them here for interoperability.
+			 */
 			while (ie_tlv_iter_next(&clone)) {
-				if (ie_tlv_iter_get_tag(&clone) != tag)
+				if (ie_tlv_iter_get_tag(&clone) != tag) {
 					continue;
+				} else if (ie_tlv_iter_data_eq(&iter, &clone)) {
+					continue;
+				}
 
 				return false;
 			}
-- 
2.30.2


  parent reply	other threads:[~2024-10-05  2:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-02 17:08 Interop problem with Quantum Fiber WiFi7 pods (duplicate RSNXE IE) Vivek Das Mohapatra
2024-10-02 17:40 ` James Prestwood
2024-10-02 18:14 ` Denis Kenzior
2024-10-02 21:41   ` Vivek Das Mohapatra
2024-10-02 21:55     ` Vivek Das Mohapatra
2024-10-03 12:17       ` James Prestwood
2024-10-04  2:58         ` Denis Kenzior
2024-10-04 11:45           ` Vivek Das Mohapatra
2024-10-05  2:19             ` RFC: Be more lenient about duplicate IEs with identical payloads Vivek Das Mohapatra
2024-10-05  2:19               ` [PATCH 1/2] unit: add a test for harmless IE clones Vivek Das Mohapatra
2024-10-07 18:26                 ` Denis Kenzior
2024-10-05  2:19               ` Vivek Das Mohapatra [this message]
2024-10-07 18:27                 ` [PATCH 2/2] mpdu: tolerate technically illegal but harmless cloned IEs Denis Kenzior
2024-10-07 18:29                   ` Vivek Das Mohapatra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241005021929.2075817-3-vivek@collabora.com \
    --to=vivek@collabora.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox