2023-11-20 06:25:35

by Anuj Khera

[permalink] [raw]
Subject: [PATCH] wifi: cfg80211: Rename bssid to peer_addr in cfg80211_pmksa

The cfg80211_pmksa structure uses bssid member to store
the PMKSA for a BSS in Station mode. Change the name of
structure member bssid to peer_addr so that same member
can be used to store the PMKSA for a station in AP mode
using station MAC address.

Signed-off-by: Anuj Khera <[email protected]>
---
drivers/net/wireless/ath/ath6kl/cfg80211.c | 8 ++++----
.../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 12 ++++++------
drivers/net/wireless/microchip/wilc1000/cfg80211.c | 10 +++++-----
drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 8 ++++----
include/net/cfg80211.h | 5 +++--
net/wireless/nl80211.c | 2 +-
net/wireless/trace.h | 2 +-
net/wireless/wext-compat.c | 2 +-
8 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c
index e37db4af33de..853f0e55e828 100644
--- a/drivers/net/wireless/ath/ath6kl/cfg80211.c
+++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c
@@ -1877,8 +1877,8 @@ static int ath6kl_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
struct ath6kl *ar = ath6kl_priv(netdev);
struct ath6kl_vif *vif = netdev_priv(netdev);

- return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->fw_vif_idx, pmksa->bssid,
- pmksa->pmkid, true);
+ return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->fw_vif_idx,
+ pmksa->peer_addr, pmksa->pmkid, true);
}

static int ath6kl_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
@@ -1887,8 +1887,8 @@ static int ath6kl_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
struct ath6kl *ar = ath6kl_priv(netdev);
struct ath6kl_vif *vif = netdev_priv(netdev);

- return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->fw_vif_idx, pmksa->bssid,
- pmksa->pmkid, false);
+ return ath6kl_wmi_setpmkid_cmd(ar->wmi, vif->fw_vif_idx,
+ pmksa->peer_addr, pmksa->pmkid, false);
}

static int ath6kl_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index 133c5ea6429c..e00a2b858945 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -4329,7 +4329,7 @@ brcmf_pmksa_v3_op(struct brcmf_if *ifp, struct cfg80211_pmksa *pmksa,
/* Single PMK operation */
pmk_op->count = cpu_to_le16(1);
length += sizeof(struct brcmf_pmksa_v3);
- memcpy(pmk_op->pmk[0].bssid, pmksa->bssid, ETH_ALEN);
+ memcpy(pmk_op->pmk[0].bssid, pmksa->peer_addr, ETH_ALEN);
memcpy(pmk_op->pmk[0].pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
pmk_op->pmk[0].pmkid_len = WLAN_PMKID_LEN;
pmk_op->pmk[0].time_left = cpu_to_le32(alive ? BRCMF_PMKSA_NO_EXPIRY : 0);
@@ -4375,7 +4375,7 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev,
if (!check_vif_up(ifp->vif))
return -EIO;

- brcmf_dbg(CONN, "set_pmksa - PMK bssid: %pM =\n", pmksa->bssid);
+ brcmf_dbg(CONN, "set_pmksa - PMK bssid: %pM =\n", pmksa->peer_addr);
brcmf_dbg(CONN, "%*ph\n", WLAN_PMKID_LEN, pmksa->pmkid);

if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PMKID_V3))
@@ -4385,10 +4385,10 @@ brcmf_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *ndev,

npmk = le32_to_cpu(cfg->pmk_list.npmk);
for (i = 0; i < npmk; i++)
- if (!memcmp(pmksa->bssid, pmk[i].bssid, ETH_ALEN))
+ if (!memcmp(pmksa->peer_addr, pmk[i].bssid, ETH_ALEN))
break;
if (i < BRCMF_MAXPMKID) {
- memcpy(pmk[i].bssid, pmksa->bssid, ETH_ALEN);
+ memcpy(pmk[i].bssid, pmksa->peer_addr, ETH_ALEN);
memcpy(pmk[i].pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
if (i == npmk) {
npmk++;
@@ -4420,7 +4420,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev,
if (!check_vif_up(ifp->vif))
return -EIO;

- brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", pmksa->bssid);
+ brcmf_dbg(CONN, "del_pmksa - PMK bssid = %pM\n", pmksa->peer_addr);

if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_PMKID_V3))
return brcmf_pmksa_v3_op(ifp, pmksa, false);
@@ -4429,7 +4429,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *ndev,

npmk = le32_to_cpu(cfg->pmk_list.npmk);
for (i = 0; i < npmk; i++)
- if (!memcmp(pmksa->bssid, pmk[i].bssid, ETH_ALEN))
+ if (!memcmp(pmksa->peer_addr, pmk[i].bssid, ETH_ALEN))
break;

if ((npmk > 0) && (i < npmk)) {
diff --git a/drivers/net/wireless/microchip/wilc1000/cfg80211.c b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
index ad2509d8c99a..a2630506a619 100644
--- a/drivers/net/wireless/microchip/wilc1000/cfg80211.c
+++ b/drivers/net/wireless/microchip/wilc1000/cfg80211.c
@@ -877,14 +877,14 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
u8 flag = 0;

for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
- if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
- ETH_ALEN)) {
+ if (!memcmp(pmksa->peer_addr,
+ priv->pmkid_list.pmkidlist[i].bssid, ETH_ALEN)) {
flag = PMKID_FOUND;
break;
}
}
if (i < WILC_MAX_NUM_PMKIDS) {
- memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
+ memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->peer_addr,
ETH_ALEN);
memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
WLAN_PMKID_LEN);
@@ -909,8 +909,8 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
struct wilc_priv *priv = &vif->priv;

for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
- if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
- ETH_ALEN)) {
+ if (!memcmp(pmksa->peer_addr,
+ priv->pmkid_list.pmkidlist[i].bssid, ETH_ALEN)) {
memset(&priv->pmkid_list.pmkidlist[i], 0,
sizeof(struct wilc_pmkid));
break;
diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 1ff763c10064..4dd78dd05955 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1851,14 +1851,14 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy,
struct adapter *padapter = rtw_netdev_priv(ndev);
struct security_priv *psecuritypriv = &padapter->securitypriv;

- if (is_zero_ether_addr((u8 *)pmksa->bssid))
+ if (is_zero_ether_addr((u8 *)pmksa->peer_addr))
return -EINVAL;

blInserted = false;

/* overwrite PMKID */
for (index = 0 ; index < NUM_PMKID_CACHE; index++) {
- if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) {
+ if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->peer_addr, ETH_ALEN)) {
memcpy(psecuritypriv->PMKIDList[index].PMKID, (u8 *)pmksa->pmkid, WLAN_PMKID_LEN);
psecuritypriv->PMKIDList[index].bUsed = true;
psecuritypriv->PMKIDIndex = index + 1;
@@ -1868,7 +1868,7 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy,
}

if (!blInserted) {
- memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, (u8 *)pmksa->bssid, ETH_ALEN);
+ memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, (u8 *)pmksa->peer_addr, ETH_ALEN);
memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, (u8 *)pmksa->pmkid, WLAN_PMKID_LEN);

psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true;
@@ -1889,7 +1889,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy,
struct security_priv *psecuritypriv = &padapter->securitypriv;

for (index = 0 ; index < NUM_PMKID_CACHE; index++) {
- if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) {
+ if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->peer_addr, ETH_ALEN)) {
/*
* BSSID is matched, the same AP => Remove this PMKID information
* and reset it.
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index b137a33a1b68..2eb650097348 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3345,7 +3345,8 @@ enum wiphy_params_flags {
* This structure is passed to the set/del_pmksa() method for PMKSA
* caching.
*
- * @bssid: The AP's BSSID (may be %NULL).
+ * @peer_addr: The AP's BSSID (may be %NULL) in case of Station mode. The STA's
+ * mac address (may be %NULL) in case of AP mode.
* @pmkid: The identifier to refer a PMKSA.
* @pmk: The PMK for the PMKSA identified by @pmkid. This is used for key
* derivation by a FILS STA. Otherwise, %NULL.
@@ -3370,7 +3371,7 @@ enum wiphy_params_flags {
* threshold to generate a new PMK before the current one expires.
*/
struct cfg80211_pmksa {
- const u8 *bssid;
+ const u8 *peer_addr;
const u8 *pmkid;
const u8 *pmk;
size_t pmk_len;
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 569234bc2be6..e4659c204102 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -12189,7 +12189,7 @@ static int nl80211_setdel_pmksa(struct sk_buff *skb, struct genl_info *info)
pmksa.pmkid = nla_data(info->attrs[NL80211_ATTR_PMKID]);

if (info->attrs[NL80211_ATTR_MAC]) {
- pmksa.bssid = nla_data(info->attrs[NL80211_ATTR_MAC]);
+ pmksa.peer_addr = nla_data(info->attrs[NL80211_ATTR_MAC]);
} else if (info->attrs[NL80211_ATTR_SSID] &&
info->attrs[NL80211_ATTR_FILS_CACHE_ID] &&
(info->genlhdr->cmd == NL80211_CMD_DEL_PMKSA ||
diff --git a/net/wireless/trace.h b/net/wireless/trace.h
index 30cd1bd58aac..8bc6e7dc70e7 100644
--- a/net/wireless/trace.h
+++ b/net/wireless/trace.h
@@ -1925,7 +1925,7 @@ DECLARE_EVENT_CLASS(rdev_pmksa,
TP_fast_assign(
WIPHY_ASSIGN;
NETDEV_ASSIGN;
- MAC_ASSIGN(bssid, pmksa->bssid);
+ MAC_ASSIGN(bssid, pmksa->peer_addr);
),
TP_printk(WIPHY_PR_FMT ", " NETDEV_PR_FMT ", bssid: %pM",
WIPHY_PR_ARG, NETDEV_PR_ARG, __entry->bssid)
diff --git a/net/wireless/wext-compat.c b/net/wireless/wext-compat.c
index 2371069f3c43..ee7d9066485f 100644
--- a/net/wireless/wext-compat.c
+++ b/net/wireless/wext-compat.c
@@ -1544,7 +1544,7 @@ static int cfg80211_wext_siwpmksa(struct net_device *dev,
if (wdev->iftype != NL80211_IFTYPE_STATION)
return -EINVAL;

- cfg_pmksa.bssid = pmksa->bssid.sa_data;
+ cfg_pmksa.peer_addr = pmksa->bssid.sa_data;
cfg_pmksa.pmkid = pmksa->pmkid;

wiphy_lock(&rdev->wiphy);
--
2.17.1


2023-11-21 12:57:06

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH] wifi: cfg80211: Rename bssid to peer_addr in cfg80211_pmksa

Anuj Khera <[email protected]> writes:

> The cfg80211_pmksa structure uses bssid member to store
> the PMKSA for a BSS in Station mode. Change the name of
> structure member bssid to peer_addr so that same member
> can be used to store the PMKSA for a station in AP mode
> using station MAC address.
>
> Signed-off-by: Anuj Khera <[email protected]>
> ---
> drivers/net/wireless/ath/ath6kl/cfg80211.c | 8 ++++----
> .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 12 ++++++------
> drivers/net/wireless/microchip/wilc1000/cfg80211.c | 10 +++++-----
> drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 8 ++++----
> include/net/cfg80211.h | 5 +++--
> net/wireless/nl80211.c | 2 +-
> net/wireless/trace.h | 2 +-
> net/wireless/wext-compat.c | 2 +-
> 8 files changed, 25 insertions(+), 24 deletions(-)

For a rename like this I would expect to see patch 2 adding the actual
functionality.

Johannes, just so you know this patch has nothing to do with
ath10k/ath11k/ath12k. I guess this is for the proprietary Qualcomm
driver?

--
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

2023-11-24 17:35:57

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] wifi: cfg80211: Rename bssid to peer_addr in cfg80211_pmksa

On Mon, 2023-11-20 at 11:54 +0530, Anuj Khera wrote:
> The cfg80211_pmksa structure uses bssid member to store
> the PMKSA for a BSS in Station mode. Change the name of
> structure member bssid to peer_addr so that same member
> can be used to store the PMKSA for a station in AP mode
> using station MAC address.
>
> Signed-off-by: Anuj Khera <[email protected]>
> ---

Please tag your patches with a version, and document the changes between
them.

> *
> - * @bssid: The AP's BSSID (may be %NULL).
> + * @peer_addr: The AP's BSSID (may be %NULL) in case of Station mode. The STA's
> + * mac address (may be %NULL) in case of AP mode.
>

"MAC address", I guess?

And the "may be %NULL" really makes zero sense in AP mode, who are you
going to have the entry for?!

It barely even makes sense in client mode.

johannes