Commit a180b0b1 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge tag 'wireless-next-2024-01-03' of...

Merge tag 'wireless-next-2024-01-03' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next

Johannes Berg says:

====================
Just a couple of more things over the holidays:

 - first kunit tests for both cfg80211 and mac80211
 - a few multi-link fixes
 - DSCP mapping update
 - RCU fix

* tag 'wireless-next-2024-01-03' of git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next:
  wifi: mac80211: remove redundant ML element check
  wifi: cfg80211: parse all ML elements in an ML probe response
  wifi: cfg80211: correct comment about MLD ID
  wifi: cfg80211: Update the default DSCP-to-UP mapping
  wifi: cfg80211: tests: add some scanning related tests
  wifi: mac80211: kunit: extend MFP tests
  wifi: mac80211: kunit: generalize public action test
  wifi: mac80211: add kunit tests for public action handling
  kunit: add a convenience allocation wrapper for SKBs
  kunit: add parameter generation macro using description from array
  wifi: mac80211: fix spelling typo in comment
  wifi: cfg80211: fix RCU dereference in __cfg80211_bss_update
====================

Link: https://lore.kernel.org/r/20240103144423.52269-3-johannes@sipsolutions.net


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents a2634a5f 3aca362a
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -566,13 +566,9 @@ By reusing the same ``cases`` array from above, we can write the test as a
		},
	};

	// Need a helper function to generate a name for each test case.
	static void case_to_desc(const struct sha1_test_case *t, char *desc)
	{
		strcpy(desc, t->str);
	}
	// Creates `sha1_gen_params()` to iterate over `cases`.
	KUNIT_ARRAY_PARAM(sha1, cases, case_to_desc);
	// Creates `sha1_gen_params()` to iterate over `cases` while using
	// the struct member `str` for the case description.
	KUNIT_ARRAY_PARAM_DESC(sha1, cases, str);

	// Looks no different from a normal test.
	static void sha1_test(struct kunit *test)
@@ -588,7 +584,7 @@ By reusing the same ``cases`` array from above, we can write the test as a
	}

	// Instead of KUNIT_CASE, we use KUNIT_CASE_PARAM and pass in the
	// function declared by KUNIT_ARRAY_PARAM.
	// function declared by KUNIT_ARRAY_PARAM or KUNIT_ARRAY_PARAM_DESC.
	static struct kunit_case sha1_test_cases[] = {
		KUNIT_CASE_PARAM(sha1_test, sha1_gen_params),
		{}

include/kunit/skbuff.h

0 → 100644
+56 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * KUnit resource management helpers for SKBs (skbuff).
 *
 * Copyright (C) 2023 Intel Corporation
 */

#ifndef _KUNIT_SKBUFF_H
#define _KUNIT_SKBUFF_H

#include <kunit/resource.h>
#include <linux/skbuff.h>

static void kunit_action_kfree_skb(void *p)
{
	kfree_skb((struct sk_buff *)p);
}

/**
 * kunit_zalloc_skb() - Allocate and initialize a resource managed skb.
 * @test: The test case to which the skb belongs
 * @len: size to allocate
 *
 * Allocate a new struct sk_buff with GFP_KERNEL, zero fill the give length
 * and add it as a resource to the kunit test for automatic cleanup.
 *
 * Returns: newly allocated SKB, or %NULL on error
 */
static inline struct sk_buff *kunit_zalloc_skb(struct kunit *test, int len,
					       gfp_t gfp)
{
	struct sk_buff *res = alloc_skb(len, GFP_KERNEL);

	if (!res || skb_pad(res, len))
		return NULL;

	if (kunit_add_action_or_reset(test, kunit_action_kfree_skb, res))
		return NULL;

	return res;
}

/**
 * kunit_kfree_skb() - Like kfree_skb except for allocations managed by KUnit.
 * @test: The test case to which the resource belongs.
 * @skb: The SKB to free.
 */
static inline void kunit_kfree_skb(struct kunit *test, struct sk_buff *skb)
{
	if (!skb)
		return;

	kunit_release_action(test, kunit_action_kfree_skb, (void *)skb);
}

#endif /* _KUNIT_SKBUFF_H */
+19 −0
Original line number Diff line number Diff line
@@ -1514,6 +1514,25 @@ do { \
		return NULL;									\
	}

/**
 * KUNIT_ARRAY_PARAM_DESC() - Define test parameter generator from an array.
 * @name:  prefix for the test parameter generator function.
 * @array: array of test parameters.
 * @desc_member: structure member from array element to use as description
 *
 * Define function @name_gen_params which uses @array to generate parameters.
 */
#define KUNIT_ARRAY_PARAM_DESC(name, array, desc_member)					\
	static const void *name##_gen_params(const void *prev, char *desc)			\
	{											\
		typeof((array)[0]) *__next = prev ? ((typeof(__next)) prev) + 1 : (array);	\
		if (__next - (array) < ARRAY_SIZE((array))) {					\
			strscpy(desc, __next->desc_member, KUNIT_PARAM_DESC_SIZE);		\
			return __next;								\
		}										\
		return NULL;									\
	}

// TODO(dlatypov@google.com): consider eventually migrating users to explicitly
// include resource.h themselves if they need it.
#include <kunit/resource.h>
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
#include "sta_info.h"
#include "driver-ops.h"

/* sta attributtes */
/* sta attributes */

#define STA_READ(name, field, format_string)				\
static ssize_t sta_ ##name## _read(struct file *file,			\
+10 −0
Original line number Diff line number Diff line
@@ -2608,4 +2608,14 @@ void ieee80211_check_wbrf_support(struct ieee80211_local *local);
void ieee80211_add_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef);
void ieee80211_remove_wbrf(struct ieee80211_local *local, struct cfg80211_chan_def *chandef);

#if IS_ENABLED(CONFIG_MAC80211_KUNIT_TEST)
#define EXPORT_SYMBOL_IF_MAC80211_KUNIT(sym) EXPORT_SYMBOL_IF_KUNIT(sym)
#define VISIBLE_IF_MAC80211_KUNIT
ieee80211_rx_result
ieee80211_drop_unencrypted_mgmt(struct ieee80211_rx_data *rx);
#else
#define EXPORT_SYMBOL_IF_MAC80211_KUNIT(sym)
#define VISIBLE_IF_MAC80211_KUNIT static
#endif

#endif /* IEEE80211_I_H */
Loading