From fbcefd4a9b43719f72cdcb48271957a443d17f86 Mon Sep 17 00:00:00 2001 From: Damien Bergamini Date: Mon, 26 Jan 2009 21:55:59 +0000 Subject: move ni_macaddr field at the top of the ieee80211_node structure. this way we can avoid putting a full node structure (which is huge) on the stack in ieee80211_find_node(). this is a bit tricky but the RB_FIND macro wants an "elem" structure, not a field of "elem". --- sys/net80211/ieee80211_node.c | 9 ++++----- sys/net80211/ieee80211_node.h | 12 ++++++------ 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'sys') diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c index 7cc051cb2d9..4f43cd26ffe 100644 --- a/sys/net80211/ieee80211_node.c +++ b/sys/net80211/ieee80211_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.c,v 1.50 2009/01/26 19:09:41 damien Exp $ */ +/* $OpenBSD: ieee80211_node.c,v 1.51 2009/01/26 21:55:58 damien Exp $ */ /* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */ /*- @@ -810,10 +810,9 @@ ieee80211_dup_bss(struct ieee80211com *ic, const u_int8_t *macaddr) struct ieee80211_node * ieee80211_find_node(struct ieee80211com *ic, const u_int8_t *macaddr) { - struct ieee80211_node ni; - - IEEE80211_ADDR_COPY(ni.ni_macaddr, macaddr); - return (RB_FIND(ieee80211_tree, &ic->ic_tree, &ni)); + /* XXX ugly, but avoids a full node structure in the stack */ + return (RB_FIND(ieee80211_tree, &ic->ic_tree, + (struct ieee80211_node *)macaddr)); } /* diff --git a/sys/net80211/ieee80211_node.h b/sys/net80211/ieee80211_node.h index e06de3c0b3a..0cf7a12a896 100644 --- a/sys/net80211/ieee80211_node.h +++ b/sys/net80211/ieee80211_node.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ieee80211_node.h,v 1.36 2009/01/26 21:28:55 damien Exp $ */ +/* $OpenBSD: ieee80211_node.h,v 1.37 2009/01/26 21:55:58 damien Exp $ */ /* $NetBSD: ieee80211_node.h,v 1.9 2004/04/30 22:57:32 dyoung Exp $ */ /*- @@ -137,7 +137,9 @@ struct ieee80211_ba { * the ieee80211com structure. */ struct ieee80211_node { - RB_ENTRY(ieee80211_node) ni_node; + /* ni_macaddr must be the first field for RB_FIND() */ + u_int8_t ni_macaddr[IEEE80211_ADDR_LEN]; + u_int8_t ni_bssid[IEEE80211_ADDR_LEN]; struct ieee80211com *ni_ic; /* back-pointer */ @@ -148,10 +150,6 @@ struct ieee80211_node { u_int32_t ni_rstamp; /* recv timestamp */ u_int8_t ni_rssi; /* recv ssi */ - /* header */ - u_int8_t ni_macaddr[IEEE80211_ADDR_LEN]; - u_int8_t ni_bssid[IEEE80211_ADDR_LEN]; - /* beacon, probe response */ u_int8_t ni_tstamp[8]; /* from last rcv'd beacon */ u_int16_t ni_intval; /* beacon interval */ @@ -239,6 +237,8 @@ struct ieee80211_node { #define IEEE80211_NODE_HT 0x0400 /* HT negotiated */ #define IEEE80211_NODE_SA_QUERY 0x0800 /* SA Query in progress */ #define IEEE80211_NODE_SA_QUERY_FAILED 0x1000 /* last SA Query failed */ + + RB_ENTRY(ieee80211_node) ni_node; }; RB_HEAD(ieee80211_tree, ieee80211_node); -- cgit v1.2.3