View | Details | Raw Unified | Return to bug 170098 | Differences between
and this patch

Collapse All | Expand All

(-)b/ieee80211_node.c (-11 / +58 lines)
Lines 2156-2187 ieee80211_node_timeout(void *arg) Link Here
2156
		ieee80211_node_timeout, ic);
2156
		ieee80211_node_timeout, ic);
2157
}
2157
}
2158
2158
2159
/*
2160
 * May directly be called and do customized iterate functions.
2161
 * Only requirement is to decrement each node's ref count.
2162
 */
2159
void
2163
void
2160
ieee80211_iterate_nodes(struct ieee80211_node_table *nt,
2164
ieee80211_iterate_nt(struct ieee80211_node_table *nt,
2161
	ieee80211_iter_func *f, void *arg)
2165
    struct ieee80211_node **ni_arr, uint16_t max_aid)
2162
{
2166
{
2163
	struct ieee80211_node *ni;
2167
	struct ieee80211_node *ni;
2164
	u_int gen;
2168
	u_int gen;
2169
	int i = 0;
2165
2170
2166
	IEEE80211_NODE_ITERATE_LOCK(nt);
2171
	IEEE80211_NODE_ITERATE_LOCK(nt);
2172
	IEEE80211_NODE_LOCK(nt);
2173
2167
	gen = ++nt->nt_scangen;
2174
	gen = ++nt->nt_scangen;
2175
2168
restart:
2176
restart:
2169
	IEEE80211_NODE_LOCK(nt);
2170
	TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
2177
	TAILQ_FOREACH(ni, &nt->nt_node, ni_list) {
2171
		if (ni->ni_scangen != gen) {
2178
		if (ni->ni_scangen == gen)
2172
			ni->ni_scangen = gen;
2179
			continue;
2173
			(void) ieee80211_ref_node(ni);
2180
2174
			IEEE80211_NODE_UNLOCK(nt);
2181
		if (i >= max_aid) {
2175
			(*f)(arg, ni);
2182
			if_printf(nt->nt_ic->ic_ifp,
2176
			ieee80211_free_node(ni);
2183
			    "Node array overflow: max=%u", max_aid);
2177
			goto restart;
2184
			break;
2178
		}
2185
		}
2186
2187
		ni->ni_scangen = gen;
2188
		(*(ni_arr + i++)) = ieee80211_ref_node(ni);
2189
		goto restart;
2179
	}
2190
	}
2180
	IEEE80211_NODE_UNLOCK(nt);
2181
2191
2192
	IEEE80211_NODE_UNLOCK(nt);
2182
	IEEE80211_NODE_ITERATE_UNLOCK(nt);
2193
	IEEE80211_NODE_ITERATE_UNLOCK(nt);
2183
}
2194
}
2184
2195
2196
/*
2197
 * Just a wrapper, so we don't have to change every ieee80211_iterate_nodes()
2198
 * reference in the source.
2199
 */
2200
void
2201
ieee80211_iterate_nodes(struct ieee80211_node_table *nt,
2202
	ieee80211_iter_func *f, void *arg)
2203
{
2204
	struct ieee80211_node **ni_arr;
2205
	struct ieee80211_node *ni;
2206
	unsigned long size;
2207
	int i;
2208
	uint16_t max_aid;
2209
2210
	max_aid = TAILQ_FIRST(&nt->nt_ic->ic_vaps)->iv_max_aid;
2211
	size = max_aid * sizeof(*ni_arr);
2212
	ni_arr = (struct ieee80211_node **)malloc(size, M_80211_NODE,
2213
	    M_NOWAIT | M_ZERO);
2214
	if (ni_arr == NULL)
2215
		return;
2216
2217
	ieee80211_iterate_nt(nt, ni_arr, max_aid);
2218
2219
	for (i = 0; i < max_aid; i++) {
2220
		ni = *(ni_arr + i);
2221
		if (ni == NULL)	/* end of the list */
2222
			break;
2223
2224
		(*f)(arg, ni);
2225
		/* ieee80211_free_node() locks by itself */
2226
		ieee80211_free_node(ni);
2227
	}
2228
2229
	free(ni_arr, M_80211_NODE);
2230
}
2231
2185
void
2232
void
2186
ieee80211_dump_node(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
2233
ieee80211_dump_node(struct ieee80211_node_table *nt, struct ieee80211_node *ni)
2187
{
2234
{
(-)b/ieee80211_node.h (+2 lines)
Lines 438-443 int ieee80211_node_delucastkey(struct ieee80211_node *); Link Here
438
void	ieee80211_node_timeout(void *arg);
438
void	ieee80211_node_timeout(void *arg);
439
439
440
typedef void ieee80211_iter_func(void *, struct ieee80211_node *);
440
typedef void ieee80211_iter_func(void *, struct ieee80211_node *);
441
void	ieee80211_iterate_nt(struct ieee80211_node_table *,
442
		struct ieee80211_node **, uint16_t);
441
void	ieee80211_iterate_nodes(struct ieee80211_node_table *,
443
void	ieee80211_iterate_nodes(struct ieee80211_node_table *,
442
		ieee80211_iter_func *, void *);
444
		ieee80211_iter_func *, void *);
443
445

Return to bug 170098