diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2008-02-27 03:56:40 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-03-06 15:30:47 -0500 |
commit | 03e4497ebeaa8011eb0ab0a54496ed6413b9d1a4 (patch) | |
tree | 96eb34d88a56f84f06f155e1d4a0d6d34d0f7933 /net/mac80211/mesh_plink.c | |
parent | dbbea6713d6096cd1c411cb453a6b71292c78b33 (diff) |
mac80211: fix sta_info mesh timer bug
I noticed a bug I introduced when mesh is enabled: sta_info_destroy()
will end up calling cancel_timer() on a timer that has never been
initialized because the timer is only initialized in mesh_plink_alloc(),
not in sta_info_alloc(). This patch moves the initialization of all mesh
related fields into sta_info_alloc(), adds a bit of sanity checking to
the cfg80211 handlers and sta_info_insert() and makes mesh_plink_alloc()
a static helper function that is only used from the mesh plink code.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Luis Carlos Cobo <luisca@cozybit.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/mesh_plink.c')
-rw-r--r-- | net/mac80211/mesh_plink.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 85cb75d53c43..7f02ae8abe90 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c | |||
@@ -88,40 +88,19 @@ static inline void mesh_plink_fsm_restart(struct sta_info *sta) | |||
88 | sta->llid = sta->plid = sta->reason = sta->plink_retries = 0; | 88 | sta->llid = sta->plid = sta->reason = sta->plink_retries = 0; |
89 | } | 89 | } |
90 | 90 | ||
91 | /** | 91 | static struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, |
92 | * mesh_plink_alloc - allocate a new mesh peer link | 92 | u8 *hw_addr, u64 rates) |
93 | * | ||
94 | * @sdata: local mesh interface | ||
95 | * @hw_addr: hardware address (ETH_ALEN length) | ||
96 | * @rates: rates the mesh peer supports | ||
97 | * | ||
98 | * The initial state of the new plink is set to LISTEN | ||
99 | * | ||
100 | * Returns: NULL on error. | ||
101 | */ | ||
102 | struct sta_info *mesh_plink_alloc(struct ieee80211_sub_if_data *sdata, | ||
103 | u8 *hw_addr, u64 rates, gfp_t gfp) | ||
104 | { | 93 | { |
105 | struct ieee80211_local *local = sdata->local; | 94 | struct ieee80211_local *local = sdata->local; |
106 | struct sta_info *sta; | 95 | struct sta_info *sta; |
107 | 96 | ||
108 | if (compare_ether_addr(hw_addr, sdata->dev->dev_addr) == 0) | ||
109 | /* never add ourselves as neighbours */ | ||
110 | return NULL; | ||
111 | |||
112 | if (is_multicast_ether_addr(hw_addr)) | ||
113 | return NULL; | ||
114 | |||
115 | if (local->num_sta >= MESH_MAX_PLINKS) | 97 | if (local->num_sta >= MESH_MAX_PLINKS) |
116 | return NULL; | 98 | return NULL; |
117 | 99 | ||
118 | sta = sta_info_alloc(sdata, hw_addr, gfp); | 100 | sta = sta_info_alloc(sdata, hw_addr, GFP_ATOMIC); |
119 | if (!sta) | 101 | if (!sta) |
120 | return NULL; | 102 | return NULL; |
121 | 103 | ||
122 | sta->plink_state = LISTEN; | ||
123 | spin_lock_init(&sta->plink_lock); | ||
124 | init_timer(&sta->plink_timer); | ||
125 | sta->flags |= WLAN_STA_AUTHORIZED; | 104 | sta->flags |= WLAN_STA_AUTHORIZED; |
126 | sta->supp_rates[local->hw.conf.channel->band] = rates; | 105 | sta->supp_rates[local->hw.conf.channel->band] = rates; |
127 | 106 | ||
@@ -249,7 +228,7 @@ void mesh_neighbour_update(u8 *hw_addr, u64 rates, struct net_device *dev, | |||
249 | 228 | ||
250 | sta = sta_info_get(local, hw_addr); | 229 | sta = sta_info_get(local, hw_addr); |
251 | if (!sta) { | 230 | if (!sta) { |
252 | sta = mesh_plink_alloc(sdata, hw_addr, rates, GFP_ATOMIC); | 231 | sta = mesh_plink_alloc(sdata, hw_addr, rates); |
253 | if (!sta) { | 232 | if (!sta) { |
254 | rcu_read_unlock(); | 233 | rcu_read_unlock(); |
255 | return; | 234 | return; |
@@ -518,7 +497,7 @@ void mesh_rx_plink_frame(struct net_device *dev, struct ieee80211_mgmt *mgmt, | |||
518 | } | 497 | } |
519 | 498 | ||
520 | rates = ieee80211_sta_get_rates(local, &elems, rx_status->band); | 499 | rates = ieee80211_sta_get_rates(local, &elems, rx_status->band); |
521 | sta = mesh_plink_alloc(sdata, mgmt->sa, rates, GFP_ATOMIC); | 500 | sta = mesh_plink_alloc(sdata, mgmt->sa, rates); |
522 | if (!sta) { | 501 | if (!sta) { |
523 | mpl_dbg("Mesh plink error: plink table full\n"); | 502 | mpl_dbg("Mesh plink error: plink table full\n"); |
524 | rcu_read_unlock(); | 503 | rcu_read_unlock(); |