From: Masashi Honma <masashi.honma@gmail.com>
To: linux-wireless@vger.kernel.org
Cc: johannes@sipsolutions.net, Masashi Honma <masashi.honma@gmail.com>
Subject: [PATCH v9 7/9] Add KUnit test for ieee80211_mesh_preq_size_ok
Date: Sat, 30 May 2026 08:09:49 +0900 [thread overview]
Message-ID: <20260529230952.124754-7-masashi.honma@gmail.com> (raw)
In-Reply-To: <20260529230952.124754-1-masashi.honma@gmail.com>
Signed-off-by: Masashi Honma <masashi.honma@gmail.com>
---
net/mac80211/tests/elems.c | 105 +++++++++++++++++++++++++++++++++++++
1 file changed, 105 insertions(+)
diff --git a/net/mac80211/tests/elems.c b/net/mac80211/tests/elems.c
index 1039794a0183..576ba746a526 100644
--- a/net/mac80211/tests/elems.c
+++ b/net/mac80211/tests/elems.c
@@ -9,6 +9,94 @@
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
+static const struct mesh_preq_parse_test_case {
+ const char *desc;
+ u8 len;
+ bool ae_enabled;
+ u8 target_count;
+ bool result;
+} mesh_preq_parse_cases[] = {
+ {
+ .desc = "shorter than header",
+ .len = 16,
+ .ae_enabled = false,
+ .target_count = 1,
+ .result = false,
+ },
+ {
+ .desc = "too short non AE, target count is not included",
+ .len = 29,
+ .ae_enabled = false,
+ .target_count = 1,
+ .result = false,
+ },
+ {
+ .desc = "too short non AE, target count is 1",
+ .len = 36,
+ .ae_enabled = false,
+ .target_count = 1,
+ .result = false,
+ },
+ {
+ .desc = "too short AE, target count is not included",
+ .len = 35,
+ .ae_enabled = true,
+ .target_count = 1,
+ .result = false,
+ },
+ {
+ .desc = "too short AE, target count is 1",
+ .len = 42,
+ .ae_enabled = true,
+ .target_count = 1,
+ .result = false,
+ },
+ {
+ .desc = "target count is zero",
+ .len = 26,
+ .ae_enabled = false,
+ .target_count = 0,
+ .result = false,
+ },
+ {
+ .desc = "target count is 21",
+ .len = 255,
+ .ae_enabled = false,
+ .target_count = 21,
+ .result = false,
+ },
+ {
+ .desc = "non AE, target count is 1",
+ .len = 37,
+ .ae_enabled = false,
+ .target_count = 1,
+ .result = true,
+ },
+ {
+ .desc = "non AE, target count is 20",
+ .len = 246,
+ .ae_enabled = false,
+ .target_count = 20,
+ .result = true,
+ },
+ {
+ .desc = "AE, target count is 1",
+ .len = 43,
+ .ae_enabled = true,
+ .target_count = 1,
+ .result = true,
+ },
+ {
+ .desc = "AE, target count is 20",
+ .len = 252,
+ .ae_enabled = true,
+ .target_count = 20,
+ .result = true,
+ },
+};
+
+KUNIT_ARRAY_PARAM_DESC(mesh_preq_parse, mesh_preq_parse_cases, desc);
+
static void mle_defrag(struct kunit *test)
{
struct ieee80211_elems_parse_params parse_params = {
@@ -91,8 +179,25 @@ static void mle_defrag(struct kunit *test)
kfree_skb(skb);
}
+static void mesh_preq_parse(struct kunit *test)
+{
+ const struct mesh_preq_parse_test_case *params = test->param_value;
+ u8 data[64] = {};
+ struct ieee80211_mesh_hwmp_preq_top *top = (void *)data;
+ struct ieee80211_mesh_hwmp_preq_bottom *bottom;
+
+ top->flags = params->ae_enabled ? AE_F : 0;
+ bottom = ieee80211_mesh_hwmp_preq_get_bottom(data);
+ bottom->target_count = params->target_count;
+
+ KUNIT_EXPECT_EQ(test,
+ ieee80211_mesh_preq_size_ok(data, params->len),
+ params->result);
+}
+
static struct kunit_case element_parsing_test_cases[] = {
KUNIT_CASE(mle_defrag),
+ KUNIT_CASE_PARAM(mesh_preq_parse, mesh_preq_parse_gen_params),
{}
};
--
2.43.0
next prev parent reply other threads:[~2026-05-29 23:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-29 23:09 [PATCH v9 1/9] wifi: mac80211: Use struct instead of macro for PREQ frame Masashi Honma
2026-05-29 23:09 ` [PATCH v9 2/9] wifi: mac80211: Use struct instead of macro for PREP frame Masashi Honma
2026-05-29 23:09 ` [PATCH v9 3/9] wifi: mac80211: Use struct instead of macro for PERR frame Masashi Honma
2026-05-29 23:09 ` [PATCH v9 4/9] wifi: mac80211: Fix overread in PREQ frame processing Masashi Honma
2026-05-29 23:09 ` [PATCH v9 5/9] wifi: mac80211: Fix overread in PREP " Masashi Honma
2026-05-29 23:09 ` [PATCH v9 6/9] wifi: mac80211: Fix PERR " Masashi Honma
2026-05-29 23:09 ` Masashi Honma [this message]
2026-05-29 23:09 ` [PATCH v9 8/9] Add KUnit test for ieee80211_mesh_prep_size_ok Masashi Honma
2026-05-29 23:09 ` [PATCH v9 9/9] Add KUnit test for ieee80211_mesh_perr_size_ok Masashi Honma
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=20260529230952.124754-7-masashi.honma@gmail.com \
--to=masashi.honma@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/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