提交 6eb6edf0 编写于 作者: J James Ketrenos 提交者: Jeff Garzik

[PATCH] ieee80211: in-tree driver updates to sync with latest ieee80211 series

Changed crypto method from requiring a struct ieee80211_device reference
to the init handler.  Instead we now have a get/set flags method for
each crypto component.

Setting of TKIP countermeasures can now be done via
set_flags(IEEE80211_CRYPTO_TKIP_COUNTERMEASURES)
Signed-off-by: NJames Ketrenos <jketreno@linux.intel.com>
Signed-off-by: NJeff Garzik <jgarzik@pobox.com>
上级 e5658d3e
...@@ -876,7 +876,6 @@ struct ieee80211_device { ...@@ -876,7 +876,6 @@ struct ieee80211_device {
/* WPA data */ /* WPA data */
int wpa_enabled; int wpa_enabled;
int drop_unencrypted; int drop_unencrypted;
int tkip_countermeasures;
int privacy_invoked; int privacy_invoked;
size_t wpa_ie_len; size_t wpa_ie_len;
u8 *wpa_ie; u8 *wpa_ie;
......
...@@ -25,13 +25,17 @@ ...@@ -25,13 +25,17 @@
#include <linux/skbuff.h> #include <linux/skbuff.h>
enum {
IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1<<0),
};
struct ieee80211_crypto_ops { struct ieee80211_crypto_ops {
const char *name; const char *name;
/* init new crypto context (e.g., allocate private data space, /* init new crypto context (e.g., allocate private data space,
* select IV, etc.); returns NULL on failure or pointer to allocated * select IV, etc.); returns NULL on failure or pointer to allocated
* private data on success */ * private data on success */
void *(*init) (struct ieee80211_device * ieee, int keyidx); void *(*init) (int keyidx);
/* deinitialize crypto context and free allocated private data */ /* deinitialize crypto context and free allocated private data */
void (*deinit) (void *priv); void (*deinit) (void *priv);
...@@ -60,6 +64,10 @@ struct ieee80211_crypto_ops { ...@@ -60,6 +64,10 @@ struct ieee80211_crypto_ops {
* statistics */ * statistics */
char *(*print_stats) (char *p, void *priv); char *(*print_stats) (char *p, void *priv);
/* Crypto specific flag get/set for configuration settings */
unsigned long (*get_flags)(void *priv);
unsigned long (*set_flags)(unsigned long flags, void *priv);
/* maximum number of bytes added by encryption; encrypt buf is /* maximum number of bytes added by encryption; encrypt buf is
* allocated with extra_prefix_len bytes, copy of in_buf, and * allocated with extra_prefix_len bytes, copy of in_buf, and
* extra_postfix_len; encrypt need not use all this space, but * extra_postfix_len; encrypt need not use all this space, but
......
...@@ -202,8 +202,7 @@ struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name) ...@@ -202,8 +202,7 @@ struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name)
return NULL; return NULL;
} }
static void *ieee80211_crypt_null_init(struct ieee80211_device *ieee, static void *ieee80211_crypt_null_init(int keyidx)
int keyidx)
{ {
return (void *)1; return (void *)1;
} }
......
...@@ -74,7 +74,7 @@ static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, ...@@ -74,7 +74,7 @@ static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm,
crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN); crypto_cipher_encrypt(tfm, &dst, &src, AES_BLOCK_LEN);
} }
static void *ieee80211_ccmp_init(struct ieee80211_device *ieee, int key_idx) static void *ieee80211_ccmp_init(int key_idx)
{ {
struct ieee80211_ccmp_data *priv; struct ieee80211_ccmp_data *priv;
......
...@@ -60,10 +60,24 @@ struct ieee80211_tkip_data { ...@@ -60,10 +60,24 @@ struct ieee80211_tkip_data {
/* scratch buffers for virt_to_page() (crypto API) */ /* scratch buffers for virt_to_page() (crypto API) */
u8 rx_hdr[16], tx_hdr[16]; u8 rx_hdr[16], tx_hdr[16];
struct ieee80211_device *ieee; unsigned long flags;
}; };
static void *ieee80211_tkip_init(struct ieee80211_device *ieee, int key_idx) static unsigned long ieee80211_tkip_set_flags(unsigned long flags, void *priv)
{
struct ieee80211_tkip_data *_priv = priv;
unsigned long old_flags = _priv->flags;
_priv->flags = flags;
return old_flags;
}
static unsigned long ieee80211_tkip_get_flags(void *priv)
{
struct ieee80211_tkip_data *_priv = priv;
return _priv->flags;
}
static void *ieee80211_tkip_init(int key_idx)
{ {
struct ieee80211_tkip_data *priv; struct ieee80211_tkip_data *priv;
...@@ -72,8 +86,6 @@ static void *ieee80211_tkip_init(struct ieee80211_device *ieee, int key_idx) ...@@ -72,8 +86,6 @@ static void *ieee80211_tkip_init(struct ieee80211_device *ieee, int key_idx)
goto fail; goto fail;
memset(priv, 0, sizeof(*priv)); memset(priv, 0, sizeof(*priv));
priv->ieee = ieee;
priv->key_idx = key_idx; priv->key_idx = key_idx;
priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0); priv->tfm_arc4 = crypto_alloc_tfm("arc4", 0);
...@@ -315,13 +327,13 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) ...@@ -315,13 +327,13 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 *pos; u8 *pos;
struct scatterlist sg; struct scatterlist sg;
if (tkey->ieee->tkip_countermeasures) { if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
if (net_ratelimit()) { if (net_ratelimit()) {
struct ieee80211_hdr_4addr *hdr = struct ieee80211_hdr_4addr *hdr =
(struct ieee80211_hdr_4addr *)skb->data; (struct ieee80211_hdr_4addr *)skb->data;
printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " printk(KERN_DEBUG "TKIP countermeasures: dropped "
"TX packet to " MAC_FMT "\n", "TX packet to " MAC_FMT "\n",
tkey->ieee->dev->name, MAC_ARG(hdr->addr1)); MAC_ARG(hdr->addr1));
} }
return -1; return -1;
} }
...@@ -366,11 +378,11 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) ...@@ -366,11 +378,11 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
hdr = (struct ieee80211_hdr_4addr *)skb->data; hdr = (struct ieee80211_hdr_4addr *)skb->data;
if (tkey->ieee->tkip_countermeasures) { if (tkey->flags & IEEE80211_CRYPTO_TKIP_COUNTERMEASURES) {
if (net_ratelimit()) { if (net_ratelimit()) {
printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " printk(KERN_DEBUG "TKIP countermeasures: dropped "
"received packet from " MAC_FMT "\n", "received packet from " MAC_FMT "\n",
tkey->ieee->dev->name, MAC_ARG(hdr->addr2)); MAC_ARG(hdr->addr2));
} }
return -1; return -1;
} }
...@@ -694,6 +706,8 @@ static struct ieee80211_crypto_ops ieee80211_crypt_tkip = { ...@@ -694,6 +706,8 @@ static struct ieee80211_crypto_ops ieee80211_crypt_tkip = {
.extra_mpdu_prefix_len = 4 + 4, /* IV + ExtIV */ .extra_mpdu_prefix_len = 4 + 4, /* IV + ExtIV */
.extra_mpdu_postfix_len = 4, /* ICV */ .extra_mpdu_postfix_len = 4, /* ICV */
.extra_msdu_postfix_len = 8, /* MIC */ .extra_msdu_postfix_len = 8, /* MIC */
.get_flags = ieee80211_tkip_get_flags,
.set_flags = ieee80211_tkip_set_flags,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
......
...@@ -37,7 +37,7 @@ struct prism2_wep_data { ...@@ -37,7 +37,7 @@ struct prism2_wep_data {
struct crypto_tfm *tfm; struct crypto_tfm *tfm;
}; };
static void *prism2_wep_init(struct ieee80211_device *ieee, int keyidx) static void *prism2_wep_init(int keyidx)
{ {
struct prism2_wep_data *priv; struct prism2_wep_data *priv;
......
...@@ -155,7 +155,6 @@ struct net_device *alloc_ieee80211(int sizeof_priv) ...@@ -155,7 +155,6 @@ struct net_device *alloc_ieee80211(int sizeof_priv)
spin_lock_init(&ieee->lock); spin_lock_init(&ieee->lock);
ieee->wpa_enabled = 0; ieee->wpa_enabled = 0;
ieee->tkip_countermeasures = 0;
ieee->drop_unencrypted = 0; ieee->drop_unencrypted = 0;
ieee->privacy_invoked = 0; ieee->privacy_invoked = 0;
......
...@@ -355,7 +355,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, ...@@ -355,7 +355,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
} }
if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
new_crypt->priv = new_crypt->ops->init(ieee, key); new_crypt->priv = new_crypt->ops->init(key);
if (!new_crypt->ops || !new_crypt->priv) { if (!new_crypt->ops || !new_crypt->priv) {
kfree(new_crypt); kfree(new_crypt);
...@@ -598,7 +598,7 @@ int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee, ...@@ -598,7 +598,7 @@ int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee,
memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
new_crypt->ops = ops; new_crypt->ops = ops;
if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) if (new_crypt->ops && try_module_get(new_crypt->ops->owner))
new_crypt->priv = new_crypt->ops->init(ieee, idx); new_crypt->priv = new_crypt->ops->init(idx);
if (new_crypt->priv == NULL) { if (new_crypt->priv == NULL) {
kfree(new_crypt); kfree(new_crypt);
ret = -EINVAL; ret = -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册