Skip to content

Commit

Permalink
mac80211: make station management completely depend on vif
Browse files Browse the repository at this point in the history
The station management currently uses the virtual
interface, but you cannot add the same station to
multiple virtual interfaces if you're communicating
with it in multiple ways.

This restriction should be lifted so that in the
future we can, for instance, support bluetooth 3
with an access point that mac80211 is already
associated to.

We can do that by requiring all sta_info_get users
to provide the virtual interface and making the RX
code aware that an address may match more than one
station struct. Thanks to the previous patches this
one isn't all that large and except for the RX and
TX status paths changes has low complexity.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Dec 21, 2009
1 parent 15920d8 commit abe6063
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 101 deletions.
3 changes: 1 addition & 2 deletions net/mac80211/agg-rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ void __ieee80211_stop_rx_ba_session(struct sta_info *sta, u16 tid,
void ieee80211_sta_stop_rx_ba_session(struct ieee80211_sub_if_data *sdata, u8 *ra, u16 tid,
u16 initiator, u16 reason)
{
struct ieee80211_local *local = sdata->local;
struct sta_info *sta;

rcu_read_lock();

sta = sta_info_get(local, ra);
sta = sta_info_get(sdata, ra);
if (!sta) {
rcu_read_unlock();
return;
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/agg-tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ void ieee80211_start_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u16 tid)
}

rcu_read_lock();
sta = sta_info_get(local, ra);
sta = sta_info_get(sdata, ra);
if (!sta) {
rcu_read_unlock();
#ifdef CONFIG_MAC80211_HT_DEBUG
Expand Down Expand Up @@ -564,7 +564,7 @@ void ieee80211_stop_tx_ba_cb(struct ieee80211_vif *vif, u8 *ra, u8 tid)
#endif /* CONFIG_MAC80211_HT_DEBUG */

rcu_read_lock();
sta = sta_info_get(local, ra);
sta = sta_info_get(sdata, ra);
if (!sta) {
#ifdef CONFIG_MAC80211_HT_DEBUG
printk(KERN_DEBUG "Could not find station: %pM\n", ra);
Expand Down
25 changes: 10 additions & 15 deletions net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
rcu_read_lock();

if (mac_addr) {
sta = sta_info_get(sdata->local, mac_addr);
sta = sta_info_get(sdata, mac_addr);
if (!sta) {
ieee80211_key_free(key);
err = -ENOENT;
Expand Down Expand Up @@ -181,7 +181,7 @@ static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
if (mac_addr) {
ret = -ENOENT;

sta = sta_info_get(sdata->local, mac_addr);
sta = sta_info_get(sdata, mac_addr);
if (!sta)
goto out_unlock;

Expand Down Expand Up @@ -228,7 +228,7 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
rcu_read_lock();

if (mac_addr) {
sta = sta_info_get(sdata->local, mac_addr);
sta = sta_info_get(sdata, mac_addr);
if (!sta)
goto out;

Expand Down Expand Up @@ -414,15 +414,13 @@ static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
u8 *mac, struct station_info *sinfo)
{
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct sta_info *sta;
int ret = -ENOENT;

rcu_read_lock();

/* XXX: verify sta->dev == dev */

sta = sta_info_get(local, mac);
sta = sta_info_get(sdata, mac);
if (sta) {
ret = 0;
sta_set_sinfo(sta, sinfo);
Expand Down Expand Up @@ -778,8 +776,7 @@ static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
if (mac) {
rcu_read_lock();

/* XXX: get sta belonging to dev */
sta = sta_info_get(local, mac);
sta = sta_info_get(sdata, mac);
if (!sta) {
rcu_read_unlock();
return -ENOENT;
Expand All @@ -800,14 +797,14 @@ static int ieee80211_change_station(struct wiphy *wiphy,
u8 *mac,
struct station_parameters *params)
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct ieee80211_local *local = wiphy_priv(wiphy);
struct sta_info *sta;
struct ieee80211_sub_if_data *vlansdata;

rcu_read_lock();

/* XXX: get sta belonging to dev */
sta = sta_info_get(local, mac);
sta = sta_info_get(sdata, mac);
if (!sta) {
rcu_read_unlock();
return -ENOENT;
Expand Down Expand Up @@ -846,7 +843,6 @@ static int ieee80211_change_station(struct wiphy *wiphy,
static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
u8 *dst, u8 *next_hop)
{
struct ieee80211_local *local = wiphy_priv(wiphy);
struct ieee80211_sub_if_data *sdata;
struct mesh_path *mpath;
struct sta_info *sta;
Expand All @@ -855,7 +851,7 @@ static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
sdata = IEEE80211_DEV_TO_SUB_IF(dev);

rcu_read_lock();
sta = sta_info_get(local, next_hop);
sta = sta_info_get(sdata, next_hop);
if (!sta) {
rcu_read_unlock();
return -ENOENT;
Expand Down Expand Up @@ -894,7 +890,6 @@ static int ieee80211_change_mpath(struct wiphy *wiphy,
struct net_device *dev,
u8 *dst, u8 *next_hop)
{
struct ieee80211_local *local = wiphy_priv(wiphy);
struct ieee80211_sub_if_data *sdata;
struct mesh_path *mpath;
struct sta_info *sta;
Expand All @@ -903,7 +898,7 @@ static int ieee80211_change_mpath(struct wiphy *wiphy,

rcu_read_lock();

sta = sta_info_get(local, next_hop);
sta = sta_info_get(sdata, next_hop);
if (!sta) {
rcu_read_unlock();
return -ENOENT;
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/ibss.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,

rcu_read_lock();

sta = sta_info_get(local, mgmt->sa);
sta = sta_info_get(sdata, mgmt->sa);
if (sta) {
u32 prev_rates;

Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/key.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ void ieee80211_key_link(struct ieee80211_key *key,
*/

/* same here, the AP could be using QoS */
ap = sta_info_get(key->local, key->sdata->u.mgd.bssid);
ap = sta_info_get(key->sdata, key->sdata->u.mgd.bssid);
if (ap) {
if (test_sta_flags(ap, WLAN_STA_WME))
key->conf.flags |=
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/mesh_hwmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static u32 hwmp_route_info_get(struct ieee80211_sub_if_data *sdata,
bool process = true;

rcu_read_lock();
sta = sta_info_get(local, mgmt->sa);
sta = sta_info_get(sdata, mgmt->sa);
if (!sta) {
rcu_read_unlock();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions net/mac80211/mesh_plink.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void mesh_neighbour_update(u8 *hw_addr, u32 rates, struct ieee80211_sub_if_data

rcu_read_lock();

sta = sta_info_get(local, hw_addr);
sta = sta_info_get(sdata, hw_addr);
if (!sta) {
sta = mesh_plink_alloc(sdata, hw_addr, rates);
if (!sta) {
Expand Down Expand Up @@ -455,7 +455,7 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, struct ieee80211_m

rcu_read_lock();

sta = sta_info_get(local, mgmt->sa);
sta = sta_info_get(sdata, mgmt->sa);
if (!sta && ftype != PLINK_OPEN) {
mpl_dbg("Mesh plink: cls or cnf from unknown peer\n");
rcu_read_unlock();
Expand Down
10 changes: 5 additions & 5 deletions net/mac80211/mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static u32 ieee80211_enable_ht(struct ieee80211_sub_if_data *sdata,
ieee80211_hw_config(local, 0);

rcu_read_lock();
sta = sta_info_get(local, bssid);
sta = sta_info_get(sdata, bssid);
if (sta)
rate_control_rate_update(local, sband, sta,
IEEE80211_RC_HT_CHANGED);
Expand Down Expand Up @@ -1070,7 +1070,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
netif_carrier_off(sdata->dev);

rcu_read_lock();
sta = sta_info_get(local, bssid);
sta = sta_info_get(sdata, bssid);
if (sta)
ieee80211_sta_tear_down_BA_sessions(sta);
rcu_read_unlock();
Expand Down Expand Up @@ -1109,7 +1109,7 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,

rcu_read_lock();

sta = sta_info_get(local, bssid);
sta = sta_info_get(sdata, bssid);
if (!sta) {
rcu_read_unlock();
return;
Expand Down Expand Up @@ -1489,7 +1489,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
rcu_read_lock();

/* Add STA entry for the AP */
sta = sta_info_get(local, wk->bss->cbss.bssid);
sta = sta_info_get(sdata, wk->bss->cbss.bssid);
if (!sta) {
newsta = true;

Expand Down Expand Up @@ -1857,7 +1857,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,

rcu_read_lock();

sta = sta_info_get(local, bssid);
sta = sta_info_get(sdata, bssid);
if (WARN_ON(!sta)) {
rcu_read_unlock();
return;
Expand Down
119 changes: 64 additions & 55 deletions net/mac80211/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,6 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
{
struct ieee80211_sub_if_data *sdata = rx->sdata;
struct net_device *dev = sdata->dev;
struct ieee80211_local *local = rx->local;
struct sk_buff *skb, *xmit_skb;
struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
struct sta_info *dsta;
Expand All @@ -1495,8 +1494,8 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
printk(KERN_DEBUG "%s: failed to clone "
"multicast frame\n", dev->name);
} else {
dsta = sta_info_get(local, skb->data);
if (dsta && dsta->sdata->dev == dev) {
dsta = sta_info_get(sdata, skb->data);
if (dsta) {
/*
* The destination station is associated to
* this AP (in this VLAN), so send the frame
Expand Down Expand Up @@ -2363,6 +2362,8 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
int prepares;
struct ieee80211_sub_if_data *prev = NULL;
struct sk_buff *skb_new;
struct sta_info *sta, *tmp;
bool found_sta = false;

hdr = (struct ieee80211_hdr *)skb->data;
memset(&rx, 0, sizeof(rx));
Expand All @@ -2379,68 +2380,76 @@ static void __ieee80211_rx_handle_packet(struct ieee80211_hw *hw,
ieee80211_parse_qos(&rx);
ieee80211_verify_alignment(&rx);

rx.sta = sta_info_get(local, hdr->addr2);
if (rx.sta)
rx.sdata = rx.sta->sdata;

if (rx.sdata && ieee80211_is_data(hdr->frame_control)) {
rx.flags |= IEEE80211_RX_RA_MATCH;
prepares = prepare_for_handlers(rx.sdata, &rx, hdr);
if (prepares) {
if (status->flag & RX_FLAG_MMIC_ERROR) {
if (rx.flags & IEEE80211_RX_RA_MATCH)
ieee80211_rx_michael_mic_report(hdr, &rx);
} else
prev = rx.sdata;
if (ieee80211_is_data(hdr->frame_control)) {
for_each_sta_info(local, hdr->addr2, sta, tmp) {
rx.sta = sta;
found_sta = true;
rx.sdata = sta->sdata;

rx.flags |= IEEE80211_RX_RA_MATCH;
prepares = prepare_for_handlers(rx.sdata, &rx, hdr);
if (prepares) {
if (status->flag & RX_FLAG_MMIC_ERROR) {
if (rx.flags & IEEE80211_RX_RA_MATCH)
ieee80211_rx_michael_mic_report(hdr, &rx);
} else
prev = rx.sdata;
}
}
} else list_for_each_entry_rcu(sdata, &local->interfaces, list) {
if (!netif_running(sdata->dev))
continue;
}
if (!found_sta) {
list_for_each_entry_rcu(sdata, &local->interfaces, list) {
if (!netif_running(sdata->dev))
continue;

if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
continue;
if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
continue;

rx.flags |= IEEE80211_RX_RA_MATCH;
prepares = prepare_for_handlers(sdata, &rx, hdr);
rx.sta = sta_info_get(sdata, hdr->addr2);

if (!prepares)
continue;
rx.flags |= IEEE80211_RX_RA_MATCH;
prepares = prepare_for_handlers(sdata, &rx, hdr);

if (status->flag & RX_FLAG_MMIC_ERROR) {
rx.sdata = sdata;
if (rx.flags & IEEE80211_RX_RA_MATCH)
ieee80211_rx_michael_mic_report(hdr, &rx);
continue;
}
if (!prepares)
continue;

/*
* frame is destined for this interface, but if it's not
* also for the previous one we handle that after the
* loop to avoid copying the SKB once too much
*/
if (status->flag & RX_FLAG_MMIC_ERROR) {
rx.sdata = sdata;
if (rx.flags & IEEE80211_RX_RA_MATCH)
ieee80211_rx_michael_mic_report(hdr,
&rx);
continue;
}

if (!prev) {
prev = sdata;
continue;
}
/*
* frame is destined for this interface, but if it's
* not also for the previous one we handle that after
* the loop to avoid copying the SKB once too much
*/

/*
* frame was destined for the previous interface
* so invoke RX handlers for it
*/
if (!prev) {
prev = sdata;
continue;
}

skb_new = skb_copy(skb, GFP_ATOMIC);
if (!skb_new) {
if (net_ratelimit())
printk(KERN_DEBUG "%s: failed to copy "
"multicast frame for %s\n",
wiphy_name(local->hw.wiphy),
prev->dev->name);
continue;
/*
* frame was destined for the previous interface
* so invoke RX handlers for it
*/

skb_new = skb_copy(skb, GFP_ATOMIC);
if (!skb_new) {
if (net_ratelimit())
printk(KERN_DEBUG "%s: failed to copy "
"multicast frame for %s\n",
wiphy_name(local->hw.wiphy),
prev->dev->name);
continue;
}
ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate);
prev = sdata;
}
ieee80211_invoke_rx_handlers(prev, &rx, skb_new, rate);
prev = sdata;
}
if (prev)
ieee80211_invoke_rx_handlers(prev, &rx, skb, rate);
Expand Down
Loading

0 comments on commit abe6063

Please sign in to comment.