Skip to content

Commit

Permalink
mac80211: proper bss private data handling
Browse files Browse the repository at this point in the history
cfg80211 offers private data for each BSS struct,
which mac80211 uses. However, mac80211 uses internal
and external (cfg80211) BSS pointers interchangeably
and has a hack to put the cfg80211 bss struct into
the private struct.

Remove this hack, properly converting between the
pointers wherever necessary.

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 28, 2009
1 parent 8e664fb commit 0c1ad2c
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 72 deletions.
2 changes: 1 addition & 1 deletion net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1343,7 +1343,7 @@ int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
return 0;
}

ap = sdata->u.mgd.associated->cbss.bssid;
ap = sdata->u.mgd.associated->bssid;

if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
if (sdata->u.mgd.powersave)
Expand Down
45 changes: 26 additions & 19 deletions net/mac80211/ibss.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,17 @@ static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
struct ieee80211_bss *bss)
{
struct cfg80211_bss *cbss =
container_of((void *)bss, struct cfg80211_bss, priv);
struct ieee80211_supported_band *sband;
u32 basic_rates;
int i, j;
u16 beacon_int = bss->cbss.beacon_interval;
u16 beacon_int = cbss->beacon_interval;

if (beacon_int < 10)
beacon_int = 10;

sband = sdata->local->hw.wiphy->bands[bss->cbss.channel->band];
sband = sdata->local->hw.wiphy->bands[cbss->channel->band];

basic_rates = 0;

Expand All @@ -212,12 +214,12 @@ static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
}
}

__ieee80211_sta_join_ibss(sdata, bss->cbss.bssid,
__ieee80211_sta_join_ibss(sdata, cbss->bssid,
beacon_int,
bss->cbss.channel,
cbss->channel,
basic_rates,
bss->cbss.capability,
bss->cbss.tsf);
cbss->capability,
cbss->tsf);
}

static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
Expand All @@ -229,6 +231,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
{
struct ieee80211_local *local = sdata->local;
int freq;
struct cfg80211_bss *cbss;
struct ieee80211_bss *bss;
struct sta_info *sta;
struct ieee80211_channel *channel;
Expand Down Expand Up @@ -283,8 +286,10 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
if (!bss)
return;

cbss = container_of((void *)bss, struct cfg80211_bss, priv);

/* was just updated in ieee80211_bss_info_update */
beacon_timestamp = bss->cbss.tsf;
beacon_timestamp = cbss->tsf;

/* check if we need to merge IBSS */

Expand All @@ -297,11 +302,11 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
goto put_bss;

/* not an IBSS */
if (!(bss->cbss.capability & WLAN_CAPABILITY_IBSS))
if (!(cbss->capability & WLAN_CAPABILITY_IBSS))
goto put_bss;

/* different channel */
if (bss->cbss.channel != local->oper_channel)
if (cbss->channel != local->oper_channel)
goto put_bss;

/* different SSID */
Expand All @@ -311,7 +316,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
goto put_bss;

/* same BSSID */
if (memcmp(bss->cbss.bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0)
if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0)
goto put_bss;

if (rx_status->flag & RX_FLAG_TSFT) {
Expand Down Expand Up @@ -514,7 +519,7 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
struct ieee80211_local *local = sdata->local;
struct ieee80211_bss *bss;
struct cfg80211_bss *cbss;
struct ieee80211_channel *chan = NULL;
const u8 *bssid = NULL;
int active_ibss;
Expand All @@ -538,21 +543,23 @@ static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
chan = ifibss->channel;
if (!is_zero_ether_addr(ifibss->bssid))
bssid = ifibss->bssid;
bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan, bssid,
ifibss->ssid, ifibss->ssid_len,
WLAN_CAPABILITY_IBSS |
WLAN_CAPABILITY_PRIVACY,
capability);
cbss = cfg80211_get_bss(local->hw.wiphy, chan, bssid,
ifibss->ssid, ifibss->ssid_len,
WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_PRIVACY,
capability);

if (cbss) {
struct ieee80211_bss *bss;

if (bss) {
bss = (void *)cbss->priv;
#ifdef CONFIG_MAC80211_IBSS_DEBUG
printk(KERN_DEBUG " sta_find_ibss: selected %pM current "
"%pM\n", bss->cbss.bssid, ifibss->bssid);
"%pM\n", cbss->bssid, ifibss->bssid);
#endif /* CONFIG_MAC80211_IBSS_DEBUG */

printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM"
" based on configured SSID\n",
sdata->name, bss->cbss.bssid);
sdata->name, cbss->bssid);

ieee80211_sta_join_ibss(sdata, bss);
ieee80211_rx_bss_put(local, bss);
Expand Down
7 changes: 2 additions & 5 deletions net/mac80211/ieee80211_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ struct ieee80211_fragment_entry {


struct ieee80211_bss {
/* Yes, this is a hack */
struct cfg80211_bss cbss;

/* don't want to look up all the time */
size_t ssid_len;
u8 ssid[IEEE80211_MAX_SSID_LEN];
Expand Down Expand Up @@ -274,7 +271,7 @@ struct ieee80211_work {
bool privacy;
} probe_auth;
struct {
struct ieee80211_bss *bss;
struct cfg80211_bss *bss;
const u8 *supp_rates;
const u8 *ht_information_ie;
enum ieee80211_smps_mode smps;
Expand Down Expand Up @@ -317,7 +314,7 @@ struct ieee80211_if_managed {
int probe_send_count;

struct mutex mtx;
struct ieee80211_bss *associated;
struct cfg80211_bss *associated;

u8 bssid[ETH_ALEN];

Expand Down
4 changes: 1 addition & 3 deletions net/mac80211/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len,
WIPHY_FLAG_4ADDR_STATION;
wiphy->privid = mac80211_wiphy_privid;

/* Yes, putting cfg80211_bss into ieee80211_bss is a hack */
wiphy->bss_priv_size = sizeof(struct ieee80211_bss) -
sizeof(struct cfg80211_bss);
wiphy->bss_priv_size = sizeof(struct ieee80211_bss);

local = wiphy_priv(wiphy);

Expand Down
Loading

0 comments on commit 0c1ad2c

Please sign in to comment.