wifi: mac80211: track the id of the NAN cluster we joined

Currently, we store in nan.conf the cluster id that was configured from
upper layer to be used when the device opens a cluster.
But after we joined a cluster, the configured cluster id is no longer
relevant. Particularly, in reconfig we will give the driver the
(possibly) wrong cluster id.

Add an API to be called by the driver when joined a cluster
in which the cluster id will be updated.
Use the locally stored cluster id instead of cfg80211's copy.

Ignore cluster id updates from cfg80211 if we already have one
configured.

Adjust the drivers that use the cfg80211 API
(cfg80211_nan_cluster_joined) directly, otherwise we break functionality
(i.e. accept frame check won't evaluate to true).

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260504101829.5dada1b756a4.I0f1060215267fd8aef31afd99f8f42e6fde7f234@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
Miri Korenblit 2026-05-04 10:20:41 +03:00 committed by Johannes Berg
parent e2ae5b19ac
commit 43ef5856bd
4 changed files with 36 additions and 3 deletions

View File

@ -7891,6 +7891,20 @@ void ieee80211_nan_func_match(struct ieee80211_vif *vif,
*/
void ieee80211_nan_sched_update_done(struct ieee80211_vif *vif);
/**
* ieee80211_nan_cluster_joined - notify about NAN cluster join.
*
* This function is used to notify mac80211 about NAN cluster join.
*
* @vif: &struct ieee80211_vif pointer from the add_interface callback.
* @cluster_id: the cluster ID that was joined
* @new_cluster: true if this is a new cluster
* @gfp: allocation flags
*/
void ieee80211_nan_cluster_joined(struct ieee80211_vif *vif,
const u8 *cluster_id, bool new_cluster,
gfp_t gfp);
/**
* ieee80211_calc_rx_airtime - calculate estimated transmission airtime for RX.
*

View File

@ -5215,6 +5215,25 @@ void ieee80211_nan_func_match(struct ieee80211_vif *vif,
}
EXPORT_SYMBOL(ieee80211_nan_func_match);
void ieee80211_nan_cluster_joined(struct ieee80211_vif *vif,
const u8 *cluster_id, bool new_cluster,
gfp_t gfp)
{
struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
if (WARN_ON(vif->type != NL80211_IFTYPE_NAN))
return;
if (WARN_ON(!sdata->u.nan.started))
return;
ether_addr_copy(sdata->u.nan.conf.cluster_id, cluster_id);
cfg80211_nan_cluster_joined(ieee80211_vif_to_wdev(vif), cluster_id,
new_cluster, gfp);
}
EXPORT_SYMBOL(ieee80211_nan_cluster_joined);
static int ieee80211_set_multicast_to_unicast(struct wiphy *wiphy,
struct net_device *dev,
const bool enabled)

View File

@ -4629,7 +4629,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
* action frames or authentication frames that are addressed to
* the local NAN interface.
*/
return memcmp(sdata->wdev.u.nan.cluster_id,
return memcmp(sdata->u.nan.conf.cluster_id,
hdr->addr3, ETH_ALEN) == 0 &&
(ieee80211_is_public_action(hdr, skb->len) ||
(ieee80211_is_auth(hdr->frame_control) &&
@ -4646,7 +4646,7 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx)
if (!nmi)
return false;
if (!ether_addr_equal(nmi->wdev.u.nan.cluster_id,
if (!ether_addr_equal(nmi->u.nan.conf.cluster_id,
hdr->addr3))
return false;

View File

@ -2854,7 +2854,7 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,
ret = -ENOTCONN;
goto free;
}
memcpy(hdr.addr3, nmi->wdev.u.nan.cluster_id, ETH_ALEN);
memcpy(hdr.addr3, nmi->u.nan.conf.cluster_id, ETH_ALEN);
hdrlen = 24;
break;
}