* [PATCH wireless-next] wifi: cfg80211: make cluster id an array
@ 2026-03-01 11:18 Miri Korenblit
2026-03-01 14:26 ` kernel test robot
2026-03-01 15:38 ` kernel test robot
0 siblings, 2 replies; 3+ messages in thread
From: Miri Korenblit @ 2026-03-01 11:18 UTC (permalink / raw)
To: linux-wireless
cfg80211_nan_conf::cluster_id is currently a pointer, but there is no real
reason to not have it an array. It makes things easier as there is no
need to check the pointer validity each time.
If a cluster ID wasn't provided by user space it will be randomized.
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
drivers/net/wireless/intel/iwlwifi/mld/nan.c | 5 ++---
include/net/cfg80211.h | 3 +--
net/mac80211/cfg.c | 12 ++----------
net/wireless/nl80211.c | 14 +++++++++++---
4 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/mld/nan.c b/drivers/net/wireless/intel/iwlwifi/mld/nan.c
index 2dbd3d58b0c6..4d8e85f2bd7c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mld/nan.c
+++ b/drivers/net/wireless/intel/iwlwifi/mld/nan.c
@@ -54,9 +54,8 @@ static int iwl_mld_nan_config(struct iwl_mld *mld,
ether_addr_copy(cmd.nmi_addr, vif->addr);
cmd.master_pref = conf->master_pref;
- if (conf->cluster_id)
- memcpy(cmd.cluster_id, conf->cluster_id + 4,
- sizeof(cmd.cluster_id));
+ memcpy(cmd.cluster_id, conf->cluster_id + 4,
+ sizeof(cmd.cluster_id));
cmd.scan_period = conf->scan_period < 255 ? conf->scan_period : 255;
cmd.dwell_time =
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index fc01de19c798..73f4aa15c956 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -4020,7 +4020,6 @@ struct cfg80211_nan_band_config {
* (i.e. BIT(NL80211_BAND_2GHZ)).
* @cluster_id: cluster ID used for NAN synchronization. This is a MAC address
* that can take a value from 50-6F-9A-01-00-00 to 50-6F-9A-01-FF-FF.
- * If NULL, the device will pick a random Cluster ID.
* @scan_period: period (in seconds) between NAN scans.
* @scan_dwell_time: dwell time (in milliseconds) for NAN scans.
* @discovery_beacon_interval: interval (in TUs) for discovery beacons.
@@ -4036,7 +4035,7 @@ struct cfg80211_nan_band_config {
struct cfg80211_nan_conf {
u8 master_pref;
u8 bands;
- const u8 *cluster_id;
+ u8 cluster_id[ETH_ALEN] __aligned(2);
u16 scan_period;
u16 scan_dwell_time;
u8 discovery_beacon_interval;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index b92b4a5c2636..490e2d9b1720 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -330,7 +330,6 @@ static void ieee80211_stop_p2p_device(struct wiphy *wiphy,
static void ieee80211_nan_conf_free(struct cfg80211_nan_conf *conf)
{
- kfree(conf->cluster_id);
kfree(conf->extra_nan_attrs);
kfree(conf->vendor_elems);
memset(conf, 0, sizeof(*conf));
@@ -372,9 +371,6 @@ static int ieee80211_nan_conf_copy(struct cfg80211_nan_conf *dst,
memcpy(&dst->band_cfgs, &src->band_cfgs,
sizeof(dst->band_cfgs));
- kfree(dst->cluster_id);
- dst->cluster_id = NULL;
-
kfree(dst->extra_nan_attrs);
dst->extra_nan_attrs = NULL;
dst->extra_nan_attrs_len = 0;
@@ -383,12 +379,8 @@ static int ieee80211_nan_conf_copy(struct cfg80211_nan_conf *dst,
dst->vendor_elems = NULL;
dst->vendor_elems_len = 0;
- if (src->cluster_id) {
- dst->cluster_id = kmemdup(src->cluster_id, ETH_ALEN,
- GFP_KERNEL);
- if (!dst->cluster_id)
- goto no_mem;
- }
+ if (is_zero_ether_addr(dst->cluster_id))
+ ether_addr_copy(dst->cluster_id, src->cluster_id);
if (src->extra_nan_attrs && src->extra_nan_attrs_len) {
dst->extra_nan_attrs = kmemdup(src->extra_nan_attrs,
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index b94231c8441c..e220ccbba91b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -21,6 +21,7 @@
#include <linux/nospec.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
+#include <linux/random.h>
#include <net/net_namespace.h>
#include <net/genetlink.h>
#include <net/cfg80211.h>
@@ -15725,9 +15726,16 @@ static int nl80211_parse_nan_conf(struct wiphy *wiphy,
return err;
changed |= CFG80211_NAN_CONF_CHANGED_CONFIG;
- if (attrs[NL80211_NAN_CONF_CLUSTER_ID] && start)
- conf->cluster_id =
- nla_data(attrs[NL80211_NAN_CONF_CLUSTER_ID]);
+ if (attrs[NL80211_NAN_CONF_CLUSTER_ID] && start) {
+ ether_addr_copy(conf->cluster_id,
+ nla_data(attrs[NL80211_NAN_CONF_CLUSTER_ID]));
+ } else if (start) {
+ conf->cluster_id[0] = 0x50;
+ conf->cluster_id[1] = 0x6f;
+ conf->cluster_id[2] = 0x9a;
+ conf->cluster_id[3] = 0x01;
+ get_random_bytes(&conf->cluster_id[4], 2);
+ }
if (attrs[NL80211_NAN_CONF_EXTRA_ATTRS]) {
conf->extra_nan_attrs =
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH wireless-next] wifi: cfg80211: make cluster id an array
2026-03-01 11:18 [PATCH wireless-next] wifi: cfg80211: make cluster id an array Miri Korenblit
@ 2026-03-01 14:26 ` kernel test robot
2026-03-01 15:38 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-03-01 14:26 UTC (permalink / raw)
To: Miri Korenblit, linux-wireless; +Cc: oe-kbuild-all
Hi Miri,
kernel test robot noticed the following build warnings:
[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v7.0-rc1 next-20260227]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Miri-Korenblit/wifi-cfg80211-make-cluster-id-an-array/20260301-192010
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link: https://lore.kernel.org/r/20260301131848.b0085a6b4eb3.Ib16bf5cca55463d4c89e18099cf1dfe4de95d405%40changeid
patch subject: [PATCH wireless-next] wifi: cfg80211: make cluster id an array
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20260301/202603012218.ucVoRBov-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 15.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260301/202603012218.ucVoRBov-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603012218.ucVoRBov-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/net/wireless/virtual/mac80211_hwsim.c: In function 'mac80211_hwsim_start_nan':
>> drivers/net/wireless/virtual/mac80211_hwsim.c:4081:13: warning: the comparison will always evaluate as 'true' for the address of 'cluster_id' will never be NULL [-Waddress]
4081 | if (conf->cluster_id && !is_zero_ether_addr(conf->cluster_id) &&
| ^~~~
In file included from include/net/mac80211.h:22,
from drivers/net/wireless/virtual/mac80211_hwsim.c:22:
include/net/cfg80211.h:4038:12: note: 'cluster_id' declared here
4038 | u8 cluster_id[ETH_ALEN] __aligned(2);
| ^~~~~~~~~~
vim +4081 drivers/net/wireless/virtual/mac80211_hwsim.c
a37a6f54439bf8 Ilan Peer 2025-09-08 4052
a37a6f54439bf8 Ilan Peer 2025-09-08 4053 static int mac80211_hwsim_start_nan(struct ieee80211_hw *hw,
a37a6f54439bf8 Ilan Peer 2025-09-08 4054 struct ieee80211_vif *vif,
a37a6f54439bf8 Ilan Peer 2025-09-08 4055 struct cfg80211_nan_conf *conf)
a37a6f54439bf8 Ilan Peer 2025-09-08 4056 {
a37a6f54439bf8 Ilan Peer 2025-09-08 4057 struct mac80211_hwsim_data *data = hw->priv;
a37a6f54439bf8 Ilan Peer 2025-09-08 4058 u64 tsf = mac80211_hwsim_get_tsf(hw, NULL);
a37a6f54439bf8 Ilan Peer 2025-09-08 4059 u32 dw_int = 512 * 1000;
a37a6f54439bf8 Ilan Peer 2025-09-08 4060 u64 until_dw = dw_int - do_div(tsf, dw_int);
a37a6f54439bf8 Ilan Peer 2025-09-08 4061 struct wireless_dev *wdev = ieee80211_vif_to_wdev(vif);
a37a6f54439bf8 Ilan Peer 2025-09-08 4062
a37a6f54439bf8 Ilan Peer 2025-09-08 4063 if (vif->type != NL80211_IFTYPE_NAN)
a37a6f54439bf8 Ilan Peer 2025-09-08 4064 return -EINVAL;
a37a6f54439bf8 Ilan Peer 2025-09-08 4065
a37a6f54439bf8 Ilan Peer 2025-09-08 4066 if (data->nan_device_vif)
a37a6f54439bf8 Ilan Peer 2025-09-08 4067 return -EALREADY;
a37a6f54439bf8 Ilan Peer 2025-09-08 4068
a37a6f54439bf8 Ilan Peer 2025-09-08 4069 /* set this before starting the timer, as preemption might occur */
a37a6f54439bf8 Ilan Peer 2025-09-08 4070 data->nan_device_vif = vif;
a37a6f54439bf8 Ilan Peer 2025-09-08 4071 data->nan_bands = conf->bands;
a37a6f54439bf8 Ilan Peer 2025-09-08 4072 data->nan_curr_dw_band = NL80211_BAND_2GHZ;
a37a6f54439bf8 Ilan Peer 2025-09-08 4073
a37a6f54439bf8 Ilan Peer 2025-09-08 4074 wiphy_debug(hw->wiphy, "nan_started, next_dw=%llu\n",
a37a6f54439bf8 Ilan Peer 2025-09-08 4075 until_dw);
a37a6f54439bf8 Ilan Peer 2025-09-08 4076
a37a6f54439bf8 Ilan Peer 2025-09-08 4077 hrtimer_start(&data->nan_timer,
a37a6f54439bf8 Ilan Peer 2025-09-08 4078 ns_to_ktime(until_dw * NSEC_PER_USEC),
a37a6f54439bf8 Ilan Peer 2025-09-08 4079 HRTIMER_MODE_REL_SOFT);
a37a6f54439bf8 Ilan Peer 2025-09-08 4080
a37a6f54439bf8 Ilan Peer 2025-09-08 @4081 if (conf->cluster_id && !is_zero_ether_addr(conf->cluster_id) &&
a37a6f54439bf8 Ilan Peer 2025-09-08 4082 is_zero_ether_addr(hwsim_nan_cluster_id)) {
a37a6f54439bf8 Ilan Peer 2025-09-08 4083 memcpy(hwsim_nan_cluster_id, conf->cluster_id, ETH_ALEN);
a37a6f54439bf8 Ilan Peer 2025-09-08 4084 } else if (is_zero_ether_addr(hwsim_nan_cluster_id)) {
a37a6f54439bf8 Ilan Peer 2025-09-08 4085 hwsim_nan_cluster_id[0] = 0x50;
a37a6f54439bf8 Ilan Peer 2025-09-08 4086 hwsim_nan_cluster_id[1] = 0x6f;
a37a6f54439bf8 Ilan Peer 2025-09-08 4087 hwsim_nan_cluster_id[2] = 0x9a;
a37a6f54439bf8 Ilan Peer 2025-09-08 4088 hwsim_nan_cluster_id[3] = 0x01;
a37a6f54439bf8 Ilan Peer 2025-09-08 4089 hwsim_nan_cluster_id[4] = get_random_u8();
a37a6f54439bf8 Ilan Peer 2025-09-08 4090 hwsim_nan_cluster_id[5] = get_random_u8();
a37a6f54439bf8 Ilan Peer 2025-09-08 4091 }
a37a6f54439bf8 Ilan Peer 2025-09-08 4092
a37a6f54439bf8 Ilan Peer 2025-09-08 4093 data->notify_dw = conf->enable_dw_notification;
a37a6f54439bf8 Ilan Peer 2025-09-08 4094
a37a6f54439bf8 Ilan Peer 2025-09-08 4095 cfg80211_nan_cluster_joined(wdev, hwsim_nan_cluster_id, true,
a37a6f54439bf8 Ilan Peer 2025-09-08 4096 GFP_KERNEL);
a37a6f54439bf8 Ilan Peer 2025-09-08 4097
a37a6f54439bf8 Ilan Peer 2025-09-08 4098 return 0;
a37a6f54439bf8 Ilan Peer 2025-09-08 4099 }
a37a6f54439bf8 Ilan Peer 2025-09-08 4100
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH wireless-next] wifi: cfg80211: make cluster id an array
2026-03-01 11:18 [PATCH wireless-next] wifi: cfg80211: make cluster id an array Miri Korenblit
2026-03-01 14:26 ` kernel test robot
@ 2026-03-01 15:38 ` kernel test robot
1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-03-01 15:38 UTC (permalink / raw)
To: Miri Korenblit, linux-wireless; +Cc: llvm, oe-kbuild-all
Hi Miri,
kernel test robot noticed the following build warnings:
[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v7.0-rc1 next-20260227]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Miri-Korenblit/wifi-cfg80211-make-cluster-id-an-array/20260301-192010
base: https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link: https://lore.kernel.org/r/20260301131848.b0085a6b4eb3.Ib16bf5cca55463d4c89e18099cf1dfe4de95d405%40changeid
patch subject: [PATCH wireless-next] wifi: cfg80211: make cluster id an array
config: sparc64-allmodconfig (https://download.01.org/0day-ci/archive/20260301/202603012302.fG1YckJP-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 9a109fbb6e184ec9bcce10615949f598f4c974a9)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260301/202603012302.fG1YckJP-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603012302.fG1YckJP-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/net/wireless/virtual/mac80211_hwsim.c:4081:12: warning: address of array 'conf->cluster_id' will always evaluate to 'true' [-Wpointer-bool-conversion]
4081 | if (conf->cluster_id && !is_zero_ether_addr(conf->cluster_id) &&
| ~~~~~~^~~~~~~~~~ ~~
1 warning generated.
vim +4081 drivers/net/wireless/virtual/mac80211_hwsim.c
a37a6f54439bf8 Ilan Peer 2025-09-08 4052
a37a6f54439bf8 Ilan Peer 2025-09-08 4053 static int mac80211_hwsim_start_nan(struct ieee80211_hw *hw,
a37a6f54439bf8 Ilan Peer 2025-09-08 4054 struct ieee80211_vif *vif,
a37a6f54439bf8 Ilan Peer 2025-09-08 4055 struct cfg80211_nan_conf *conf)
a37a6f54439bf8 Ilan Peer 2025-09-08 4056 {
a37a6f54439bf8 Ilan Peer 2025-09-08 4057 struct mac80211_hwsim_data *data = hw->priv;
a37a6f54439bf8 Ilan Peer 2025-09-08 4058 u64 tsf = mac80211_hwsim_get_tsf(hw, NULL);
a37a6f54439bf8 Ilan Peer 2025-09-08 4059 u32 dw_int = 512 * 1000;
a37a6f54439bf8 Ilan Peer 2025-09-08 4060 u64 until_dw = dw_int - do_div(tsf, dw_int);
a37a6f54439bf8 Ilan Peer 2025-09-08 4061 struct wireless_dev *wdev = ieee80211_vif_to_wdev(vif);
a37a6f54439bf8 Ilan Peer 2025-09-08 4062
a37a6f54439bf8 Ilan Peer 2025-09-08 4063 if (vif->type != NL80211_IFTYPE_NAN)
a37a6f54439bf8 Ilan Peer 2025-09-08 4064 return -EINVAL;
a37a6f54439bf8 Ilan Peer 2025-09-08 4065
a37a6f54439bf8 Ilan Peer 2025-09-08 4066 if (data->nan_device_vif)
a37a6f54439bf8 Ilan Peer 2025-09-08 4067 return -EALREADY;
a37a6f54439bf8 Ilan Peer 2025-09-08 4068
a37a6f54439bf8 Ilan Peer 2025-09-08 4069 /* set this before starting the timer, as preemption might occur */
a37a6f54439bf8 Ilan Peer 2025-09-08 4070 data->nan_device_vif = vif;
a37a6f54439bf8 Ilan Peer 2025-09-08 4071 data->nan_bands = conf->bands;
a37a6f54439bf8 Ilan Peer 2025-09-08 4072 data->nan_curr_dw_band = NL80211_BAND_2GHZ;
a37a6f54439bf8 Ilan Peer 2025-09-08 4073
a37a6f54439bf8 Ilan Peer 2025-09-08 4074 wiphy_debug(hw->wiphy, "nan_started, next_dw=%llu\n",
a37a6f54439bf8 Ilan Peer 2025-09-08 4075 until_dw);
a37a6f54439bf8 Ilan Peer 2025-09-08 4076
a37a6f54439bf8 Ilan Peer 2025-09-08 4077 hrtimer_start(&data->nan_timer,
a37a6f54439bf8 Ilan Peer 2025-09-08 4078 ns_to_ktime(until_dw * NSEC_PER_USEC),
a37a6f54439bf8 Ilan Peer 2025-09-08 4079 HRTIMER_MODE_REL_SOFT);
a37a6f54439bf8 Ilan Peer 2025-09-08 4080
a37a6f54439bf8 Ilan Peer 2025-09-08 @4081 if (conf->cluster_id && !is_zero_ether_addr(conf->cluster_id) &&
a37a6f54439bf8 Ilan Peer 2025-09-08 4082 is_zero_ether_addr(hwsim_nan_cluster_id)) {
a37a6f54439bf8 Ilan Peer 2025-09-08 4083 memcpy(hwsim_nan_cluster_id, conf->cluster_id, ETH_ALEN);
a37a6f54439bf8 Ilan Peer 2025-09-08 4084 } else if (is_zero_ether_addr(hwsim_nan_cluster_id)) {
a37a6f54439bf8 Ilan Peer 2025-09-08 4085 hwsim_nan_cluster_id[0] = 0x50;
a37a6f54439bf8 Ilan Peer 2025-09-08 4086 hwsim_nan_cluster_id[1] = 0x6f;
a37a6f54439bf8 Ilan Peer 2025-09-08 4087 hwsim_nan_cluster_id[2] = 0x9a;
a37a6f54439bf8 Ilan Peer 2025-09-08 4088 hwsim_nan_cluster_id[3] = 0x01;
a37a6f54439bf8 Ilan Peer 2025-09-08 4089 hwsim_nan_cluster_id[4] = get_random_u8();
a37a6f54439bf8 Ilan Peer 2025-09-08 4090 hwsim_nan_cluster_id[5] = get_random_u8();
a37a6f54439bf8 Ilan Peer 2025-09-08 4091 }
a37a6f54439bf8 Ilan Peer 2025-09-08 4092
a37a6f54439bf8 Ilan Peer 2025-09-08 4093 data->notify_dw = conf->enable_dw_notification;
a37a6f54439bf8 Ilan Peer 2025-09-08 4094
a37a6f54439bf8 Ilan Peer 2025-09-08 4095 cfg80211_nan_cluster_joined(wdev, hwsim_nan_cluster_id, true,
a37a6f54439bf8 Ilan Peer 2025-09-08 4096 GFP_KERNEL);
a37a6f54439bf8 Ilan Peer 2025-09-08 4097
a37a6f54439bf8 Ilan Peer 2025-09-08 4098 return 0;
a37a6f54439bf8 Ilan Peer 2025-09-08 4099 }
a37a6f54439bf8 Ilan Peer 2025-09-08 4100
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-01 15:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-01 11:18 [PATCH wireless-next] wifi: cfg80211: make cluster id an array Miri Korenblit
2026-03-01 14:26 ` kernel test robot
2026-03-01 15:38 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox