Date: Tue, 2 Aug 2005 20:22:16 GMT From: Sam Leffler <sam@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 81355 for review Message-ID: <200508022022.j72KMGbL015563@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=81355 Change 81355 by sam@sam_ebb on 2005/08/02 20:21:36 count dynamic references and disallow module unload if any exist Affected files ... .. //depot/projects/wifi/sys/net80211/ieee80211_crypto_ccmp.c#9 edit .. //depot/projects/wifi/sys/net80211/ieee80211_crypto_tkip.c#11 edit .. //depot/projects/wifi/sys/net80211/ieee80211_crypto_wep.c#9 edit .. //depot/projects/wifi/sys/net80211/ieee80211_scan_ap.c#2 edit .. //depot/projects/wifi/sys/net80211/ieee80211_scan_sta.c#2 edit Differences ... ==== //depot/projects/wifi/sys/net80211/ieee80211_crypto_ccmp.c#9 (text+ko) ==== @@ -91,6 +91,9 @@ static int ccmp_decrypt(struct ieee80211_key *, u_int64_t pn, struct mbuf *, int hdrlen); +/* number of references from net80211 layer */ +static int nrefs = 0; + static void * ccmp_attach(struct ieee80211com *ic, struct ieee80211_key *k) { @@ -103,6 +106,7 @@ return NULL; } ctx->cc_ic = ic; + nrefs++; /* NB: we assume caller locking */ return ctx; } @@ -112,6 +116,8 @@ struct ccmp_ctx *ctx = k->wk_private; FREE(ctx, M_DEVBUF); + KASSERT(nrefs > 0, ("imbalanced attach/detach")); + nrefs--; /* NB: we assume caller locking */ } static int @@ -637,7 +643,14 @@ ieee80211_crypto_register(&ccmp); return 0; case MOD_UNLOAD: - ieee80211_crypto_unregister(&ccmp); + case MOD_QUIESCE: + if (nrefs) { + printf("wlan_ccmp: still in use (%u dynamic refs)\n", + nrefs); + return EBUSY; + } + if (type == MOD_UNLOAD) + ieee80211_crypto_unregister(&ccmp); return 0; } return EINVAL; ==== //depot/projects/wifi/sys/net80211/ieee80211_crypto_tkip.c#11 (text+ko) ==== @@ -106,6 +106,9 @@ static int tkip_decrypt(struct tkip_ctx *, struct ieee80211_key *, struct mbuf *, int hdr_len); +/* number of references from net80211 layer */ +static int nrefs = 0; + static void * tkip_attach(struct ieee80211com *ic, struct ieee80211_key *k) { @@ -119,6 +122,7 @@ } ctx->tc_ic = ic; + nrefs++; /* NB: we assume caller locking */ return ctx; } @@ -128,6 +132,8 @@ struct tkip_ctx *ctx = k->wk_private; FREE(ctx, M_DEVBUF); + KASSERT(nrefs > 0, ("imbalanced attach/detach")); + nrefs--; /* NB: we assume caller locking */ } static int @@ -976,7 +982,14 @@ ieee80211_crypto_register(&tkip); return 0; case MOD_UNLOAD: - ieee80211_crypto_unregister(&tkip); + case MOD_QUIESCE: + if (nrefs) { + printf("wlan_tkip: still in use (%u dynamic refs)\n", + nrefs); + return EBUSY; + } + if (type == MOD_UNLOAD) + ieee80211_crypto_unregister(&tkip); return 0; } return EINVAL; ==== //depot/projects/wifi/sys/net80211/ieee80211_crypto_wep.c#9 (text+ko) ==== @@ -82,6 +82,9 @@ u_int32_t wc_iv; /* initial vector for crypto */ }; +/* number of references from net80211 layer */ +static int nrefs = 0; + static void * wep_attach(struct ieee80211com *ic, struct ieee80211_key *k) { @@ -96,6 +99,7 @@ ctx->wc_ic = ic; get_random_bytes(&ctx->wc_iv, sizeof(ctx->wc_iv)); + nrefs++; /* NB: we assume caller locking */ return ctx; } @@ -105,6 +109,8 @@ struct wep_ctx *ctx = k->wk_private; FREE(ctx, M_DEVBUF); + KASSERT(nrefs > 0, ("imbalanced attach/detach")); + nrefs--; /* NB: we assume caller locking */ } static int @@ -481,7 +487,14 @@ ieee80211_crypto_register(&wep); return 0; case MOD_UNLOAD: - ieee80211_crypto_unregister(&wep); + case MOD_QUIESCE: + if (nrefs) { + printf("wlan_wep: still in use (%u dynamic refs)\n", + nrefs); + return EBUSY; + } + if (type == MOD_UNLOAD) + ieee80211_crypto_unregister(&wep); return 0; } return EINVAL; ==== //depot/projects/wifi/sys/net80211/ieee80211_scan_ap.c#2 (text+ko) ==== @@ -56,6 +56,9 @@ static int ap_flush(struct ieee80211_scan_state *); +/* number of references from net80211 layer */ +static int nrefs = 0; + /* * Attach prior to any scanning work. */ @@ -68,6 +71,7 @@ M_80211_SCAN, M_NOWAIT); ss->ss_priv = as; ap_flush(ss); + nrefs++; /* NB: we assume caller locking */ return 1; } @@ -79,8 +83,11 @@ { struct ap_state *as = ss->ss_priv; - if (as != NULL) + if (as != NULL) { + KASSERT(nrefs > 0, ("imbalanced attach/detach")); + nrefs--; /* NB: we assume caller locking */ FREE(as, M_80211_SCAN); + } return 1; } @@ -378,7 +385,14 @@ ieee80211_scanner_register(IEEE80211_M_HOSTAP, &ap_default); return 0; case MOD_UNLOAD: - ieee80211_scanner_unregister_all(&ap_default); + case MOD_QUIESCE: + if (nrefs) { + printf("wlan_scan_ap: still in use (%u dynamic refs)\n", + nrefs); + return EBUSY; + } + if (type == MOD_UNLOAD) + ieee80211_scanner_unregister_all(&ap_default); return 0; } return EINVAL; ==== //depot/projects/wifi/sys/net80211/ieee80211_scan_sta.c#2 (text+ko) ==== @@ -110,6 +110,9 @@ static int match_bss(struct ieee80211com *, const struct ieee80211_scan_state *, const struct sta_entry *); +/* number of references from net80211 layer */ +static int nrefs = 0; + /* * Attach prior to any scanning work. */ @@ -126,6 +129,7 @@ mtx_init(&st->st_scanlock, "scangen", "802.11 scangen", MTX_DEF); TAILQ_INIT(&st->st_entry); ss->ss_priv = st; + nrefs++; /* NB: we assume caller locking */ return 1; } @@ -142,6 +146,8 @@ mtx_destroy(&st->st_lock); mtx_destroy(&st->st_scanlock); FREE(st, M_80211_SCAN); + KASSERT(nrefs > 0, ("imbalanced attach/detach")); + nrefs--; /* NB: we assume caller locking */ } return 1; } @@ -1345,8 +1351,16 @@ ieee80211_scanner_register(IEEE80211_M_AHDEMO, &adhoc_default); return 0; case MOD_UNLOAD: - ieee80211_scanner_unregister_all(&sta_default); - ieee80211_scanner_unregister_all(&adhoc_default); + case MOD_QUIESCE: + if (nrefs) { + printf("wlan_scan_sta: still in use (%u dynamic refs)\n", + nrefs); + return EBUSY; + } + if (type == MOD_UNLOAD) { + ieee80211_scanner_unregister_all(&sta_default); + ieee80211_scanner_unregister_all(&adhoc_default); + } return 0; } return EINVAL;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508022022.j72KMGbL015563>