* [PATCH 1/4] rndis_wlan: copy only useful data from rndis_command respond
@ 2010-03-02 22:38 Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 2/4] rndis_wlan: remove unused variables from priv structure Jussi Kivilinna
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Jussi Kivilinna @ 2010-03-02 22:38 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
rndis_query_oid() uses full output buffer size to copy response buffer
from rndis_command()/device. This doesn't cause problems as response buffer
is sized based on output buffer but does copy extra unset bytes.
So change rndis_query_oid() so that only meaningful bytes are being copied.
Also in case of malfunctioning device/cable/etc returned data offset from
device might be wrong so bound check memory access correctly, so add
checks for this.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
drivers/net/wireless/rndis_wlan.c | 33 +++++++++++++++++++++++++++++----
1 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 305c106..b275713 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -704,6 +704,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
struct rndis_query_c *get_c;
} u;
int ret, buflen;
+ int resplen, respoffs, copylen;
buflen = *len + sizeof(*u.get);
if (buflen < CONTROL_BUFFER_SIZE)
@@ -733,11 +734,34 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
le32_to_cpu(u.get_c->status));
if (ret == 0) {
- memcpy(data, u.buf + le32_to_cpu(u.get_c->offset) + 8, *len);
+ resplen = le32_to_cpu(u.get_c->len);
+ respoffs = le32_to_cpu(u.get_c->offset) + 8;
- ret = le32_to_cpu(u.get_c->len);
- if (ret > *len)
- *len = ret;
+ if (respoffs > buflen) {
+ /* Device returned data offset outside buffer, error. */
+ devdbg(dev, "rndis_query_oid(%s): received invalid "
+ "data offset: %d > %d", oid_to_string(oid),
+ respoffs, buflen);
+
+ ret = -EINVAL;
+ goto exit_unlock;
+ }
+
+ if ((resplen + respoffs) > buflen) {
+ /* Device would have returned more data if buffer would
+ * have been big enough. Copy just the bits that we got.
+ */
+ copylen = buflen - respoffs;
+ } else {
+ copylen = resplen;
+ }
+
+ if (copylen > *len)
+ copylen = *len;
+
+ memcpy(data, u.buf + respoffs, copylen);
+
+ *len = resplen;
ret = rndis_error_status(u.get_c->status);
if (ret < 0)
@@ -746,6 +770,7 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
le32_to_cpu(u.get_c->status), ret);
}
+exit_unlock:
mutex_unlock(&priv->command_lock);
if (u.buf != priv->command_buffer)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] rndis_wlan: remove unused variables from priv structure
2010-03-02 22:38 [PATCH 1/4] rndis_wlan: copy only useful data from rndis_command respond Jussi Kivilinna
@ 2010-03-02 22:38 ` Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 3/4] rndis_wlan: get max_num_pmkids from device Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 4/4] rndis_wlan: Implement cfg80211 PMKSA API Jussi Kivilinna
2 siblings, 0 replies; 6+ messages in thread
From: Jussi Kivilinna @ 2010-03-02 22:38 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
Some variables were left unused after cfg80211 conversion. Remove those and related deadcode.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
drivers/net/wireless/rndis_wlan.c | 14 --------------
1 files changed, 0 insertions(+), 14 deletions(-)
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index b275713..51e6880 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -476,13 +476,7 @@ struct rndis_wlan_private {
/* encryption stuff */
int encr_tx_key_index;
struct rndis_wlan_encr_key encr_keys[4];
- enum nl80211_auth_type wpa_auth_type;
int wpa_version;
- int wpa_keymgmt;
- int wpa_ie_len;
- u8 *wpa_ie;
- int wpa_cipher_pair;
- int wpa_cipher_group;
u8 command_buffer[COMMAND_BUFFER_SIZE];
};
@@ -1112,8 +1106,6 @@ static int set_auth_mode(struct usbnet *usbdev, u32 wpa_version,
}
priv->wpa_version = wpa_version;
- priv->wpa_auth_type = auth_type;
- priv->wpa_keymgmt = keymgmt;
return 0;
}
@@ -1137,7 +1129,6 @@ static int set_priv_filter(struct usbnet *usbdev)
static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
{
- struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
__le32 tmp;
int encr_mode, ret;
@@ -1165,8 +1156,6 @@ static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
return ret;
}
- priv->wpa_cipher_pair = pairwise;
- priv->wpa_cipher_group = groupwise;
return 0;
}
@@ -2849,9 +2838,6 @@ static void rndis_wlan_unbind(struct usbnet *usbdev, struct usb_interface *intf)
flush_workqueue(priv->workqueue);
destroy_workqueue(priv->workqueue);
- if (priv && priv->wpa_ie_len)
- kfree(priv->wpa_ie);
-
rndis_unbind(usbdev, intf);
wiphy_unregister(priv->wdev.wiphy);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] rndis_wlan: get max_num_pmkids from device
2010-03-02 22:38 [PATCH 1/4] rndis_wlan: copy only useful data from rndis_command respond Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 2/4] rndis_wlan: remove unused variables from priv structure Jussi Kivilinna
@ 2010-03-02 22:38 ` Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 4/4] rndis_wlan: Implement cfg80211 PMKSA API Jussi Kivilinna
2 siblings, 0 replies; 6+ messages in thread
From: Jussi Kivilinna @ 2010-03-02 22:38 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
Extend rndis_wlan_get_caps() to get 802.11 capabilities and maximum
supported number of PMKIDs by device.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
drivers/net/wireless/rndis_wlan.c | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 51e6880..4054b70 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -117,6 +117,7 @@ MODULE_PARM_DESC(workaround_interval,
#define OID_802_11_ADD_KEY cpu_to_le32(0x0d01011d)
#define OID_802_11_REMOVE_KEY cpu_to_le32(0x0d01011e)
#define OID_802_11_ASSOCIATION_INFORMATION cpu_to_le32(0x0d01011f)
+#define OID_802_11_CAPABILITY cpu_to_le32(0x0d010122)
#define OID_802_11_PMKID cpu_to_le32(0x0d010123)
#define OID_802_11_NETWORK_TYPES_SUPPORTED cpu_to_le32(0x0d010203)
#define OID_802_11_NETWORK_TYPE_IN_USE cpu_to_le32(0x0d010204)
@@ -358,6 +359,19 @@ struct ndis_80211_assoc_info {
__le32 offset_resp_ies;
} __attribute__((packed));
+struct ndis_80211_auth_encr_pair {
+ __le32 auth_mode;
+ __le32 encr_mode;
+} __attribute__((packed));
+
+struct ndis_80211_capability {
+ __le32 length;
+ __le32 version;
+ __le32 num_pmkids;
+ __le32 num_auth_encr_pair;
+ struct ndis_80211_auth_encr_pair auth_encr_pair[0];
+} __attribute__((packed));
+
/*
* private data
*/
@@ -2498,12 +2512,14 @@ static void rndis_wlan_indication(struct usbnet *usbdev, void *ind, int buflen)
}
}
-static int rndis_wlan_get_caps(struct usbnet *usbdev)
+static int rndis_wlan_get_caps(struct usbnet *usbdev, struct wiphy *wiphy)
{
struct {
__le32 num_items;
__le32 items[8];
} networks_supported;
+ struct ndis_80211_capability *caps;
+ u8 caps_buf[sizeof(*caps) + sizeof(caps->auth_encr_pair) * 16];
int len, retval, i, n;
struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
@@ -2531,6 +2547,21 @@ static int rndis_wlan_get_caps(struct usbnet *usbdev)
}
}
+ /* get device 802.11 capabilities, number of PMKIDs */
+ caps = (struct ndis_80211_capability *)caps_buf;
+ len = sizeof(caps_buf);
+ retval = rndis_query_oid(usbdev, OID_802_11_CAPABILITY, caps, &len);
+ if (retval >= 0) {
+ devdbg(usbdev, "OID_802_11_CAPABILITY -> len %d, ver %d, "
+ "pmkids %d, auth-encr-pairs %d",
+ le32_to_cpu(caps->length),
+ le32_to_cpu(caps->version),
+ le32_to_cpu(caps->num_pmkids),
+ le32_to_cpu(caps->num_auth_encr_pair));
+ wiphy->max_num_pmkids = le32_to_cpu(caps->num_pmkids);
+ } else
+ wiphy->max_num_pmkids = 0;
+
return retval;
}
@@ -2778,7 +2809,7 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf)
wiphy->max_scan_ssids = 1;
/* TODO: fill-out band/encr information based on priv->caps */
- rndis_wlan_get_caps(usbdev);
+ rndis_wlan_get_caps(usbdev, wiphy);
memcpy(priv->channels, rndis_channels, sizeof(rndis_channels));
memcpy(priv->rates, rndis_rates, sizeof(rndis_rates));
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] rndis_wlan: Implement cfg80211 PMKSA API
2010-03-02 22:38 [PATCH 1/4] rndis_wlan: copy only useful data from rndis_command respond Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 2/4] rndis_wlan: remove unused variables from priv structure Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 3/4] rndis_wlan: get max_num_pmkids from device Jussi Kivilinna
@ 2010-03-02 22:38 ` Jussi Kivilinna
2010-03-03 7:26 ` Jussi Kivilinna
2 siblings, 1 reply; 6+ messages in thread
From: Jussi Kivilinna @ 2010-03-02 22:38 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
Add support for cfg80211 set_pmksa/del_pmksa/flush_pmksa. Updating PMKID
entry list is done on driver side since NDIS API requires full list update.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
drivers/net/wireless/rndis_wlan.c | 271 +++++++++++++++++++++++++++++++++++++
1 files changed, 271 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 4054b70..65f5236 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -372,6 +372,18 @@ struct ndis_80211_capability {
struct ndis_80211_auth_encr_pair auth_encr_pair[0];
} __attribute__((packed));
+struct ndis_80211_bssid_info {
+ u8 bssid[6];
+ u8 padding[2];
+ u8 pmkid[16];
+};
+
+struct ndis_80211_pmkid {
+ __le32 length;
+ __le32 bssid_info_count;
+ struct ndis_80211_bssid_info bssid_info[0];
+};
+
/*
* private data
*/
@@ -542,6 +554,14 @@ static int rndis_get_station(struct wiphy *wiphy, struct net_device *dev,
static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
int idx, u8 *mac, struct station_info *sinfo);
+static int rndis_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
+ struct cfg80211_pmksa *pmksa);
+
+static int rndis_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
+ struct cfg80211_pmksa *pmksa);
+
+static int rndis_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev);
+
static struct cfg80211_ops rndis_config_ops = {
.change_virtual_intf = rndis_change_virtual_intf,
.scan = rndis_scan,
@@ -558,6 +578,9 @@ static struct cfg80211_ops rndis_config_ops = {
.set_default_key = rndis_set_default_key,
.get_station = rndis_get_station,
.dump_station = rndis_dump_station,
+ .set_pmksa = rndis_set_pmksa,
+ .del_pmksa = rndis_del_pmksa,
+ .flush_pmksa = rndis_flush_pmksa,
};
static void *rndis_wiphy_privid = &rndis_wiphy_privid;
@@ -1565,6 +1588,190 @@ static void set_multicast_list(struct usbnet *usbdev)
le32_to_cpu(filter), ret);
}
+#ifdef DEBUG
+static void debug_print_pmkids(struct usbnet *usbdev,
+ struct ndis_80211_pmkid *pmkids,
+ const char *func_str)
+{
+ struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
+ int i, len, count, max_pmkids;
+
+ max_pmkids = priv->wdev.wiphy->max_num_pmkids;
+ len = le32_to_cpu(pmkids->length);
+ count = le32_to_cpu(pmkids->bssid_info_count);
+
+ devdbg(usbdev, "%s: %d PMKIDs", func_str, count);
+
+ if (count > max_pmkids)
+ count = max_pmkids;
+
+ for (i = 0; i < count; i++) {
+ u32 *tmp = (u32 *)pmkids->bssid_info[i].pmkid;
+
+ devdbg(usbdev, "%s: bssid: %pM, pmkid: %08X:%08X:%08X:%08X",
+ func_str, pmkids->bssid_info[i].bssid,
+ cpu_to_be32(tmp[0]), cpu_to_be32(tmp[1]),
+ cpu_to_be32(tmp[2]), cpu_to_be32(tmp[3]));
+ }
+}
+#else
+static void debug_print_pmkids(struct usbnet *usbdev,
+ struct ndis_80211_pmkid *pmkids,
+ const char *func_str)
+{
+ return;
+}
+#endif
+
+static struct ndis_80211_pmkid *get_device_pmkids(struct usbnet *usbdev)
+{
+ struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
+ struct ndis_80211_pmkid *pmkids;
+ int len, ret, max_pmkids;
+
+ max_pmkids = priv->wdev.wiphy->max_num_pmkids;
+ len = sizeof(*pmkids) + max_pmkids * sizeof(pmkids->bssid_info[0]);
+
+ pmkids = kzalloc(len, GFP_KERNEL);
+ if (!pmkids)
+ return ERR_PTR(-ENOMEM);
+
+ pmkids->length = cpu_to_le32(len);
+ pmkids->bssid_info_count = cpu_to_le32(max_pmkids);
+
+ ret = rndis_query_oid(usbdev, OID_802_11_PMKID, pmkids, &len);
+ if (ret < 0) {
+ devdbg(usbdev, "get_device_pmkids(): OID_802_11_PMKID(%d, %d)"
+ " -> %d", len, max_pmkids, ret);
+
+ kfree(pmkids);
+ return ERR_PTR(ret);
+ }
+
+ if (le32_to_cpu(pmkids->bssid_info_count) > max_pmkids)
+ pmkids->bssid_info_count = cpu_to_le32(max_pmkids);
+
+ debug_print_pmkids(usbdev, pmkids, "get_device_pmkids()");
+
+ return pmkids;
+}
+
+static int set_device_pmkids(struct usbnet *usbdev,
+ struct ndis_80211_pmkid *pmkids)
+{
+ int ret, len, num_pmkids;
+
+ num_pmkids = le32_to_cpu(pmkids->bssid_info_count);
+ len = sizeof(*pmkids) + num_pmkids * sizeof(pmkids->bssid_info[0]);
+ pmkids->length = cpu_to_le32(len);
+
+ debug_print_pmkids(usbdev, pmkids, "set_device_pmkids()");
+
+ ret = rndis_set_oid(usbdev, OID_802_11_PMKID, pmkids,
+ le32_to_cpu(pmkids->length));
+ if (ret < 0) {
+ devdbg(usbdev, "set_device_pmkids(): OID_802_11_PMKID(%d, %d)"
+ " -> %d", len, num_pmkids, ret);
+ }
+
+ kfree(pmkids);
+ return ret;
+}
+
+static struct ndis_80211_pmkid *remove_pmkid(struct usbnet *usbdev,
+ struct ndis_80211_pmkid *pmkids,
+ struct cfg80211_pmksa *pmksa,
+ int max_pmkids)
+{
+ int i, len, count, newlen, err;
+
+ len = le32_to_cpu(pmkids->length);
+ count = le32_to_cpu(pmkids->bssid_info_count);
+
+ if (count > max_pmkids)
+ count = max_pmkids;
+
+ for (i = 0; i < count; i++)
+ if (!compare_ether_addr(pmkids->bssid_info[i].bssid,
+ pmksa->bssid))
+ break;
+
+ /* pmkid not found */
+ if (i == count) {
+ devdbg(usbdev, "remove_pmkid(): bssid not found (%pM)",
+ pmksa->bssid);
+ err = -ENOENT;
+ goto error;
+ }
+
+ for (; i + 1 < count; i++)
+ pmkids->bssid_info[i] = pmkids->bssid_info[i + 1];
+
+ count--;
+ newlen = sizeof(*pmkids) + count * sizeof(pmkids->bssid_info[0]);
+
+ pmkids->length = cpu_to_le32(newlen);
+ pmkids->bssid_info_count = cpu_to_le32(count);
+
+ return pmkids;
+error:
+ kfree(pmkids);
+ return ERR_PTR(err);
+}
+
+static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev,
+ struct ndis_80211_pmkid *pmkids,
+ struct cfg80211_pmksa *pmksa,
+ int max_pmkids)
+{
+ int i, err, len, count, newlen;
+
+ len = le32_to_cpu(pmkids->length);
+ count = le32_to_cpu(pmkids->bssid_info_count);
+
+ if (count > max_pmkids)
+ count = max_pmkids;
+
+ /* update with new pmkid */
+ for (i = 0; i < count; i++) {
+ if (compare_ether_addr(pmkids->bssid_info[i].bssid,
+ pmksa->bssid))
+ continue;
+
+ memcpy(pmkids->bssid_info[i].pmkid, pmksa->pmkid,
+ WLAN_PMKID_LEN);
+
+ return pmkids;
+ }
+
+ /* out of space, return error */
+ if (i == max_pmkids) {
+ devdbg(usbdev, "update_pmkid(): out of space");
+ err = -ENOSPC;
+ goto error;
+ }
+
+ /* add new pmkid */
+ newlen = sizeof(*pmkids) + (count + 1) * sizeof(pmkids->bssid_info[0]);
+
+ pmkids = krealloc(pmkids, newlen, GFP_KERNEL);
+ if (!pmkids) {
+ err = -ENOMEM;
+ goto error;
+ }
+
+ pmkids->length = cpu_to_le32(newlen);
+ pmkids->bssid_info_count = cpu_to_le32(count + 1);
+
+ memcpy(pmkids->bssid_info[count].bssid, pmksa->bssid, ETH_ALEN);
+ memcpy(pmkids->bssid_info[count].pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
+
+ return pmkids;
+error:
+ kfree(pmkids);
+ return ERR_PTR(err);
+}
+
/*
* cfg80211 ops
*/
@@ -2164,6 +2371,70 @@ static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
return 0;
}
+static int rndis_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
+ struct cfg80211_pmksa *pmksa)
+{
+ struct rndis_wlan_private *priv = wiphy_priv(wiphy);
+ struct usbnet *usbdev = priv->usbdev;
+ struct ndis_80211_pmkid *pmkids;
+
+ devdbg(usbdev, "rndis_set_pmksa()");
+
+ pmkids = get_device_pmkids(usbdev);
+ if (IS_ERR(pmkids)) {
+ /* couldn't read PMKID cache from device */
+ return PTR_ERR(pmkids);
+ }
+
+ pmkids = update_pmkid(usbdev, pmkids, pmksa, wiphy->max_num_pmkids);
+ if (IS_ERR(pmkids)) {
+ /* not found, list full, etc */
+ return PTR_ERR(pmkids);
+ }
+
+ return set_device_pmkids(usbdev, pmkids);
+}
+
+static int rndis_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
+ struct cfg80211_pmksa *pmksa)
+{
+ struct rndis_wlan_private *priv = wiphy_priv(wiphy);
+ struct usbnet *usbdev = priv->usbdev;
+ struct ndis_80211_pmkid *pmkids;
+
+ devdbg(usbdev, "rndis_del_pmksa()");
+
+ pmkids = get_device_pmkids(usbdev);
+ if (IS_ERR(pmkids)) {
+ /* Couldn't read PMKID cache from device */
+ return PTR_ERR(pmkids);
+ }
+
+ pmkids = remove_pmkid(usbdev, pmkids, pmksa, wiphy->max_num_pmkids);
+ if (IS_ERR(pmkids)) {
+ /* not found, etc */
+ return PTR_ERR(pmkids);
+ }
+
+ return set_device_pmkids(usbdev, pmkids);
+}
+
+static int rndis_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
+{
+ struct rndis_wlan_private *priv = wiphy_priv(wiphy);
+ struct usbnet *usbdev = priv->usbdev;
+ struct ndis_80211_pmkid pmkid;
+
+ devdbg(usbdev, "rndis_flush_pmksa()");
+
+ memset(&pmkid, 0, sizeof(pmkid));
+
+ pmkid.length = cpu_to_le32(sizeof(pmkid));
+ pmkid.bssid_info_count = cpu_to_le32(0);
+
+ return rndis_set_oid(usbdev, OID_802_11_PMKID, &pmkid, sizeof(pmkid));
+}
+
/*
* workers, indication handlers, device poller
*/
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 4/4] rndis_wlan: Implement cfg80211 PMKSA API
2010-03-02 22:38 ` [PATCH 4/4] rndis_wlan: Implement cfg80211 PMKSA API Jussi Kivilinna
@ 2010-03-03 7:26 ` Jussi Kivilinna
0 siblings, 0 replies; 6+ messages in thread
From: Jussi Kivilinna @ 2010-03-03 7:26 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
Hello,
Please ignore these patches, I didn't pull latest wireless-testing
before sending these. These patches still devdbg/devwarn, instead of
new netdev_dbg/etc. Sorry.
-Jussi
Quoting "Jussi Kivilinna" <jussi.kivilinna@mbnet.fi>:
> Add support for cfg80211 set_pmksa/del_pmksa/flush_pmksa. Updating PMKID
> entry list is done on driver side since NDIS API requires full list update.
>
> Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
> ---
>
> drivers/net/wireless/rndis_wlan.c | 271
> +++++++++++++++++++++++++++++++++++++
> 1 files changed, 271 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/net/wireless/rndis_wlan.c
> b/drivers/net/wireless/rndis_wlan.c
> index 4054b70..65f5236 100644
> --- a/drivers/net/wireless/rndis_wlan.c
> +++ b/drivers/net/wireless/rndis_wlan.c
> @@ -372,6 +372,18 @@ struct ndis_80211_capability {
> struct ndis_80211_auth_encr_pair auth_encr_pair[0];
> } __attribute__((packed));
>
> +struct ndis_80211_bssid_info {
> + u8 bssid[6];
> + u8 padding[2];
> + u8 pmkid[16];
> +};
> +
> +struct ndis_80211_pmkid {
> + __le32 length;
> + __le32 bssid_info_count;
> + struct ndis_80211_bssid_info bssid_info[0];
> +};
> +
> /*
> * private data
> */
> @@ -542,6 +554,14 @@ static int rndis_get_station(struct wiphy
> *wiphy, struct net_device *dev,
> static int rndis_dump_station(struct wiphy *wiphy, struct net_device *dev,
> int idx, u8 *mac, struct station_info *sinfo);
>
> +static int rndis_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
> + struct cfg80211_pmksa *pmksa);
> +
> +static int rndis_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
> + struct cfg80211_pmksa *pmksa);
> +
> +static int rndis_flush_pmksa(struct wiphy *wiphy, struct net_device
> *netdev);
> +
> static struct cfg80211_ops rndis_config_ops = {
> .change_virtual_intf = rndis_change_virtual_intf,
> .scan = rndis_scan,
> @@ -558,6 +578,9 @@ static struct cfg80211_ops rndis_config_ops = {
> .set_default_key = rndis_set_default_key,
> .get_station = rndis_get_station,
> .dump_station = rndis_dump_station,
> + .set_pmksa = rndis_set_pmksa,
> + .del_pmksa = rndis_del_pmksa,
> + .flush_pmksa = rndis_flush_pmksa,
> };
>
> static void *rndis_wiphy_privid = &rndis_wiphy_privid;
> @@ -1565,6 +1588,190 @@ static void set_multicast_list(struct usbnet *usbdev)
> le32_to_cpu(filter), ret);
> }
>
> +#ifdef DEBUG
> +static void debug_print_pmkids(struct usbnet *usbdev,
> + struct ndis_80211_pmkid *pmkids,
> + const char *func_str)
> +{
> + struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
> + int i, len, count, max_pmkids;
> +
> + max_pmkids = priv->wdev.wiphy->max_num_pmkids;
> + len = le32_to_cpu(pmkids->length);
> + count = le32_to_cpu(pmkids->bssid_info_count);
> +
> + devdbg(usbdev, "%s: %d PMKIDs", func_str, count);
> +
> + if (count > max_pmkids)
> + count = max_pmkids;
> +
> + for (i = 0; i < count; i++) {
> + u32 *tmp = (u32 *)pmkids->bssid_info[i].pmkid;
> +
> + devdbg(usbdev, "%s: bssid: %pM, pmkid: %08X:%08X:%08X:%08X",
> + func_str, pmkids->bssid_info[i].bssid,
> + cpu_to_be32(tmp[0]), cpu_to_be32(tmp[1]),
> + cpu_to_be32(tmp[2]), cpu_to_be32(tmp[3]));
> + }
> +}
> +#else
> +static void debug_print_pmkids(struct usbnet *usbdev,
> + struct ndis_80211_pmkid *pmkids,
> + const char *func_str)
> +{
> + return;
> +}
> +#endif
> +
> +static struct ndis_80211_pmkid *get_device_pmkids(struct usbnet *usbdev)
> +{
> + struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
> + struct ndis_80211_pmkid *pmkids;
> + int len, ret, max_pmkids;
> +
> + max_pmkids = priv->wdev.wiphy->max_num_pmkids;
> + len = sizeof(*pmkids) + max_pmkids * sizeof(pmkids->bssid_info[0]);
> +
> + pmkids = kzalloc(len, GFP_KERNEL);
> + if (!pmkids)
> + return ERR_PTR(-ENOMEM);
> +
> + pmkids->length = cpu_to_le32(len);
> + pmkids->bssid_info_count = cpu_to_le32(max_pmkids);
> +
> + ret = rndis_query_oid(usbdev, OID_802_11_PMKID, pmkids, &len);
> + if (ret < 0) {
> + devdbg(usbdev, "get_device_pmkids(): OID_802_11_PMKID(%d, %d)"
> + " -> %d", len, max_pmkids, ret);
> +
> + kfree(pmkids);
> + return ERR_PTR(ret);
> + }
> +
> + if (le32_to_cpu(pmkids->bssid_info_count) > max_pmkids)
> + pmkids->bssid_info_count = cpu_to_le32(max_pmkids);
> +
> + debug_print_pmkids(usbdev, pmkids, "get_device_pmkids()");
> +
> + return pmkids;
> +}
> +
> +static int set_device_pmkids(struct usbnet *usbdev,
> + struct ndis_80211_pmkid *pmkids)
> +{
> + int ret, len, num_pmkids;
> +
> + num_pmkids = le32_to_cpu(pmkids->bssid_info_count);
> + len = sizeof(*pmkids) + num_pmkids * sizeof(pmkids->bssid_info[0]);
> + pmkids->length = cpu_to_le32(len);
> +
> + debug_print_pmkids(usbdev, pmkids, "set_device_pmkids()");
> +
> + ret = rndis_set_oid(usbdev, OID_802_11_PMKID, pmkids,
> + le32_to_cpu(pmkids->length));
> + if (ret < 0) {
> + devdbg(usbdev, "set_device_pmkids(): OID_802_11_PMKID(%d, %d)"
> + " -> %d", len, num_pmkids, ret);
> + }
> +
> + kfree(pmkids);
> + return ret;
> +}
> +
> +static struct ndis_80211_pmkid *remove_pmkid(struct usbnet *usbdev,
> + struct ndis_80211_pmkid *pmkids,
> + struct cfg80211_pmksa *pmksa,
> + int max_pmkids)
> +{
> + int i, len, count, newlen, err;
> +
> + len = le32_to_cpu(pmkids->length);
> + count = le32_to_cpu(pmkids->bssid_info_count);
> +
> + if (count > max_pmkids)
> + count = max_pmkids;
> +
> + for (i = 0; i < count; i++)
> + if (!compare_ether_addr(pmkids->bssid_info[i].bssid,
> + pmksa->bssid))
> + break;
> +
> + /* pmkid not found */
> + if (i == count) {
> + devdbg(usbdev, "remove_pmkid(): bssid not found (%pM)",
> + pmksa->bssid);
> + err = -ENOENT;
> + goto error;
> + }
> +
> + for (; i + 1 < count; i++)
> + pmkids->bssid_info[i] = pmkids->bssid_info[i + 1];
> +
> + count--;
> + newlen = sizeof(*pmkids) + count * sizeof(pmkids->bssid_info[0]);
> +
> + pmkids->length = cpu_to_le32(newlen);
> + pmkids->bssid_info_count = cpu_to_le32(count);
> +
> + return pmkids;
> +error:
> + kfree(pmkids);
> + return ERR_PTR(err);
> +}
> +
> +static struct ndis_80211_pmkid *update_pmkid(struct usbnet *usbdev,
> + struct ndis_80211_pmkid *pmkids,
> + struct cfg80211_pmksa *pmksa,
> + int max_pmkids)
> +{
> + int i, err, len, count, newlen;
> +
> + len = le32_to_cpu(pmkids->length);
> + count = le32_to_cpu(pmkids->bssid_info_count);
> +
> + if (count > max_pmkids)
> + count = max_pmkids;
> +
> + /* update with new pmkid */
> + for (i = 0; i < count; i++) {
> + if (compare_ether_addr(pmkids->bssid_info[i].bssid,
> + pmksa->bssid))
> + continue;
> +
> + memcpy(pmkids->bssid_info[i].pmkid, pmksa->pmkid,
> + WLAN_PMKID_LEN);
> +
> + return pmkids;
> + }
> +
> + /* out of space, return error */
> + if (i == max_pmkids) {
> + devdbg(usbdev, "update_pmkid(): out of space");
> + err = -ENOSPC;
> + goto error;
> + }
> +
> + /* add new pmkid */
> + newlen = sizeof(*pmkids) + (count + 1) * sizeof(pmkids->bssid_info[0]);
> +
> + pmkids = krealloc(pmkids, newlen, GFP_KERNEL);
> + if (!pmkids) {
> + err = -ENOMEM;
> + goto error;
> + }
> +
> + pmkids->length = cpu_to_le32(newlen);
> + pmkids->bssid_info_count = cpu_to_le32(count + 1);
> +
> + memcpy(pmkids->bssid_info[count].bssid, pmksa->bssid, ETH_ALEN);
> + memcpy(pmkids->bssid_info[count].pmkid, pmksa->pmkid, WLAN_PMKID_LEN);
> +
> + return pmkids;
> +error:
> + kfree(pmkids);
> + return ERR_PTR(err);
> +}
> +
> /*
> * cfg80211 ops
> */
> @@ -2164,6 +2371,70 @@ static int rndis_dump_station(struct wiphy
> *wiphy, struct net_device *dev,
> return 0;
> }
>
> +static int rndis_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
> + struct cfg80211_pmksa *pmksa)
> +{
> + struct rndis_wlan_private *priv = wiphy_priv(wiphy);
> + struct usbnet *usbdev = priv->usbdev;
> + struct ndis_80211_pmkid *pmkids;
> +
> + devdbg(usbdev, "rndis_set_pmksa()");
> +
> + pmkids = get_device_pmkids(usbdev);
> + if (IS_ERR(pmkids)) {
> + /* couldn't read PMKID cache from device */
> + return PTR_ERR(pmkids);
> + }
> +
> + pmkids = update_pmkid(usbdev, pmkids, pmksa, wiphy->max_num_pmkids);
> + if (IS_ERR(pmkids)) {
> + /* not found, list full, etc */
> + return PTR_ERR(pmkids);
> + }
> +
> + return set_device_pmkids(usbdev, pmkids);
> +}
> +
> +static int rndis_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
> + struct cfg80211_pmksa *pmksa)
> +{
> + struct rndis_wlan_private *priv = wiphy_priv(wiphy);
> + struct usbnet *usbdev = priv->usbdev;
> + struct ndis_80211_pmkid *pmkids;
> +
> + devdbg(usbdev, "rndis_del_pmksa()");
> +
> + pmkids = get_device_pmkids(usbdev);
> + if (IS_ERR(pmkids)) {
> + /* Couldn't read PMKID cache from device */
> + return PTR_ERR(pmkids);
> + }
> +
> + pmkids = remove_pmkid(usbdev, pmkids, pmksa, wiphy->max_num_pmkids);
> + if (IS_ERR(pmkids)) {
> + /* not found, etc */
> + return PTR_ERR(pmkids);
> + }
> +
> + return set_device_pmkids(usbdev, pmkids);
> +}
> +
> +static int rndis_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
> +{
> + struct rndis_wlan_private *priv = wiphy_priv(wiphy);
> + struct usbnet *usbdev = priv->usbdev;
> + struct ndis_80211_pmkid pmkid;
> +
> + devdbg(usbdev, "rndis_flush_pmksa()");
> +
> + memset(&pmkid, 0, sizeof(pmkid));
> +
> + pmkid.length = cpu_to_le32(sizeof(pmkid));
> + pmkid.bssid_info_count = cpu_to_le32(0);
> +
> + return rndis_set_oid(usbdev, OID_802_11_PMKID, &pmkid, sizeof(pmkid));
> +}
> +
> /*
> * workers, indication handlers, device poller
> */
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/4] rndis_wlan: remove unused variables from priv structure
2010-03-04 16:27 [PATCH 1/4 v2] rndis_wlan: copy only useful data from rndis_command respond Jussi Kivilinna
@ 2010-03-04 16:27 ` Jussi Kivilinna
0 siblings, 0 replies; 6+ messages in thread
From: Jussi Kivilinna @ 2010-03-04 16:27 UTC (permalink / raw)
To: John W. Linville; +Cc: linux-wireless
Some variables were left unused after cfg80211 conversion. Remove those and related deadcode.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
---
drivers/net/wireless/rndis_wlan.c | 14 --------------
1 files changed, 0 insertions(+), 14 deletions(-)
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index a4f70de..15bae0a 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -476,13 +476,7 @@ struct rndis_wlan_private {
/* encryption stuff */
int encr_tx_key_index;
struct rndis_wlan_encr_key encr_keys[4];
- enum nl80211_auth_type wpa_auth_type;
int wpa_version;
- int wpa_keymgmt;
- int wpa_ie_len;
- u8 *wpa_ie;
- int wpa_cipher_pair;
- int wpa_cipher_group;
u8 command_buffer[COMMAND_BUFFER_SIZE];
};
@@ -1116,8 +1110,6 @@ static int set_auth_mode(struct usbnet *usbdev, u32 wpa_version,
}
priv->wpa_version = wpa_version;
- priv->wpa_auth_type = auth_type;
- priv->wpa_keymgmt = keymgmt;
return 0;
}
@@ -1142,7 +1134,6 @@ static int set_priv_filter(struct usbnet *usbdev)
static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
{
- struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev);
__le32 tmp;
int encr_mode, ret;
@@ -1171,8 +1162,6 @@ static int set_encr_mode(struct usbnet *usbdev, int pairwise, int groupwise)
return ret;
}
- priv->wpa_cipher_pair = pairwise;
- priv->wpa_cipher_group = groupwise;
return 0;
}
@@ -2871,9 +2860,6 @@ static void rndis_wlan_unbind(struct usbnet *usbdev, struct usb_interface *intf)
flush_workqueue(priv->workqueue);
destroy_workqueue(priv->workqueue);
- if (priv && priv->wpa_ie_len)
- kfree(priv->wpa_ie);
-
rndis_unbind(usbdev, intf);
wiphy_unregister(priv->wdev.wiphy);
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-03-04 16:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-02 22:38 [PATCH 1/4] rndis_wlan: copy only useful data from rndis_command respond Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 2/4] rndis_wlan: remove unused variables from priv structure Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 3/4] rndis_wlan: get max_num_pmkids from device Jussi Kivilinna
2010-03-02 22:38 ` [PATCH 4/4] rndis_wlan: Implement cfg80211 PMKSA API Jussi Kivilinna
2010-03-03 7:26 ` Jussi Kivilinna
-- strict thread matches above, loose matches on Subject: below --
2010-03-04 16:27 [PATCH 1/4 v2] rndis_wlan: copy only useful data from rndis_command respond Jussi Kivilinna
2010-03-04 16:27 ` [PATCH 2/4] rndis_wlan: remove unused variables from priv structure Jussi Kivilinna
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).