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 =
ns_to_ktime(until_dw * NSEC_PER_USEC),
HRTIMER_MODE_REL_SOFT);
- if (conf->cluster_id && !is_zero_ether_addr(conf->cluster_id) &&
+ if (!is_zero_ether_addr(conf->cluster_id) &&
is_zero_ether_addr(hwsim_nan_cluster_id)) {
memcpy(hwsim_nan_cluster_id, conf->cluster_id, ETH_ALEN);
} else if (is_zero_ether_addr(hwsim_nan_cluster_id)) {
* (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.
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;
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));
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;
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,
#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>
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 =