mac80211 (ath9k, ath5k, etc.) set BSSID Patch
Hi,
this patch corrects some bugs of the mac80211 wireless driver framework related to setting a static BSSID in the ad-hoc mode (e.g. for mesh networks like OLSR).
This patch should correct the bug which was reported by Elektra in that wiki, too. Elektra, can you please test it?
http://wiki.villagetelco.org/index.php/Information_about_cell-id_splitting%2C_stuck_beacons%2C_and_failed_IBSS_merges!#The_phenomenon_of_IBSS-ID_cell_splits
Regards
Alina
Signature · 2 lines
Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a
net/mac80211/mlme.c +16 -7
@@ -1660,6 +1660,7 @@/* check if we need to merge IBSS */ if (sdata->vif.type == NL80211_IFTYPE_ADHOC && beacon && + (!(sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)) && bss->capability & WLAN_CAPABILITY_IBSS && bss->freq == local->oper_channel->center_freq && elems->ssid_len == sdata->u.sta.ssid_len &&
@@ -1706,13 +1707,15 @@ jiffies);#endif /* CONFIG_MAC80211_IBSS_DEBUG */ if (beacon_timestamp > rx_timestamp) { +if (memcmp (sdata->u.sta.bssid, mgmt->bssid,ETH_ALEN ) !=0 ) {#ifdef CONFIG_MAC80211_IBSS_DEBUG -printk (KERN_DEBUG "%s: beacon TSF higher than " -"local TSF - IBSS merge with BSSID %s\n" , - sdata->dev->name,print_mac (mac, mgmt->bssid)); +printk (KERN_DEBUG "%s: beacon TSF higher than " +"local TSF - IBSS merge with BSSID %s\n" , + sdata->dev->name,print_mac (mac, mgmt->bssid));#endif -ieee80211_sta_join_ibss (sdata, &sdata->u.sta, bss); -ieee80211_ibss_add_sta (sdata, mgmt->bssid, mgmt->sa, supp_rates); +ieee80211_sta_join_ibss (sdata, &sdata->u.sta, bss); +ieee80211_ibss_add_sta (sdata, mgmt->bssid, mgmt->sa, supp_rates); + } } }
@@ -2031,6 +2034,9 @@if (ieee80211_sta_active_ibss (sdata))return ; +if (sdata->u.sta.flags &IEEE80211_STA_BSSID_SET ) +return ; +printk (KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n" , sdata->dev->name);ieee80211_request_scan (sdata, ifsta->ssid, ifsta->ssid_len);
@@ -2576,11 +2582,14 @@ {struct ieee80211_if_sta *ifsta;int res; +int valid; ifsta = &sdata->u.sta; + valid =is_valid_ether_addr (bssid);if (memcmp (ifsta->bssid, bssid,ETH_ALEN ) !=0 ) { -memcpy (ifsta->bssid, bssid,ETH_ALEN ); +if (valid)memcpy (ifsta->bssid, bssid,ETH_ALEN ); +else memset (ifsta->bssid,0 ,ETH_ALEN ); res =0 ;/* * Hack! See also ieee80211_sta_set_ssid.
@@ -2594,7 +2603,7 @@ } } -if (is_valid_ether_addr (bssid)) +if (valid) ifsta->flags |=IEEE80211_STA_BSSID_SET ;else ifsta->flags &= ~IEEE80211_STA_BSSID_SET ;
Johannes Berg
maintainerHi Alina,
Quoted 7 lines
#endif /* CONFIG_MAC80211_IBSS_DEBUG */ if (beacon_timestamp > rx_timestamp) {net/mac80211/mlme.c +1
-3+if (memcmp (sdata->u.sta.bssid, mgmt->bssid,ETH_ALEN ) !=0 ) {#ifdef CONFIG_MAC80211_IBSS_DEBUG -printk (KERN_DEBUG "%s: beacon TSF higher than " -"local TSF - IBSS merge with BSSID %s\n" , - sdata->dev->name,print_mac (mac, mgmt->bssid));
net/mac80211/mlme.c line 1719
Quoted 10 lines
net/mac80211/mlme.c +6
-2+printk (KERN_DEBUG "%s: beacon TSF higher than " +"local TSF - IBSS merge with BSSID %s\n" , + sdata->dev->name,print_mac (mac, mgmt->bssid));#endif -ieee80211_sta_join_ibss (sdata, &sdata->u.sta, bss); -ieee80211_ibss_add_sta (sdata, mgmt->bssid, mgmt->sa, supp_rates); +ieee80211_sta_join_ibss (sdata, &sdata->u.sta, bss); +ieee80211_ibss_add_sta (sdata, mgmt->bssid, mgmt->sa, supp_rates); + } }
Can you move the memcmp() into the other condition to avoid indenting twice please? Also, it seems there needs to be a STA_BSSID_SET exclusion somewhere above to avoid doing merges?
net/mac80211/mlme.c line 2585
Quoted 5 lines
net/mac80211/mlme.c +1
-0@@ -2576,11 +2582,14 @@ {struct ieee80211_if_sta *ifsta;int res; +int valid;
please use a bool for that
net/mac80211/mlme.c line 2593
Quoted 8 lines
net/mac80211/mlme.c +3
-1ifsta = &sdata->u.sta; + valid =is_valid_ether_addr (bssid);if (memcmp (ifsta->bssid, bssid,ETH_ALEN ) !=0 ) { -memcpy (ifsta->bssid, bssid,ETH_ALEN ); +if (valid)memcpy (ifsta->bssid, bssid,ETH_ALEN ); +else memset (ifsta->bssid,0 ,ETH_ALEN ); res =0 ;
and indent these properly
I won't comment on the actual code right now, the IBSS code is pretty much unknown to me and I don't use it.
johannes
Quoted 1 line · Alina Friedrichsen
this patch corrects some bugs of the mac80211 wireless driver framework related to setting a static BSSID in the ad-hoc mode (e.g. for mesh networks like OLSR).
This is not how IEEE 802.11 IBSS is supposed to work. If there are issues in IBSS splits, merges, or timesync, I would consider fixes to those to be preferred over hacks that hide the issues and cause interoperability issues with standard compliant IBSS implementations.
Anyway, since I don't really care that much about IBSS to actually start using lots of time to fix problems there, I would not object to this type of change as long it does not change the default behavior (i.e., by default, mac80211 should operate in standard compliant manner) and the users are not mislead to enable such a hack while still believing that their devices are operating in a standard IBSS.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Hello Jouni!
Quoted 4 lines
This is not how IEEE 802.11 IBSS is supposed to work. If there are issues in IBSS splits, merges, or timesync, I would consider fixes to those to be preferred over hacks that hide the issues and cause interoperability issues with standard compliant IBSS implementations.
This breaks nothing. I think if you set your BSSID manually, you really=
don't want that the driver changed it back. If you want this behavior,= you don't set it.
Handle BSSID splits in a mile width city mesh network with 500 or more = nodes is impossible in a other way, I think. The standard was never wri= tten for that dimensions.
Besides it fixes a bug that driver want to try to merge with the same B= SSID, which is unnecessary and causes problems.
See:
http://wiki.villagetelco.org/index.php/Information_about_cell-id_splitt=
ing%2C_stuck_beacons%2C_and_failed_IBSS_merges!#The_phenomenon_of_IBSS-= ID_cell_splits
Quoted 1 line
Anyway, since I don't really care that much about IBSS
We need it much here in the "Freifunk" mesh network of Berlin.
Quoted 3 lines
to actually start
using lots of time to fix problems there, I would not object to this type of change as long it does not change the default behavior (i.e.,=
by
Quoted 1 line
default, mac80211 should operate in standard compliant manner) and th=
e
Quoted 1 line
users are not mislead to enable such a hack while still believing tha=
t
Quoted 1 line
their devices are operating in a standard IBSS.
ACK
Regards
Alina
--=20
Psssst! Schon vom neuen GMX MultiMessenger geh=F6rt? Der kann`s mit all=
en: http://www.gmx.net/de/go/multimessenger
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 1 line · Alina Friedrichsen
This breaks nothing. I think if you set your BSSID manually, you really don't want that the driver changed it back. If you want this behavior, you don't set it.
But it _does_ break interoperability with standard compliant IBSS implementations if the forced BSSID means that the STA does not merge with another part of the IBSS when this should happen by the STA changing its BSSID to match with the other part. If you do not want the code behave as described for IBSS, use something else than IBSS..
Quoted 1 line
Handle BSSID splits in a mile width city mesh network with 500 or more nodes is impossible in a other way, I think. The standard was never written for that dimensions.
Agreed, but we should not claim that the behavior with hardcoded BSSID would be standard IBSS. It is something different and we should not confuse users by calling it the same. I would have nothing against this type of optional feature if it were called something else than IBSS (or "adhoc" which iwconfig uses for IBSS).
Quoted 1 line
Besides it fixes a bug that driver want to try to merge with the same BSSID, which is unnecessary and causes problems.
If that fix is separate from the change that introduces hardcoding of the BSSID, it would be better to bring that in as a separate patch.
Signature · 1 line
Jouni Malinen PGP id EFC895FA
Hi Jouni!
Quoted 4 lines
But it _does_ break interoperability with standard compliant IBSS implementations if the forced BSSID means that the STA does not merge with another part of the IBSS when this should happen by the STA changing its BSSID to match with the other part.
But in the practice this is not a bug, it's an optional feature and you=
can mix nodes with fixed BSSID and nodes without, so that the backbone= nodes (routers) force the rather client nodes (e.g. notebooks) to use =
this BSSID, so that the mesh network don't break into many pieces. That=
was happen many times before we use a fixed BSSID.
You don't need to use it, if you don't want it, but we must use it, or = it will not work.
Quoted 1 line
Agreed, but we should not claim that the behavior with hardcoded BSSI=
D
Quoted 1 line
would be standard IBSS.
It's a little modified IBSS, that allow you to build bigger networks. N= ot a huge change, that is completely incompatible with the standard.
Quoted 3 lines
It is something different and we should not
confuse users by calling it the same. I would have nothing against this type of optional feature if it were called something else than I=
BSS
Quoted 1 line
(or "adhoc" which iwconfig uses for IBSS).
I can call it Moonchild [0], if you want. ;)
I don't care on the name of it.
Quoted 2 lines
If that fix is separate from the change that introduces hardcoding of the BSSID, it would be better to bring that in as a separate patch.
I don't introduce setting of a fixed BSSID with this patch, I only fix = some bugs of the current implementation.
Regards
Alina
[0] The Neverending Story
--=20
Sensationsangebot verl=E4ngert: GMX FreeDSL - Telefonanschluss + DSL=20 f=FCr nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=3DOM.AD.PD003K1308T45=
69a
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Johannes,
thanks for your comments. I'm not so familiar with your coding style for now. Here is the revised patch.
Quoted 2 lines
Can you move the
memcmp()into the other condition to avoid indenting twice please?
Done.
Quoted 2 lines
Also, it seems there needs to be a
STA_BSSID_SETexclusion somewhere above to avoid doing merges?
Yes this function is even called if you set a fixed BSSID, where you don't want any merges. Done in line 1663.
Quoted 1 line
please use a bool for that
Yes, but the called function is written in the old C style before C99, so I think I should use the same type.
Quoted 3 lines
static inline int
is_valid_ether_addr(const u8 *addr)and indent these properly
Done.
Quoted 2 lines
I won't comment on the actual code right now, the IBSS code is pretty much unknown to me and I don't use it.
You only need it for mesh networks.
Regards
Alina
Signature · 2 lines
Sensationsangebot verlängert: GMX FreeDSL - Telefonanschluss + DSL für nur 16,37 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K1308T4569a
net/mac80211/mlme.c +13 -3
@@ -1660,6 +1660,7 @@/* check if we need to merge IBSS */ if (sdata->vif.type == NL80211_IFTYPE_ADHOC && beacon && + (!(sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)) && bss->capability & WLAN_CAPABILITY_IBSS && bss->freq == local->oper_channel->center_freq && elems->ssid_len == sdata->u.sta.ssid_len &&
@@ -1705,7 +1706,8 @@ (unsigned long long )(rx_timestamp - beacon_timestamp), jiffies);#endif /* CONFIG_MAC80211_IBSS_DEBUG */ -if (beacon_timestamp > rx_timestamp) { +if (beacon_timestamp > rx_timestamp && +memcmp (sdata->u.sta.bssid, mgmt->bssid,ETH_ALEN ) !=0 ) {#ifdef CONFIG_MAC80211_IBSS_DEBUG printk(KERN_DEBUG "%s: beacon TSF higher than " "local TSF - IBSS merge with BSSID %s\n",
@@ -2031,6 +2033,9 @@if (ieee80211_sta_active_ibss (sdata))return ; +if (sdata->u.sta.flags &IEEE80211_STA_BSSID_SET ) +return ; +printk (KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n" , sdata->dev->name);ieee80211_request_scan (sdata, ifsta->ssid, ifsta->ssid_len);
@@ -2576,11 +2581,16 @@ {struct ieee80211_if_sta *ifsta;int res; +int valid; ifsta = &sdata->u.sta; + valid =is_valid_ether_addr (bssid);if (memcmp (ifsta->bssid, bssid,ETH_ALEN ) !=0 ) { -memcpy (ifsta->bssid, bssid,ETH_ALEN ); +if (valid) +memcpy (ifsta->bssid, bssid,ETH_ALEN ); +else +memset (ifsta->bssid,0 ,ETH_ALEN ); res =0 ;/* * Hack! See also ieee80211_sta_set_ssid.
@@ -2594,7 +2604,7 @@ } } -if (is_valid_ether_addr (bssid)) +if (valid) ifsta->flags |=IEEE80211_STA_BSSID_SET ;else ifsta->flags &= ~IEEE80211_STA_BSSID_SET ;
Johannes Berg
maintainerHi Alina,
Quoted 3 lines
Quoted 1 line
please use a bool for that
Yes, but the called function is written in the old C style before C99, so I think I should use the same type.
I disagree, even if the function doesn't use the proper types pervasively, we shouldn't be adding old-style stuff.
What Jouni pointed out still stands, you should separate the bugfix and the 'disregard ibss join' feature into two patches.
johannes
Hi Johannes!
Quoted 2 lines
I disagree, even if the function doesn't use the proper types pervasively, we shouldn't be adding old-style stuff.
Okay, I can use bool to if you want, too.
Quoted 2 lines
What Jouni pointed out still stands, you should separate the bugfix and the 'disregard ibss join' feature into two patches.
As I say, the "the 'disregard ibss join' feature" is already implemented only not complete. If you want a driver, that do in some situations merges and some others don't, you can easily remove the line 1663. But I think it would nice, if the main driver implement it properly, not half.
For now we can only use the madwifi and an awful hacked proprietary 2.4er kernel broadcom driver for it. It would nice to have a clean free software implementation for it.
Regards
Alina
Signature · 1 line
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
net/mac80211/mlme.c +13 -3
@@ -1660,6 +1660,7 @@/* check if we need to merge IBSS */ if (sdata->vif.type == NL80211_IFTYPE_ADHOC && beacon && + (!(sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)) && bss->capability & WLAN_CAPABILITY_IBSS && bss->freq == local->oper_channel->center_freq && elems->ssid_len == sdata->u.sta.ssid_len &&
@@ -1705,7 +1706,8 @@ (unsigned long long )(rx_timestamp - beacon_timestamp), jiffies);#endif /* CONFIG_MAC80211_IBSS_DEBUG */ -if (beacon_timestamp > rx_timestamp) { +if (beacon_timestamp > rx_timestamp && +memcmp (sdata->u.sta.bssid, mgmt->bssid,ETH_ALEN ) !=0 ) {#ifdef CONFIG_MAC80211_IBSS_DEBUG printk(KERN_DEBUG "%s: beacon TSF higher than " "local TSF - IBSS merge with BSSID %s\n",
@@ -2031,6 +2033,9 @@if (ieee80211_sta_active_ibss (sdata))return ; +if (sdata->u.sta.flags &IEEE80211_STA_BSSID_SET ) +return ; +printk (KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n" , sdata->dev->name);ieee80211_request_scan (sdata, ifsta->ssid, ifsta->ssid_len);
@@ -2576,11 +2581,16 @@ {struct ieee80211_if_sta *ifsta;int res; +bool valid; ifsta = &sdata->u.sta; + valid =is_valid_ether_addr (bssid);if (memcmp (ifsta->bssid, bssid,ETH_ALEN ) !=0 ) { -memcpy (ifsta->bssid, bssid,ETH_ALEN ); +if (valid) +memcpy (ifsta->bssid, bssid,ETH_ALEN ); +else +memset (ifsta->bssid,0 ,ETH_ALEN ); res =0 ;/* * Hack! See also ieee80211_sta_set_ssid.
@@ -2594,7 +2604,7 @@ } } -if (is_valid_ether_addr (bssid)) +if (valid) ifsta->flags |=IEEE80211_STA_BSSID_SET ;else ifsta->flags &= ~IEEE80211_STA_BSSID_SET ;
Re: mac80211 (ath9k, ath5k, etc.) set fixed BSSID + channel Patch
Hello,
here is a new version of this patch, that fixes a bug that manual channel setting in the ad-hoc (IBSS) mode doesn't work properly, too.
It would nice, if it can be committed, before it's out of sync.
Regards
Alina
Signature · 1 line
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger
net/mac80211/mlme.c +14 -3
@@ -1660,6 +1660,7 @@/* check if we need to merge IBSS */ if (sdata->vif.type == NL80211_IFTYPE_ADHOC && beacon && + (!(sdata->u.sta.flags & IEEE80211_STA_BSSID_SET)) && bss->capability & WLAN_CAPABILITY_IBSS && bss->freq == local->oper_channel->center_freq && elems->ssid_len == sdata->u.sta.ssid_len &&
@@ -1705,7 +1706,8 @@ (unsigned long long )(rx_timestamp - beacon_timestamp), jiffies);#endif /* CONFIG_MAC80211_IBSS_DEBUG */ -if (beacon_timestamp > rx_timestamp) { +if (beacon_timestamp > rx_timestamp && +memcmp (sdata->u.sta.bssid, mgmt->bssid,ETH_ALEN ) !=0 ) {#ifdef CONFIG_MAC80211_IBSS_DEBUG printk(KERN_DEBUG "%s: beacon TSF higher than " "local TSF - IBSS merge with BSSID %s\n",
@@ -2031,6 +2033,10 @@if (ieee80211_sta_active_ibss (sdata))return ; +if ((sdata->u.sta.flags &IEEE80211_STA_BSSID_SET ) && + (!(sdata->u.sta.flags &IEEE80211_STA_AUTO_CHANNEL_SEL ))) +return ; +printk (KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " "IBSS networks with same SSID (merge)\n" , sdata->dev->name);ieee80211_request_scan (sdata, ifsta->ssid, ifsta->ssid_len);
@@ -2576,11 +2582,16 @@ {struct ieee80211_if_sta *ifsta;int res; +bool valid; ifsta = &sdata->u.sta; + valid =is_valid_ether_addr (bssid);if (memcmp (ifsta->bssid, bssid,ETH_ALEN ) !=0 ) { -memcpy (ifsta->bssid, bssid,ETH_ALEN ); +if (valid) +memcpy (ifsta->bssid, bssid,ETH_ALEN ); +else +memset (ifsta->bssid,0 ,ETH_ALEN ); res =0 ;/* * Hack! See also ieee80211_sta_set_ssid.
@@ -2594,7 +2605,7 @@ } } -if (is_valid_ether_addr (bssid)) +if (valid) ifsta->flags |=IEEE80211_STA_BSSID_SET ;else ifsta->flags &= ~IEEE80211_STA_BSSID_SET ;
net/mac80211/wext.c +4 -2
@@ -230,13 +230,15 @@ {struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); -if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +if (sdata->vif.type ==NL80211_IFTYPE_ADHOC || + sdata->vif.type ==NL80211_IFTYPE_STATION ) sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL ;/* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */ if (freq->e ==0 ) {if (freq->m <0 ) { -if (sdata->vif.type ==NL80211_IFTYPE_STATION ) +if (sdata->vif.type ==NL80211_IFTYPE_ADHOC || + sdata->vif.type ==NL80211_IFTYPE_STATION ) sdata->u.sta.flags |=IEEE80211_STA_AUTO_CHANNEL_SEL ;return 0 ;
Johannes Berg
maintainerRe: mac80211 (ath9k, ath5k, etc.) set fixed BSSID + channel Patch
[dropping openwrt list, it ignores non-subscribers anyway]
Quoted 6 lines · Alina Friedrichsen
Hello,
here is a new version of this patch, that fixes a bug that manual channel setting in the ad-hoc (IBSS) mode doesn't work properly, too.
It would nice, if it can be committed, before it's out of sync.
You need to provide a proper changelog that explains the changes, a proper subject (don't mention any drivers) and a signed-off-by, see
http://wireless.kernel.org/en/developers/Documentation/SubmittingPatches
please.
johannes