Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 89965
b: refs/heads/master
c: 43ba7e9
h: refs/heads/master
i:
  89963: 2b8eb55
v: v3
  • Loading branch information
Johannes Berg authored and John W. Linville committed Feb 29, 2008
1 parent 4c661b6 commit 18a31dc
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d46e144b65bf053b25d134ec9f52a38e63e04bb4
refs/heads/master: 43ba7e958f2ca05e4e9171a15402288419289d71
11 changes: 2 additions & 9 deletions trunk/net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,6 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
if (!netif_running(dev))
return -ENETDOWN;

/* XXX: get sta belonging to dev */
sta = sta_info_get(local, mac);
if (sta) {
sta_info_put(sta);
return -EEXIST;
}

if (params->vlan) {
sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);

Expand All @@ -579,8 +572,8 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
sdata = IEEE80211_DEV_TO_SUB_IF(dev);

sta = sta_info_add(local, dev, mac, GFP_KERNEL);
if (!sta)
return -ENOMEM;
if (IS_ERR(sta))
return PTR_ERR(sta);

sta->dev = sdata->dev;
if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN ||
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/mac80211/ieee80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,8 @@ int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)

/* Create STA entry for the new peer */
sta = sta_info_add(local, dev, remote_addr, GFP_KERNEL);
if (!sta)
return -ENOMEM;
if (IS_ERR(sta))
return PTR_ERR(sta);

sta->flags |= WLAN_STA_AUTHORIZED;

Expand Down
6 changes: 3 additions & 3 deletions trunk/net/mac80211/ieee80211_sta.c
Original file line number Diff line number Diff line change
Expand Up @@ -1807,9 +1807,9 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
if (!sta) {
struct ieee80211_sta_bss *bss;
sta = sta_info_add(local, dev, ifsta->bssid, GFP_KERNEL);
if (!sta) {
if (IS_ERR(sta)) {
printk(KERN_DEBUG "%s: failed to add STA entry for the"
" AP\n", dev->name);
" AP (error %ld)\n", dev->name, PTR_ERR(sta));
return;
}
bss = ieee80211_rx_bss_get(dev, ifsta->bssid,
Expand Down Expand Up @@ -3820,7 +3820,7 @@ struct sta_info * ieee80211_ibss_add_sta(struct net_device *dev,
wiphy_name(local->hw.wiphy), print_mac(mac, addr), dev->name);

sta = sta_info_add(local, dev, addr, GFP_ATOMIC);
if (!sta)
if (IS_ERR(sta))
return NULL;

sta->flags |= WLAN_STA_AUTHORIZED;
Expand Down
38 changes: 27 additions & 11 deletions trunk/net/mac80211/sta_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,29 @@ static int sta_info_hash_del(struct ieee80211_local *local,
return -ENOENT;
}

struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr)
/* must hold local->sta_lock */
static struct sta_info *__sta_info_find(struct ieee80211_local *local,
u8 *addr)
{
struct sta_info *sta;

read_lock_bh(&local->sta_lock);
sta = local->sta_hash[STA_HASH(addr)];
while (sta) {
if (memcmp(sta->addr, addr, ETH_ALEN) == 0) {
__sta_info_get(sta);
if (compare_ether_addr(sta->addr, addr) == 0)
break;
}
sta = sta->hnext;
}
return sta;
}

struct sta_info *sta_info_get(struct ieee80211_local *local, u8 *addr)
{
struct sta_info *sta;

read_lock_bh(&local->sta_lock);
sta = __sta_info_find(local, addr);
if (sta)
__sta_info_get(sta);
read_unlock_bh(&local->sta_lock);

return sta;
Expand Down Expand Up @@ -110,16 +120,16 @@ void sta_info_put(struct sta_info *sta)
EXPORT_SYMBOL(sta_info_put);


struct sta_info * sta_info_add(struct ieee80211_local *local,
struct net_device *dev, u8 *addr, gfp_t gfp)
struct sta_info *sta_info_add(struct ieee80211_local *local,
struct net_device *dev, u8 *addr, gfp_t gfp)
{
struct sta_info *sta;
int i;
DECLARE_MAC_BUF(mac);

sta = kzalloc(sizeof(*sta), gfp);
if (!sta)
return NULL;
return ERR_PTR(-ENOMEM);

kref_init(&sta->kref);

Expand All @@ -128,7 +138,7 @@ struct sta_info * sta_info_add(struct ieee80211_local *local,
if (!sta->rate_ctrl_priv) {
rate_control_put(sta->rate_ctrl);
kfree(sta);
return NULL;
return ERR_PTR(-ENOMEM);
}

memcpy(sta->addr, addr, ETH_ALEN);
Expand Down Expand Up @@ -158,9 +168,15 @@ struct sta_info * sta_info_add(struct ieee80211_local *local,
}
skb_queue_head_init(&sta->ps_tx_buf);
skb_queue_head_init(&sta->tx_filtered);
__sta_info_get(sta); /* sta used by caller, decremented by
* sta_info_put() */
write_lock_bh(&local->sta_lock);
/* mark sta as used (by caller) */
__sta_info_get(sta);
/* check if STA exists already */
if (__sta_info_find(local, addr)) {
write_unlock_bh(&local->sta_lock);
sta_info_put(sta);
return ERR_PTR(-EEXIST);
}
list_add(&sta->list, &local->sta_list);
local->num_sta++;
sta_info_hash_add(local, sta);
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/mac80211/sta_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ static inline void __sta_info_get(struct sta_info *sta)

struct sta_info * sta_info_get(struct ieee80211_local *local, u8 *addr);
void sta_info_put(struct sta_info *sta);
struct sta_info * sta_info_add(struct ieee80211_local *local,
struct net_device *dev, u8 *addr, gfp_t gfp);
struct sta_info *sta_info_add(struct ieee80211_local *local,
struct net_device *dev, u8 *addr, gfp_t gfp);
void sta_info_remove(struct sta_info *sta);
void sta_info_free(struct sta_info *sta);
void sta_info_init(struct ieee80211_local *local);
Expand Down

0 comments on commit 18a31dc

Please sign in to comment.