]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mac80211: track the id of the NAN cluster we joined
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Mon, 4 May 2026 07:20:41 +0000 (10:20 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 5 May 2026 10:10:14 +0000 (12:10 +0200)
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>
include/net/mac80211.h
net/mac80211/cfg.c
net/mac80211/rx.c
net/mac80211/tx.c

index 02318a4be0e1ae6964c703ddc5a7f04eb0e497cb..0d1b1d726b9c2abd708b9318c39005b814c8f78b 100644 (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.
  *
index 00261bd6674b10f413ce433fe4e163df8cd6ea0f..c71af8878562ccac03e7090bde21639f4aa5ae74 100644 (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)
index 3e5d1c47a5b067708d27163cc97b70734c0b1957..82ea7404f3dafec124b5880adc3b91f79cb38e80 100644 (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;
 
index 8e4876d1c5440083e99a1e605deb9c411a1bc119..1702f816419b79cb310c50680d724b7317455733 100644 (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;
        }