Changeset 4122

Show
Ignore:
Timestamp:
03/13/10 00:59:02 (2 years ago)
Author:
proski
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • madwifi/trunk/regression/ccmp/test_ccmp.c

    r3846 r4122  
    714714init_crypto_ccmp_test(void) 
    715715{ 
    716         struct ieee80211com *ic; 
     716        struct { 
     717                struct ieee80211vap vap; 
     718                struct ieee80211com ic; 
     719                struct net_device netdev; 
     720        } *buf; 
    717721        struct ieee80211vap *vap; 
    718722        int i, pass, total; 
    719723 
    720         ic = kzalloc(sizeof(*ic), GFP_KERNEL); 
    721         if (!ic
     724        buf = kzalloc(sizeof(*buf), GFP_KERNEL); 
     725        if (!buf
    722726                return -ENOMEM; 
    723727 
    724         ieee80211_crypto_attach(ic); 
    725  
    726         vap = kzalloc(sizeof(*vap), GFP_KERNEL); 
    727         if (!vap) { 
    728                 kfree(ic); 
    729                 return -ENOMEM; 
    730         } 
    731  
    732         vap->iv_ic = ic; 
     728        vap = &buf->vap; 
     729        vap->iv_ic = &buf->ic; 
     730        vap->iv_dev = &buf->netdev; 
     731        vap->iv_ic->ic_dev = vap->iv_dev; 
     732        strncpy(vap->iv_dev->name, "CCMP test", sizeof(vap->iv_dev->name) - 1); 
     733 
    733734        if (debug) 
    734735                vap->iv_debug = IEEE80211_MSG_CRYPTO; 
    735736 
     737        ieee80211_crypto_attach(vap->iv_ic); 
    736738        ieee80211_crypto_vattach(vap); 
    737739 
     
    745747        printk("%u of %u 802.11i AES-CCMP test vectors passed\n", pass, total); 
    746748        ieee80211_crypto_vdetach(vap); 
    747         ieee80211_crypto_detach(ic); 
    748         kfree(vap); 
    749         kfree(ic); 
     749        ieee80211_crypto_detach(vap->iv_ic); 
     750        kfree(buf); 
    750751        return (pass == total ? 0 : -ENXIO); 
    751752} 
  • madwifi/trunk/regression/tkip/test_tkip.c

    r3846 r4122  
    373373init_crypto_tkip_test(void) 
    374374{ 
    375         struct ieee80211com *ic; 
     375        struct { 
     376                struct ieee80211vap vap; 
     377                struct ieee80211com ic; 
     378                struct net_device netdev; 
     379        } *buf; 
    376380        struct ieee80211vap *vap; 
    377381        int i, pass, total; 
    378382 
    379         ic = kzalloc(sizeof(*ic), GFP_KERNEL); 
    380         if (!ic
     383        buf = kzalloc(sizeof(*buf), GFP_KERNEL); 
     384        if (!buf
    381385                return -ENOMEM; 
    382386 
    383         ieee80211_crypto_attach(ic); 
    384  
    385         vap = kzalloc(sizeof(*vap), GFP_KERNEL); 
    386         if (!vap) { 
    387                 kfree(ic); 
    388                 return -ENOMEM; 
    389         } 
    390  
    391         vap->iv_ic = ic; 
     387        vap = &buf->vap; 
     388        vap->iv_ic = &buf->ic; 
     389        vap->iv_dev = &buf->netdev; 
     390        vap->iv_ic->ic_dev = vap->iv_dev; 
     391        strncpy(vap->iv_dev->name, "TKIP test", sizeof(vap->iv_dev->name) - 1); 
     392 
    392393        if (debug) 
    393394                vap->iv_debug = IEEE80211_MSG_CRYPTO; 
    394395 
     396        ieee80211_crypto_attach(vap->iv_ic); 
    395397        ieee80211_crypto_vattach(vap); 
    396398 
     
    404406        printk("%u of %u 802.11i TKIP test vectors passed\n", pass, total); 
    405407        ieee80211_crypto_vdetach(vap); 
    406         ieee80211_crypto_detach(ic); 
    407         kfree(vap); 
    408         kfree(ic); 
     408        ieee80211_crypto_detach(vap->iv_ic); 
     409        kfree(buf); 
    409410        return (pass == total ? 0 : -ENXIO); 
    410411} 
  • madwifi/trunk/regression/wep/test_wep.c

    r3846 r4122  
    318318init_crypto_wep_test(void) 
    319319{ 
    320         struct ieee80211com *ic; 
     320        struct { 
     321                struct ieee80211vap vap; 
     322                struct ieee80211com ic; 
     323                struct net_device netdev; 
     324        } *buf; 
    321325        struct ieee80211vap *vap; 
    322326        int i, pass, total; 
    323327 
    324         ic = kzalloc(sizeof(*ic), GFP_KERNEL); 
    325         if (!ic
     328        buf = kzalloc(sizeof(*buf), GFP_KERNEL); 
     329        if (!buf
    326330                return -ENOMEM; 
    327331 
    328         ieee80211_crypto_attach(ic); 
    329  
    330         vap = kzalloc(sizeof(*vap), GFP_KERNEL); 
    331         if (!vap) { 
    332                 kfree(ic); 
    333                 return -ENOMEM; 
    334         } 
    335  
    336         vap->iv_ic = ic; 
     332        vap = &buf->vap; 
     333        vap->iv_ic = &buf->ic; 
     334        vap->iv_dev = &buf->netdev; 
     335        vap->iv_ic->ic_dev = vap->iv_dev; 
     336        strncpy(vap->iv_dev->name, "WEP test", sizeof(vap->iv_dev->name) - 1); 
     337 
    337338        if (debug) 
    338339                vap->iv_debug = IEEE80211_MSG_CRYPTO; 
    339340 
     341        ieee80211_crypto_attach(vap->iv_ic); 
    340342        ieee80211_crypto_vattach(vap); 
    341343 
     
    349351        printk("%u of %u 802.11i WEP test vectors passed\n", pass, total); 
    350352        ieee80211_crypto_vdetach(vap); 
    351         ieee80211_crypto_detach(ic); 
    352         kfree(vap); 
    353         kfree(ic); 
     353        ieee80211_crypto_detach(vap->iv_ic); 
     354        kfree(buf); 
    354355        return (pass == total ? 0 : -ENXIO); 
    355356}