diff --git a/ath/if_ath.c b/ath/if_ath.c index 594a158..39c7dbf 100644 --- a/ath/if_ath.c +++ b/ath/if_ath.c @@ -164,18 +164,9 @@ static void ath_beacon_config(struct ath_softc *, struct ieee80211vap *); static int ath_desc_alloc(struct ath_softc *); static void ath_desc_free(struct ath_softc *); -#ifdef IEEE80211_DEBUG_REFCNT -static struct ieee80211_node *ath_node_alloc_debug(struct ieee80211vap *, - const char *func, int line); -static void ath_node_cleanup_debug(struct ieee80211_node *, const char *func, - int line); -static void ath_node_free_debug(struct ieee80211_node *, const char *func, - int line); -#else static struct ieee80211_node *ath_node_alloc(struct ieee80211vap *); static void ath_node_cleanup(struct ieee80211_node *); static void ath_node_free(struct ieee80211_node *); -#endif static u_int8_t ath_node_getrssi(const struct ieee80211_node *); static struct sk_buff *ath_rxbuf_take_skb(struct ath_softc *, struct ath_buf *); @@ -276,51 +267,14 @@ static void ath_descdma_cleanup(struct ath_softc *, struct ath_descdma *, static const char *ath_get_hal_status_desc(HAL_STATUS status); static int ath_rcv_dev_event(struct notifier_block *, unsigned long, void *); -#ifdef IEEE80211_DEBUG_REFCNT -#define ath_return_txbuf(_sc, _pbuf) \ - ath_return_txbuf_debug(_sc, _pbuf, __func__, __LINE__) -static void ath_return_txbuf_debug(struct ath_softc *sc, struct ath_buf **buf, - const char *func, int line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ static void ath_return_txbuf(struct ath_softc *sc, struct ath_buf **buf); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - -#ifdef IEEE80211_DEBUG_REFCNT -#define ath_return_txbuf_locked(_sc, _pbuf) \ - ath_return_txbuf_locked_debug(_sc, _pbuf, __func__, __LINE__) -static void ath_return_txbuf_locked_debug(struct ath_softc *sc, struct ath_buf **buf, - const char *func, int line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ static void ath_return_txbuf_locked(struct ath_softc *sc, struct ath_buf **buf); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ath_return_txbuf_list(_sc, _head) \ - ath_return_txbuf_list_debug(_sc, _head, __func__, __LINE__) -static void ath_return_txbuf_list_debug(struct ath_softc *sc, ath_bufhead *bfhead, - const char *func, int line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ static void ath_return_txbuf_list(struct ath_softc *sc, ath_bufhead *bfhead); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - -#ifdef IEEE80211_DEBUG_REFCNT -#define ath_return_txbuf_list_locked(_sc, _head) \ - ath_return_txbuf_list_locked_debug(_sc, _head, __func__, __LINE__) -static void ath_return_txbuf_list_locked_debug(struct ath_softc *sc, ath_bufhead *bfhead, - const char *func, int line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ static void ath_return_txbuf_list_locked(struct ath_softc *sc, ath_bufhead *bfhead); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ -#ifdef IEEE80211_DEBUG_REFCNT -#define cleanup_ath_buf(_sc, _buf, _dir) \ - cleanup_ath_buf_debug(_sc, _buf, _dir, __func__, __LINE__) -static struct ath_buf *cleanup_ath_buf_debug(struct ath_softc *sc, struct ath_buf *buf, - int direction, const char *func, int line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ -static struct ath_buf *cleanup_ath_buf(struct ath_softc *sc, struct ath_buf *buf, - int direction); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ +static struct ath_buf *cleanup_ath_buf(struct ath_softc *sc, + struct ath_buf *buf, int direction); /* Regulatory agency testing - continuous transmit support */ static void txcont_on(struct ieee80211com *ic); @@ -1036,19 +990,11 @@ ath_attach(u_int16_t devid, struct net_device *dev, HAL_BUS_TAG tag) /* call MI attach routine. */ ieee80211_ifattach(ic); /* override default methods */ -#ifdef IEEE80211_DEBUG_REFCNT - ic->ic_node_alloc_debug = ath_node_alloc_debug; - sc->sc_node_free_debug = ic->ic_node_free_debug; - ic->ic_node_free_debug = ath_node_free_debug; - sc->sc_node_cleanup_debug = ic->ic_node_cleanup_debug; - ic->ic_node_cleanup_debug = ath_node_cleanup_debug; -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ ic->ic_node_alloc = ath_node_alloc; sc->sc_node_free = ic->ic_node_free; ic->ic_node_free = ath_node_free; sc->sc_node_cleanup = ic->ic_node_cleanup; ic->ic_node_cleanup = ath_node_cleanup; -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ ic->ic_node_getrssi = ath_node_getrssi; #ifdef ATH_SUPERG_XR @@ -3210,11 +3156,7 @@ _take_txbuf_locked(struct ath_softc *sc, int for_management) STAILQ_REMOVE_HEAD(&sc->sc_txbuf, bf_list); /* This should be redundant, unless someone illegally * accessed the buffer after returning it. */ -#ifdef IEEE80211_DEBUG_REFCNT - cleanup_ath_buf_debug(sc, bf, BUS_DMA_TODEVICE, func, line); -#else cleanup_ath_buf(sc, bf, BUS_DMA_TODEVICE); -#endif atomic_inc(&sc->sc_txbuf_counter); #ifdef IEEE80211_DEBUG_REFCNT bf->bf_taken_at_func = func; @@ -5747,11 +5689,7 @@ ath_desc_free(struct ath_softc *sc) } static struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ath_node_alloc_debug(struct ieee80211vap *vap, const char *func, int line) -#else ath_node_alloc(struct ieee80211vap *vap) -#endif { struct ath_softc *sc = vap->iv_ic->ic_dev->priv; const size_t space = sizeof(struct ath_node) + sc->sc_rc->arc_space; @@ -5778,11 +5716,7 @@ ath_node_alloc(struct ieee80211vap *vap) } static void -#ifdef IEEE80211_DEBUG_REFCNT -ath_node_cleanup_debug(struct ieee80211_node *ni, const char *func, int line) -#else ath_node_cleanup(struct ieee80211_node *ni) -#endif { struct ieee80211com *ic = ni->ni_ic; struct ath_softc *sc = ni->ni_ic->ic_dev->priv; @@ -5803,22 +5737,14 @@ ath_node_cleanup(struct ieee80211_node *ni) while (an->an_uapsd_qdepth) { bf = STAILQ_FIRST(&an->an_uapsd_q); STAILQ_REMOVE_HEAD(&an->an_uapsd_q, bf_list); -#ifdef IEEE80211_DEBUG_REFCNT - ath_return_txbuf_debug(sc, &bf, func, line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ ath_return_txbuf(sc, &bf); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ an->an_uapsd_qdepth--; } while (an->an_uapsd_overflowqdepth) { bf = STAILQ_FIRST(&an->an_uapsd_overflowq); STAILQ_REMOVE_HEAD(&an->an_uapsd_overflowq, bf_list); -#ifdef IEEE80211_DEBUG_REFCNT - ath_return_txbuf_debug(sc, &bf, func, line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ ath_return_txbuf(sc, &bf); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ an->an_uapsd_overflowqdepth--; } @@ -5827,29 +5753,16 @@ ath_node_cleanup(struct ieee80211_node *ni) sc->sc_rc->ops->node_cleanup(sc, ATH_NODE(ni)); ATH_NODE_UAPSD_LOCK_IRQ(an); -#ifdef IEEE80211_DEBUG_REFCNT - sc->sc_node_cleanup_debug(ni, func, line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ sc->sc_node_cleanup(ni); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ ATH_NODE_UAPSD_UNLOCK_IRQ(an); } static void -#ifdef IEEE80211_DEBUG_REFCNT -ath_node_free_debug(struct ieee80211_node *ni, const char *func, int line) -#else ath_node_free(struct ieee80211_node *ni) -#endif { - struct ath_softc *sc = ni->ni_ic->ic_dev->priv; + struct ath_softc *sc = (struct ath_softc *)ni->ni_ic; -#ifdef IEEE80211_DEBUG_REFCNT - sc->sc_node_free_debug(ni, func, line); -#else sc->sc_node_free(ni); -#endif - #ifdef ATH_SUPERG_XR ath_grppoll_period_update(sc); #endif @@ -6190,22 +6103,12 @@ ath_node_move_data(const struct ieee80211_node *ni) #endif static struct sk_buff * -#ifdef IEEE80211_DEBUG_REFCNT -#define ath_alloc_skb(_size, _align) \ - ath_alloc_skb_debug(_size, _align, __func__, __LINE__) -ath_alloc_skb_debug(u_int size, u_int align, const char *func, int line) -#else ath_alloc_skb(u_int size, u_int align) -#endif { struct sk_buff *skb; u_int off; -#ifdef IEEE80211_DEBUG_REFCNT - skb = ieee80211_dev_alloc_skb_debug(size + align - 1, func, line); -#else skb = ieee80211_dev_alloc_skb(size + align - 1); -#endif if (skb != NULL) { off = ((unsigned long) skb->data) % align; if (off != 0) @@ -12320,12 +12223,7 @@ ath_registers_dump_delta(struct ieee80211com *ic) /* Caller must have the TXBUF_LOCK */ static void -#ifdef IEEE80211_DEBUG_REFCNT -ath_return_txbuf_locked_debug(struct ath_softc *sc, struct ath_buf **bf, - const char *func, int line) -#else ath_return_txbuf_locked(struct ath_softc *sc, struct ath_buf **bf) -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ { struct ath_buf *bfaddr; ATH_TXBUF_LOCK_ASSERT(sc); @@ -12333,19 +12231,16 @@ ath_return_txbuf_locked(struct ath_softc *sc, struct ath_buf **bf) if ((bf == NULL) || ((*bf) == NULL)) return; bfaddr = *bf; -#ifdef IEEE80211_DEBUG_REFCNT - cleanup_ath_buf_debug(sc, (*bf), BUS_DMA_TODEVICE, func, line); -#else cleanup_ath_buf(sc, (*bf), BUS_DMA_TODEVICE); -#endif STAILQ_INSERT_TAIL(&sc->sc_txbuf, (*bf), bf_list); *bf = NULL; atomic_dec(&sc->sc_txbuf_counter); #ifdef IEEE80211_DEBUG_REFCNT DPRINTF(sc, ATH_DEBUG_TXBUF, - "[TXBUF=%03d/%03d] (invoked from %s:%d) returned txbuf %p.\n", - ath_get_buffer_count(sc), ATH_TXBUF, - func, line, bfaddr); + "[TXBUF=%03d/%03d] returned txbuf %p.\n", + ath_get_buffer_count(sc), ATH_TXBUF); + if (DFLAG_ISSET(sc, ATH_DEBUG_TXBUF)) + dump_stack(); #endif /* #ifdef IEEE80211_DEBUG_REFCNT */ if (netif_queue_stopped(sc->sc_dev) && (ath_get_buffers_available(sc) > ATH_TXBUF_MGT_RESERVED) && @@ -12367,30 +12262,16 @@ ath_return_txbuf_locked(struct ath_softc *sc, struct ath_buf **bf) /* Takes the TXBUF_LOCK */ static void -#ifdef IEEE80211_DEBUG_REFCNT -ath_return_txbuf_debug(struct ath_softc *sc, struct ath_buf **bf, - const char *func, int line) -#else ath_return_txbuf(struct ath_softc *sc, struct ath_buf **bf) -#endif { ATH_TXBUF_LOCK_IRQ(sc); -#ifdef IEEE80211_DEBUG_REFCNT - ath_return_txbuf_locked_debug(sc, bf, func, line); -#else ath_return_txbuf_locked(sc, bf); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ ATH_TXBUF_UNLOCK_IRQ(sc); } /* Takes the lock */ static void -#ifdef IEEE80211_DEBUG_REFCNT -ath_return_txbuf_list_debug(struct ath_softc *sc, ath_bufhead *bfhead, - const char *func, int line) -#else ath_return_txbuf_list(struct ath_softc *sc, ath_bufhead *bfhead) -#endif { if (!bfhead) return; @@ -12398,11 +12279,7 @@ ath_return_txbuf_list(struct ath_softc *sc, ath_bufhead *bfhead) if (!STAILQ_EMPTY(bfhead)) { struct ath_buf *tbf, *nextbf; STAILQ_FOREACH_SAFE(tbf, bfhead, bf_list, nextbf) { -#ifdef IEEE80211_DEBUG_REFCNT - ath_return_txbuf_locked_debug(sc, &tbf, func, line); -#else ath_return_txbuf_locked(sc, &tbf); -#endif } } ATH_TXBUF_UNLOCK_IRQ(sc); @@ -12410,12 +12287,7 @@ ath_return_txbuf_list(struct ath_softc *sc, ath_bufhead *bfhead) } /* Caller must have the lock */ static void -#ifdef IEEE80211_DEBUG_REFCNT -ath_return_txbuf_list_locked_debug(struct ath_softc *sc, ath_bufhead *bfhead, - const char *func, int line) -#else ath_return_txbuf_list_locked(struct ath_softc *sc, ath_bufhead *bfhead) -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ { ATH_TXBUF_LOCK_ASSERT(sc); if (!bfhead) @@ -12424,23 +12296,14 @@ ath_return_txbuf_list_locked(struct ath_softc *sc, ath_bufhead *bfhead) if (!STAILQ_EMPTY(bfhead)) { struct ath_buf *tbf, *nextbf; STAILQ_FOREACH_SAFE(tbf, bfhead, bf_list, nextbf) { -#ifdef IEEE80211_DEBUG_REFCNT - ath_return_txbuf_locked_debug(sc, &tbf, func, line); -#else ath_return_txbuf_locked(sc, &tbf); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ } } STAILQ_INIT(bfhead); } static struct ath_buf * -#ifdef IEEE80211_DEBUG_REFCNT -cleanup_ath_buf_debug(struct ath_softc *sc, struct ath_buf *bf, int direction, - const char *func, int line) -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ cleanup_ath_buf(struct ath_softc *sc, struct ath_buf *bf, int direction) -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ { if (bf == NULL) return bf; diff --git a/ath/if_athvar.h b/ath/if_athvar.h index c67daa2..dfad896 100644 --- a/ath/if_athvar.h +++ b/ath/if_athvar.h @@ -648,13 +648,8 @@ struct ath_softc { int sc_default_ieee80211_debug; /* default debug flags for new VAPs */ int (*sc_recv_mgmt)(struct ieee80211vap *, struct ieee80211_node *, struct sk_buff *, int, int, u_int64_t); -#ifdef IEEE80211_DEBUG_REFCNT - void (*sc_node_cleanup_debug)(struct ieee80211_node *, const char *func, int line); - void (*sc_node_free_debug)(struct ieee80211_node *, const char *func, int line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ void (*sc_node_cleanup)(struct ieee80211_node *); void (*sc_node_free)(struct ieee80211_node *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ void *sc_bdev; /* associated bus device */ struct ath_hal *sc_ah; /* Atheros HAL */ spinlock_t sc_hal_lock; /* hardware access lock */ diff --git a/net80211/ieee80211_node.c b/net80211/ieee80211_node.c index 3f3afa8..03fc194 100644 --- a/net80211/ieee80211_node.c +++ b/net80211/ieee80211_node.c @@ -66,53 +66,22 @@ ((_vap)->iv_aid_bitmap[IEEE80211_AID(_b) / 32] & \ (1 << (IEEE80211_AID(_b) % 32))) -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_alloc_node(_vap, _mac) \ - ieee80211_alloc_node_debug(_vap, _mac, __func__, __LINE__) -static struct ieee80211_node *ieee80211_alloc_node_debug(struct ieee80211vap *, - const u_int8_t *, const char *func, int line); -#else static struct ieee80211_node *ieee80211_alloc_node(struct ieee80211vap *, const u_int8_t *); -#endif static int ieee80211_sta_join1(struct ieee80211_node *); -#ifdef IEEE80211_DEBUG_REFCNT -static struct ieee80211_node *node_alloc_debug(struct ieee80211vap *, - const char *func, int line); -static void node_cleanup_debug(struct ieee80211_node *, const char *func, - int line); -static void node_free_debug(struct ieee80211_node *, const char *func, - int line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ static struct ieee80211_node *node_alloc(struct ieee80211vap *); static void node_cleanup(struct ieee80211_node *); static void node_free(struct ieee80211_node *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ static int32_t node_count(struct ieee80211com *ic); static u_int8_t node_getrssi(const struct ieee80211_node *); -#ifdef IEEE80211_DEBUG_REFCNT -#define node_table_leave_locked(_table, _node) \ - node_table_leave_locked_debug(_table, _node, __func__, __LINE__) -static void node_table_leave_locked_debug(struct ieee80211_node_table *, - struct ieee80211_node *, const char *func, int line); -#else static void node_table_leave_locked(struct ieee80211_node_table *, struct ieee80211_node *); -#endif - -#ifdef IEEE80211_DEBUG_REFCNT -#define node_table_join_locked(_table, _node) \ - node_table_join_locked_debug(_table, _node, __func__, __LINE__) -static void node_table_join_locked_debug(struct ieee80211_node_table *, - struct ieee80211_node *, const char *func, int line); -#else static void node_table_join_locked(struct ieee80211_node_table *, struct ieee80211_node *); -#endif static void ieee80211_node_timeout(unsigned long); @@ -135,15 +104,9 @@ ieee80211_node_attach(struct ieee80211com *ic) ic->ic_inact.data = (unsigned long) ic; mod_timer(&ic->ic_inact, jiffies + IEEE80211_INACT_WAIT * HZ); -#ifdef IEEE80211_DEBUG_REFCNT - ic->ic_node_alloc_debug = node_alloc_debug; - ic->ic_node_free_debug = node_free_debug; - ic->ic_node_cleanup_debug = node_cleanup_debug; -#else ic->ic_node_alloc = node_alloc; ic->ic_node_free = node_free; ic->ic_node_cleanup = node_cleanup; -#endif ic->ic_node_count = node_count; ic->ic_node_getrssi = node_getrssi; @@ -780,25 +743,15 @@ ieee80211_node_table_init(struct ieee80211com *ic, mod_timer(&nt->nt_wds_aging_timer, jiffies + HZ * WDS_AGING_TIMER_VAL); } -static __inline -void -#ifdef IEEE80211_DEBUG_REFCNT -node_table_join_locked_debug(struct ieee80211_node_table *nt, - struct ieee80211_node *ni, const char *func, int line) -#else -node_table_join_locked(struct ieee80211_node_table *nt, +static __inline void +node_table_join_locked(struct ieee80211_node_table *nt, struct ieee80211_node *ni) -#endif { struct ieee80211_node *tni = NULL; IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); ni->ni_table = nt; -#ifdef IEEE80211_DEBUG_REFCNT - tni = ieee80211_ref_node_debug(ni, func, line); -#else tni = ieee80211_ref_node(ni); -#endif TAILQ_INSERT_TAIL(&nt->nt_node, tni, ni_list); tni = NULL; @@ -806,15 +759,9 @@ node_table_join_locked(struct ieee80211_node_table *nt, ni, ni_hash); } -static __inline -void -#ifdef IEEE80211_DEBUG_REFCNT -node_table_leave_locked_debug(struct ieee80211_node_table *nt, - struct ieee80211_node *ni, const char *func, int line) -#else +static __inline void node_table_leave_locked(struct ieee80211_node_table *nt, struct ieee80211_node *ni) -#endif { struct ieee80211_node *hni; IEEE80211_NODE_TABLE_LOCK_ASSERT(nt); @@ -825,28 +772,20 @@ node_table_leave_locked(struct ieee80211_node_table *nt, LIST_REMOVE(ni, ni_hash); } ni->ni_table = NULL; -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_unref_node_debug(&ni, func, line); -#else ieee80211_unref_node(&ni); -#endif } /* This is overridden by ath_node_alloc in ath/if_ath.c, and so - * should never get called. - */ + * should never get called. */ static struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -node_alloc_debug(struct ieee80211vap *vap, const char *func, int line) -#else node_alloc(struct ieee80211vap *vap) -#endif { struct ieee80211_node *ni; MALLOC(ni, struct ieee80211_node *, sizeof(struct ieee80211_node), M_80211_NODE, M_NOWAIT | M_ZERO); - printk(KERN_ERR "%s: ERROR, this function should never be called!", __func__); + printk(KERN_ERR "%s: ERROR, this function should never be called!", + __func__); dump_stack(); return ni; } @@ -860,11 +799,7 @@ node_alloc(struct ieee80211vap *vap) * Context: hwIRQ, softIRQ and process context */ static void -#ifdef IEEE80211_DEBUG_REFCNT -node_cleanup_debug(struct ieee80211_node *ni, const char *func, int line) -#else node_cleanup(struct ieee80211_node *ni) -#endif { struct ieee80211vap *vap = ni->ni_vap; @@ -875,9 +810,10 @@ node_cleanup(struct ieee80211_node *ni) ni->ni_flags &= ~IEEE80211_NODE_PWR_MGT; #ifdef IEEE80211_DEBUG_REFCNT IEEE80211_NOTE(vap, IEEE80211_MSG_POWER, ni, - "%s (%s%d): power save mode off, %u STAs in PS mode", - __func__, func, line, + "Power save mode off, %u STAs in PS mode", vap->iv_ps_sta); + if (ieee80211_msg_is_reported(vap, IEEE80211_MSG_POWER)) + dump_stack(); #endif if (ni->ni_flags & IEEE80211_NODE_UAPSD_TRIG) { ni->ni_flags &= ~IEEE80211_NODE_UAPSD_TRIG; @@ -887,9 +823,7 @@ node_cleanup(struct ieee80211_node *ni) } } - /* - * Drain power save queue and, if needed, clear TIM. - */ + /* Drain power save queue and, if needed, clear TIM. */ if (ieee80211_node_saveq_drain(ni) != 0 && vap->iv_set_tim != NULL) vap->iv_set_tim(ni, 0); @@ -908,13 +842,8 @@ node_cleanup(struct ieee80211_node *ni) * XXX does this leave us open to inheriting old state? */ - if (ni->ni_rxfrag != NULL) { -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_dev_kfree_skb_debug(&ni->ni_rxfrag, func, line); -#else + if (ni->ni_rxfrag != NULL) ieee80211_dev_kfree_skb(&ni->ni_rxfrag); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - } ieee80211_crypto_delkey(vap, &ni->ni_ucastkey, ni); ni->ni_rxkeyoff = 0; } @@ -926,10 +855,6 @@ node_print_message( int show_counter, int refcnt_adjust, const struct ieee80211_node *ni, -#ifdef IEEE80211_DEBUG_REFCNT - const char *func1, int line1, -#endif - const char *func2, int line2, const char *message, ...) { @@ -952,18 +877,10 @@ node_print_message( } va_start(args, message); vsnprintf(expanded_message, sizeof(expanded_message), message, args); -#ifdef IEEE80211_DEBUG_REFCNT - printk(KERN_DEBUG "%s/%s: %s%s:%d -> %s:%d %s [node %p<" MAC_FMT ">%s%s%s%s, refs=%02d]\n", -#else - printk(KERN_DEBUG "%s/%s: %s%s:%d %s [node %p<" MAC_FMT ">%s%s%s%s, refs=%02d]\n", -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ + printk(KERN_DEBUG "%s/%s: %s %s [node %p<" MAC_FMT ">%s%s%s%s, refs=%02d]\n", ni->ni_ic->ic_dev->name, ni->ni_vap->iv_dev->name, node_count, -#ifdef IEEE80211_DEBUG_REFCNT - func1, line1, -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - func2, line2, expanded_message, ni, MAC_ADDR(ni->ni_macaddr), ni->ni_table != NULL ? " in " : "", @@ -971,19 +888,18 @@ node_print_message( ni->ni_table != NULL ? " table" : "", ni->ni_table != NULL ? "" : " (not in any tables)", adjusted_refcount); + dump_stack(); va_end(args); } -EXPORT_SYMBOL(node_print_message); +#else +# define node_print_message(...) #endif static void -#ifdef IEEE80211_DEBUG_REFCNT -node_free_debug(struct ieee80211_node *ni, const char *func, int line) -#else node_free(struct ieee80211_node *ni) -#endif { - KASSERT(atomic_read(&ni->ni_refcnt) == 0, ("node being free whilst still referenced")); + KASSERT(atomic_read(&ni->ni_refcnt) == 0, + ("node being free whilst still referenced")); if (ni->ni_challenge != NULL) FREE(ni->ni_challenge, M_DEVBUF); @@ -1031,24 +947,14 @@ node_getrssi(const struct ieee80211_node *ni) * count of one, and adds it to the node table. */ struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_alloc_node_table_debug(struct ieee80211vap *vap, - const u_int8_t *macaddr, - const char *func, int line) -#else ieee80211_alloc_node_table(struct ieee80211vap *vap, const u_int8_t *macaddr) -#endif { struct ieee80211com *ic = vap->iv_ic; struct ieee80211_node_table *nt = &ic->ic_sta; struct ieee80211_node *ni; -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_alloc_node_debug(vap, macaddr, func, line); -#else ni = ieee80211_alloc_node(vap, macaddr); -#endif if (ni != NULL) { ni->ni_inact = ni->ni_inact_reload = nt->nt_inact_init; @@ -1056,24 +962,17 @@ ieee80211_alloc_node_table(struct ieee80211vap *vap, IEEE80211_NODE_SAVEQ_INIT(ni, "unknown"); IEEE80211_NODE_TABLE_LOCK_IRQ(nt); -#ifdef IEEE80211_DEBUG_REFCNT - node_table_join_locked_debug(nt, ni, func, line); -#else node_table_join_locked(nt, ni); -#endif IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); } else { - printk(KERN_ERR "Failed to allocate node for " MAC_FMT ".\n", MAC_ADDR(macaddr)); + printk(KERN_ERR "Failed to allocate node for " MAC_FMT ".\n", + MAC_ADDR(macaddr)); } return ni; } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_alloc_node_table_debug); -#else EXPORT_SYMBOL(ieee80211_alloc_node_table); -#endif /* Allocate a node structure and initialise specialised structures * This function does not add the node to the node table, thus this @@ -1081,21 +980,13 @@ EXPORT_SYMBOL(ieee80211_alloc_node_table); * This is useful when sending one off errors or request denials. */ static struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_alloc_node_debug(struct ieee80211vap *vap, const u_int8_t *macaddr, const char *func, int line) -#else ieee80211_alloc_node(struct ieee80211vap *vap, const u_int8_t *macaddr) -#endif { struct ieee80211com *ic = vap->iv_ic; struct ieee80211_node *ni; /* This always allocates zeroed memoery */ -#ifdef IEEE80211_DEBUG_REFCNT - ni = ic->ic_node_alloc_debug(vap, func, line); -#else ni = ic->ic_node_alloc(vap); -#endif if (ni != NULL) { atomic_set(&ni->ni_refcnt, 1); IEEE80211_ADDR_COPY(ni->ni_macaddr, macaddr); @@ -1111,17 +1002,12 @@ ieee80211_alloc_node(struct ieee80211vap *vap, const u_int8_t *macaddr) ni->ni_vap = vap; ni->ni_ic = ic; atomic_inc(&ni->ni_ic->ic_node_counter); -#ifdef IEEE80211_DEBUG - node_print_message(IEEE80211_MSG_NODE|IEEE80211_MSG_NODE_REF, + + node_print_message(IEEE80211_MSG_NODE | IEEE80211_MSG_NODE_REF, 1 /* show counter */, 0 /* adjust refcount */, ni, -#ifdef IEEE80211_DEBUG_REFCNT - func, line, -#endif - __func__, __LINE__, "alloc" /* message */); -#endif } else { /* XXX msg */ vap->iv_stats.is_rx_nodealloc++; @@ -1130,22 +1016,17 @@ ieee80211_alloc_node(struct ieee80211vap *vap, const u_int8_t *macaddr) return ni; } -/* Add wds address to the node table */ +/* Add wds address to the node table. */ int -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_add_wds_addr_debug(struct ieee80211_node_table *nt, - struct ieee80211_node *ni, const u_int8_t *macaddr, u_int8_t wds_static, - const char *func, int line) -#else ieee80211_add_wds_addr(struct ieee80211_node_table *nt, struct ieee80211_node *ni, const u_int8_t *macaddr, u_int8_t wds_static) -#endif { int hash; struct ieee80211_wds_addr *wds; - MALLOC(wds, struct ieee80211_wds_addr *, sizeof(struct ieee80211_wds_addr), - M_80211_WDS, M_NOWAIT | M_ZERO); + MALLOC(wds, struct ieee80211_wds_addr *, + sizeof(struct ieee80211_wds_addr), + M_80211_WDS, M_NOWAIT | M_ZERO); if (wds == NULL) { /* XXX msg */ return 1; @@ -1158,29 +1039,17 @@ ieee80211_add_wds_addr(struct ieee80211_node_table *nt, IEEE80211_ADDR_COPY(wds->wds_macaddr, macaddr); IEEE80211_NODE_TABLE_LOCK_IRQ(nt); -#ifdef IEEE80211_DEBUG_REFCNT - wds->wds_ni = ieee80211_ref_node_debug(ni, func, line); -#else wds->wds_ni = ieee80211_ref_node(ni); -#endif LIST_INSERT_HEAD(&nt->nt_wds_hash[hash], wds, wds_hash); IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); return 0; } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_add_wds_addr_debug); -#else EXPORT_SYMBOL(ieee80211_add_wds_addr); -#endif /* remove wds address from the wds hash table */ void -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_remove_wds_addr_debug(struct ieee80211_node_table *nt, const u_int8_t *macaddr, - const char *func, int line) -#else -ieee80211_remove_wds_addr(struct ieee80211_node_table *nt, const u_int8_t *macaddr) -#endif +ieee80211_remove_wds_addr(struct ieee80211_node_table *nt, + const u_int8_t *macaddr) { int hash; struct ieee80211_wds_addr *wds, *twds; @@ -1190,31 +1059,19 @@ ieee80211_remove_wds_addr(struct ieee80211_node_table *nt, const u_int8_t *macad LIST_FOREACH_SAFE(wds, &nt->nt_wds_hash[hash], wds_hash, twds) { if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { LIST_REMOVE(wds, wds_hash); -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_unref_node_debug(&wds->wds_ni, func, line); -#else ieee80211_unref_node(&wds->wds_ni); -#endif FREE(wds, M_80211_WDS); break; } } IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_remove_wds_addr_debug); -#else EXPORT_SYMBOL(ieee80211_remove_wds_addr); -#endif /* Remove node references from wds table */ void -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_del_wds_node_debug(struct ieee80211_node_table *nt, struct ieee80211_node *ni, - const char *func, int line) -#else -ieee80211_del_wds_node(struct ieee80211_node_table *nt, struct ieee80211_node *ni) -#endif +ieee80211_del_wds_node(struct ieee80211_node_table *nt, + struct ieee80211_node *ni) { int hash; struct ieee80211_wds_addr *wds, *twds; @@ -1224,22 +1081,14 @@ ieee80211_del_wds_node(struct ieee80211_node_table *nt, struct ieee80211_node *n LIST_FOREACH_SAFE(wds, &nt->nt_wds_hash[hash], wds_hash, twds) { if (wds->wds_ni == ni) { LIST_REMOVE(wds, wds_hash); -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_unref_node_debug(&wds->wds_ni, func, line); -#else ieee80211_unref_node(&wds->wds_ni); -#endif FREE(wds, M_80211_WDS); } } } IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_del_wds_node_debug); -#else EXPORT_SYMBOL(ieee80211_del_wds_node); -#endif static void ieee80211_node_wds_ageout(unsigned long data) @@ -1271,30 +1120,17 @@ ieee80211_node_wds_ageout(unsigned long data) * If tmp is 0, it is added to the node table and the reference is used. * If tmp is 1, then the caller gets to use the reference. */ struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_dup_bss_debug(struct ieee80211vap *vap, const u_int8_t *macaddr, - unsigned char tmp, const char *func, int line) -#else ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr, unsigned char tmp) -#endif { struct ieee80211_node *ni; /* FIXME: Hack */ if (tmp) { -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_alloc_node_debug(vap, macaddr, func, line); -#else ni = ieee80211_alloc_node(vap, macaddr); -#endif } else { -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_alloc_node_table_debug(vap, macaddr, func, line); -#else ni = ieee80211_alloc_node_table(vap, macaddr); -#endif IEEE80211_DPRINTF(vap, IEEE80211_MSG_ASSOC, "%s: ni:%p allocated for " MAC_FMT "\n", __func__, ni, MAC_ADDR(macaddr)); @@ -1312,13 +1148,8 @@ ieee80211_dup_bss(struct ieee80211vap *vap, const u_int8_t *macaddr, } static struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_find_wds_node_locked_debug(struct ieee80211_node_table *nt, - const u_int8_t *macaddr, const char *func, int line) -#else ieee80211_find_wds_node_locked(struct ieee80211_node_table *nt, const u_int8_t *macaddr) -#endif { struct ieee80211_wds_addr *wds; int hash; @@ -1327,32 +1158,19 @@ ieee80211_find_wds_node_locked(struct ieee80211_node_table *nt, hash = IEEE80211_NODE_HASH(macaddr); LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { + /* Reset the aging count. */ if (wds->wds_agingcount != WDS_AGING_STATIC) - wds->wds_agingcount = WDS_AGING_COUNT; /* reset the aging count */ -#ifdef IEEE80211_DEBUG_REFCNT - return ieee80211_ref_node_debug(wds->wds_ni, func, line); -#else + wds->wds_agingcount = WDS_AGING_COUNT; return ieee80211_ref_node(wds->wds_ni); -#endif } } return NULL; } /* NB: A node reference is acquired here; the caller MUST release it. */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_find_node_locked(nt, mac) \ - ieee80211_find_node_locked_debug(nt, mac, __func__, __LINE__) -#endif - static struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_find_node_locked_debug(struct ieee80211_node_table *nt, - const u_int8_t *macaddr, const char *func, int line) -#else ieee80211_find_node_locked(struct ieee80211_node_table *nt, const u_int8_t *macaddr) -#endif { struct ieee80211_node *ni; int hash; @@ -1363,11 +1181,7 @@ ieee80211_find_node_locked(struct ieee80211_node_table *nt, hash = IEEE80211_NODE_HASH(macaddr); LIST_FOREACH(ni, &nt->nt_hash[hash], ni_hash) { if (IEEE80211_ADDR_EQ(ni->ni_macaddr, macaddr)) { -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_ref_node_debug(ni, func, line); -#else ieee80211_ref_node(ni); -#endif return ni; } } @@ -1375,67 +1189,36 @@ ieee80211_find_node_locked(struct ieee80211_node_table *nt, /* Now, we look for the desired mac address in the 4 address nodes. */ LIST_FOREACH(wds, &nt->nt_wds_hash[hash], wds_hash) { - if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) { -#ifdef IEEE80211_DEBUG_REFCNT - return ieee80211_ref_node_debug(wds->wds_ni, func, line); -#else + if (IEEE80211_ADDR_EQ(wds->wds_macaddr, macaddr)) return ieee80211_ref_node(wds->wds_ni); -#endif - } } return NULL; } struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_find_wds_node_debug(struct ieee80211_node_table *nt, const u_int8_t *macaddr, - const char *func, int line) -#else -ieee80211_find_wds_node(struct ieee80211_node_table *nt, const u_int8_t *macaddr) -#endif +ieee80211_find_wds_node(struct ieee80211_node_table *nt, + const u_int8_t *macaddr) { struct ieee80211_node *ni; IEEE80211_NODE_TABLE_LOCK_IRQ(nt); -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_find_wds_node_locked_debug(nt, macaddr, func, line); -#else ni = ieee80211_find_wds_node_locked(nt, macaddr); -#endif IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); return ni; } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_find_wds_node_debug); -#else EXPORT_SYMBOL(ieee80211_find_wds_node); -#endif struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_find_node_debug(struct ieee80211_node_table *nt, - const u_int8_t *macaddr, const char *func, int line) -#else ieee80211_find_node(struct ieee80211_node_table *nt, const u_int8_t *macaddr) -#endif { struct ieee80211_node *ni; IEEE80211_NODE_TABLE_LOCK_IRQ(nt); -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_find_node_locked_debug(nt, macaddr, func, line); -#else ni = ieee80211_find_node_locked(nt, macaddr); -#endif IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); return ni; } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_find_node_debug); -#else EXPORT_SYMBOL(ieee80211_find_node); -#endif - /* * Fake up a node; this handles node discovery in adhoc mode. @@ -1446,14 +1229,8 @@ EXPORT_SYMBOL(ieee80211_find_node); * Caller must ieee80211_ref_node() */ struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_fakeup_adhoc_node_debug(struct ieee80211vap *vap, - const u_int8_t macaddr[IEEE80211_ADDR_LEN], - const char *func, int line) -#else ieee80211_fakeup_adhoc_node(struct ieee80211vap *vap, const u_int8_t macaddr[IEEE80211_ADDR_LEN]) -#endif { struct ieee80211_node *ni; @@ -1535,13 +1312,8 @@ ieee80211_add_neighbor(struct ieee80211vap *vap, const struct ieee80211_frame *w * NB: A node reference is acquired here; the caller MUST release it. */ struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_find_rxnode_debug(struct ieee80211com *ic, - const struct ieee80211_frame_min *wh, const char *func, int line) -#else ieee80211_find_rxnode(struct ieee80211com *ic, const struct ieee80211_frame_min *wh) -#endif { #define IS_CTL(wh) \ ((wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == IEEE80211_FC0_TYPE_CTL) @@ -1552,24 +1324,16 @@ ieee80211_find_rxnode(struct ieee80211com *ic, struct ieee80211_node_table *nt; struct ieee80211_node *ni; - /* XXX check ic_bss first in station mode */ - /* XXX 4-address frames? */ + /* XXX: check ic_bss first in station mode */ + /* XXX: 4-address frames? */ nt = &ic->ic_sta; IEEE80211_NODE_TABLE_LOCK_IRQ(nt); /* NB: Control frames typically have one address, except * for RTS and PSPOLL */ if (IS_CTL(wh) && !IS_PSPOLL(wh) && !IS_RTS(wh)) -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_find_node_locked_debug(nt, wh->i_addr1, func, line); -#else ni = ieee80211_find_node_locked(nt, wh->i_addr1); -#endif else -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_find_node_locked_debug(nt, wh->i_addr2, func, line); -#else ni = ieee80211_find_node_locked(nt, wh->i_addr2); -#endif IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); return ni; @@ -1577,11 +1341,7 @@ ieee80211_find_rxnode(struct ieee80211com *ic, #undef IS_CTL #undef IS_RTS } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_find_rxnode_debug); -#else EXPORT_SYMBOL(ieee80211_find_rxnode); -#endif /* * Return the appropriate node for sending a data frame. This handles node @@ -1590,61 +1350,32 @@ EXPORT_SYMBOL(ieee80211_find_rxnode); * NB: A node reference is acquired here; the caller MUST release it. */ struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_find_txnode_debug(struct ieee80211vap *vap, const u_int8_t *mac, - const char *func, int line) -#else ieee80211_find_txnode(struct ieee80211vap *vap, const u_int8_t *mac) -#endif { struct ieee80211_node_table *nt; struct ieee80211_node *ni = NULL; - /* - * The destination address should be in the node table + /* The destination address should be in the node table * unless we are operating in station mode or this is a - * multicast/broadcast frame. - */ - if (vap->iv_opmode == IEEE80211_M_STA || IEEE80211_IS_MULTICAST(mac)) { -#ifdef IEEE80211_DEBUG_REFCNT - return ieee80211_ref_node_debug(vap->iv_bss, func, line); -#else + * multicast/broadcast frame. */ + if (vap->iv_opmode == IEEE80211_M_STA || IEEE80211_IS_MULTICAST(mac)) return ieee80211_ref_node(vap->iv_bss); -#endif - } /* XXX: Can't hold lock across dup_bss due to recursive locking. */ nt = &vap->iv_ic->ic_sta; IEEE80211_NODE_TABLE_LOCK_IRQ(nt); -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_find_node_locked_debug(nt, mac, func, line); -#else ni = ieee80211_find_node_locked(nt, mac); -#endif IEEE80211_NODE_TABLE_UNLOCK_IRQ(nt); if (ni == NULL) { if (vap->iv_opmode == IEEE80211_M_IBSS || vap->iv_opmode == IEEE80211_M_AHDEMO) { - /* - * In adhoc mode cons up a node for the destination. + /* In adhoc mode cons up a node for the destination. * Note that we need an additional reference for the - * caller to be consistent with ieee80211_find_node. - */ -#ifdef IEEE80211_DEBUG_REFCNT - ni = ieee80211_fakeup_adhoc_node_debug(vap, mac, - func, line); -#else + * caller to be consistent with ieee80211_find_node. */ ni = ieee80211_fakeup_adhoc_node(vap, mac); -#endif - - if (ni != NULL) { -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_ref_node_debug(ni, func, line); -#else + if (ni != NULL) ieee80211_ref_node(ni); -#endif - } } else { IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_OUTPUT, mac, "no node, discard frame (%s)", __func__); @@ -1653,49 +1384,28 @@ ieee80211_find_txnode(struct ieee80211vap *vap, const u_int8_t *mac) } return ni; } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_find_txnode_debug); -#else EXPORT_SYMBOL(ieee80211_find_txnode); -#endif -/* Context: hwIRQ, softIRQ and process context - */ +/* Context: hwIRQ, softIRQ and process context. */ void -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line) -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ ieee80211_free_node(struct ieee80211_node *ni) -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ { struct ieee80211vap *vap = ni->ni_vap; atomic_dec(&ni->ni_ic->ic_node_counter); -#ifdef IEEE80211_DEBUG - node_print_message(IEEE80211_MSG_NODE|IEEE80211_MSG_NODE_REF, + + node_print_message(IEEE80211_MSG_NODE | IEEE80211_MSG_NODE_REF, 1 /* show counter */, 0 /* adjust refcount */, ni, -#ifdef IEEE80211_DEBUG_REFCNT - func, line, -#endif - __func__, __LINE__, "free" /* message */); -#endif + if (vap->iv_aid_bitmap != NULL) IEEE80211_AID_CLR(vap, ni->ni_associd); -#ifdef IEEE80211_DEBUG_REFCNT - vap->iv_ic->ic_node_free_debug(ni, func, line); -#else vap->iv_ic->ic_node_free(ni); -#endif } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_free_node_debug); -#else EXPORT_SYMBOL(ieee80211_free_node); -#endif static void _reset_node(void *arg, struct ieee80211_node *ni) { @@ -1733,11 +1443,7 @@ ieee80211_node_table_cleanup(struct ieee80211_node_table *nt) if (vap->iv_aid_bitmap != NULL) IEEE80211_AID_CLR(vap, ni->ni_associd); } -#ifdef IEEE80211_DEBUG_REFCNT - ic->ic_node_cleanup_debug(ni, __func__, __LINE__); -#else ic->ic_node_cleanup(ni); -#endif } del_timer(&nt->nt_wds_aging_timer); IEEE80211_SCAN_LOCK_DESTROY(nt); @@ -1884,14 +1590,17 @@ ieee80211_node_timeout(unsigned long arg) } void -ieee80211_iterate_nodes(struct ieee80211_node_table *nt, ieee80211_iter_func *f, void *arg) +ieee80211_iterate_nodes(struct ieee80211_node_table *nt, + ieee80211_iter_func *f, void *arg) { ieee80211_iterate_dev_nodes(NULL, nt, f, arg); } EXPORT_SYMBOL(ieee80211_iterate_nodes); void -ieee80211_iterate_dev_nodes(struct net_device *dev, struct ieee80211_node_table *nt, ieee80211_iter_func *f, void *arg) +ieee80211_iterate_dev_nodes(struct net_device *dev, + struct ieee80211_node_table *nt, + ieee80211_iter_func *f, void *arg) { struct ieee80211_node *ni; u_int gen; @@ -1906,7 +1615,7 @@ restart: continue; /* skip node not for this vap */ if (ni->ni_scangen != gen) { ni->ni_scangen = gen; - (void) ieee80211_ref_node(ni); + (void)ieee80211_ref_node(ni); IEEE80211_NODE_TABLE_UNLOCK_IRQ_EARLY(nt); (*f)(arg, ni); @@ -2322,11 +2031,7 @@ ieee80211_node_leave(struct ieee80211_node *ni) ieee80211_sta_leave(ni); done: /* Run a cleanup */ -#ifdef IEEE80211_DEBUG_REFCNT - ic->ic_node_cleanup_debug(ni, __func__, __LINE__); -#else ic->ic_node_cleanup(ni); -#endif } EXPORT_SYMBOL(ieee80211_node_leave); @@ -2395,60 +2100,32 @@ ieee80211_node_reset(struct ieee80211_node *ni, struct ieee80211vap *vap) EXPORT_SYMBOL(ieee80211_node_reset); struct ieee80211_node * -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_ref_node_debug(struct ieee80211_node *ni, const char *func, int line) -#else ieee80211_ref_node(struct ieee80211_node *ni) -#endif { if (ni == NULL) { printk(KERN_ERR "%s: NULL node.\n", __func__); dump_stack(); - return ni; - } - if (atomic_read(&ni->ni_refcnt) < 1) { -#ifdef IEEE80211_DEBUG + }else if (atomic_read(&ni->ni_refcnt) < 1) { node_print_message(IEEE80211_MSG_ANY, 0 /* show counter */, 0 /* adjust refcount */, ni, -#ifdef IEEE80211_DEBUG_REFCNT - func, line, -#endif - __func__, __LINE__, - "attempt to access node with invalid refcount of %d." - " No changes made." /* message */, + "attempt to access node with invalid " + "refcount of %d. No changes made.", atomic_read(&ni->ni_refcnt)); -#endif - dump_stack(); - return ni; + } else { + atomic_inc(&ni->ni_refcnt); + node_print_message(IEEE80211_MSG_NODE_REF, + 0 /* show counter */, + 0 /* adjust refcount */, + ni, "ref"); } - atomic_inc(&ni->ni_refcnt); -#ifdef IEEE80211_DEBUG - node_print_message(IEEE80211_MSG_NODE_REF, - 0 /* show counter */, - 0 /* adjust refcount */, - ni, -#ifdef IEEE80211_DEBUG_REFCNT - func, line, -#endif - __func__, __LINE__, - "ref" /* message */); -#endif return ni; } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_ref_node_debug); -#else EXPORT_SYMBOL(ieee80211_ref_node); -#endif void -#ifdef IEEE80211_DEBUG_REFCNT -ieee80211_unref_node_debug(struct ieee80211_node **pni, const char *func, int line) -#else ieee80211_unref_node(struct ieee80211_node **pni) -#endif { struct ieee80211_node *ni = NULL; if (pni == NULL) { @@ -2463,48 +2140,27 @@ ieee80211_unref_node(struct ieee80211_node **pni) return; } if (atomic_read(&ni->ni_refcnt) < 1) { -#ifdef IEEE80211_DEBUG node_print_message(IEEE80211_MSG_ANY, 0 /* show counter */, 0 /* adjust refcount */, ni, -#ifdef IEEE80211_DEBUG_REFCNT - func, line, -#endif - __func__, __LINE__, - "attempt to access node with invalid refcount of %d." - " No changes made." /* message */, + "attempt to access node with invalid " + "refcount of %d. No changes made.", atomic_read(&ni->ni_refcnt)); -#endif dump_stack(); return; } -#ifdef IEEE80211_DEBUG node_print_message(IEEE80211_MSG_NODE_REF, 0 /* show counter */, -1 /* adjust refcount */, ni, -#ifdef IEEE80211_DEBUG_REFCNT - func, line, -#endif - __func__, __LINE__, "unref" /* message */); -#endif - if (atomic_dec_and_test(&ni->ni_refcnt)) { -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_free_node_debug(ni, func, line); -#else /* #ifdef IEEE80211_DEBUG_REFCNT */ + if (atomic_dec_and_test(&ni->ni_refcnt)) ieee80211_free_node(ni); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - } *pni = NULL; } -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_unref_node_debug); -#else EXPORT_SYMBOL(ieee80211_unref_node); -#endif int32_t ieee80211_get_node_count(struct ieee80211com *ic) diff --git a/net80211/ieee80211_node.h b/net80211/ieee80211_node.h index 28cc607..bada5bc 100644 --- a/net80211/ieee80211_node.h +++ b/net80211/ieee80211_node.h @@ -257,88 +257,34 @@ struct ieee80211_node_table { /* Allocates a new ieee80211_node * that has a reference count of one, and * adds it to the node table. */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_alloc_node_table(_vap, _mac) \ - ieee80211_alloc_node_table_debug(_vap, _mac, __func__, __LINE__) -struct ieee80211_node *ieee80211_alloc_node_table_debug(struct ieee80211vap *, - const u_int8_t *, const char *name, int line); -#else struct ieee80211_node *ieee80211_alloc_node_table(struct ieee80211vap *, const u_int8_t *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ /* Allocates a new ieee80211_node * that has a reference count. * If tmp is 0, it is added to the node table and the reference is used. * If tmp is 1, then the caller gets to use the reference. */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_dup_bss(_vap, _mac, _tmp) \ - ieee80211_dup_bss_debug(_vap, _mac, _tmp, __func__, __LINE__) -struct ieee80211_node *ieee80211_dup_bss_debug(struct ieee80211vap *, - const u_int8_t *, unsigned char tmp, const char *, int); -#else struct ieee80211_node *ieee80211_dup_bss(struct ieee80211vap *, const u_int8_t *, unsigned char tmp); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ void ieee80211_node_reset(struct ieee80211_node *, struct ieee80211vap *); -/* Returns a ieee80211_node * with refcount incremented, if found */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_find_node(_nt, _mac) \ - ieee80211_find_node_debug(_nt, _mac, __func__, __LINE__) -struct ieee80211_node *ieee80211_find_node_debug(struct ieee80211_node_table *, - const u_int8_t *, const char *, int); -#else +/* The following return node reference that the caller must manage. */ struct ieee80211_node *ieee80211_find_node(struct ieee80211_node_table *, const u_int8_t *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - -/* Returns a ieee80211_node * with refcount incremented, if found */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_find_rxnode(_nt, _wh) \ - ieee80211_find_rxnode_debug(_nt, _wh, __func__, __LINE__) -struct ieee80211_node *ieee80211_find_rxnode_debug(struct ieee80211com *, - const struct ieee80211_frame_min *, const char *, int); -#else struct ieee80211_node *ieee80211_find_rxnode(struct ieee80211com *, const struct ieee80211_frame_min *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - -/* Returns a ieee80211_node * with refcount incremented, if found */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_find_txnode(_nt, _mac) \ - ieee80211_find_txnode_debug(_nt, _mac, __func__, __LINE__) -struct ieee80211_node *ieee80211_find_txnode_debug(struct ieee80211vap *, - const u_int8_t *, const char *, int); -#else struct ieee80211_node *ieee80211_find_txnode(struct ieee80211vap *, const u_int8_t *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_free_node(_ni) \ - ieee80211_free_node_debug(_ni, __func__, __LINE__) -void ieee80211_free_node_debug(struct ieee80211_node *ni, const char *func, int line); -#else void ieee80211_free_node(struct ieee80211_node *ni); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ /* Reference counting only needs to be locked out against the transitions, * 0->1 and 1->0 (i.e., when we do not own the reference we are getting). * This only happens when finding the a node reference from the node table, * which is locked seperately. Thus, we do not need to lock the follwoing * functions. - * Increment the reference counter for ieee80211_node * - */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_ref_node(_ni) \ - ieee80211_ref_node_debug(_ni, __func__, __LINE__) -struct ieee80211_node * -ieee80211_ref_node_debug(struct ieee80211_node *ni, const char *func, int line); -#else -struct ieee80211_node * -ieee80211_ref_node(struct ieee80211_node *ni); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ + * Increment the reference counter for ieee80211_node *. */ +struct ieee80211_node *ieee80211_ref_node(struct ieee80211_node *ni); #define PASS_NODE(_ni) \ ieee80211_pass_node(&_ni) @@ -350,58 +296,21 @@ ieee80211_pass_node(struct ieee80211_node **pni) { return (tmp); } -/* Decrement ieee80211_node * refcount, and relinquish the pointer. */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_unref_node(_pni) \ - ieee80211_unref_node_debug(_pni, __func__, __LINE__) -void -ieee80211_unref_node_debug(struct ieee80211_node **pni, const char *func, int line); -#else -void -ieee80211_unref_node(struct ieee80211_node **pni); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ +void ieee80211_unref_node(struct ieee80211_node **pni); /* Increments reference count of ieee80211_node *ni */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_add_wds_addr(_table, _node, _mac, _static) \ - ieee80211_add_wds_addr_debug(_table, _node, _mac, _static, __func__, __LINE__) -int ieee80211_add_wds_addr_debug(struct ieee80211_node_table *, struct ieee80211_node *, - const u_int8_t *, u_int8_t, const char *func, int line); -#else int ieee80211_add_wds_addr(struct ieee80211_node_table *, struct ieee80211_node *, const u_int8_t *, u_int8_t); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ /* Decrements reference count of ieee80211_node *ni */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_remove_wds_addr(_table, _mac) \ - ieee80211_remove_wds_addr_debug(_table, _mac, __func__, __LINE__) -void ieee80211_remove_wds_addr_debug(struct ieee80211_node_table *, const u_int8_t *, - const char *func, int line); -#else void ieee80211_remove_wds_addr(struct ieee80211_node_table *, const u_int8_t *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ /* Decrements reference count of node, if found */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_del_wds_node(_table, _node) \ - ieee80211_del_wds_node_debug(_table, _node, __func__, __LINE__) -void ieee80211_del_wds_node_debug(struct ieee80211_node_table *, struct ieee80211_node *, - const char *func, int line); -#else void ieee80211_del_wds_node(struct ieee80211_node_table *, struct ieee80211_node *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ /* Increments reference count of node, if found */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_find_wds_node(_table, _mac) \ - ieee80211_find_wds_node_debug(_table, _mac, __func__, __LINE__) -struct ieee80211_node *ieee80211_find_wds_node_debug(struct ieee80211_node_table *, - const u_int8_t *, const char *func, int line); -#else struct ieee80211_node *ieee80211_find_wds_node(struct ieee80211_node_table *, const u_int8_t *); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ typedef void ieee80211_iter_func(void *, struct ieee80211_node *); void ieee80211_iterate_nodes(struct ieee80211_node_table *, ieee80211_iter_func *, void *); @@ -411,15 +320,8 @@ void ieee80211_dump_node(struct ieee80211_node_table *, struct ieee80211_node *); void ieee80211_dump_nodes(struct ieee80211_node_table *); /* Returns a node with refcount of one. Caller must release that reference */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_fakeup_adhoc_node(_vap, _mac) \ - ieee80211_fakeup_adhoc_node_debug(_vap, _mac, __func__, __LINE__) -struct ieee80211_node *ieee80211_fakeup_adhoc_node_debug(struct ieee80211vap *, - const u_int8_t macaddr[], const char *, int); -#else struct ieee80211_node *ieee80211_fakeup_adhoc_node(struct ieee80211vap *, const u_int8_t macaddr[]); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ struct ieee80211_scanparams; /* Returns a node with refcount of one. Caller must release that reference */ struct ieee80211_node *ieee80211_add_neighbor(struct ieee80211vap *, diff --git a/net80211/ieee80211_scan.c b/net80211/ieee80211_scan.c index c5bd561..3e0a01c 100644 --- a/net80211/ieee80211_scan.c +++ b/net80211/ieee80211_scan.c @@ -435,9 +435,8 @@ ieee80211_start_scan(struct ieee80211vap *vap, int flags, u_int duration, * the requested scan has not, then we update the running scan * flag. This is needed when wpa_supplicant is used with * ap_scan=1. Without it, the driver will never associate. */ - - if (((flags & IEEE80211_SCAN_NOPICK) == 0) - && (ss->ss_flags & IEEE80211_SCAN_NOPICK)) { + if (((flags & IEEE80211_SCAN_NOPICK) == 0) && + (ss->ss_flags & IEEE80211_SCAN_NOPICK)) { IEEE80211_DPRINTF(vap, IEEE80211_MSG_SCAN, "%s: clearing SCAN_NOPICK flag\n", __func__); diff --git a/net80211/ieee80211_skb.c b/net80211/ieee80211_skb.c index 5dfacd0..610b82a 100644 --- a/net80211/ieee80211_skb.c +++ b/net80211/ieee80211_skb.c @@ -99,10 +99,7 @@ EXPORT_SYMBOL(skb_refs_counter); static void skb_print_message( int show_counter, const struct sk_buff *skb, -#ifdef IEEE80211_DEBUG_REFCNT - const char *func1, int line1, -#endif - const char *func2, int line2, + const char *func, int line, const char *message, ...) { @@ -126,19 +123,15 @@ static void skb_print_message( } va_start(args, message); vsnprintf(expanded_message, sizeof(expanded_message), message, args); -#ifdef IEEE80211_DEBUG_REFCNT - printk(KERN_DEBUG "%s: %s%s:%d -> %s:%d %s\n", -#else printk(KERN_DEBUG "%s: %s%s:%d %s\n", -#endif ((skb != NULL) ? DEV_NAME(skb->dev) : "none"), skb_count, -#ifdef IEEE80211_DEBUG_REFCNT - func1, line1, -#endif - func2, line2, + func, line, expanded_message); va_end(args); +#ifdef IEEE80211_DEBUG_REFCNT + dump_stack(); +#endif } #ifdef IEEE80211_DEBUG_REFCNT @@ -146,13 +139,11 @@ static void skb_print_message( static void print_skb_refchange_message( const struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2); + const char *func, int line); static void print_skb_trackchange_message( const struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2, + const char *func, int line, char *message); /* Called automatically when an SKB reaches zero users, @@ -160,20 +151,19 @@ print_skb_trackchange_message( #ifdef IEEE80211_DEBUG_REFCNT_SKBDEST static void skb_destructor(struct sk_buff *skb); #endif -static void get_skb_description(char *dst, int dst_size, const char *label, const struct sk_buff *skb, int users_adjustment); +static void get_skb_description(char *dst, int dst_size, const char *label, + const struct sk_buff *skb, int users_adjustment); static struct sk_buff * clean_clone_or_copy(struct sk_buff *skb); static struct sk_buff * track_skb(struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2); + const char *func, int line); static struct sk_buff * untrack_skb(struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2); + const char *func, int line); #define UNREF_USE_KFREE_SKB 0 #define UNREF_USE_DEV_KFREE_SKB_ANY 1 @@ -183,15 +173,13 @@ untrack_skb(struct sk_buff *skb, int users_adjustment, /* Assumes SKB is not yet freed at the time of the call and shows the new users * count as (users - 1). */ static void unref_skb(struct sk_buff *skb, int type, - const char *func1, int line1, - const char *func2, int line2); + const char *func, int line); /* Assumes SKB reference counter has already been updated and reports count as * atomic_read(&skb->users). */ static struct sk_buff * ref_skb(struct sk_buff *skb, - const char *func1, int line1, - const char *func2, int line2); + const char *func, int line); #ifdef IEEE80211_DEBUG_REFCNT_SKBDEST @@ -248,8 +236,7 @@ static void get_skb_description(char *dst, int dst_size, const char *label, cons static void print_skb_refchange_message( const struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2) + const char *func, int line) { char skb_desc[128] = { '\0' }; if (0 == (ath_debug_global & GLOBAL_DEBUG_SKB_REF)) @@ -257,14 +244,13 @@ static void print_skb_refchange_message( get_skb_description(skb_desc, sizeof(skb_desc), "skb", skb, users_adjustment); skb_print_message(0 /* no global count */, skb, - func1, line1, func2, line2, + func, line, skb_desc); } static void print_skb_trackchange_message( const struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2, + const char *func, int line, char *message) { char skb_desc[128] = { '\0' }; @@ -273,7 +259,7 @@ static void print_skb_trackchange_message( get_skb_description(skb_desc, sizeof(skb_desc), "skb", skb, users_adjustment); skb_print_message(1 /* show global count */, skb, - func1, line1, func2, line2, + func, line, "%s%s", skb_desc, message); } @@ -286,25 +272,24 @@ clean_clone_or_copy(struct sk_buff *skb) { static struct sk_buff * track_skb(struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2) + const char *func, int line) { if (NULL == skb) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func2, line2, "ERROR: NULL skb received. Skipping."); return NULL; } if (M_FLAG_GET(skb, M_SKB_TRACKED)) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func2, line2, "ERROR: Already tracked skb received. Skipping."); dump_stack(); return skb; } if (skb_shared(skb)) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func2, line2, "ERROR: Shared skb received. References leaked??"); dump_stack(); } @@ -312,7 +297,7 @@ track_skb(struct sk_buff *skb, int users_adjustment, atomic_inc(&skb_refs_counter); M_FLAG_SET(skb, M_SKB_TRACKED); print_skb_trackchange_message(skb, users_adjustment, - func1, line1, func2, line2, + func2, line2, " is now ** TRACKED **"); #ifdef IEEE80211_DEBUG_REFCNT_SKBDEST /* Install our debug destructor, chaining to the original... */ @@ -326,27 +311,24 @@ track_skb(struct sk_buff *skb, int users_adjustment, static struct sk_buff * untrack_skb(struct sk_buff *skb, int users_adjustment, - const char *func1, int line1, - const char *func2, int line2) + const char *func, int line) { if (NULL == skb) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: NULL skb received. No changes made."); return NULL; } if (!M_FLAG_GET(skb, M_SKB_TRACKED)) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: Untracked skb received. No changes made."); - dump_stack(); return skb; } if (skb_shared(skb)) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: Shared skb received. References leaked??"); - dump_stack(); } atomic_dec(&skb_total_counter); atomic_dec(&skb_refs_counter); @@ -359,7 +341,7 @@ untrack_skb(struct sk_buff *skb, int users_adjustment, } #endif /* #ifdef IEEE80211_DEBUG_REFCNT_SKBDEST */ print_skb_trackchange_message(skb, users_adjustment, - func1, line1, func2, line2, + func, line, " is now ** UNTRACKED **"); return skb; } @@ -373,19 +355,18 @@ untrack_skb(struct sk_buff *skb, int users_adjustment, * count as (users - 1). */ static void unref_skb(struct sk_buff *skb, int type, - const char *func1, int line1, - const char *func2, int line2) + const char *func, int line) { if (NULL == skb) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: NULL skb received."); dump_stack(); return; } if (!M_FLAG_GET(skb, M_SKB_TRACKED)) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: Untracked skb received. Probable duplicate free error!"); dump_stack(); return; @@ -393,7 +374,7 @@ unref_skb(struct sk_buff *skb, int type, /* If free is unacceptable for current user count, report the error. */ if (atomic_read(&skb->users) < 1) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: free an skb with %d users", atomic_read(&skb->users)); dump_stack(); @@ -402,7 +383,7 @@ unref_skb(struct sk_buff *skb, int type, if (skb_shared(skb)) { atomic_dec(&skb_refs_counter); - print_skb_refchange_message(skb, -1, func1, line1, func2, line2); + print_skb_refchange_message(skb, -1, func2, line2); } else { if (SKB_NI(skb) != NULL) { @@ -415,7 +396,7 @@ unref_skb(struct sk_buff *skb, int type, * report it again in the destructor. */ SKB_NI(skb) = NULL; } - untrack_skb(skb, -1, func1, line1, func2, line2); + untrack_skb(skb, -1, func, line); } #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) @@ -423,7 +404,7 @@ unref_skb(struct sk_buff *skb, int type, (type == UNREF_USE_KFREE_SKB || type == UNREF_USE_DEV_KFREE_SKB)) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: free an skb in interrupt context using a non-" "safe form of skb free function."); type = UNREF_USE_DEV_KFREE_SKB_ANY; @@ -453,25 +434,24 @@ unref_skb(struct sk_buff *skb, int type, * atomic_read(&skb->users). */ static struct sk_buff * ref_skb(struct sk_buff *skb, - const char *func1, int line1, - const char *func2, int line2) + const char *func, int line) { if (NULL == skb) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: NULL skb received. No changes made."); dump_stack(); return NULL; } if (!M_FLAG_GET(skb, M_SKB_TRACKED)) { skb_print_message(0 /* show_counter */, - skb, func1, line1, func2, line2, + skb, func, line, "ERROR: Untracked skb received. Probable use after free! " "No changes made."); dump_stack(); return skb; } - print_skb_refchange_message(skb, 0, func1, line1, func2, line2); + print_skb_refchange_message(skb, 0, func, line); return skb; } @@ -485,11 +465,7 @@ ref_skb(struct sk_buff *skb, * If SKB refcount is going to zero: * - Free the node reference and set it to null. * - Break the linked list, clearing next skb's prev pointer if possible. */ -#ifdef IEEE80211_DEBUG_REFCNT -void ieee80211_dev_kfree_skb_debug(struct sk_buff **pskb, const char *func, int line) -#else void ieee80211_dev_kfree_skb(struct sk_buff **pskb) -#endif { struct sk_buff *skb; @@ -505,17 +481,12 @@ void ieee80211_dev_kfree_skb(struct sk_buff **pskb) skb->next = NULL; } - if (SKB_NI(skb) != NULL) { -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_unref_node_debug(&SKB_NI(skb), func, line); -#else + if (SKB_NI(skb) != NULL) ieee80211_unref_node(&SKB_NI(skb)); -#endif - } #ifdef IEEE80211_DEBUG_REFCNT unref_skb(skb, UNREF_USE_DEV_KFREE_SKB_ANY, - func, line, __func__, __LINE__); + __func__, __LINE__); #else dev_kfree_skb_any(skb); #endif @@ -525,13 +496,8 @@ void ieee80211_dev_kfree_skb(struct sk_buff **pskb) /* ieee80211_dev_kfree_skb_list will invoke ieee80211_dev_kfree_skb on each node in * a list of skbs, starting with the first. */ -#ifdef IEEE80211_DEBUG_REFCNT -void -ieee80211_dev_kfree_skb_list_debug(struct sk_buff **pskb, const char *func, int line) -#else void ieee80211_dev_kfree_skb_list(struct sk_buff **pskb) -#endif { struct sk_buff *skb, *tskb; @@ -542,33 +508,21 @@ ieee80211_dev_kfree_skb_list(struct sk_buff **pskb) while (skb) { tskb = skb->next; -#ifdef IEEE80211_DEBUG_REFCNT - ieee80211_dev_kfree_skb_debug(&skb, func, line); -#else ieee80211_dev_kfree_skb(&skb); -#endif skb = tskb; } *pskb = NULL; } -#ifdef IEEE80211_DEBUG_REFCNT -struct sk_buff * -ieee80211_dev_alloc_skb_debug(int size, const char *func, int line) -#else struct sk_buff * ieee80211_dev_alloc_skb(int size) -#endif { struct sk_buff *skb = dev_alloc_skb(size); if (skb == NULL) { skb_print_message( 0 /* show_counter */, NULL /* skb */, -#ifdef IEEE80211_DEBUG_REFCNT - func, line, -#endif __func__, __LINE__, "sk_buff allocation of size %u failed", size); @@ -576,39 +530,28 @@ ieee80211_dev_alloc_skb(int size) } #ifdef IEEE80211_DEBUG_REFCNT - return track_skb(skb, 0, func, line, __func__, __LINE__); + return track_skb(skb, 0, __func__, __LINE__); #else return skb; #endif } -#ifdef IEEE80211_DEBUG_REFCNT -void -ieee80211_skb_track_debug(struct sk_buff *skb, const char *func, int line) { - track_skb(skb, 0 /* users_adjustment */, - func, line, __func__, __LINE__); -} -#else void ieee80211_skb_track(struct sk_buff *skb) { +#ifdef IEEE80211_DEBUG_REFCNT + track_skb(skb, 0 /* users_adjustment */, + __func__, __LINE__); +#else /* Just a dumb counter, in no-debug builds */ atomic_inc(&skb_total_counter); -} #endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - -#ifdef IEEE80211_DEBUG_REFCNT -void -ieee80211_skb_untrack_debug(struct sk_buff *skb, const char *func, int line) { - untrack_skb(skb, 0 /* users_adjustment */, - func, line, __func__, __LINE__); } -#else + void ieee80211_skb_untrack(struct sk_buff *skb) { /* Just a dumb counter, in no-debug builds */ atomic_dec(&skb_total_counter); } -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ #ifdef IEEE80211_DEBUG_REFCNT int @@ -634,79 +577,83 @@ int vlan_hwaccel_rx_debug(struct sk_buff *skb, struct vlan_group *grp, unsigned short vlan_tag, const char *func, int line) { return vlan_hwaccel_rx( - untrack_skb(skb, 0, func, line, __func__, __LINE__), + untrack_skb(skb, 0, __func__, __LINE__), grp, vlan_tag); } int netif_rx_debug(struct sk_buff *skb, const char *func, int line) { - return netif_rx(untrack_skb(skb, 0, func, line, __func__, __LINE__)); + return netif_rx(untrack_skb(skb, 0, __func__, __LINE__)); } -struct sk_buff * alloc_skb_debug(unsigned int length, gfp_t gfp_mask, +struct sk_buff *alloc_skb_debug(unsigned int length, gfp_t gfp_mask, const char *func, int line) { - return track_skb(alloc_skb(length, gfp_mask), 0 /* users_adjustment */, - func, line, __func__, __LINE__); + return track_skb(alloc_skb(length, gfp_mask), + 0 /* users_adjustment */, + __func__, __LINE__); } -struct sk_buff * dev_alloc_skb_debug(unsigned int length, +struct sk_buff *dev_alloc_skb_debug(unsigned int length, const char *func, int line) { - return track_skb(dev_alloc_skb(length), 0 /* users_adjustment */, - func, line, __func__, __LINE__); + return track_skb(dev_alloc_skb(length), + 0 /* users_adjustment */, + __func__, __LINE__); } -struct sk_buff * skb_clone_debug(struct sk_buff *skb, gfp_t pri, +struct sk_buff *skb_clone_debug(struct sk_buff *skb, gfp_t pri, const char *func, int line) { return track_skb( - clean_clone_or_copy(skb_clone(skb, pri)), 0 /* users_adjustment */, - func, line, __func__, __LINE__); + clean_clone_or_copy(skb_clone(skb, pri)), + 0 /* users_adjustment */, + __func__, __LINE__); } -struct sk_buff * skb_copy_debug(struct sk_buff *skb, gfp_t pri, +struct sk_buff *skb_copy_debug(struct sk_buff *skb, gfp_t pri, const char *func, int line) { return track_skb( clean_clone_or_copy(skb_copy(skb, pri)), 0 /* users_adjustment */, - func, line, __func__, __LINE__); + __func__, __LINE__); } -struct sk_buff * skb_get_debug(struct sk_buff *skb, +struct sk_buff *skb_get_debug(struct sk_buff *skb, const char *func, int line) { return ref_skb(skb_get(skb), - func, line, __func__, __LINE__); + __func__, __LINE__); } -struct sk_buff * skb_realloc_headroom_debug(struct sk_buff *skb, unsigned int headroom, +struct sk_buff *skb_realloc_headroom_debug(struct sk_buff *skb, unsigned int headroom, const char *func, int line) { /* skb_realloc_headroom ALWAYS returns a copy or a clone, refcount of * new one is always zero and refcount of original is not touched. */ return track_skb( - clean_clone_or_copy(skb_realloc_headroom(skb, headroom)), + clean_clone_or_copy( + skb_realloc_headroom(skb, headroom)), 0 /* users_adjustment */, - func, line, __func__, __LINE__); + __func__, __LINE__); } -struct sk_buff * pskb_copy_debug(struct sk_buff *skb, gfp_t pri, +struct sk_buff *pskb_copy_debug(struct sk_buff *skb, gfp_t pri, const char *func, int line) { return track_skb( - clean_clone_or_copy(pskb_copy(skb, pri)), - 0 /* users_adjustment */, - func, line, __func__, __LINE__); + clean_clone_or_copy(pskb_copy(skb, pri)), + 0 /* users_adjustment */, + __func__, __LINE__); } int dev_queue_xmit_debug(struct sk_buff *skb, const char *func, int line) { - return dev_queue_xmit(untrack_skb(skb, 0, func, line, __func__, __LINE__)); + return dev_queue_xmit(untrack_skb(skb, 0, __func__, __LINE__)); } -struct sk_buff * skb_share_check_debug(struct sk_buff *skb, gfp_t pri, +struct sk_buff *skb_share_check_debug(struct sk_buff *skb, gfp_t pri, const char *func, int line) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) @@ -716,9 +663,9 @@ struct sk_buff * skb_share_check_debug(struct sk_buff *skb, gfp_t pri, struct sk_buff *nskb = track_skb( clean_clone_or_copy(skb_clone(skb, pri)), 0, - func, line, __func__, __LINE__); + __func__, __LINE__); unref_skb(skb, UNREF_USE_DEV_KFREE_SKB_ANY, - func, line, __func__, __LINE__); + __func__, __LINE__); skb = nskb; } return skb; @@ -731,7 +678,7 @@ void kfree_skb_fast_debug(struct sk_buff *skb, unref_skb(skb, UNREF_USE_DEV_KFREE_SKB_ANY, func, line, __func__, __LINE__); } -struct sk_buff * skb_unshare_debug(struct sk_buff *skb, gfp_t pri, +struct sk_buff *skb_unshare_debug(struct sk_buff *skb, gfp_t pri, const char *func, int line) { #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) @@ -740,15 +687,15 @@ struct sk_buff * skb_unshare_debug(struct sk_buff *skb, gfp_t pri, if (skb_cloned(skb)) { struct sk_buff *nskb = track_skb( clean_clone_or_copy(skb_copy(skb, pri)), 0, - func, line, __func__, __LINE__); + __func__, __LINE__); unref_skb(skb, UNREF_USE_DEV_KFREE_SKB_ANY, - func, line, __func__, __LINE__); + __func__, __LINE__); skb = nskb; } return skb; } -struct sk_buff * skb_copy_expand_debug(const struct sk_buff *skb, int newheadroom, +struct sk_buff *skb_copy_expand_debug(const struct sk_buff *skb, int newheadroom, int newtailroom, gfp_t gfp_mask, const char *func, int line) { @@ -756,7 +703,7 @@ struct sk_buff * skb_copy_expand_debug(const struct sk_buff *skb, int newheadroo clean_clone_or_copy( skb_copy_expand(skb, newheadroom, newtailroom, gfp_mask)), 0 /* users_adjustment */, - func, line, __func__, __LINE__); + __func__, __LINE__); } EXPORT_SYMBOL(vlan_hwaccel_rx_debug); @@ -774,22 +721,13 @@ EXPORT_SYMBOL(kfree_skb_fast_debug); EXPORT_SYMBOL(skb_unshare_debug); EXPORT_SYMBOL(skb_copy_expand_debug); -#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ - -#ifdef IEEE80211_DEBUG_REFCNT -EXPORT_SYMBOL(ieee80211_dev_kfree_skb_debug); -EXPORT_SYMBOL(ieee80211_dev_kfree_skb_list_debug); -EXPORT_SYMBOL(ieee80211_dev_alloc_skb_debug); -EXPORT_SYMBOL(ieee80211_skb_track_debug); -EXPORT_SYMBOL(ieee80211_skb_untrack_debug); EXPORT_SYMBOL(ieee80211_skb_counter); EXPORT_SYMBOL(ieee80211_skb_references); -#else -EXPORT_SYMBOL(ieee80211_dev_kfree_skb); -EXPORT_SYMBOL(ieee80211_dev_kfree_skb_list); +#endif /* #ifdef IEEE80211_DEBUG_REFCNT */ + EXPORT_SYMBOL(ieee80211_dev_alloc_skb); -EXPORT_SYMBOL(ieee80211_skb_track); EXPORT_SYMBOL(ieee80211_skb_untrack); -#endif - +EXPORT_SYMBOL(ieee80211_dev_kfree_skb_list); +EXPORT_SYMBOL(ieee80211_dev_kfree_skb); +EXPORT_SYMBOL(ieee80211_skb_track); diff --git a/net80211/ieee80211_skb.h b/net80211/ieee80211_skb.h index 57f2595..eaafa90 100644 --- a/net80211/ieee80211_skb.h +++ b/net80211/ieee80211_skb.h @@ -81,13 +81,7 @@ extern atomic_t skb_refs_counter; * If SKB refcount is going to zero: * - Free the node reference and set it to null. * - Break the linked list, clearing next skb's prev pointer if possible. */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_dev_kfree_skb(_pskb) \ - ieee80211_dev_kfree_skb_debug(_pskb, __func__, __LINE__) -void ieee80211_dev_kfree_skb_debug(struct sk_buff **pskb, const char *func, int line); -#else void ieee80211_dev_kfree_skb(struct sk_buff **pskb); -#endif static inline void ieee80211_skb_copy_noderef(struct sk_buff *src, struct sk_buff *dst) @@ -98,35 +92,12 @@ static inline void ieee80211_skb_copy_noderef(struct sk_buff *src, /* ieee80211_dev_kfree_skb_list will invoke ieee80211_dev_kfree_skb on each node in * a list of skbs, starting with the first. */ -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_dev_kfree_skb_list(_pskb) \ - ieee80211_dev_kfree_skb_list_debug(_pskb, __func__, __LINE__) -void ieee80211_dev_kfree_skb_list_debug(struct sk_buff **pskb, const char *func, int line); -#else void ieee80211_dev_kfree_skb_list(struct sk_buff **pskb); -#endif -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_dev_alloc_skb(_size) \ - ieee80211_dev_alloc_skb_debug(_size, __func__, __LINE__) -struct sk_buff *ieee80211_dev_alloc_skb_debug(int size, const char *func, int line); -#else struct sk_buff *ieee80211_dev_alloc_skb(int size); -#endif -#ifdef IEEE80211_DEBUG_REFCNT -#define ieee80211_skb_track(_skb) \ - ieee80211_skb_track_debug(_skb, __func__, __LINE__) -#define ieee80211_skb_untrack(_skb) \ - ieee80211_skb_untrack_debug(_skb, __func__, __LINE__) -void ieee80211_skb_track_debug(struct sk_buff *skb, - const char *func, int line); -void ieee80211_skb_untrack_debug(struct sk_buff *skb, - const char *func, int line); -#else void ieee80211_skb_track(struct sk_buff *skb); void ieee80211_skb_untrack(struct sk_buff *skb); -#endif #ifdef IEEE80211_DEBUG_REFCNT int ieee80211_skb_counter(void); diff --git a/net80211/ieee80211_var.h b/net80211/ieee80211_var.h index 280f058..abf4f25 100644 --- a/net80211/ieee80211_var.h +++ b/net80211/ieee80211_var.h @@ -464,18 +464,9 @@ struct ieee80211com { /* Node state management */ int32_t (*ic_node_count)(struct ieee80211com *); -#ifdef IEEE80211_DEBUG_REFCNT - struct ieee80211_node *(*ic_node_alloc_debug)(struct ieee80211vap *, - const char *func, int line); - void (*ic_node_cleanup_debug)(struct ieee80211_node *, - const char *func, int line); - void (*ic_node_free_debug)(struct ieee80211_node *, - const char *func, int line); -#else struct ieee80211_node *(*ic_node_alloc)(struct ieee80211vap *); void (*ic_node_cleanup)(struct ieee80211_node *); void (*ic_node_free)(struct ieee80211_node *); -#endif u_int8_t (*ic_node_getrssi)(const struct ieee80211_node *); u_int8_t (*ic_node_move_data)(const struct ieee80211_node *);