Make crypto test suite more robust

Allocate all memory at once to simplify error handling.  Allocate a
network device and use it both for the master and the VAP.  Set a
descriptive name on the network device, as it's used in error and debug
messages.


git-svn-id: http://madwifi-project.org/svn/madwifi/trunk@4122 0192ed92-7a03-0410-a25b-9323aeb14dbd
This commit is contained in:
proski 2010-03-12 23:59:02 +00:00
parent 6f08b9347d
commit 6b7b69cb37
3 changed files with 45 additions and 42 deletions

View File

@ -713,26 +713,28 @@ MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
static int __init
init_crypto_ccmp_test(void)
{
struct ieee80211com *ic;
struct {
struct ieee80211vap vap;
struct ieee80211com ic;
struct net_device netdev;
} *buf;
struct ieee80211vap *vap;
int i, pass, total;
ic = kzalloc(sizeof(*ic), GFP_KERNEL);
if (!ic)
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
return -ENOMEM;
ieee80211_crypto_attach(ic);
vap = &buf->vap;
vap->iv_ic = &buf->ic;
vap->iv_dev = &buf->netdev;
vap->iv_ic->ic_dev = vap->iv_dev;
strncpy(vap->iv_dev->name, "CCMP test", sizeof(vap->iv_dev->name) - 1);
vap = kzalloc(sizeof(*vap), GFP_KERNEL);
if (!vap) {
kfree(ic);
return -ENOMEM;
}
vap->iv_ic = ic;
if (debug)
vap->iv_debug = IEEE80211_MSG_CRYPTO;
ieee80211_crypto_attach(vap->iv_ic);
ieee80211_crypto_vattach(vap);
pass = 0;
@ -744,9 +746,8 @@ init_crypto_ccmp_test(void)
}
printk("%u of %u 802.11i AES-CCMP test vectors passed\n", pass, total);
ieee80211_crypto_vdetach(vap);
ieee80211_crypto_detach(ic);
kfree(vap);
kfree(ic);
ieee80211_crypto_detach(vap->iv_ic);
kfree(buf);
return (pass == total ? 0 : -ENXIO);
}
module_init(init_crypto_ccmp_test);

View File

@ -372,26 +372,28 @@ MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
static int __init
init_crypto_tkip_test(void)
{
struct ieee80211com *ic;
struct {
struct ieee80211vap vap;
struct ieee80211com ic;
struct net_device netdev;
} *buf;
struct ieee80211vap *vap;
int i, pass, total;
ic = kzalloc(sizeof(*ic), GFP_KERNEL);
if (!ic)
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
return -ENOMEM;
ieee80211_crypto_attach(ic);
vap = &buf->vap;
vap->iv_ic = &buf->ic;
vap->iv_dev = &buf->netdev;
vap->iv_ic->ic_dev = vap->iv_dev;
strncpy(vap->iv_dev->name, "TKIP test", sizeof(vap->iv_dev->name) - 1);
vap = kzalloc(sizeof(*vap), GFP_KERNEL);
if (!vap) {
kfree(ic);
return -ENOMEM;
}
vap->iv_ic = ic;
if (debug)
vap->iv_debug = IEEE80211_MSG_CRYPTO;
ieee80211_crypto_attach(vap->iv_ic);
ieee80211_crypto_vattach(vap);
pass = 0;
@ -403,9 +405,8 @@ init_crypto_tkip_test(void)
}
printk("%u of %u 802.11i TKIP test vectors passed\n", pass, total);
ieee80211_crypto_vdetach(vap);
ieee80211_crypto_detach(ic);
kfree(vap);
kfree(ic);
ieee80211_crypto_detach(vap->iv_ic);
kfree(buf);
return (pass == total ? 0 : -ENXIO);
}
module_init(init_crypto_tkip_test);

View File

@ -317,26 +317,28 @@ MODULE_PARM_DESC(debug, "Enable IEEE80211_MSG_CRYPTO");
static int __init
init_crypto_wep_test(void)
{
struct ieee80211com *ic;
struct {
struct ieee80211vap vap;
struct ieee80211com ic;
struct net_device netdev;
} *buf;
struct ieee80211vap *vap;
int i, pass, total;
ic = kzalloc(sizeof(*ic), GFP_KERNEL);
if (!ic)
buf = kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
return -ENOMEM;
ieee80211_crypto_attach(ic);
vap = &buf->vap;
vap->iv_ic = &buf->ic;
vap->iv_dev = &buf->netdev;
vap->iv_ic->ic_dev = vap->iv_dev;
strncpy(vap->iv_dev->name, "WEP test", sizeof(vap->iv_dev->name) - 1);
vap = kzalloc(sizeof(*vap), GFP_KERNEL);
if (!vap) {
kfree(ic);
return -ENOMEM;
}
vap->iv_ic = ic;
if (debug)
vap->iv_debug = IEEE80211_MSG_CRYPTO;
ieee80211_crypto_attach(vap->iv_ic);
ieee80211_crypto_vattach(vap);
pass = 0;
@ -348,9 +350,8 @@ init_crypto_wep_test(void)
}
printk("%u of %u 802.11i WEP test vectors passed\n", pass, total);
ieee80211_crypto_vdetach(vap);
ieee80211_crypto_detach(ic);
kfree(vap);
kfree(ic);
ieee80211_crypto_detach(vap->iv_ic);
kfree(buf);
return (pass == total ? 0 : -ENXIO);
}
module_init(init_crypto_wep_test);