Skip to content

Commit

Permalink
cfg80211: Add support for key operations on NL80211_IFTYPE_MLO_LINK
Browse files Browse the repository at this point in the history
Allow key operations on NL80211_IFTYPE_MLO_LINK to support configuring
per MLO link keys such as GTK/IGTK/BIGTK.

Add necessary changes in mac80211 and drivers to conform to updated
function signatures

Signed-off-by: Veerendranath Jakkam <quic_vjakkam@quicinc.com>
  • Loading branch information
Veerendranath Jakkam authored and intel-lab-lkp committed Feb 22, 2022
1 parent 153c8af commit 01fd327
Show file tree
Hide file tree
Showing 20 changed files with 486 additions and 211 deletions.
52 changes: 41 additions & 11 deletions drivers/net/wireless/ath/ath6kl/cfg80211.c
Expand Up @@ -1123,17 +1123,25 @@ void ath6kl_cfg80211_ch_switch_notify(struct ath6kl_vif *vif, int freq,
mutex_unlock(&vif->wdev.mtx);
}

static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
static int ath6kl_cfg80211_add_key(struct wiphy *wiphy,
struct wireless_dev *wdev,
u8 key_index, bool pairwise,
const u8 *mac_addr,
struct key_params *params)
{
struct ath6kl *ar = ath6kl_priv(ndev);
struct ath6kl_vif *vif = netdev_priv(ndev);
struct ath6kl *ar;
struct ath6kl_vif *vif;
struct ath6kl_key *key = NULL;
int seq_len;
u8 key_usage;
u8 key_type;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ar = ath6kl_priv(ndev);
vif = netdev_priv(ndev);

if (!ath6kl_cfg80211_ready(vif))
return -EIO;
Expand Down Expand Up @@ -1248,12 +1256,20 @@ static int ath6kl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
(u8 *) mac_addr, SYNC_BOTH_WMIFLAG);
}

static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
static int ath6kl_cfg80211_del_key(struct wiphy *wiphy,
struct wireless_dev *wdev,
u8 key_index, bool pairwise,
const u8 *mac_addr)
{
struct ath6kl *ar = ath6kl_priv(ndev);
struct ath6kl_vif *vif = netdev_priv(ndev);
struct ath6kl *ar;
struct ath6kl_vif *vif;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ar = ath6kl_priv(ndev);
vif = netdev_priv(ndev);

ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);

Expand All @@ -1278,15 +1294,22 @@ static int ath6kl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
return ath6kl_wmi_deletekey_cmd(ar->wmi, vif->fw_vif_idx, key_index);
}

static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev,
static int ath6kl_cfg80211_get_key(struct wiphy *wiphy,
struct wireless_dev *wdev,
u8 key_index, bool pairwise,
const u8 *mac_addr, void *cookie,
void (*callback) (void *cookie,
struct key_params *))
{
struct ath6kl_vif *vif = netdev_priv(ndev);
struct ath6kl_vif *vif;
struct ath6kl_key *key = NULL;
struct key_params params;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

vif = netdev_priv(ndev);

ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);

Expand Down Expand Up @@ -1314,15 +1337,22 @@ static int ath6kl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev,
}

static int ath6kl_cfg80211_set_default_key(struct wiphy *wiphy,
struct net_device *ndev,
struct wireless_dev *wdev,
u8 key_index, bool unicast,
bool multicast)
{
struct ath6kl *ar = ath6kl_priv(ndev);
struct ath6kl_vif *vif = netdev_priv(ndev);
struct ath6kl *ar;
struct ath6kl_vif *vif;
struct ath6kl_key *key = NULL;
u8 key_usage;
enum ath6kl_crypto_type key_type = NONE_CRYPT;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ar = ath6kl_priv(ndev);
vif = netdev_priv(ndev);

ath6kl_dbg(ATH6KL_DBG_WLAN_CFG, "%s: index %d\n", __func__, key_index);

Expand Down
38 changes: 24 additions & 14 deletions drivers/net/wireless/ath/wil6210/cfg80211.c
Expand Up @@ -1620,19 +1620,23 @@ static void wil_del_rx_key(u8 key_index, enum wmi_key_usage key_usage,
}

static int wil_cfg80211_add_key(struct wiphy *wiphy,
struct net_device *ndev,
struct wireless_dev *wdev,
u8 key_index, bool pairwise,
const u8 *mac_addr,
struct key_params *params)
{
int rc;
struct wil6210_vif *vif = ndev_to_vif(ndev);
struct wil6210_vif *vif;
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
struct wireless_dev *wdev = vif_to_wdev(vif);
enum wmi_key_usage key_usage = wil_detect_key_usage(wdev, pairwise);
struct wil_sta_info *cs = wil_find_sta_by_key_usage(wil, vif->mid,
key_usage,
mac_addr);
struct wil_sta_info *cs;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

vif = ndev_to_vif(ndev);
cs = wil_find_sta_by_key_usage(wil, vif->mid, key_usage, mac_addr);

if (!params) {
wil_err(wil, "NULL params\n");
Expand Down Expand Up @@ -1697,17 +1701,21 @@ static int wil_cfg80211_add_key(struct wiphy *wiphy,
}

static int wil_cfg80211_del_key(struct wiphy *wiphy,
struct net_device *ndev,
struct wireless_dev *wdev,
u8 key_index, bool pairwise,
const u8 *mac_addr)
{
struct wil6210_vif *vif = ndev_to_vif(ndev);
struct wil6210_vif *vif;
struct wil6210_priv *wil = wiphy_to_wil(wiphy);
struct wireless_dev *wdev = vif_to_wdev(vif);
enum wmi_key_usage key_usage = wil_detect_key_usage(wdev, pairwise);
struct wil_sta_info *cs = wil_find_sta_by_key_usage(wil, vif->mid,
key_usage,
mac_addr);
struct wil_sta_info *cs;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

vif = ndev_to_vif(ndev);
cs = wil_find_sta_by_key_usage(wil, vif->mid, key_usage, mac_addr);

wil_dbg_misc(wil, "del_key: %pM %s[%d]\n", mac_addr,
key_usage_str[key_usage], key_index);
Expand All @@ -1724,7 +1732,7 @@ static int wil_cfg80211_del_key(struct wiphy *wiphy,

/* Need to be present or wiphy_new() will WARN */
static int wil_cfg80211_set_default_key(struct wiphy *wiphy,
struct net_device *ndev,
struct wireless_dev *wdev,
u8 key_index, bool unicast,
bool multicast)
{
Expand Down Expand Up @@ -2038,11 +2046,13 @@ void wil_cfg80211_ap_recovery(struct wil6210_priv *wil)
struct net_device *ndev;
struct cfg80211_beacon_data bcon = {};
struct key_params key_params = {};
struct wireless_dev *wdev;

if (!vif || vif->ssid_len == 0)
continue;

ndev = vif_to_ndev(vif);
wdev = ndev->ieee80211_ptr;
bcon.proberesp_ies = vif->proberesp_ies;
bcon.assocresp_ies = vif->assocresp_ies;
bcon.probe_resp = vif->proberesp;
Expand Down Expand Up @@ -2073,7 +2083,7 @@ void wil_cfg80211_ap_recovery(struct wil6210_priv *wil)
key_params.key = vif->gtk;
key_params.key_len = vif->gtk_len;
key_params.seq_len = IEEE80211_GCMP_PN_LEN;
rc = wil_cfg80211_add_key(wiphy, ndev, vif->gtk_index, false,
rc = wil_cfg80211_add_key(wiphy, wdev, vif->gtk_index, false,
NULL, &key_params);
if (rc)
wil_err(wil, "vif %d recovery add key failed (%d)\n",
Expand Down
58 changes: 44 additions & 14 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
Expand Up @@ -2360,14 +2360,22 @@ brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
}

static s32
brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *ndev,
brcmf_cfg80211_config_default_key(struct wiphy *wiphy,
struct wireless_dev *wdev,
u8 key_idx, bool unicast, bool multicast)
{
struct brcmf_if *ifp = netdev_priv(ndev);
struct brcmf_pub *drvr = ifp->drvr;
struct brcmf_if *ifp;
struct brcmf_pub *drvr;
u32 index;
u32 wsec;
s32 err = 0;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ifp = netdev_priv(ndev);
drvr = ifp->drvr;

brcmf_dbg(TRACE, "Enter\n");
brcmf_dbg(CONN, "key index (%d)\n", key_idx);
Expand All @@ -2394,13 +2402,18 @@ brcmf_cfg80211_config_default_key(struct wiphy *wiphy, struct net_device *ndev,
}

static s32
brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
brcmf_cfg80211_del_key(struct wiphy *wiphy, struct wireless_dev *wdev,
u8 key_idx, bool pairwise, const u8 *mac_addr)
{
struct brcmf_if *ifp = netdev_priv(ndev);
struct brcmf_if *ifp;
struct brcmf_wsec_key *key;
s32 err;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ifp = netdev_priv(ndev);
brcmf_dbg(TRACE, "Enter\n");
brcmf_dbg(CONN, "key index (%d)\n", key_idx);

Expand Down Expand Up @@ -2431,20 +2444,25 @@ brcmf_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
}

static s32
brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
brcmf_cfg80211_add_key(struct wiphy *wiphy, struct wireless_dev *wdev,
u8 key_idx, bool pairwise, const u8 *mac_addr,
struct key_params *params)
{
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct brcmf_if *ifp = netdev_priv(ndev);
struct brcmf_if *ifp;
struct brcmf_pub *drvr = cfg->pub;
struct brcmf_wsec_key *key;
s32 val;
s32 wsec;
s32 err;
u8 keybuf[8];
bool ext_key;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ifp = netdev_priv(ndev);
brcmf_dbg(TRACE, "Enter\n");
brcmf_dbg(CONN, "key index (%d)\n", key_idx);
if (!check_vif_up(ifp->vif))
Expand All @@ -2457,7 +2475,7 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
}

if (params->key_len == 0)
return brcmf_cfg80211_del_key(wiphy, ndev, key_idx, pairwise,
return brcmf_cfg80211_del_key(wiphy, wdev, key_idx, pairwise,
mac_addr);

if (params->key_len > sizeof(key->data)) {
Expand Down Expand Up @@ -2553,20 +2571,27 @@ brcmf_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
}

static s32
brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_idx,
bool pairwise, const u8 *mac_addr, void *cookie,
brcmf_cfg80211_get_key(struct wiphy *wiphy, struct wireless_dev *wdev,
u8 key_idx, bool pairwise, const u8 *mac_addr,
void *cookie,
void (*callback)(void *cookie,
struct key_params *params))
{
struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
struct key_params params;
struct brcmf_if *ifp = netdev_priv(ndev);
struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
struct brcmf_if *ifp;
struct brcmf_cfg80211_profile *profile;
struct brcmf_pub *drvr = cfg->pub;
struct brcmf_cfg80211_security *sec;
s32 wsec;
s32 err = 0;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ifp = netdev_priv(ndev);
profile = &ifp->vif->profile;
brcmf_dbg(TRACE, "Enter\n");
brcmf_dbg(CONN, "key index (%d)\n", key_idx);
if (!check_vif_up(ifp->vif))
Expand Down Expand Up @@ -2610,10 +2635,15 @@ brcmf_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_idx,

static s32
brcmf_cfg80211_config_default_mgmt_key(struct wiphy *wiphy,
struct net_device *ndev, u8 key_idx)
struct wireless_dev *wdev, u8 key_idx)
{
struct brcmf_if *ifp = netdev_priv(ndev);
struct brcmf_if *ifp;
struct net_device *ndev = wdev->netdev;

if (!ndev)
return -EOPNOTSUPP;

ifp = netdev_priv(ndev);
brcmf_dbg(TRACE, "Enter key_idx %d\n", key_idx);

if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MFP))
Expand Down
14 changes: 11 additions & 3 deletions drivers/net/wireless/marvell/libertas/cfg.c
Expand Up @@ -1437,11 +1437,15 @@ static int lbs_cfg_disconnect(struct wiphy *wiphy, struct net_device *dev,
}

static int lbs_cfg_set_default_key(struct wiphy *wiphy,
struct net_device *netdev,
struct wireless_dev *wdev,
u8 key_index, bool unicast,
bool multicast)
{
struct lbs_private *priv = wiphy_priv(wiphy);
struct net_device *netdev = wdev->netdev;

if (!netdev)
return -EOPNOTSUPP;

if (netdev == priv->mesh_dev)
return -EOPNOTSUPP;
Expand All @@ -1456,14 +1460,18 @@ static int lbs_cfg_set_default_key(struct wiphy *wiphy,
}


static int lbs_cfg_add_key(struct wiphy *wiphy, struct net_device *netdev,
static int lbs_cfg_add_key(struct wiphy *wiphy, struct wireless_dev *wdev,
u8 idx, bool pairwise, const u8 *mac_addr,
struct key_params *params)
{
struct lbs_private *priv = wiphy_priv(wiphy);
u16 key_info;
u16 key_type;
int ret = 0;
struct net_device *netdev = wdev->netdev;

if (!netdev)
return -EOPNOTSUPP;

if (netdev == priv->mesh_dev)
return -EOPNOTSUPP;
Expand Down Expand Up @@ -1517,7 +1525,7 @@ static int lbs_cfg_add_key(struct wiphy *wiphy, struct net_device *netdev,
}


static int lbs_cfg_del_key(struct wiphy *wiphy, struct net_device *netdev,
static int lbs_cfg_del_key(struct wiphy *wiphy, struct wireless_dev *wdev,
u8 key_index, bool pairwise, const u8 *mac_addr)
{

Expand Down

0 comments on commit 01fd327

Please sign in to comment.