HowTo/bssidFix: patch-01-ibss-fix.diff

File patch-01-ibss-fix.diff, 2.9 KB (added by mcgrof, 14 years ago)

IBSS fix for large networks

  • net80211/ieee80211_node.c

    A Solution to Ad-Hoc BSSID Partitioning Problems
    When wifi network cards are placed in ad-hoc mode (iwconfig ath0 mode 'ad-hoc')
    they will automatically search for networks with the same essid (iwconfig ath0
    essid 'blah'). They will adopt the bssid of the first node to turn on that has
    the specified essid.
    Unfortunately, this algorithm and/or implementation is not very good and even
    in relatively small networks, nodes that have the same 'essid' will end up
    with different a 'bssid'. Since the wifi card drivers filter incoming packets
    by bsssid, nodes that should be in the same ad-hoc network can't exchange
    The solution to this problem can be found by modifying the madwifi drivers 
    (for Atheros wifi cards only), so that the bssid a node generates is a hash 
    of the essid instead of its MAC address. This ensures that nodes with identical
    essid's end up with identical bssid's.
    Although it has not been extensively tested with non-modified nodes, this 
    modification to the madwifi drivers should be fully backwards compatible with
    non-modified nodes. 
    Signed-Off by: Luis Rodriguez <>
    diff -Naur madwifi- madwifi-
    old new  
    5353#include <net80211/ieee80211_var.h>
    5454#include <net80211/if_athproto.h>
     56static int ibss_grid = 1;
     58MODULE_PARM(ibss_grid, "i");
     60#include <linux/moduleparam.h>
     61module_param(ibss_grid, int, 0600);
     63MODULE_PARM_DESC(ibss_grid, "IBSS hack based on SSID for large networks");
    5766 * Association id's are managed with a bit vector.
    5867 */
    301310        ni->ni_capinfo |= IEEE80211_CAPINFO_IBSS;   /* XXX */
    302311        if (vap->iv_flags & IEEE80211_F_DESBSSID)
    303312            IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_des_bssid);
    304         else
    305             ni->ni_bssid[0] |= 0x02;    /* local bit for IBSS */
     313        else {
     314            /* XXX: If we're on a large network then hash the SSID
     315             * instead of the MAC address to generate the BSSID.
     316             * This ensures that nodes with identical SSIDs end
     317             * up with identical BSSIDs, regardless of any
     318             * timing bugs. We might be able to fix this for good
     319             * elsewhere */
     320            if(ibss_grid) {
     321                int i;
     322                printk(KERN_INFO "net80211: IBSS BSSID "
     323                    "generation based on hash of SSID - "
     324                    "temporary fix for large networks\n");
     325                for(i=0; i<IEEE80211_ADDR_LEN;i++)
     326                    ni->ni_bssid[i] = ni->ni_essid[i %
     327                        ni->ni_esslen];
     328            }
     329            else
     330                ni->ni_bssid[0] |= 0x02;/* local bit for IBSS */
     331        }
    306332    } else if (vap->iv_opmode == IEEE80211_M_AHDEMO) {
    307333        if (vap->iv_flags & IEEE80211_F_DESBSSID)
    308334            IEEE80211_ADDR_COPY(ni->ni_bssid, vap->iv_des_bssid);